Projet

Général

Profil

Révision 6d2da7ad

ID6d2da7ad27d2209343118ebc237643d84ad1ab6f
Parent d38eda28
Enfant 33c40d05

Ajouté par Steve Schnepp il y a presque 12 ans

p/cpu_linux_multi: remove the use of /proc/cpuinfo

Voir les différences:

plugins/system/cpu_linux_multi
37 37
# multigraph, supersampling, extended cpu informations
38 38
#
39 39
# require: mpstat (to actually collect the data)
40
# require linux /proc
41
#   (sorry, quick/dirty retrieve the number of cpu from /proc/cpuinfo)
42 40
#
43 41
#
44 42
# ENV (default):
......
186 184

  
187 185
my $cpu_count_cache = undef;
188 186
sub cpu_count() {
189
	# XXX: is there any way to do that cleanly ?
190 187
	if (not defined $cpu_count_cache) {
191
		$cpu_count_cache = `grep -c ^processor /proc/cpuinfo`;
192
		chomp $cpu_count_cache;
188
               open MPSTAT, "$mpstat -P ALL |" or die "open mpstat|: $!\n";
189
               $cpu_count_cache = 0;
190
               while (<MPSTAT>) {
191
                       chomp;
192
                       my @field = split();
193
                       next unless ($field[1] && ($field[1] =~ /^([0-9]+)$/));
194
                       $cpu_count_cache ++;
195
               }
196
               close(MPSTAT);
193 197
	}
194 198
	return $cpu_count_cache;
195 199
}

Formats disponibles : Unified diff