2011-03-23 14:59:44 +01:00
|
|
|
#!/bin/sh
|
2012-01-11 22:03:10 +01:00
|
|
|
# Netmon Nodewatcher (C) 2010-2012 Freifunk Oldenburg
|
|
|
|
# License; GPL v3
|
2011-05-25 22:15:19 +02:00
|
|
|
|
2014-08-17 14:59:05 +02:00
|
|
|
test -f /tmp/started || exit
|
|
|
|
|
2018-10-31 17:35:39 +01:00
|
|
|
# Allow only one instance
|
|
|
|
lockfile="/var/lock/${0##*/}.lock"
|
|
|
|
if ! lock -n "$lockfile"; then
|
|
|
|
echo "Only one instance of $0 allowed."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
trap "lock -u \"$lockfile\"" INT TERM EXIT
|
|
|
|
|
2019-10-01 21:03:26 +02:00
|
|
|
SCRIPT_VERSION="55"
|
2018-10-31 17:35:39 +01:00
|
|
|
|
2012-01-11 22:03:10 +01:00
|
|
|
#Get the configuration from the uci configuration file
|
|
|
|
#If it does not exists, then get it from a normal bash file with variables.
|
2011-03-23 14:59:44 +01:00
|
|
|
if [ -f /etc/config/nodewatcher ];then
|
2016-06-11 17:20:51 +02:00
|
|
|
SCRIPT_ERROR_LEVEL=$(uci get nodewatcher.@script[0].error_level)
|
|
|
|
SCRIPT_LOGFILE=$(uci get nodewatcher.@script[0].logfile)
|
|
|
|
SCRIPT_DATA_FILE=$(uci get nodewatcher.@script[0].data_file)
|
|
|
|
MESH_INTERFACE=$(uci get nodewatcher.@network[0].mesh_interface)
|
|
|
|
IFACEBLACKLIST=$(uci get nodewatcher.@network[0].iface_blacklist)
|
|
|
|
IPWHITELIST=$(uci get nodewatcher.@network[0].ip_whitelist)
|
|
|
|
SCRIPT_STATUS_FILE=$(uci get nodewatcher.@script[0].status_text_file)
|
2011-03-23 14:59:44 +01:00
|
|
|
else
|
2016-06-11 17:20:51 +02:00
|
|
|
. "$(dirname "$0")/nodewatcher_config"
|
2011-03-23 14:59:44 +01:00
|
|
|
fi
|
|
|
|
|
2016-06-11 17:20:51 +02:00
|
|
|
if [ "$SCRIPT_ERROR_LEVEL" -gt "1" ]; then
|
2013-01-31 22:43:38 +01:00
|
|
|
err() {
|
2016-06-11 17:20:51 +02:00
|
|
|
echo "$1" >> "$SCRIPT_LOGFILE"
|
2013-01-31 22:43:38 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
err() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2017-12-29 16:00:02 +01:00
|
|
|
#This method checks if the log file has become too big and deletes the first X lines
|
2011-03-23 14:59:44 +01:00
|
|
|
delete_log() {
|
2016-06-11 17:20:51 +02:00
|
|
|
if [ -f "$SCRIPT_LOGFILE" ]; then
|
|
|
|
if [ "$(find "$SCRIPT_LOGFILE" -printf "%s")" -gt "6000" ]; then
|
|
|
|
sed -i '1,60d' "$SCRIPT_LOGFILE"
|
|
|
|
err "$(date): Logfile has been made smaller"
|
2016-06-11 17:20:47 +02:00
|
|
|
fi
|
|
|
|
fi
|
2011-03-23 14:59:44 +01:00
|
|
|
}
|
|
|
|
|
2015-10-10 10:24:57 +02:00
|
|
|
inArray() {
|
2016-06-11 17:20:47 +02:00
|
|
|
local value
|
|
|
|
for value in $1; do
|
|
|
|
if [ "$value" = "$2" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
2015-10-10 10:24:57 +02:00
|
|
|
}
|
|
|
|
|
2017-12-29 16:00:02 +01:00
|
|
|
#This method generates the crawl data XML file that is being fetched by netmon
|
2012-01-11 22:03:10 +01:00
|
|
|
#and provided by a small local httpd
|
2011-03-23 14:59:44 +01:00
|
|
|
crawl() {
|
2016-06-11 17:20:47 +02:00
|
|
|
#Get system data from other locations
|
2016-06-11 17:20:51 +02:00
|
|
|
err "$(date): Collecting basic system status data"
|
2016-06-11 17:20:47 +02:00
|
|
|
hostname="$(cat /proc/sys/kernel/hostname)"
|
2017-10-03 01:04:07 +02:00
|
|
|
mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
|
2018-11-12 20:14:54 +01:00
|
|
|
[ "$hostname" = "OpenWrt" ] && hostname="$mac"
|
2017-11-03 15:00:00 +01:00
|
|
|
[ "$hostname" = "FFF" ] && hostname="$mac"
|
|
|
|
description="$(uci -q get fff.system.description)"
|
2016-06-11 17:20:47 +02:00
|
|
|
if [ -n "$description" ]; then
|
2016-09-18 15:54:00 +02:00
|
|
|
description="<description><![CDATA[$description]]></description>"
|
2016-06-11 17:20:47 +02:00
|
|
|
fi
|
2017-11-03 15:00:00 +01:00
|
|
|
latitude="$(uci -q get fff.system.latitude)"
|
|
|
|
longitude="$(uci -q get fff.system.longitude)"
|
2016-06-11 17:20:47 +02:00
|
|
|
if [ -n "$longitude" -a -n "$latitude" ]; then
|
|
|
|
geo="<geo><lat>$latitude</lat><lng>$longitude</lng></geo>";
|
|
|
|
fi
|
2017-11-03 15:00:00 +01:00
|
|
|
position_comment="$(uci -q get fff.system.position_comment)"
|
2016-06-11 17:20:47 +02:00
|
|
|
if [ -n "$position_comment" ]; then
|
2016-09-18 15:54:00 +02:00
|
|
|
position_comment="<position_comment><![CDATA[$position_comment]]></position_comment>"
|
2016-06-11 17:20:47 +02:00
|
|
|
fi
|
2017-11-03 15:00:00 +01:00
|
|
|
contact="$(uci -q get fff.system.contact)"
|
2016-06-11 17:20:47 +02:00
|
|
|
if [ -n "$contact" ]; then
|
|
|
|
contact="<contact>$contact</contact>"
|
|
|
|
fi
|
|
|
|
uptime=$(awk '{ printf "<uptime>"$1"</uptime><idletime>"$2"</idletime>" }' /proc/uptime)
|
|
|
|
|
2013-01-31 22:43:38 +01:00
|
|
|
memory=$(awk '
|
|
|
|
/^MemTotal/ { printf "<memory_total>"$2"</memory_total>" }
|
|
|
|
/^Cached:/ { printf "<memory_caching>"$2"</memory_caching>" }
|
|
|
|
/^Buffers/ { printf "<memory_buffering>"$2"</memory_buffering>" }
|
|
|
|
/^MemFree/ { printf "<memory_free>"$2"</memory_free>" }
|
|
|
|
' /proc/meminfo)
|
2016-06-11 17:20:47 +02:00
|
|
|
cpu=$(awk -F': ' '
|
2013-01-31 22:43:38 +01:00
|
|
|
/model/ { printf "<cpu>"$2"</cpu>" }
|
|
|
|
/system type/ { printf "<chipset>"$2"</chipset>" }
|
2016-06-11 17:20:49 +02:00
|
|
|
/platform/ { printf "<chipset>"$2"</chipset>" }
|
2013-01-31 22:43:38 +01:00
|
|
|
' /proc/cpuinfo)
|
2016-06-11 17:20:47 +02:00
|
|
|
model="<model>$(cat /var/sysinfo/model)</model>"
|
2016-06-11 17:20:51 +02:00
|
|
|
local_time="$(date +%s)"
|
2016-06-11 17:20:47 +02:00
|
|
|
load=$(awk '{ printf "<loadavg>"$3"</loadavg><processes>"$4"</processes>" }' /proc/loadavg)
|
2011-03-23 14:59:44 +01:00
|
|
|
|
2016-06-11 17:20:51 +02:00
|
|
|
err "$(date): Collecting version information"
|
2016-06-11 17:20:47 +02:00
|
|
|
|
2013-01-31 22:43:38 +01:00
|
|
|
batman_adv_version=$(cat /sys/module/batman_adv/version)
|
2016-06-11 17:20:47 +02:00
|
|
|
kernel_version=$(uname -r)
|
2016-06-11 17:20:50 +02:00
|
|
|
if [ -x /usr/bin/fastd ]; then
|
|
|
|
fastd_version="<fastd_version>$(/usr/bin/fastd -v | awk '{ print $2 }')</fastd_version>"
|
|
|
|
fi
|
2016-06-11 17:20:47 +02:00
|
|
|
nodewatcher_version=$SCRIPT_VERSION
|
2019-10-01 21:03:26 +02:00
|
|
|
if [ -x /usr/sbin/babeld ]; then
|
|
|
|
babel_version="<babel_version>$(/usr/sbin/babeld -V 2>&1)</babel_version>"
|
|
|
|
fi
|
2011-03-23 14:59:44 +01:00
|
|
|
|
2016-06-11 17:20:47 +02:00
|
|
|
if [ -f "$SCRIPT_STATUS_FILE" ]; then
|
|
|
|
status_text="<status_text>$(cat "$SCRIPT_STATUS_FILE")</status_text>"
|
|
|
|
fi
|
2015-12-10 16:17:14 +01:00
|
|
|
|
2019-06-27 14:44:27 +02:00
|
|
|
# Checks if fastd is running
|
|
|
|
if pidof fastd >/dev/null ; then
|
2017-05-30 22:11:43 +02:00
|
|
|
vpn_active="<vpn_active>1</vpn_active>"
|
|
|
|
else
|
|
|
|
vpn_active="<vpn_active>0</vpn_active>"
|
|
|
|
fi
|
|
|
|
|
2013-01-31 22:43:38 +01:00
|
|
|
# example for /etc/openwrt_release:
|
|
|
|
#DISTRIB_ID="OpenWrt"
|
|
|
|
#DISTRIB_RELEASE="Attitude Adjustment"
|
|
|
|
#DISTRIB_REVISION="r35298"
|
|
|
|
#DISTRIB_CODENAME="attitude_adjustment"
|
|
|
|
#DISTRIB_TARGET="atheros/generic"
|
|
|
|
#DISTRIB_DESCRIPTION="OpenWrt Attitude Adjustment 12.09-rc1"
|
2016-06-11 17:20:47 +02:00
|
|
|
. /etc/openwrt_release
|
2013-01-31 22:43:38 +01:00
|
|
|
distname=$DISTRIB_ID
|
|
|
|
distversion=$DISTRIB_RELEASE
|
|
|
|
|
|
|
|
# example for /etc/firmware_release:
|
|
|
|
#FIRMWARE_VERSION="95f36685e7b6cbf423f02cf5c7f1e785fd4ccdae-dirty"
|
2015-07-17 18:47:06 +02:00
|
|
|
#BUILD_DATE="build date: Di 29. Jan 19:33:34 CET 2013"
|
2013-01-31 22:43:38 +01:00
|
|
|
#OPENWRT_CORE_REVISION="35298"
|
|
|
|
#OPENWRT_FEEDS_PACKAGES_REVISION="35298"
|
2016-06-11 17:20:47 +02:00
|
|
|
. /etc/firmware_release
|
2016-06-11 17:20:48 +02:00
|
|
|
|
|
|
|
SYSTEM_DATA="<status>online</status>"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"$status_text"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<hostname>$hostname</hostname>"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"${description}"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"${geo}"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"${position_comment}"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"${contact}"
|
2018-11-12 20:12:34 +01:00
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<hood>$(uci -q get "system.@system[0].hood")</hood>"
|
2018-11-23 16:56:43 +01:00
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<hoodid>$(uci -q get "system.@system[0].hoodid")</hoodid>"
|
2016-06-11 17:20:48 +02:00
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<distname>$distname</distname>"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<distversion>$distversion</distversion>"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"$cpu"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"$model"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"$memory"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"$load"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"$uptime"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<local_time>$local_time</local_time>"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<batman_advanced_version>$batman_adv_version</batman_advanced_version>"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<kernel_version>$kernel_version</kernel_version>"
|
2016-06-11 17:20:50 +02:00
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"$fastd_version"
|
2016-06-11 17:20:48 +02:00
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<nodewatcher_version>$nodewatcher_version</nodewatcher_version>"
|
2019-10-01 21:03:26 +02:00
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"$babel_version"
|
2016-06-11 17:20:48 +02:00
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<firmware_version>$FIRMWARE_VERSION</firmware_version>"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<firmware_revision>$BUILD_DATE</firmware_revision>"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<openwrt_core_revision>$OPENWRT_CORE_REVISION</openwrt_core_revision>"
|
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"<openwrt_feeds_packages_revision>$OPENWRT_FEEDS_PACKAGES_REVISION</openwrt_feeds_packages_revision>"
|
2017-05-30 22:11:43 +02:00
|
|
|
SYSTEM_DATA=$SYSTEM_DATA"$vpn_active"
|
2013-01-31 22:43:38 +01:00
|
|
|
|
2016-06-11 17:20:51 +02:00
|
|
|
err "$(date): Collecting information from network interfaces"
|
2011-03-23 14:59:44 +01:00
|
|
|
|
2016-06-11 17:20:47 +02:00
|
|
|
#Get interfaces
|
|
|
|
interface_data=""
|
|
|
|
#Loop interfaces
|
2016-06-11 17:20:51 +02:00
|
|
|
#for entry in $IFACES; do
|
|
|
|
for filename in $(grep 'up\|unknown' /sys/class/net/*/operstate); do
|
2013-01-31 22:43:38 +01:00
|
|
|
ifpath=${filename%/operstate*}
|
|
|
|
iface=${ifpath#/sys/class/net/}
|
2015-10-10 10:24:57 +02:00
|
|
|
if inArray "$IFACEBLACKLIST" "$iface"; then
|
2013-01-31 22:43:38 +01:00
|
|
|
continue
|
|
|
|
fi
|
2015-10-10 10:24:59 +02:00
|
|
|
|
|
|
|
#Get interface data for whitelisted interfaces
|
2016-06-11 17:20:51 +02:00
|
|
|
# shellcheck disable=SC2016
|
2015-10-10 10:24:59 +02:00
|
|
|
awkscript='
|
2013-01-31 22:43:38 +01:00
|
|
|
/ether/ { printf "<mac_addr>"$2"</mac_addr>" }
|
2015-10-10 10:24:59 +02:00
|
|
|
/mtu/ { printf "<mtu>"$5"</mtu>" }'
|
|
|
|
if inArray "$IPWHITELIST" "$iface"; then
|
2016-06-11 17:20:51 +02:00
|
|
|
# shellcheck disable=SC2016
|
2015-10-10 10:24:59 +02:00
|
|
|
awkscript=$awkscript'
|
|
|
|
/inet / { split($2, a, "/"); printf "<ipv4_addr>"a[1]"</ipv4_addr>" }
|
|
|
|
/inet6/ && /scope global/ { printf "<ipv6_addr>"$2"</ipv6_addr>" }
|
|
|
|
/inet6/ && /scope link/ { printf "<ipv6_link_local_addr>"$2"</ipv6_link_local_addr>"}'
|
|
|
|
fi
|
2016-06-11 17:20:51 +02:00
|
|
|
addrs=$(ip addr show dev "${iface}" | awk "$awkscript")
|
2015-10-10 10:24:59 +02:00
|
|
|
|
2016-06-11 17:20:51 +02:00
|
|
|
traffic_rx=$(cat "$ifpath/statistics/rx_bytes")
|
|
|
|
traffic_tx=$(cat "$ifpath/statistics/tx_bytes")
|
2016-06-11 17:20:47 +02:00
|
|
|
|
2013-01-31 22:43:38 +01:00
|
|
|
interface_data=$interface_data"<$iface><name>$iface</name>$addrs<traffic_rx>$traffic_rx</traffic_rx><traffic_tx>$traffic_tx</traffic_tx>"
|
|
|
|
|
2016-06-11 17:20:51 +02:00
|
|
|
interface_data=$interface_data$(iwconfig "${iface}" 2>/dev/null | awk -F':' '
|
2013-01-31 22:43:38 +01:00
|
|
|
/Mode/{ split($2, m, " "); printf "<wlan_mode>"m[1]"</wlan_mode>" }
|
|
|
|
/Cell/{ split($0, c, " "); printf "<wlan_bssid>"c[5]"</wlan_bssid>" }
|
|
|
|
/ESSID/ { split($0, e, "\""); printf "<wlan_essid>"e[2]"</wlan_essid>" }
|
|
|
|
/Freq/{ split($3, f, " "); printf "<wlan_frequency>"f[1]f[2]"</wlan_frequency>" }
|
|
|
|
/Tx-Power/{ split($0, p, "="); sub(/[[:space:]]*$/, "", p[2]); printf "<wlan_tx_power>"p[2]"</wlan_tx_power>" }
|
2017-12-29 16:00:02 +01:00
|
|
|
')
|
|
|
|
|
|
|
|
interface_data=$interface_data$(iw dev "${iface}" info 2>/dev/null | awk '
|
|
|
|
/ssid/{ split($0, s, " "); printf "<wlan_ssid>"s[2]"</wlan_ssid>" }
|
|
|
|
/type/ { split($0, t, " "); printf "<wlan_type>"t[2]"</wlan_type>" }
|
|
|
|
/channel/{ split($0, c, " "); printf "<wlan_channel>"c[2]"</wlan_channel>" }
|
|
|
|
/width/{ split($0, w, ": "); sub(/ .*/, "", w[2]); printf "<wlan_width>"w[2]"</wlan_width>" }
|
|
|
|
')
|
|
|
|
|
|
|
|
interface_data=$interface_data"</$iface>"
|
2016-06-11 17:20:47 +02:00
|
|
|
done
|
2011-03-23 14:59:44 +01:00
|
|
|
|
2016-06-11 17:20:51 +02:00
|
|
|
err "$(date): Collecting information from batman advanced and its interfaces"
|
2016-06-11 17:20:47 +02:00
|
|
|
#B.A.T.M.A.N. advanced
|
2013-01-31 22:43:38 +01:00
|
|
|
if [ -f /sys/module/batman_adv/version ]; then
|
2019-07-28 21:59:55 +02:00
|
|
|
for iface in $(batctl if | sed 's/ //'); do
|
|
|
|
status=${iface##*:}
|
|
|
|
iface=${iface%%:*}
|
2013-01-31 22:43:38 +01:00
|
|
|
BATMAN_ADV_INTERFACES=$BATMAN_ADV_INTERFACES"<$iface><name>$iface</name><status>$status</status></$iface>"
|
|
|
|
done
|
|
|
|
|
2015-10-10 16:46:39 +02:00
|
|
|
# Build a list of direct neighbors
|
2019-03-25 13:09:46 +01:00
|
|
|
batman_adv_originators=$(/usr/sbin/batctl o -H | awk \
|
2015-10-10 16:46:39 +02:00
|
|
|
'BEGIN { FS=" "; i=0 } # set the delimiter to " "
|
|
|
|
{ sub("\\(", "", $0) # remove parentheses
|
2013-01-31 22:43:38 +01:00
|
|
|
sub("\\)", "", $0)
|
|
|
|
sub("\\[", "", $0)
|
2019-03-25 13:09:46 +01:00
|
|
|
sub("\\]", "", $0)
|
|
|
|
sub("\\*", "", $0)
|
2013-01-31 22:43:38 +01:00
|
|
|
sub(" ", " ", $0)
|
2015-10-10 16:46:39 +02:00
|
|
|
o=$1".*"$1 # build a regex to find lines that contains the $1 (=originator) twice
|
|
|
|
if ($0 ~ o) # filter for this regex (will remove entries without direct neighbor)
|
|
|
|
{
|
|
|
|
printf "<originator_"i"><originator>"$1"</originator><link_quality>"$3"</link_quality><nexthop>"$4"</nexthop><last_seen>"$2"</last_seen><outgoing_interface>"$5"</outgoing_interface></originator_"i">"
|
|
|
|
i++
|
|
|
|
}
|
2019-03-25 13:09:46 +01:00
|
|
|
}')
|
2016-06-11 17:20:47 +02:00
|
|
|
|
2019-03-25 13:09:46 +01:00
|
|
|
batman_adv_gateway_mode=$(/usr/sbin/batctl gw)
|
2016-06-11 17:20:47 +02:00
|
|
|
|
2019-03-25 13:09:46 +01:00
|
|
|
batman_adv_gateway_list=$(/usr/sbin/batctl gwl -H | awk \
|
2016-06-11 17:20:47 +02:00
|
|
|
'BEGIN { FS=" "; i=0 }
|
|
|
|
/No gateways/ { next }
|
2018-01-13 15:28:54 +01:00
|
|
|
{ sub("\\(", "", $0)
|
2016-06-11 17:20:47 +02:00
|
|
|
sub("\\)", "", $0)
|
2018-01-13 15:28:54 +01:00
|
|
|
sub("\\[ *", "", $0)
|
2016-06-11 17:20:47 +02:00
|
|
|
sub("\\]:", "", $0)
|
2019-03-25 13:09:46 +01:00
|
|
|
sub("\\* ", "true ", $0)
|
|
|
|
sub(" ", "false ", $0)
|
2016-06-11 17:20:47 +02:00
|
|
|
printf "<gateway_"i"><selected>"$1"</selected><gateway>"$2"</gateway><link_quality>"$3"</link_quality><nexthop>"$4"</nexthop><outgoing_interface>"$5"</outgoing_interface><gw_class>"$6" "$7" "$8"</gw_class></gateway_"i">"
|
|
|
|
i++
|
2019-03-25 13:09:46 +01:00
|
|
|
}')
|
2013-01-31 22:43:38 +01:00
|
|
|
fi
|
2016-06-11 17:20:51 +02:00
|
|
|
err "$(date): Collecting information about conected clients"
|
2016-06-11 17:20:47 +02:00
|
|
|
#CLIENTS
|
|
|
|
client_count=0
|
2018-01-21 13:53:02 +01:00
|
|
|
dataclient=""
|
2018-07-25 14:24:10 +02:00
|
|
|
CLIENT_INTERFACES=$(ls "/sys/class/net/$MESH_INTERFACE/brif" | grep -v '^bat')
|
2016-06-11 17:20:47 +02:00
|
|
|
for clientif in ${CLIENT_INTERFACES}; do
|
2016-06-11 17:20:51 +02:00
|
|
|
local cc=$(bridge fdb show br "$MESH_INTERFACE" brport "$clientif" | grep -v self | grep -v permanent -c)
|
|
|
|
client_count=$((client_count + cc))
|
2018-01-21 13:53:02 +01:00
|
|
|
dataclient="$dataclient<$clientif>$cc</$clientif>"
|
2016-06-11 17:20:47 +02:00
|
|
|
done
|
2011-05-26 19:12:29 +02:00
|
|
|
|
2018-01-21 20:47:48 +01:00
|
|
|
dataair=""
|
|
|
|
w2dump="$(iw dev w2ap survey dump 2> /dev/null | sed '/Survey/,/\[in use\]/d')"
|
|
|
|
if [ -n "$w2dump" ] ; then
|
|
|
|
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}")"
|
|
|
|
dataair="$dataair<airtime2><active>$w2_ACT</active><busy>$w2_BUS</busy></airtime2>"
|
|
|
|
fi
|
|
|
|
w5dump="$(iw dev w5ap survey dump 2> /dev/null | sed '/Survey/,/\[in use\]/d')"
|
|
|
|
if [ -n "$w5dump" ] ; then
|
|
|
|
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}")"
|
|
|
|
dataair="$dataair<airtime5><active>$w5_ACT</active><busy>$w5_BUS</busy></airtime5>"
|
|
|
|
fi
|
|
|
|
|
2016-06-11 17:20:51 +02:00
|
|
|
err "$(date): Putting all information into a XML-File and save it at $SCRIPT_DATA_FILE"
|
2011-05-25 22:15:19 +02:00
|
|
|
|
2016-06-11 17:20:48 +02:00
|
|
|
DATA="<?xml version='1.0' standalone='yes'?><data>"
|
|
|
|
DATA=$DATA"<system_data>$SYSTEM_DATA</system_data>"
|
|
|
|
DATA=$DATA"<interface_data>$interface_data</interface_data>"
|
|
|
|
DATA=$DATA"<batman_adv_interfaces>$BATMAN_ADV_INTERFACES</batman_adv_interfaces>"
|
|
|
|
DATA=$DATA"<batman_adv_originators>$batman_adv_originators</batman_adv_originators>"
|
|
|
|
DATA=$DATA"<batman_adv_gateway_mode>$batman_adv_gateway_mode</batman_adv_gateway_mode>"
|
|
|
|
DATA=$DATA"<batman_adv_gateway_list>$batman_adv_gateway_list</batman_adv_gateway_list>"
|
|
|
|
DATA=$DATA"<client_count>$client_count</client_count>"
|
2018-01-21 13:53:02 +01:00
|
|
|
DATA=$DATA"<clients>$dataclient</clients>"
|
2018-01-21 20:47:48 +01:00
|
|
|
DATA=$DATA"$dataair"
|
2016-06-11 17:20:48 +02:00
|
|
|
DATA=$DATA"</data>"
|
2011-05-25 22:15:19 +02:00
|
|
|
|
2016-11-04 21:44:06 +01:00
|
|
|
#write data to xml file that provides the data on httpd
|
2016-06-11 17:20:51 +02:00
|
|
|
SCRIPT_DATA_DIR=$(dirname "$SCRIPT_DATA_FILE")
|
|
|
|
test -d "$SCRIPT_DATA_DIR" || mkdir -p "$SCRIPT_DATA_DIR"
|
|
|
|
echo "$DATA" | gzip | tee "$SCRIPT_DATA_FILE" | alfred -s 64
|
2011-03-23 14:59:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LANG=C
|
|
|
|
|
2012-01-11 22:03:10 +01:00
|
|
|
#Prüft ob das logfile zu groß geworden ist
|
2016-06-11 17:20:51 +02:00
|
|
|
err "$(date): Check logfile"
|
2012-01-11 22:03:10 +01:00
|
|
|
delete_log
|
2011-03-23 14:59:44 +01:00
|
|
|
|
2012-01-11 22:03:10 +01:00
|
|
|
#Erzeugt die statusdaten
|
2016-06-11 17:20:51 +02:00
|
|
|
err "$(date): Generate actual status data"
|
2012-01-11 22:03:10 +01:00
|
|
|
crawl
|
2011-03-23 14:59:44 +01:00
|
|
|
|
2015-07-17 18:47:06 +02:00
|
|
|
exit 0
|