A couple of scripts for publishing the state of an openwrt router to mqtt.
Relies on mosquitto_pub and mosquitto_sub being present
Init.d scripts including one to start a pair of file monitors and one to publish whether or not the router is onlien
#!/bin/ash | |
used=`top -n1 | grep -v grep | grep Mem | awk '{ print $2 }' | cut -d'K' -f 1` | |
free=`top -n1 | grep -v grep | grep Mem | awk '{ print $4 }' | cut -d'K' -f 1` | |
cat > /root/feed_update_payload.json <<EOF | |
{ | |
"version":"1.0.0", | |
"datastreams":[ | |
{"id":"used", |
/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. | |
* | |
* The information contained herein is property of Nordic Semiconductor ASA. | |
* Terms and conditions of usage are described in detail in NORDIC | |
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. | |
* | |
* Licensees are granted free, non-transferable use of the information. NO | |
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from | |
* the file. | |
* |