2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 22:05:11 +00:00

Parse /proc/cpuinfo and build a list of CPU from it. This will make it

possible to suggest hardware monitoring drivers based of CPU ID.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4209 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2006-10-15 08:46:36 +00:00
parent 6270cf381a
commit 18e31433bd

View File

@@ -2057,6 +2057,35 @@ sub kernel_version_at_least
return 0;
}
# @cpu is a list of reference to hashes, one hash per CPU.
# Each entry has the following keys: vendor_id, cpu family, model,
# model name and stepping, directly taken from /proc/cpuinfo.
use vars qw(@cpu);
sub initialize_cpu_list
{
open(local *INPUTFILE, "/proc/cpuinfo") or die "Can't access /proc/cpuinfo!";
local $_;
my %entry;
while (<INPUTFILE>) {
if (m/^processor\s*:\s*(\d+)/) {
push @cpu, \%entry if scalar keys(%entry); # Previous entry
%entry = (); # New entry
next;
}
if (m/^(vendor_id|cpu family|model|model name|stepping)\s*:\s*(.+)$/) {
my $k = $1;
my $v = $2;
$v =~ s/\s+/ /g; # Merge multiple spaces
$v =~ s/ $//; # Trim trailing space
$entry{$k} = $v;
next;
}
}
push @cpu, \%entry if scalar keys(%entry); # Last entry
close INPUTFILE;
}
###########
# MODULES #
###########
@@ -5282,6 +5311,7 @@ sub main
initialize_modules_list;
initialize_modules_supported;
initialize_kernel_version;
initialize_cpu_list();
print "# sensors-detect revision $revision\n\n";