forked from freifunk-franken/firmware
Moved json part to own nodewatcher-json
This commit is contained in:
parent
9cc28b9114
commit
b52801fe14
|
@ -1,7 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
json_load_file /tmp/nodewatcher.json
|
||||
json_load_file $SCRIPT_DATA_FILE
|
||||
|
||||
json_select babel
|
||||
|
||||
|
@ -30,6 +32,6 @@ fi
|
|||
|
||||
json_close_object #neighbours
|
||||
|
||||
json_dump > /tmp/nodewatcher.json
|
||||
json_dump > $SCRIPT_DATA_FILE
|
||||
|
||||
#exit 0
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
MACADDR=$(cat /sys/class/net/br-client/address | /bin/sed 's/://g')
|
||||
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
|
||||
|
||||
if [ -n "$(uci -q get fff.mqtt.server)" ] ; then
|
||||
mosquitto_pub -h "$(uci get fff.mqtt.server)" -p 1883 -t /monitoring/v2/$MACADDR -m "$(cat /tmp/nodewatcher.json)"
|
||||
mosquitto_pub -h "$(uci get fff.mqtt.server)" -p 1883 -t /monitoring/v2/$MACADDR -m "$SCRIPT_DATA_FILE"
|
||||
fi
|
||||
|
|
|
@ -17,8 +17,10 @@ inArray() {
|
|||
|
||||
debug "Collecting information from network interfaces"
|
||||
|
||||
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
json_load_file /tmp/nodewatcher.json
|
||||
json_load_file $SCRIPT_DATA_FILE
|
||||
|
||||
json_add_array "interfaces"
|
||||
|
||||
|
@ -94,5 +96,5 @@ for filename in $(grep 'up\|unknown' /sys/class/net/*/operstate); do
|
|||
json_close_object #iface object
|
||||
done
|
||||
|
||||
json_dump > /tmp/nodewatcher.json
|
||||
json_dump > $SCRIPT_DATA_FILE
|
||||
#exit 0
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
MESH_INTERFACE=$(uci get nodewatcher.@network[0].mesh_interface)
|
||||
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
|
||||
|
||||
debug() {
|
||||
(>&2 echo "nodewatcher: $1")
|
||||
|
@ -9,7 +10,7 @@ debug() {
|
|||
debug "Collecting information about connected clients"
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
json_load_file /tmp/nodewatcher.json
|
||||
json_load_file $SCRIPT_DATA_FILE
|
||||
|
||||
json_add_object "clients"
|
||||
|
||||
|
@ -30,6 +31,6 @@ json_close_object #interfaces array
|
|||
json_add_string "count" "$client_count"
|
||||
json_close_object #clients
|
||||
|
||||
json_dump > /tmp/nodewatcher.json
|
||||
json_dump > $SCRIPT_DATA_FILE
|
||||
|
||||
#exit 0
|
|
@ -0,0 +1 @@
|
|||
*/5 * * * * sleep $(/usr/bin/random 0 29); /usr/sbin/nodewatcher-json
|
|
@ -5,6 +5,7 @@ json_init
|
|||
|
||||
SCRIPT_STATUS_FILE=$(uci get nodewatcher.@script[0].status_text_file)
|
||||
SCRIPT_VERSION=$(cat /etc/nodewatcher_version)
|
||||
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
|
||||
|
||||
debug() {
|
||||
(>&2 echo "nodewatcher: $1")
|
||||
|
@ -140,5 +141,5 @@ vpn_active=0
|
|||
pidof fastd >/dev/null && vpn_active=1
|
||||
json_add_string "vpn_active" "$vpn_active"
|
||||
|
||||
json_dump > /tmp/nodewatcher.json
|
||||
json_dump > $SCRIPT_DATA_FILE
|
||||
#exit 0
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh
|
||||
|
||||
test -f /tmp/started || exit
|
||||
|
||||
# Allow only one instance
|
||||
lockfile="/var/lock/${0##*/}.json.lock"
|
||||
if ! lock -n "$lockfile"; then
|
||||
echo "Only one instance of $0 allowed."
|
||||
exit 1
|
||||
fi
|
||||
trap "lock -u \"$lockfile\"" INT TERM EXIT
|
||||
|
||||
[ -s /etc/config/nodewatcher ] || exit 1
|
||||
[ "$(uci get nodewatcher.@script[0].disabled)" = "1" ] && exit 0
|
||||
|
||||
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
|
||||
|
||||
debug() {
|
||||
(>&2 echo "nodewatcher: $1")
|
||||
}
|
||||
|
||||
#This method generates the crawl data JSON file that is being fetched by netmon
|
||||
#and provided by a small local httpd
|
||||
crawl() {
|
||||
debug "Putting all information into a JSON-File and save it at $SCRIPT_DATA_FILE"
|
||||
|
||||
for f in /usr/lib/nodewatcher-json.d/*.sh; do
|
||||
tmp="$($f)"
|
||||
if [ $? -ne 0 ]; then
|
||||
debug "Error when executing subscript $f, exiting!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
SCRIPT_DATA_DIR=$(dirname "$SCRIPT_DATA_FILE")
|
||||
test -d "$SCRIPT_DATA_DIR" || mkdir -p "$SCRIPT_DATA_DIR"
|
||||
}
|
||||
|
||||
LANG=C
|
||||
|
||||
#Erzeugt die statusdaten
|
||||
debug "Generate actual status data"
|
||||
crawl
|
||||
|
||||
exit 0
|
|
@ -1,8 +1,9 @@
|
|||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
json_load_file /tmp/nodewatcher.json
|
||||
json_load_file $SCRIPT_DATA_FILE
|
||||
|
||||
json_add_array "s2nproxy"
|
||||
|
||||
|
@ -139,4 +140,4 @@ config_foreach s2np s2nproxy
|
|||
|
||||
json_close_object #s2nproxy
|
||||
|
||||
json_dump > /tmp/nodewatcher.json
|
||||
json_dump > $SCRIPT_DATA_FILE
|
|
@ -1,9 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
json_load_file /tmp/nodewatcher.json
|
||||
json_load_file $SCRIPT_DATA_FILE
|
||||
|
||||
config_load simple-tc
|
||||
tc_enabled="0"
|
||||
|
@ -31,6 +32,6 @@ json_add_string "out" "$tc_out"
|
|||
json_close_object #wan
|
||||
json_close_object #traffic_control
|
||||
|
||||
json_dump > /tmp/nodewatcher.json
|
||||
json_dump > $SCRIPT_DATA_FILE
|
||||
|
||||
#exit 0
|
|
@ -1,7 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file).json
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
json_load_file /tmp/nodewatcher.json
|
||||
json_load_file $SCRIPT_DATA_FILE
|
||||
|
||||
json_add_object "airtime"
|
||||
|
||||
|
@ -26,6 +28,6 @@ if [ -n "$w5dump" ] ; then
|
|||
fi
|
||||
json_close_object #airtime
|
||||
|
||||
json_dump > /tmp/nodewatcher.json
|
||||
json_dump > $SCRIPT_DATA_FILE
|
||||
|
||||
#exit 0
|
Loading…
Reference in New Issue