OSSP CVS Repository

ossp - Difference in ossp-pkg/snmpdx/snmpdx.d/hwCpu.pm versions 1.2 and 1.3
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/snmpdx/snmpdx.d/hwCpu.pm 1.2 -> 1.3

--- hwCpu.pm     2003/09/08 10:49:35     1.2
+++ hwCpu.pm     2003/09/08 11:07:56     1.3
@@ -37,24 +37,45 @@
     my ($self, $obj) = @_;
 
     if ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i) {
+        my $hwCpuNum   = undef;
+        my $hwCpuSpeed = undef; #N/A
+        my $hwCpuTemp  = undef; #N/A
+
+        #   local workspace
+        my $out; my $raw;
+
         #   query sysctl(8)
-        my $out = $self->{-ctx}->{-sys}->run("/sbin/sysctl -n hw.ncpu", "forever");
-        $obj->{-value} = $out->{-stdout};
-        $obj->{-value} =~ s/^\s*(.+?)\s*$/$1/s;
+        $out = $self->{-ctx}->{-sys}->run("/sbin/sysctl -n hw.ncpu", "forever");
+        $raw = $out->{-stdout};
+        if ($raw =~ m/^\s*(.+?)\s*$/s) {
+            $hwCpuNum = $1;
+        }
+
+        $obj->{-value} = $hwCpuNum if ($obj->{-name} =~ m/\.hwCpuNum$/);
     }
     elsif ($self->{-ctx}->{-platform}->id() =~ m/Linux/i) {
+        my $hwCpuNum   = undef;
+        my $hwCpuSpeed = undef; #N/A
+        my $hwCpuTemp  = undef; #N/A
+
+        #   local workspace
+        my $out; my $raw;
+
         #   query dmesg(8)
         #   FIXME: this works only within a reasonable time after booting
         #          but I don't know any alternative method for querying the speed!
-        my $out = $self->{-ctx}->{-sys}->run("/sbin/dmesg", "forever");
-        if ($out->{-stdout} =~ m|(\d+)(\.\d+)?[ -]*MHz|si) {
-            $obj->{-value} = $1;
+        $out = $self->{-ctx}->{-sys}->run("/bin/dmesg", "forever");
+        $raw = $out->{-stdout};
+        if ($raw =~ m/\nProcessors: (\d+)\n/si) {
+            $hwCpuNum = $1;
         }
+
+        $obj->{-value} = $hwCpuNum if ($obj->{-name} =~ m/\.hwCpuNum$/);
     }
     elsif($self->{-ctx}->{-platform}->id() =~ m/SunOS/i) {
         my $hwCpuNum   = undef;
-        #  $hwCpuSpeed see @dat[]->{hwCpuSpeed}
-        #  $hwCpuTemp  see @dat[]->{hwCpuTemp}
+        my $hwCpuSpeed = undef; #see @dat[]->{hwCpuSpeed}
+        my $hwCpuTemp  = undef; #see @dat[]->{hwCpuTemp}
 
         #   local workspace
         my $out; my $raw; my @dat; my $arch;

CVSTrac 2.0.1