#!/bin/sh # # Plugin to monitor CPU usage. # # Usage: Place in /etc/munin/node.d/ (or link it there using ln -s) # # Parameters understood: # # config (required) # autoconf (optional - used by munin-config) # # $Log$ # Revision 1.9 2004/12/10 10:47:50 jimmyo # Change name from ${scale} to ${graph_period}, to be more consistent. # # Revision 1.8 2004/12/09 22:12:56 jimmyo # Added "graph_period" option, to make "graph_sums" usable. # # Revision 1.7 2004/12/09 17:20:16 jimmyo # Patched sunos/cpu to work on Solaris 9 (SF#1077899). # # Revision 1.6 2004/11/21 00:17:12 jimmyo # Changed a lot of plugins so they use DERIVE instead of COUNTER. # # Revision 1.5 2004/05/20 19:02:38 jimmyo # Set categories on a bunch of plugins # # Revision 1.4 2004/05/06 21:39:54 jimmyo # Added plugin acpi, contributed by Alexandre Dupouy. # # Revision 1.3 2004/04/30 16:43:00 jimmyo # Cleaned up Solaris plugins. # # Revision 1.2 2004/02/18 16:39:37 jimmyo # Turned off scaling of values for cpu-graphs (no more nano-percentages). # # Revision 1.1 2004/01/02 18:50:01 jimmyo # Renamed occurrances of lrrd -> munin # # Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo # Import of LRRD CVS tree after renaming to Munin # # Revision 1.5 2003/11/07 22:12:51 jimmyo # Changed deprecated plugin options # # Revision 1.4 2003/11/07 17:43:16 jimmyo # Cleanups and log entries # # # # Magic markers - optional - used by installation scripts and # munin-config: # #%# family=auto #%# capabilities=autoconf if [ "$1" = "autoconf" ]; then if [ -x /usr/bin/kstat ]; then echo yes exit 0 else echo no exit 1 fi fi if [ "$1" = "config" ]; then echo 'graph_title CPU usage' echo 'graph_order system user waitio idle' echo 'graph_category system' ncpu=`kstat -p -c misc -n system_misc -s '/^ncpus$/' | cut -f2 -d' '` cpumax=`expr "$ncpu" '*' 100` if [ "$scaleto100" = "yes" ]; then graphlimit=100 else graphlimit=$cpumax fi echo "graph_args --base 1000 --lower-limit 0 --rigid --upper-limit $graphlimit" echo 'graph_vlabel %' echo 'graph_scale no' echo 'graph_period ${graph_period}' echo 'system.label system' echo 'system.draw AREA' echo 'system.type DERIVE' echo 'system.min 0' echo "system.max $cpumax" echo 'user.label user' echo 'user.draw STACK' echo 'user.type DERIVE' echo 'user.min 0' echo "user.max $cpumax" echo "waitio.max $cpumax" echo 'waitio.label waitio' echo 'waitio.draw STACK' echo 'waitio.type DERIVE' echo 'waitio.min 0' echo 'idle.label idle' echo 'idle.draw STACK' echo 'idle.type DERIVE' echo 'idle.min 0' echo "idle.max $cpumax" if [ "$scaleto100" = "yes" ]; then echo "system.cdef system,$ncpu,/" echo "user.cdef user,$ncpu,/" echo "waitio.cdef waitio,$ncpu,/" echo "idle.cdef idle,$ncpu,/" fi exit 0 fi kstat -p -c misc -m cpu_stat -s '/^(user|kernel|wait|idle)$/' | sed -e 's/.*://' | awk ' BEGIN { map["user"] = "user" map["kernel"] = "system" map["wait"] = "waitio" map["idle"] = "idle" } length(map[$1]) > 0 { sum[map[$1]] += $2 total += $2 } END { for (item in sum) { print item ".value", sum[item] } }'