Initial import. Rewrote some stuff while adding so there might be breakage.

This commit is contained in:
Matthew Connelly 2015-02-19 22:03:46 +00:00
parent 2d623fa003
commit bc679d92d4
18 changed files with 630 additions and 0 deletions

View File

@ -1,2 +1,17 @@
# openwrt-munin-node
openwrt-oriented munin-node implementation inspired by muninlite
## Quick installation guide
Install `munin-node`:
`mkdir -p /usr/local/bin /etc/munin-node
cd /etc/munin-node
wget -O munin-node.tar.gz https://github.com/MaffC/openwrt-munin-node/archive/master.tar.gz
tar xzf munin-node.tar.gz plugins.d
tar xzf munin-node.tar.gz munin-node -C /usr/local/bin/
rm munin-node.tar.gz`
Install dependencies for included plugins as needed:
`opkg update
opkg install perl curl iwinfo`

30
munin-node Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
base="/etc/munin-node" # plugins should be installed at plugins.d inside $base
base=.
myname='openwrt-munin-node'
ver='1.1'
host=`cat /proc/sys/kernel/hostname`
modules=""
register_module() { mn=`echo $1|sed 's/:$//'`;me=`echo $2|sed 's/:$//'`;shift 2;for f in config fetch;do rme=$me;[ "`echo $me|head -c1`" == "_" ]&&rme="$f$me";eval "${f}_$mn() { $rme `[ "$f" == "config" ]&&echo config` $@ \$@; };";done; }
is_registered() { [ ! -z "`command -v config_$1`" ] && [ ! -z "`command -v fetch_$1`" ] && return 0;return 1; }
register_modules() { for mod in `ls -1 $base/plugins.d/*`;do [ -f $mod -a -x $mod ] || continue;modn=`basename $mod`;[ "$modn" != "if" ]&&modules="$modules $modn";register_module $modn $mod;done; }
register_iface_modules() { for iface in `ifconfig|grep '^\w'|awk '{print $1}'`;do [ "$iface" == "lo" ] && continue; iface_mod=`echo $iface|sed -e 's/\./VLAN/;s/\-/_/'`;modules="$modules if_$iface_mod";register_module if_$iface_mod _if $iface;done; }
register_modules
is_registered 'if' && register_iface_modules
echo "# munin node at $host"
while read cmd mod;do
case $cmd in
list) echo $modules;;
config) is_registered $mod && config_$mod || echo "# Unknown plugin";;
fetch) is_registered $mod && fetch_$mod || echo "# Unknown plugin";;
nodes) echo $host;;
version) echo "munin node on $host version: $ver ($myname)";;
help) echo "# Commands: list, config, fetch, nodes, version, help, quit";;
quit) exit 0;;
*) echo "# Unknown command. Try help."
esac
echo '.'
done

23
plugins.d/README Normal file
View File

@ -0,0 +1,23 @@
Plugins should be installed in this directory, and should have purely alphanumeric names. Plugins can, as with all munin-node implementations I've seen, be written in any supported language, however as this munin-node implementation specifically targets OpenWRT, sh-compatible/ash-specific shellscript is recommended.
Plugins in this directory may be enabled/disabled as needed by either adding or removing the executable permission (chmod +x, chmod -x).
The following plugins were originally provided with muninlite (http://sourceforge.net/projects/muninlite/) and have been altered to varying degrees to act as generic plugins. These plugins and the muninlite project are licensed under the GPLv2 and are included for completion's sake.
- df
- if
- interrupts
- irqstats
- memory
The following plugins were originally provided with muninlite, but have been largely rewritten and may resemble their original in graph configuration only:
- cpu
- uptime
The following plugins have been written to more specifically monitor the functions of an OpenWRT router installation, and are licensed under the 3-clause BSD license:
- dhcp - Tracks the current count of valid DHCP leases.
- dns - Tracks caching/forwarding statistics in the dnsmasq caching resolver
- load - Tracks system load for the past one, five and fifteen minutes, as well as active and running processes.
- netstats - Tracks currently-open TCP, UDP, ICMP and other connections. A netstats plugin is provided with muninlite, however it is related only in name to this.
- ping - Tracks outbound latency and packet loss to a single host, intended to measure outbound connection quality/uptime through an ISP.
- skysr102 - Tracks ADSL line attenuation/noise and sync speeds. This plugin is specific to the Sky SR102 modem-router and may not work on other devices.
- upnp - Tracks the current count of valid UPnP forward leases
- wireless - Tracks total connected stations across all wireless interfaces, as well as signal and noise levels for each interface/AP.

71
plugins.d/cpu Executable file
View File

@ -0,0 +1,71 @@
#!/bin/sh
# this is kinda eh but i rewrote what i could
extinfo=""
[ `/bin/grep '^cpu ' /proc/stat|/usr/bin/awk '{print NF}'` -ge 8 ] && extinfo="iowait irq softirq"
if [ "$1" == "config" ];then
NCPU=`/bin/grep -c '^processor' /proc/cpuinfo`
PERCENT=$(($NCPU * 100))
graphlimit=$PERCENT
SYSWARNING=$(($PERCENT * 30 / 100))
SYSCRITICAL=$(($PERCENT * 50 / 100))
USRWARNING=$(($PERCENT * 80 / 100))
echo "graph_title CPU usage
graph_order system user nice idle $extinfo
graph_args --base 1000 -r --lower-limit 0 --upper-limit $graphlimit
graph_vlabel %
graph_scale no
graph_info This graph shows how CPU time is spent.
graph_category system
graph_period second
system.label system
system.draw AREA
system.max 5000
system.min 0
system.type DERIVE
system.warning $SYSWARNING
system.critical $SYSCRITICAL
system.info CPU time spent by the kernel in system activities
user.label user
user.draw STACK
user.min 0
user.max 5000
user.warning $USRWARNING
user.type DERIVE
user.info CPU time spent by normal programs and daemons
nice.label nice
nice.draw STACK
nice.min 0
nice.max 5000
nice.type DERIVE
nice.info CPU time spent by nice(1)d programs
idle.label idle
idle.draw STACK
idle.min 0
idle.max 5000
idle.type DERIVE
idle.info Idle CPU time"
[ ! -z "$extinfo" ] && echo "iowait.label iowait
iowait.draw STACK
iowait.min 0
iowait.max 5000
iowait.type DERIVE
iowait.info CPU time spent waiting for I/O operations to finish
irq.label irq
irq.draw STACK
irq.min 0
irq.max 5000
irq.type DERIVE
irq.info CPU time spent handling interrupts
softirq.label softirq
softirq.draw STACK
softirq.min 0
softirq.max 5000
softirq.type DERIVE
softirq.info CPU time spent handling 'batched' interrupts"
exit 0
fi
/bin/grep '^cpu ' /proc/stat|/usr/bin/awk '{print "user.value "$2"\nnice.value "$3"\nsystem.value "$4"\nidle.value "$5}'
[ ! -z "$extinfo" ] && /bin/grep '^cpu ' /proc/stat|/usr/bin/awk '{print "iowait.value "$6"\nirq.value "$7"\nsoftirq.value "$8}'

27
plugins.d/df Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
# this is pretty bad really but eh
PARTS=`/bin/df -P|/bin/grep '^rootfs'|/bin/sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g'`
if [ "$1" == "config" ];then
echo "graph_title Disk usage (percent)
graph_args --upper-limit 100 -l 0
graph_vlabel percent
graph_category disk
graph_info This graph shows disk usage on the machine."
for PART in $PARTS;do
PINFO=`/bin/df -P $PART|/usr/bin/tail -1`
PNAME=`echo $PINFO|/usr/bin/cut -d\ -f1|/bin/sed 's/\//_/g'`
echo "$PNAME.label $PART
$PNAME.info $PNAME -> $PART
$PNAME.warning 92
$PNAME.critical 98"
done
exit 0
fi
for PART in $PARTS;do
PINFO=`/bin/df -P $PART|/usr/bin/tail -1`
PNAME=`echo $PINFO|/usr/bin/cut -d\ -f1|/bin/sed 's/[\/.-]/_/g'`
echo "$PNAME.value `echo $PINFO|/usr/bin/cut -d\ -f5|/bin/sed -e 's/\%//g'`"
done

14
plugins.d/dhcp Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
if [ "$1" == "config" ];then
echo "graph_title DHCP Leases
graph_vlabel leases
graph_args -l 0
graph_category network
graph_scale no
leases.label leases"
exit 0
fi
echo "leases.value `/bin/cat /tmp/dhcp.leases|/usr/bin/wc -l`"

19
plugins.d/dns Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
if [ "$1" == "config" ];then
echo "graph_title dnsmasq queries
graph_info Displays DNS resolver query caching statistics
graph_args --base 1000 -l 0
graph_period minute
graph_vlabel queries per \${graph_period}
graph_category network
graph_scale no
hits.label answered
hits.type COUNTER
misses.label forwarded
misses.type COUNTER"
exit 0
fi
/bin/kill -SIGUSR1 `/usr/bin/pgrep dnsmasq`
/sbin/logread|/usr/bin/sort -r|/bin/grep dnsmasq|/usr/bin/awk -F "[ \t\n/,]+" '/queries forwarded/ { print "misses.value "$10"\nhits.value "$14; exit; }'

25
plugins.d/if Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
if [ "$1" == "config" ];then
echo "graph_order up down
graph_title $2 traffic
graph_args --base 1000
graph_vlabel bits in (+) / out (-) per \${graph_period}
graph_category network
down.label bps
down.type DERIVE
down.min 0
down.negative up
down.cdef down,8,*
up.label bps
up.type DERIVE
up.min 0
up.graph no
up.cdef up,8,*"
exit 0
fi
# mh..
IINFO=`/bin/grep "$1:" /proc/net/dev|/usr/bin/cut -d: -f2|/bin/sed -e 's/ / /g'`
echo "down.value `echo $IINFO|/usr/bin/cut -d\ -f1`"
echo "up.value `echo $IINFO|/usr/bin/cut -d\ -f9`"

25
plugins.d/interrupts Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
if [ "$1" == "config" ];then
echo "graph_title Interrupts & context switches
graph_args --base 1000 -l 0
graph_vlabel interrupts & ctx switches / \${graph_period}
graph_category system
graph_info This graph shows the number of interrupts and context switches on the system. These are typically high on a busy system.
intr.info Interrupts are events that alter sequence of instructions executed by a processor. They can come from either hardware (exceptions, NMI, IRQ) or software.
ctx.info A context switch occurs when a multitasking operatings system suspends the currently running process, and starts executing another.
intr.label interrupts
ctx.label context switches
intr.type DERIVE
ctx.type DERIVE
intr.max 100000
ctx.max 100000
intr.min 0
ctx.min 0"
exit 0
fi
# ugh
IINFO=`/bin/cat /proc/stat`
echo "ctx.value `echo "$IINFO"|/bin/grep '^ctxt'|/usr/bin/cut -d\ -f2`"
echo "intr.value `echo "$IINFO"|/bin/grep '^intr'|/usr/bin/cut -d\ -f2`"

34
plugins.d/irqstats Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
# this is just awful.
CPUS=`/bin/grep '^processor' /proc/cpuinfo`
IINFO=`/bin/sed -e 's/ \{1,\}/ /g;s/^ //' /proc/interrupts|/bin/grep '.:'`
IDS=`echo "$IINFO"|/usr/bin/cut -d: -f1`
if [ "$1" == "config" ];then
echo "graph_title Individual interrupts
graph_args --base 1000 -l 0;
graph_vlabel interrupts / \${graph_period}
graph_category system"
for ID in $IDS;do
IDL=`echo "$IINFO"|/bin/grep "^$ID:"`
INFO=`echo "$IDL"|/usr/bin/cut -d\ -f$((3+$CPUS))-`
if [ "$INFO" = "" ];then
echo "i$ID.label $ID"
else
echo "i$ID.label $INFO"
echo "i$ID.info Interrupt $ID, for device(s): $INFO"
fi
echo "i$ID.type DERIVE"
echo "i$ID.min 0"
done
exit 0
fi
for ID in $IDS;do
IDL=`echo "$IINFO"|/bin/grep "^$ID:"`
VALS=`echo "$IDL"|/usr/bin/cut -d\ -f2-$((1+$CPUS))`
VALUE=0
for VAL in $VALS;do VALUE=$(($VALUE + $VAL));done
echo "i$ID.value $VALUE"
done

26
plugins.d/load Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
if [ "$1" == "config" ];then
echo "multigraph load
graph_title Load averages
graph_args --base 1000 -l 0
graph_vlabel load average
graph_scale no
graph_category system
loadone.label load (1min)
load.label load (5min)
loadfifteen.label load (15min)
multigraph processes
graph_title System Processes
graph_args --base 1000 -l 0
graph_vlabel processes
graph_scale no
graph_category system
active.label active procs
running.label total running procs"
exit 0
fi
/usr/bin/awk '{print "multigraph load\nloadone.value "$1"\nload.value "$2"\nloadfifteen.value "$3}' /proc/loadavg
/usr/bin/awk '{print $4}' /proc/loadavg|/bin/sed -e 's/^/multigraph processes\nactive.value /;s/\//\nrunning.value /'

128
plugins.d/memory Executable file
View File

@ -0,0 +1,128 @@
#!/bin/sh
# this is just a complete fucking mess i tried my best to fix it
MINFO=`/bin/cat /proc/meminfo|/bin/sed 's/ \{1,\}/ /g;'`
MEMFREE=`echo "$MINFO"|/bin/grep "^MemFree:" |/usr/bin/awk '{print $2}'`
BUFFERS=`echo "$MINFO"|/bin/grep "^Buffers:" |/usr/bin/awk '{print $2}'`
CACHED=`echo "$MINFO"|/bin/grep "^Cached:" |/usr/bin/awk '{print $2}'`
SWAP_TOTAL=`echo "$MINFO"|/bin/grep "^SwapTotal:" |/usr/bin/awk '{print $2}'`
SWAP_FREE=`echo "$MINFO"|/bin/grep "^SwapFree:" |/usr/bin/awk '{print $2}'`
MEMTOTAL=`echo "$MINFO"|/bin/grep "^MemTotal:" |/usr/bin/awk '{print $2}'`
PAGETABLES=`echo "$MINFO"|/bin/grep "^PageTables:" |/usr/bin/awk '{print $2}'`
SWAPCACHED=`echo "$MINFO"|/bin/grep "^SwapCached:" |/usr/bin/awk '{print $2}'`
SWAPTOTAL=`echo "$MINFO"|/bin/grep "^SwapTotal:" |/usr/bin/awk '{print $2}'`
VMALLOCUSED=`echo "$MINFO"|/bin/grep "^VmallocUsed:" |/usr/bin/awk '{print $2}'`
SLAB=`echo "$MINFO"|/bin/grep "^Slab:" |/usr/bin/awk '{print $2}'`
MAPPED=`echo "$MINFO"|/bin/grep "^Mapped:" |/usr/bin/awk '{print $2}'`
COMMITTEDAS=`echo "$MINFO"|/bin/grep "^Committed_AS:" |/usr/bin/awk '{print $2}'`
ACTIVE=`echo "$MINFO"|/bin/grep "^Active:" |/usr/bin/awk '{print $2}'`
INACTIVE=`echo "$MINFO"|/bin/grep "^Inactive:" |/usr/bin/awk '{print $2}'`
ACTIVEANON=`echo "$MINFO"|/bin/grep "^ActiveAnon:" |/usr/bin/awk '{print $2}'`
ACTIVECACHE=`echo "$MINFO"|/bin/grep "^ActiveCache:" |/usr/bin/awk '{print $2}'`
INACTIVE=`echo "$MINFO"|/bin/grep "^Inactive:" |/usr/bin/awk '{print $2}'`
INACTDIRTY=`echo "$MINFO"|/bin/grep "^Inact_dirty:" |/usr/bin/awk '{print $2}'`
INACTLAUNDY=`echo "$MINFO"|/bin/grep "^Inact_laundry:"|/usr/bin/awk '{print $2}'`
INACTCLEAN=`echo "$MINFO"|/bin/grep "^Inact_clean:" |/usr/bin/awk '{print $2}'`
APPS=$(($MEMTOTAL - $MEMFREE - $BUFFERS - $CACHED))
SWAP=$(($SWAP_TOTAL - $SWAP_FREE))
if [ "$1" == "config" ];then
GRAPH_ORDER="apps";
test "$PAGETABLES" != "" && GRAPH_ORDER="$GRAPH_ORDER page_tables"
test "$SWAPCACHED" != "" && GRAPH_ORDER="$GRAPH_ORDER swap_cache"
test "$VMALLOCUSED" != "" && GRAPH_ORDER="$GRAPH_ORDER vmalloc_used"
test "$SLAB" != "" && GRAPH_ORDER="$GRAPH_ORDER slab"
GRAPH_ORDER="$GRAPH_ORDER cached buffers free swap"
echo "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit $MEMTOTAL
graph_title Memory usage
graph_category system
graph_info This graph shows what the machine uses its memory for.
graph_order $GRAPH_ORDER
apps.label apps
apps.draw AREA
apps.info Memory used by user-space applications.
buffers.label buffers
buffers.draw STACK
buffers.info Block device (e.g. harddisk) cache. Also where 'dirty' blocks are stored until written.
swap.label swap
swap.draw STACK
swap.info Swap space used.
cached.label cache
cached.draw STACK
cached.info Parked file data (file content) cache.
free.label unused
free.draw STACK
free.info Wasted memory. Memory that is not used for anything at all."
[ ! -z "$SLAB" ] && echo "slab.label slab_cache
slab.draw STACK
slab.info Memory used by the kernel (major users are caches like inode, dentry, etc)."
[ ! -z "$SWAPCACHED" ] && echo "swap_cache.label swap_cache
swap_cache.draw STACK
swap_cache.info A piece of memory that keeps track of pages that have been fetched from swap but not yet been modified."
[ ! -z "$PAGETABLES" ] && echo "page_tables.label page_tables
page_tables.draw STACK
page_tables.info Memory used to map between virtual and physical memory addresses."
[ ! -z "$VMALLOCUSED" ] && echo "vmalloc_used.label vmalloc_used
vmalloc_used.draw STACK
vmalloc_used.info Virtual memory used by the kernel (used when the memory does not have to be physically contigious)."
[ ! -z "$COMMITTEDAS" ] && echo "committed.label committed
committed.draw LINE2
committed.warn $(($SWAPTOTAL + $MEMTOTAL))
committed.info The amount of memory that would be used if all the memory that's been allocated were to be used."
[ ! -z "$MAPPED" ] && echo "mapped.label mapped
mapped.draw LINE2
mapped.info All mmap()ed pages."
[ ! -z "$ACTIVE" ] && echo "active.label active
active.draw LINE2
active.info Memory recently used. Not reclaimed unless absolutely necessary."
[ ! -z "$ACTIVEANON" ] && echo "active_anon.label active_anon
active_anon.draw LINE1"
[ ! -z "$ACTIVECACHE" ] && echo "active_cache.label active_cache
active_cache.draw LINE1"
[ ! -z "$INACTIVE" ] && echo "inactive.label inactive
inactive.draw LINE2
inactive.info Memory not currently used."
[ ! -z "$INACTDIRTY" ] && echo "inact_dirty.label inactive_dirty
inact_dirty.draw LINE1
inact_dirty.info Memory not currently used, but in need of being written to disk."
[ ! -z "$INACTLAUNDRY" ] && echo "inact_laundry.label inactive_laundry
inact_laundry.draw LINE1"
[ ! -z "$INACTCLEAN" ] && echo "inact_clean.label inactive_clean
inact_clean.draw LINE1
inact_clean.info Memory not currently used."
exit 0
fi
echo "buffers.value $(($BUFFERS * 1024))
swap.value $(($SWAP * 1024))
cached.value $(($CACHED * 1024))
free.value $(($MEMFREE * 1024))"
[ ! -z "$SLAB" ] && echo "slab.value $(($SLAB * 1024))" && APPS=$(($APPS - $SLAB))
[ ! -z "$SWAPCACHED" ] && echo "swap_cache.value $(($SWAPCACHED * 1024))" && APPS=$(($APPS - $SWAPCACHED))
[ ! -z "$PAGETABLES" ] && echo "page_tables.value $(($PAGETABLES * 1024))" && APPS=$(($APPS - $PAGETABLES))
[ ! -z "$VMALLOCUSED" ] && echo "vmalloc_used.value $(($VMALLOCUSED * 1024))" && APPS=$(($APPS - $VMALLOCUSED))
[ ! -z "$COMMITTEDAS" ] && echo "committed.value $(($COMMITTEDAS * 1024))"
[ ! -z "$MAPPED" ] && echo "mapped.value $(($MAPPED * 1024))"
[ ! -z "$ACTIVE" ] && echo "active.value $(($ACTIVE * 1024))"
[ ! -z "$ACTIVEANON" ] && echo "active_anon.value $(($ACTIVEANON * 1024))"
[ ! -z "$ACTIVECACHE" ] && echo "active_cache.value $(($ACTIVECACHE * 1024))"
[ ! -z "$INACTIVE" ] && echo "inactive.value $(($INACTIVE * 1024))"
[ ! -z "$INACTDIRTY" ] && echo "inact_dirty.value $(($INACTDIRTY * 1024))"
[ ! -z "$INACTLAUNDRY" ] && echo "inact_laundry.value $(($INACTLAUNDRY * 1024))"
[ ! -z "$INACTCLEAN" ] && echo "inact_clean.value $(($INACTCLEAN * 1024))"
echo "apps.value $(($APPS * 1024))"

30
plugins.d/netstats Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
if [ "$1" = "config" ]; then
echo "graph_title Active connections
graph_args --base 1000 -l 0
graph_scale no
graph_vlabel current connections
graph_category network
graph_info This graph tracks current TCP, UDP, ICMP and other connections
tcp.label TCP
tcp.min 0
udp.label UDP
udp.min 0
icmp.label ICMP
icmp.min 0
other.label other protos
other.min 0"
exit 0
fi
TMP=`/bin/cat /proc/net/nf_conntrack`
TCP=`echo "$TMP"|/bin/grep -c "\btcp\b"`
UDP=`echo "$TMP"|/bin/grep -c "\budp\b"`
ICMP=`echo "$TMP"|/bin/grep -c "\bicmp\b"`
OTHER=$(($(echo "$TMP"|/usr/bin/wc -l) - $TCP - $UDP - $ICMP))
echo "tcp.value $TCP
udp.value $UDP
icmp.value $ICMP
other.value $OTHER"

30
plugins.d/ping Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
# This plugin requires the opkg package perl to be installed.
host="maff.scot"
if [ "$1" == "config" ];then
echo "multigraph ping_lat
graph_title ADSL latency to $host
graph_scale no
graph_args --base 1000 -l 0
graph_vlabel latency (ms)
graph_category network
graph_info This graph shows latency statistics to $host
ping.label $host
ping.min 0
multigraph ping_loss
graph_title Packet loss to $host
graph_scale no
graph_args --base 1000 -l 0
graph_vlabel loss (%)
graph_category wan
graph_info This graph shows packet loss encountered when pinging $host
loss.label % lost
loss.colour COLOUR15"
exit 0
fi
/bin/ping -c 2 $host|/usr/bin/perl -ne '/^round.*=.*?\/([0-9\.]+)\// and print "multigraph ping_lat\nping.value $1\n";/ ([0-9]+)% packet loss/ and print "multigraph ping_loss\nloss.value $1\n"'

72
plugins.d/skysr102 Executable file
View File

@ -0,0 +1,72 @@
#!/bin/sh
# This plugin is only tested and guaranteed to work on the Sky SR102 ADSL modem-router.
# This plugin requres opkg packages curl and perl to be installed.
## CHANGE THESE TO MATCH YOUR SKY ROUTER'S IP ADDRESS AND ADMIN PASSWORD
SKY_IP="192.168.0.1"
SKY_PW="sky"
## CHANGE THESE TO MATCH YOUR SKY ROUTER'S IP ADDRESS AND ADMIN PASSWORD
if [ "$1" = "config" ]; then
echo "multigraph modem_atten
graph_title ADSL Line Attenuation
graph_args --upper-limit 31.5 -l 0
graph_scale no
graph_vlabel signal strength (dB)
graph_category wan
graph_info This graph maps ADSL line attenuation
graph_order down up
down.label downstream
down.min 0
up.label upstream
up.min 0
multigraph modem_noise
graph_title ADSL Line Noise
graph_args -l 0
graph_vlabel noise strength (dB)
graph_scale no
graph_category wan
graph_info This graph maps ADSL line noise
graph_order down up
down.label downstream
down.min 0
up.label upstream
up.min 0
multigraph modem_sync
graph_title ADSL Sync Speed
graph_args --base 1024 -l 0
graph_scale no
graph_vlabel kB/s
graph_category wan
graph_info This graph maps ADSL sync speed in kbps
graph_order down up
down.label kB/s down
down.min 0
up.label kB/s up
up.min 0"
exit 0
fi
_get() { /usr/bin/curl -s --anyauth --user "admin:$SKY_PW" -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Firefox/31.0" $2 "http://$SKY_IP/$1" 2>&1; }
TMP=`_get sky_system.html|/usr/bin/perl -ne '/Connection Speed.*?([0-9]+) kbps.*?([0-9]+) kbps.*?([0-9\.]+) dB.*?([0-9\.]+) dB.*?([0-9\.]+) dB.*?([0-9\.]+) dB/ and print "$1 $2 $3 $4 $5 $6"'`
sync_d=`echo $TMP|/usr/bin/awk '{print $1}'`
sync_u=`echo $TMP|/usr/bin/awk '{print $2}'`
atten_d=`echo $TMP|/usr/bin/awk '{print $3}'`
atten_u=`echo $TMP|/usr/bin/awk '{print $4}'`
noise_d=`echo $TMP|/usr/bin/awk '{print $5}'`
noise_u=`echo $TMP|/usr/bin/awk '{print $6}'`
echo "multigraph modem_atten
down.value $atten_d
up.value $atten_u
multigraph modem_noise
down.value $noise_d
up.value $noise_u
multigraph modem_sync
down.value $sync_d
up.value $sync_u"

13
plugins.d/upnp Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
if [ "$1" == "config" ];then
echo "graph_title UPnP Leases
graph_vlabel leases
graph_args -l 0
graph_category network
graph_scale no
leases.label leases"
exit 0
fi
echo "leases.value `cat /tmp/upnp.leases|/usr/bin/wc -l`

13
plugins.d/uptime Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
if [ "$1" == "config" ]; then
echo "graph_title Uptime
graph_args --base 1000 -l 0
graph_vlabel uptime in days
uptime.label uptime
uptime.draw AREA
uptime.cdef uptime,86400,/"
exit 0
fi
echo "uptime.value `/usr/bin/awk '{print $1}' /proc/uptime`"

35
plugins.d/wireless Executable file
View File

@ -0,0 +1,35 @@
#!/bin/sh
# This plugin requres the opkg packages iwinfo and perl to be installed, and assumes that all wifi interfaces will be in use and broadcasting an AP.
wifs=`/usr/bin/iwinfo|/bin/egrep -o "^\w+"`
if [ "$1" == "config" ];then
echo "multigraph wlan_assoc
graph_title WLAN associations
graph_vlabel clients
graph_args -l 0
graph_category network
graph_scale no
clients.label clients"
for int in $wifs;do
echo "multigraph wlan_$int
graph_title $int AP Statistics
graph_vlabel strength (dBm)
graph_args -l 0
graph_category network
graph_scale no
signal.label signal
noise.label noise"
done
exit 0
fi
assoc=0
for int in $wifs;do assoc=$(($assoc+$(/usr/bin/iwinfo $int assoclist|/bin/egrep "^\w"|/usr/bin/wc -l)));done
echo "multigraph wlan_assoc
clients.value $assoc"
for int in $wifs;do
echo "multigraph wlan_$int"
/usr/bin/iwinfo $int info|/usr/bin/perl -ne '/Signal. (-[0-9]+) .* (-[0-9]+) dBm/ and print "signal.value ".($1+100)."\nnoise.value ".($2+100)."\n"'
done