/mqtt-os-status

Operating-system related data, published to an MQTT broker at fixed intervals.

Primary LanguageShell

MQTT OS Status

Operating-system related data, published to an MQTT broker at fixed intervals.

Example output

$  mosquitto_sub -h 192.168.1.5 -t "+/os/#" -v
pi1/os {"hostname":"jeeves","type":"Linux","endianness":"LE","platform":"linux","arch":"arm","release":"3.10.25+"}
pi1/os/uptime 142.2680236
pi1/os/loadavg [1.07421875,0.68212890625,0.271484375]
pi1/os/mem {"totalmem":508874752,"freemem":396210176}
pi1/os/cpus [{"model":"unknown","speed":700,"times":{"user":373600,"nice":0,"sys":203500,"idle":547300,"irq":3700}}]
pi1/os/networkInterfaces {"lo":[{"address":"127.0.0.1","family":"IPv4","internal":true}],"eth0":[{"address":"192.168.1.5","family":"IPv4","internal":false}]}

Install as a service on Raspberry Pi

These instructions are for Raspbian on Raspberry Pi but could easily be adapted to most Linux distributions.

Source

Install forever.js

npm install -g forever

Install this module

npm install -g mqtt-os-status

Copy the sample etc/init.d/mqtt-os-status file to /etc/init.d and make it executable. Adjust the directory of your node.js installation if necessary.

sudo su
cp /home/pi/node-v0.10.2-linux-arm-pi/lib/node_modules/mqtt-os-status/etc/init.d/mqtt-os-status /etc/init.d/mqtt-os-status
chmod a+x /etc/init.d/mqtt-os-status

Edit the node binary paths, app paths, username and password, and optional adjustments to topic root and update inteval in the script as necessary

After putting the script in place, you should update the system service definitions:

update-rc.d mqtt-os-status defaults

Run or check on the script and its process with the following commands:

service mqtt-os-status start
service mqtt-os-status status
service mqtt-os-status restart
service mqtt-os-status stop