From d38eda2838006ab782a203d2637916166d17f2fc Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Wed, 19 Feb 2014 17:25:50 +0100 Subject: [PATCH 1/2] p/cpu_linux_multi: suppress perl warning --- plugins/system/cpu_linux_multi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system/cpu_linux_multi b/plugins/system/cpu_linux_multi index 63fe9591..f96b719c 100755 --- a/plugins/system/cpu_linux_multi +++ b/plugins/system/cpu_linux_multi @@ -148,7 +148,7 @@ sub graph_section() { "system:cpu" }; sub graph_name() { "cpu_extended_multi_1s" }; sub graph_title() { "CPU usage" }; sub graph_title_all() { "Overall CPU usage" }; -sub graph_title_n($) { "CPU#" . shift . " usage" }; +sub graph_title_n($) { "CPU#" . (shift) . " usage" }; sub acquire_name() { "<$plugin> collecting information" } ######################################################################## From 6d2da7ad27d2209343118ebc237643d84ad1ab6f Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Wed, 19 Feb 2014 17:26:47 +0100 Subject: [PATCH 2/2] p/cpu_linux_multi: remove the use of /proc/cpuinfo --- plugins/system/cpu_linux_multi | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/system/cpu_linux_multi b/plugins/system/cpu_linux_multi index f96b719c..e4ac9e80 100755 --- a/plugins/system/cpu_linux_multi +++ b/plugins/system/cpu_linux_multi @@ -37,8 +37,6 @@ # multigraph, supersampling, extended cpu informations # # require: mpstat (to actually collect the data) -# require linux /proc -# (sorry, quick/dirty retrieve the number of cpu from /proc/cpuinfo) # # # ENV (default): @@ -186,10 +184,16 @@ if (defined $ENV{MUNIN_MPSTAT}) { my $cpu_count_cache = undef; sub cpu_count() { - # XXX: is there any way to do that cleanly ? if (not defined $cpu_count_cache) { - $cpu_count_cache = `grep -c ^processor /proc/cpuinfo`; - chomp $cpu_count_cache; + open MPSTAT, "$mpstat -P ALL |" or die "open mpstat|: $!\n"; + $cpu_count_cache = 0; + while () { + chomp; + my @field = split(); + next unless ($field[1] && ($field[1] =~ /^([0-9]+)$/)); + $cpu_count_cache ++; + } + close(MPSTAT); } return $cpu_count_cache; }