aboutsummaryrefslogtreecommitdiffstats
path: root/SiteSummary.pm
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2008-07-25 16:55:19 +0000
committerPetter Reinholdtsen <pere@hungry.com>2008-07-25 16:55:19 +0000
commit46c7af2ac216bfce7c55347ee2ecea3d391abfa7 (patch)
tree1c8aaa47c18b94aca3e85de4042f73588f7c3745 /SiteSummary.pm
parentd723b5e7158455a0628df8c6f19ec098f02447cd (diff)
downloadsitesummary-46c7af2ac216bfce7c55347ee2ecea3d391abfa7.tar.gz
sitesummary-46c7af2ac216bfce7c55347ee2ecea3d391abfa7.tar.bz2
sitesummary-46c7af2ac216bfce7c55347ee2ecea3d391abfa7.tar.xz
* Add new statistics script hardware-models to list the different
hardware vendor and models.
Diffstat (limited to 'SiteSummary.pm')
-rw-r--r--SiteSummary.pm32
1 files changed, 32 insertions, 0 deletions
diff --git a/SiteSummary.pm b/SiteSummary.pm
index f5a1db4..033956b 100644
--- a/SiteSummary.pm
+++ b/SiteSummary.pm
@@ -19,6 +19,7 @@ our @EXPORT = qw(
get_linux_kernel_ver
get_debian_edu_profile
get_debian_edu_ver
+ get_hardware_info
);
my $pwd = "/var/lib/sitesummary/entries"; # Path to the entries
@@ -207,6 +208,37 @@ sub get_debian_edu_ver {
}
}
+sub get_hardware_info {
+ my $hostid = shift;
+ my $path = get_filepath_current($hostid, "/system/dmidecode");
+ if (open(FILE, "<", $path)) {
+ my $sysinfo = 0;
+ my ($vendor, $model, $version, $serial);
+ while (<FILE>) {
+ chomp;
+ next unless ($sysinfo || m/^System Information/);
+ $sysinfo = 1;
+ $vendor = $1 if (m/Manufacturer: (.+\S)\s*$/);
+ $model = $1 if (m/Product Name: (.+\S)\s*$/);
+ $version = $1 if (m/Version: (.+\S)\s*$/);
+ $serial = $1 if (m/Serial Number: (.+\S)\s*$/);
+ last if (m/^Handle /);
+ }
+ close(FILE);
+
+ # Append version string to get for example the thinkpad model
+ # name, but ignore bogus entries.
+ $model = "$model $version" if ($version
+ && $version ne "Not Specified"
+ && $version ne "Not Available"
+ && $version ne "None");
+
+ return ($vendor, $model, $serial);
+ } else {
+ return undef;
+ }
+}
+
sub for_all_hosts {
my $callback = shift;