diff --git a/files/ckeck_mk-supernode b/files/ckeck_mk-supernode new file mode 100644 index 0000000..19a902c --- /dev/null +++ b/files/ckeck_mk-supernode @@ -0,0 +1,70 @@ +#!/bin/bash +#/usr/lib/check_mk_agent/local +export LANG=de_DE.UTF-8 + +function confline # get first line from file $1 mathing $2, stripped of # and ; comment lines, stripped spaces and tabs down to spaces, remove trailing ; +{ + echo $(cat $1|grep -v '^$\|^\s*\#'|sed -e "s/[[:space:]]\+/ /g"|sed s/^\ //|sed s/\;//|grep -i "$2"|head -n 1) +} + +function ati # ipv4 to longint +{ + ip4=$1; ipno=0 + for (( i=0 ; i<4 ; ++i )); do + ((ipno+=${ip4%%.*}*$((254**$((3-${i})))))) # .0 .255 should not be counted + ip4=${ip4#*.} + done + echo $ipno +} + +## static data +bat_version=$(batctl -v); +kernel=$(uname -r); +release=$(lsb_release -ds); + +## Batman +echo "0 Batman-Version Version=$bat_version; $bat_version" +list=$(ls -F /sys/kernel/debug/batman_adv|grep /) +for i in $list; do + z=$(ls /sys/kernel/debug/batman_adv/$i|wc -l) + if [ $z -ge 9 ]; then + b=$(echo $i|cut -d '/' -f1) + router=$(($(batctl -m $b o|wc -l)-2 )) + clients=$(grep -cEo "\[.*W.*\]+" /sys/kernel/debug/batman_adv/$b/transtable_global) + gateways=$(( $(batctl -m $b gwl|wc -l) -1 )) + ips=$(( $(batctl -m $b dc|wc -l) - 2)) + wlow=$(( $router * 20 / 100 )) + clow=$(( $router * 5 / 100 )) + wlimit=$(( $router * 5 )) + climit=$(( $router * 10 )) + echo "P Batman-$b Router=$router.0;5:250;1:500|Clients=$clients.0;$wlow.0:$wlimit.0;$clow.0:$climit.0|Gateways=$gateways.0;0:3;0:5;|IPs=$ips.0"; + fi; + done + +## isc-dhcpd-server leases +# needs script https://github.com/eulenfunk/scripts/blob/master/dhcpleases +if [ -r /opt/freifunk/dhcpleases ] ; then + totalleases=2040 + activeleases=$(python /opt/freifunk/dhcpleases|grep "^| Total"|cut -d":" -f2|sed s/\ //) + remainingleases=$(($totalleases - $activeleases)) + actwarn=$(($totalleases * 75 / 100)) + actcrit=$(($totalleases * 90 / 100)) + echo "P Dhcp-Leases active-leases=$activeleases.0;5:$actwarn;1:$actcrit active:$activeleases remaining:$remainingleases pool=$totalleases"; + fi + +#L2TP +l_tunnel=$(ip a |grep l2tp | grep br-nodes -c); +tunneldigger=$(ifconfig|grep br-nodes -c); +echo "P L2TP Clients=$l_tunnel.0;1:100;0:150|Tunneldiggerbridges=$tunneldigger.0;0.1:1;0.1:2; L2TP-Clients:$l_tunnel Tunneldiggerbridges:$tunneldigger" + +## Conntrack +conntrack=$(conntrack -C); +conntrack_limit=$(sysctl -a 2>/dev/null |grep net.nf_conntrack_max|cut -d ' ' -f 3); +conntrack_remain=$(echo $conntrack_limit - $conntrack|bc) +wlow=0.1 +clow=1.1 +wlimit=$(echo $conntrack_limit *0.7|bc) +climit=$(echo $conntrack_limit *0.9|bc) +wrlimit=$(echo $conntrack_limit *0.3|bc) +crlimit=$(echo $conntrack_limit *0.1|bc) +echo "P Conntrack conntrack=$conntrack.0;$wlow:$wlimit;$clow:$climit|conntrack_remain=$conntrack_remain.0;$wrlimit:$conntrack_limit;$crlimit:$conntrack_limit; Conntrack:$conntrack Conntrack-Remain:$conntrack_remain Conntrack-Limit:$conntrack_limit"