aboutsummaryrefslogtreecommitdiffstats
path: root/SiteSummary.pm
diff options
context:
space:
mode:
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;