diff --git a/README.md b/README.md index ee759dd..86a3d47 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ openwrt-oriented munin-node implementation inspired by muninlite ## Quick installation guide -Install `munin-node`: +Install `munin-node` and the bundled plugins: ``` mkdir -p /usr/local/bin /etc/munin-node diff --git a/plugins.d/README b/plugins.d/README index 2e30fdc..66d16cf 100644 --- a/plugins.d/README +++ b/plugins.d/README @@ -1,15 +1,13 @@ 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. +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 were originally bundled with this project, however due to license incompatibilities (GPLv2 doesn't seem to permit me to license my project under BSD 3-Clause while including GPLv2-licensed plugins, even modified to some degree, thus there will be no non-BSD code). They will be re-included once original replacements have been written: +- cpu - 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: diff --git a/plugins.d/cpu b/plugins.d/cpu deleted file mode 100755 index 2d7993f..0000000 --- a/plugins.d/cpu +++ /dev/null @@ -1,71 +0,0 @@ -#!/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}' diff --git a/plugins.d/df b/plugins.d/df deleted file mode 100755 index 221fc24..0000000 --- a/plugins.d/df +++ /dev/null @@ -1,27 +0,0 @@ -#!/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 diff --git a/plugins.d/if b/plugins.d/if deleted file mode 100755 index ed50062..0000000 --- a/plugins.d/if +++ /dev/null @@ -1,25 +0,0 @@ -#!/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`" diff --git a/plugins.d/interrupts b/plugins.d/interrupts deleted file mode 100755 index f28fef9..0000000 --- a/plugins.d/interrupts +++ /dev/null @@ -1,25 +0,0 @@ -#!/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`" diff --git a/plugins.d/irqstats b/plugins.d/irqstats deleted file mode 100755 index 7a779de..0000000 --- a/plugins.d/irqstats +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -# this is just awful. - -CPUS=`/bin/grep -c '^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 diff --git a/plugins.d/memory b/plugins.d/memory deleted file mode 100755 index f23754e..0000000 --- a/plugins.d/memory +++ /dev/null @@ -1,128 +0,0 @@ -#!/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))" diff --git a/plugins.d/uptime b/plugins.d/uptime deleted file mode 100755 index 69de013..0000000 --- a/plugins.d/uptime +++ /dev/null @@ -1,13 +0,0 @@ -#!/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`"