diff --git a/ffpb/ffpb-debug/files/bin/ffpb-debug-live b/ffpb/ffpb-debug/files/bin/ffpb-debug-live index 366d1d33f4e28ac08e02e5966d686fb8f4561060..6ce5bd467c4944412d9832260fb3f30bac3adbe1 100755 --- a/ffpb/ffpb-debug/files/bin/ffpb-debug-live +++ b/ffpb/ffpb-debug/files/bin/ffpb-debug-live @@ -1,36 +1,134 @@ #!/bin/sh -if [ "$1" == "--send" ]; then - ts=$(date +%s) +TEMP_DATA_FILE="/tmp/ffpb-live-debug.dat" +LIVE_DEBUG_TARGET_HOST="fdca:ffee:ff12:a254::da7a" +LIVE_DEBUG_TARGET_HOST_PORT=1338 +LIVE_DEBUG_GRAPHITE_DATAPATH_BASE="ffpb.debug."$(lua -e 'print(require("gluon.sysconfig").primary_mac)') - mac=$(lua -e 'print(require("gluon.sysconfig").primary_mac)') - target_host='fdca:ffee:ff12:a254::da7a' - target_port=1338 +. /etc/openwrt_release +. /usr/share/libubox/jshn.sh - tf=/tmp/live-debug.dat - datapath="ffpb.debug.${mac}" +determine_lan_device_name() { + local _iface="$1" + local _var="$2" - cat /proc/net/dev | awk "/\\s*wlan0:/ { print \"${datapath}.wifi.rx \", \$2, \" $ts\"; print \"${datapath}.wifi.tx \", \$10, \" $ts\"; }" >> $tf - cat /proc/net/dev | awk "/\\s*wlan0-1:/ { print \"${datapath}.mesh.rx \", \$2, \" $ts\"; print \"${datapath}.mesh.tx \", \$10, \" $ts\"; }" >> $tf - cat /proc/net/dev | awk "/\\s*eth0:/ { print \"${datapath}.uplink.rx \", \$2, \" $ts\"; print \"${datapath}.uplink.tx \", \$10, \" $ts\"; }" >> $tf + json_load "$(ubus call network.interface.${_iface} status)" + json_get_var is_up "up" + if [ $is_up == 1 ] ; then + json_get_var $_var "device" + fi - associations=$(iwinfo wlan0 assoclist | grep dBm | wc -l) - echo "${datapath}.associations $associations $ts" >> $tf + json_cleanup +} - clients=$(iw dev wlan0 station dump | grep ^Station | wc -l) - echo "${datapath}.clients $clients $ts" >> $tf - neighbours=$(iw dev wlan0-1 station dump | grep ^Station | wc -l) - echo "${datapath}.neighbours $neighbours $ts" >> $tf +determine_wifi_device_name() +{ + local _iface="$1" + local _var="$2" + + if [ "${DISTRIB_CODENAME}" == "attitude_adjustment" ] ; then + eval "$_var=\"$(uci -P/var/state get wireless.${_iface}.ifname)\"" + else + json_load "$(ubus call network.wireless status)" + json_select "radio0" + json_select "interfaces" + + local _idx=1 + while json_get_type type "$_idx" && [ "$type" = object ] ; do + json_select "$(( _idx++ ))" + json_get_var section "section" + if [ "${section}" == "${_iface}" ] ; then + json_get_var $_var "ifname" + break + fi + json_select ".." + done + + json_cleanup + fi +} + + +get_device_stats() { + local _dev="$1" + rx_bytes="$2" + tx_bytes="$3" + rx_dropped="$4" + tx_dropped="$5" + json_select "${_dev}" + json_select "statistics" + json_get_vars rx_bytes tx_bytes rx_dropped tx_dropped + + json_select ".." && json_select ".." +} + + +gather_device_data() { + local rx_bytes + local ty_bytes + local rx_dropped + local tx_dropped + json_load "$(ubus call network.device status)" + + if [ -n "{$DEV_MESH_RADIO_24}" ] ; then + get_device_stats ${DEV_MESH_RADIO_24} rx_bytes tx_bytes rx_dropped tx_dropped + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.mesh_radio0.rx_bytes ${rx_bytes} ${timestamp}" >> ${TEMP_DATA_FILE} + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.mesh_radio0.tx_bytes ${tx_bytes} ${timestamp}" >> ${TEMP_DATA_FILE} + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.mesh_radio0.rx_dropped ${rx_dropped} ${timestamp}" >> ${TEMP_DATA_FILE} + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.mesh_radio0.tx_dropped ${tx_dropped} ${timestamp}" >> ${TEMP_DATA_FILE} + fi + + if [ -n "{$DEV_CLIENT_RADIO_24}" ] ; then + get_device_stats ${DEV_CLIENT_RADIO_24} rx_bytes tx_bytes rx_dropped tx_dropped + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.client_radio0.rx_bytes ${rx_bytes} ${timestamp}" >> ${TEMP_DATA_FILE} + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.client_radio0.tx_bytes ${tx_bytes} ${timestamp}" >> ${TEMP_DATA_FILE} + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.client_radio0.rx_dropped ${rx_dropped} ${timestamp}" >> ${TEMP_DATA_FILE} + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.client_radio0.tx_dropped ${tx_dropped} ${timestamp}" >> ${TEMP_DATA_FILE} + fi + + if [ -n "${DEV_MESH_VPN}" ] ; then + get_device_stats ${DEV_MESH_VPN} rx_bytes tx_bytes rx_dropped tx_dropped + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.mesh_vpn.rx_bytes ${rx_bytes} ${timestamp}" >> ${TEMP_DATA_FILE} + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.mesh_vpn.tx_bytes ${tx_bytes} ${timestamp}" >> ${TEMP_DATA_FILE} + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.mesh_vpn.rx_dropped ${rx_dropped} ${timestamp}" >> ${TEMP_DATA_FILE} + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.mesh_vpn.tx_dropped ${tx_dropped} ${timestamp}" >> ${TEMP_DATA_FILE} + fi + + json_cleanup +} + + +gather_stations_data() { + if [ -n "${DEV_CLIENT_RADIO_24}" ] ; then + cnt_assoc_clients=$(iwinfo ${DEV_CLIENT_RADIO_24} assoclist | grep dBm | wc -l) + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.cnt_assoc_clients ${cnt_assoc_clients} ${timestamp}" >> ${TEMP_DATA_FILE} + fi + + if [ -n "${DEV_CLIENT_RADIO_24}" ] ; then + cnt_client_stations=$(iw dev ${DEV_CLIENT_RADIO_24} station dump | grep ^Station | wc -l) + echo ${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.cnt_client_stations ${cnt_client_stations} ${timestamp} >> ${TEMP_DATA_FILE} + fi + + cnt_batman_clients=$(batctl tl | tail -n +3 | grep -v "\[\.P\.\.\.\]" | wc -l) + echo ${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.cnt_batman_clients ${cnt_batman_clients} ${timestamp} >> ${TEMP_DATA_FILE} + + if [ -n "${DEV_MESH_RADIO_24}" ] ; then + cnt_neighbours=$(iw dev ${DEV_MESH_RADIO_24} station dump | grep ^Station | wc -l) + echo "${LIVE_DEBUG_GRAPHITE_DATAPATH_BASE}.cnt_neighbours ${cnt_neighbours} ${timestamp}" >> ${TEMP_DATA_FILE} + fi +} - nc "${target_host}" "${target_port}" < $tf && rm $tf - exit 0 -fi echo "Starting live-debug ... press Ctrl+C to abort." +determine_wifi_device_name "mesh_radio0" DEV_MESH_RADIO_24 +determine_wifi_device_name "client_radio0" DEV_CLIENT_RADIO_24 +determine_lan_device_name "mesh_vpn" DEV_MESH_VPN while true; do - date - $0 --send - sleep 5 + timestamp=$(date +%s) + date -R -d "${timestamp}" + gather_device_data + gather_stations_data + nc "${LIVE_DEBUG_TARGET_HOST}" "${LIVE_DEBUG_TARGET_HOST_PORT}" < ${TEMP_DATA_FILE} && /bin/rm ${TEMP_DATA_FILE} + sleep 5 done - diff --git a/ffpb/ffpb-key/Makefile b/ffpb/ffpb-key/Makefile deleted file mode 100644 index b7802d6e5cf2a12a3d84c3d7e139ae25dc958e37..0000000000000000000000000000000000000000 --- a/ffpb/ffpb-key/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -include $(TOPDIR)/rules.mk - -PKG_NAME:=ffpb-key -PKG_VERSION:=1 -PKG_RELEASE:=$(GLUON_VERSION).$(GLUON_SITE_CODE)-$(GLUON_RELEASE).$(GLUON_CONFIG_VERSION) - -PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) - -include $(INCLUDE_DIR)/package.mk - -define Package/ffpb-key - SECTION:=ffpb - CATEGORY:=ffpb - TITLE:=Status-Bot Koy - DEPENDS:=+dropbear -endef - -define Package/ffpb-key/description - Setups the status bot key (SSH). -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) -endef - -define Build/Configure -endef - -define Build/Compile -endef - -define Package/ffpb-key/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,ffpb-key)) diff --git a/ffpb/ffpb-key/files/etc/dropbear/authorized_keys b/ffpb/ffpb-key/files/etc/dropbear/authorized_keys deleted file mode 100644 index 2fa137b60759d4ade0f8e2e62a2c08e90fb061ae..0000000000000000000000000000000000000000 --- a/ffpb/ffpb-key/files/etc/dropbear/authorized_keys +++ /dev/null @@ -1,2 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJfsG/myO4y9WzJSP+ixluHFmkIMJJRsvRT8t5h4y/5A7QzovOw1GpCmWJWnZ6GKXilTxb8ycqVfDcFPB2NRkdJUjYL+v4IMriPeBigAjc6FoUZXOS3TOZVhaTlNT4XxXKOYF/Rpgscv5f0iu1SG0Tp4mb2TX04pZjbnLNBABbjn592abEuMG5bH/g9odi50S0MoU/qCH9AZvkoc8vGu+flOBrKfFi+7g2GxF/w66mMvCJfK27QFSPOiFV3CT6ZfSZM138OCdC1SOi89X9+oCEQ3LB9A+bJgyYnxqp8eVpRPui6K9sPkax71tMimRJA5Xgdvqt9HpcgtNYxKJ4gYMR ffpb-statusbot -