The cpu plugin depends on the correct clock tick (HZ) to calculate the correct percentage values. Unfortunatly the HZ differs from kernel to kernel. I have introduced a HZ configuration variable:
--- cpu.orig 2006-05-09 14:25:54.000000000 +0200
+++ cpu 2006-05-12 08:21:46.000000000 +0200
@@ -9,6 +9,16 @@
# config (required)
# autoconf (optional - used by munin-config)
#
+# Environment variables:
+#
+# hz Number of clock ticks per second (default 1000).
+# Older linux kernels have 100 instead. Find out the correct
+# value in /usr/src/linux/include/asm/param.h or execute
+# (cat /proc/interrupts;sleep 1;cat /proc/interrupts)|grep timer,
+# subtract the first big numbers and decide if they are
+# closer to 100 or 1000.
+#
+#
# $Log$
# Revision 1.8 2004/12/09 22:12:56 jimmyo
# Added "graph_period" option, to make "graph_sums" usable.
@@ -49,6 +59,7 @@
#%# capabilities=autoconf
+hz=${hz:-1000}
if [ "$1" = "autoconf" ]; then
if [ -r /proc/stat ]; then
@@ -152,7 +163,7 @@
if [ ! -z "$extinfo" ]
then
- awk '/^cpu / { print "user.value " $2 "\nnice.value " $3 "\nsystem.value " $4 "\nidle.value " $5 "\niowait.value " $6 "\nirq.value " $7 "\nsoftirq.value " $8 }' < /proc/stat
+ awk -v hz=$hz '/^cpu / { print "user.value " $2*100/hz "\nnice.value " $3*100/hz "\nsystem.value " $4*100/hz "\nidle.value " $5*100/hz "\niowait.value " $6*100/hz "\nirq.value " $7*100/hz "\nsoftirq.value " $8*100/hz }' < /proc/stat
else
- awk '/^cpu / { print "user.value " $2 "\nnice.value " $3 "\nsystem.value " $4 "\nidle.value " $5 }' < /proc/stat
+ awk -v hz=$hz '/^cpu / { print "user.value " int($2*100/hz) "\nnice.value " int($3*100/hz) "\nsystem.value " int($4*100/hz) "\nidle.value " int($5*100/hz) }' < /proc/stat
fi
Notes:
- This patch relates to Ticket 120
- The "if [ ! -z "$extinfo" ]" branch is not tested due to lack of a 2.6 kernel