Skip to content
Snippets Groups Projects
Commit cb21f9c2 authored by Stefan Laudemann's avatar Stefan Laudemann
Browse files

Merge branch 'master' of git.c3pb.de:freifunk-pb/ffpb-packages into base

parents d5205510 d70703bd
No related branches found
No related tags found
No related merge requests found
#!/bin/sh #!/bin/sh
if [ "$1" == "--send" ]; then TEMP_DATA_FILE="/tmp/ffpb-live-debug.dat"
ts=$(date +%s) 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)') . /etc/openwrt_release
target_host='fdca:ffee:ff12:a254::da7a' . /usr/share/libubox/jshn.sh
target_port=1338
tf=/tmp/live-debug.dat determine_lan_device_name() {
datapath="ffpb.debug.${mac}" 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 json_load "$(ubus call network.interface.${_iface} status)"
cat /proc/net/dev | awk "/\\s*wlan0-1:/ { print \"${datapath}.mesh.rx \", \$2, \" $ts\"; print \"${datapath}.mesh.tx \", \$10, \" $ts\"; }" >> $tf json_get_var is_up "up"
cat /proc/net/dev | awk "/\\s*eth0:/ { print \"${datapath}.uplink.rx \", \$2, \" $ts\"; print \"${datapath}.uplink.tx \", \$10, \" $ts\"; }" >> $tf if [ $is_up == 1 ] ; then
json_get_var $_var "device"
fi
associations=$(iwinfo wlan0 assoclist | grep dBm | wc -l) json_cleanup
echo "${datapath}.associations $associations $ts" >> $tf }
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) determine_wifi_device_name()
echo "${datapath}.neighbours $neighbours $ts" >> $tf {
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." 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 while true; do
date timestamp=$(date +%s)
$0 --send date -R -d "${timestamp}"
sleep 5 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 done
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))
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJfsG/myO4y9WzJSP+ixluHFmkIMJJRsvRT8t5h4y/5A7QzovOw1GpCmWJWnZ6GKXilTxb8ycqVfDcFPB2NRkdJUjYL+v4IMriPeBigAjc6FoUZXOS3TOZVhaTlNT4XxXKOYF/Rpgscv5f0iu1SG0Tp4mb2TX04pZjbnLNBABbjn592abEuMG5bH/g9odi50S0MoU/qCH9AZvkoc8vGu+flOBrKfFi+7g2GxF/w66mMvCJfK27QFSPOiFV3CT6ZfSZM138OCdC1SOi89X9+oCEQ3LB9A+bJgyYnxqp8eVpRPui6K9sPkax71tMimRJA5Xgdvqt9HpcgtNYxKJ4gYMR ffpb-statusbot
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment