mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-09-18 16:48:44 +00:00
p/cpu_linux_multi: remove the use of /proc/cpuinfo
This commit is contained in:
parent
d38eda2838
commit
6d2da7ad27
1 changed files with 9 additions and 5 deletions
|
@ -37,8 +37,6 @@
|
||||||
# multigraph, supersampling, extended cpu informations
|
# multigraph, supersampling, extended cpu informations
|
||||||
#
|
#
|
||||||
# require: mpstat (to actually collect the data)
|
# require: mpstat (to actually collect the data)
|
||||||
# require linux /proc
|
|
||||||
# (sorry, quick/dirty retrieve the number of cpu from /proc/cpuinfo)
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# ENV (default):
|
# ENV (default):
|
||||||
|
@ -186,10 +184,16 @@ if (defined $ENV{MUNIN_MPSTAT}) {
|
||||||
|
|
||||||
my $cpu_count_cache = undef;
|
my $cpu_count_cache = undef;
|
||||||
sub cpu_count() {
|
sub cpu_count() {
|
||||||
# XXX: is there any way to do that cleanly ?
|
|
||||||
if (not defined $cpu_count_cache) {
|
if (not defined $cpu_count_cache) {
|
||||||
$cpu_count_cache = `grep -c ^processor /proc/cpuinfo`;
|
open MPSTAT, "$mpstat -P ALL |" or die "open mpstat|: $!\n";
|
||||||
chomp $cpu_count_cache;
|
$cpu_count_cache = 0;
|
||||||
|
while (<MPSTAT>) {
|
||||||
|
chomp;
|
||||||
|
my @field = split();
|
||||||
|
next unless ($field[1] && ($field[1] =~ /^([0-9]+)$/));
|
||||||
|
$cpu_count_cache ++;
|
||||||
|
}
|
||||||
|
close(MPSTAT);
|
||||||
}
|
}
|
||||||
return $cpu_count_cache;
|
return $cpu_count_cache;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue