[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] Supporting reading of system information from BIOS.



This patch is in response to 
http://wiki.xenproject.org/wiki/Outreach_Program_Projects#CPU.2FRAM.2FPCI_diagram_tool
 project for applying to OPW-Round9.It adds support for reading system 
architecture information from BIOS rather than from sysfs and proc interfaces 
since in a virtualisation enviroment, some of this information is no longer 
accurate, particularly any information based around numbers of cpus.
---
 dmidecode.pl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 dmidecode.pl

diff --git a/dmidecode.pl b/dmidecode.pl
new file mode 100644
index 0000000..76fdf78
--- /dev/null
+++ b/dmidecode.pl
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+
+# dmidecode.pl - a script to read the system architecture information
+# directly from the BIOS.  Only for Linux.
+#
+# Rita Sinha (rita.sinha89@xxxxxxxxx)
+# OPW Program-Round9
+# 14/10/14
+
+`id -u` == 0 || die "must be run as root";
+
+open(DmiFh, "/usr/sbin/dmidecode |") or
+  die "problem running dmidecode";
+$DmiNumProcs = 0;
+$DmiNumSockets = 0;
+while(<DmiFh>)
+  {
+    next unless /Central Processor/;
+    # We've found a processor (or at least a socket), keep going
+    while(<DmiFh>)
+       {
+         # Keep walking the dmidecode output to find out if
+         # the socket has a processor in it.
+         last if /^Handle/;
+         next unless /Status/;
+         $DmiNumSockets += 1;
+         /Populated/ and $DmiNumProcs += 1;
+         last;
+       }
+  }
+close DmiFh;
+
+open(CpuInfoFh, "/proc/cpuinfo") || die "failed to open /proc/cpuinfo!";
+$CpuInfoNumProcs = 0;
+while(<CpuInfoFh>)
+  {
+    next unless /^processor.*:/;
+    ($CpuInfoNumProcs) += (/^processor.*: (\d+)/);
+  }
+close CpuInfoFh;
+
+if ( $DmiNumProcs != $CpuInfoNumProcs )
+  {
+    print "Warning: dmidecode reports $DmiNumProcs processors, kernel reports 
$CpuInfoNumProcs processors.\n";
+  }
+
+if ( $DmiNumProcs != $DmiNumSockets )
+  {
+    print "Info: dmidecode reports $DmiNumSockets cpu sockets, but only 
$DmiNumProcs processors.\n";
+  }
+
-- 
1.8.3.1

The information contained in this electronic mail transmission 
may be privileged and confidential, and therefore, protected 
from disclosure. If you have received this communication in 
error, please notify us immediately by replying to this 
message and deleting it from your computer without copying 
or disclosing it.



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.