summaryrefslogtreecommitdiff
path: root/scripts/vyatta-cpu-summary.pl
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-01-29 16:33:35 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-01-29 16:33:35 -0800
commitc5d9187695e743178bec68353a0b9e97641fdb08 (patch)
treeb49f8484d534857e97a1e5975b737227cf733608 /scripts/vyatta-cpu-summary.pl
parent2791133497628c924962fe54724e586b72ea9e58 (diff)
parentb204513bbfbac10a826e485f677c7ed77e342d52 (diff)
downloadvyatta-op-c5d9187695e743178bec68353a0b9e97641fdb08.tar.gz
vyatta-op-c5d9187695e743178bec68353a0b9e97641fdb08.zip
Merge branch 'jenner' of 192.168.100.1:git/vyatta-op into jenner
Diffstat (limited to 'scripts/vyatta-cpu-summary.pl')
-rwxr-xr-xscripts/vyatta-cpu-summary.pl37
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/vyatta-cpu-summary.pl b/scripts/vyatta-cpu-summary.pl
new file mode 100755
index 0000000..1839a5d
--- /dev/null
+++ b/scripts/vyatta-cpu-summary.pl
@@ -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";