#!/bin/sh . /usr/share/libubox/jshn.sh json_load_file /tmp/nodewatcher.json json_add_object "airtime" w2dump="$(iw dev w2ap survey dump 2> /dev/null | sed '/Survey/,/\[in use\]/d')" if [ -n "$w2dump" ] ; then json_add_object "w2" w2_ACT="$(ACTIVE=$(echo "$w2dump" | grep "active time:"); set ${ACTIVE:-0 0 0 0 0}; echo -e "${4}")" w2_BUS="$(BUSY=$(echo "$w2dump" | grep "busy time:"); set ${BUSY:-0 0 0 0 0}; echo -e "${4}")" json_add_string "active" "$w2_ACT" json_add_string "busy" "$w2_BUS" json_close_object #w2 fi w5dump="$(iw dev w5ap survey dump 2> /dev/null | sed '/Survey/,/\[in use\]/d')" if [ -n "$w5dump" ] ; then json_add_object "w5" w5_ACT="$(ACTIVE=$(echo "$w5dump" | grep "active time:"); set ${ACTIVE:-0 0 0 0 0}; echo -e "${4}")" w5_BUS="$(BUSY=$(echo "$w5dump" | grep "busy time:"); set ${BUSY:-0 0 0 0 0}; echo -e "${4}")" json_add_string "active" "$w5_ACT" json_add_string "busy" "$w5_BUS" json_close_object #w5 fi json_close_object #airtime json_dump > /tmp/nodewatcher.json #exit 0