summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-01-29 12:35:18 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-01-29 12:35:18 -0800
commit53a2e008425841bf8ac0088bb149cf328ccb220d (patch)
treec4f15004a5ae8339ca2ac85d94ffa3799b383626
parent9d229f3b6cadf42cdcb681d13353de9c4cc63b90 (diff)
downloadvyatta-op-53a2e008425841bf8ac0088bb149cf328ccb220d.tar.gz
vyatta-op-53a2e008425841bf8ac0088bb149cf328ccb220d.zip
New show system cpu
Brief summary of cpuinfo for tech-support etc.
-rwxr-xr-xfunctions/cpu-info37
-rw-r--r--templates/show/system/cpu/node.def2
2 files changed, 39 insertions, 0 deletions
diff --git a/functions/cpu-info b/functions/cpu-info
new file mode 100755
index 0000000..1839a5d
--- /dev/null
+++ b/functions/cpu-info
@@ -0,0 +1,37 @@
+#! /usr/bin/perl
+# implement "show cpu-info"
+
+open my $cpuinfo, '<', '/proc/cpuinfo'
+ or die "Can't open /proc/cpuinfo : $!";
+
+my %models;
+my %packages;
+my %cores;
+
+my %map = (
+ 'model name' => \%models,
+ 'physical id' => \%packages,
+ 'core id' => \%cores
+);
+
+my $cpu = 0;
+while (<$cpuinfo>) {
+ chomp;
+ my ( $tag, $val ) = split /:/;
+ if ( !$tag ) {
+ ++$cpu;
+ next;
+ }
+
+ $tag =~ s/\s+$//;
+ $val =~ s/^\s+//;
+
+ my $ref = $map{$tag};
+ $ref->{$val} = $cpu if ($ref);
+}
+close $cpuinfo;
+
+print "CPU ", join( " \n", keys %models ), "\n";
+print "Packages ", scalar keys %packages, "\n";
+print "Cores ", scalar keys %cores, "\n";
+print "Threads ", $cpu, "\n";
diff --git a/templates/show/system/cpu/node.def b/templates/show/system/cpu/node.def
new file mode 100644
index 0000000..e1afaf7
--- /dev/null
+++ b/templates/show/system/cpu/node.def
@@ -0,0 +1,2 @@
+help: Show CPU's on system
+run: ${vyatta_datadir}/vyatta-op/functions/cpu-info