Index: ossp-pkg/snmpdx/snmpdx.d/hwCpu.pm RCS File: /v/ossp/cvs/ossp-pkg/snmpdx/snmpdx.d/hwCpu.pm,v rcsdiff -q -kk '-r1.3' '-r1.4' -u '/v/ossp/cvs/ossp-pkg/snmpdx/snmpdx.d/hwCpu.pm,v' 2>/dev/null --- hwCpu.pm 2003/09/08 11:07:56 1.3 +++ hwCpu.pm 2003/09/08 13:42:05 1.4 @@ -37,9 +37,8 @@ my ($self, $obj) = @_; if ($self->{-ctx}->{-platform}->id() =~ m/FreeBSD/i) { - my $hwCpuNum = undef; - my $hwCpuSpeed = undef; #N/A - my $hwCpuTemp = undef; #N/A + my $hwCpuNum = undef; + my $hwCpuInfoENTRY = undef; #N/A # local workspace my $out; my $raw; @@ -54,9 +53,8 @@ $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 + my $hwCpuNum = undef; + my $hwCpuInfoENTRY = undef; #N/A # local workspace my $out; my $raw; @@ -73,12 +71,11 @@ $obj->{-value} = $hwCpuNum if ($obj->{-name} =~ m/\.hwCpuNum$/); } elsif($self->{-ctx}->{-platform}->id() =~ m/SunOS/i) { - my $hwCpuNum = undef; - my $hwCpuSpeed = undef; #see @dat[]->{hwCpuSpeed} - my $hwCpuTemp = undef; #see @dat[]->{hwCpuTemp} + my $hwCpuNum = undef; + my $hwCpuInfoENTRY = undef; # local workspace - my $out; my $raw; my @dat; my $arch; + my $out; my $raw; my $arch; # initialize arch $arch = $self->{-ctx}->{-platform}->arch(); @@ -91,8 +88,8 @@ foreach $line (split "\n", $raw) { my ($brd,$cpu,$module,$mhz,$mb,$impl,$mask) = split(" ", $line); if ($cpu =~ m/^\d+$/) { - @dat[$cpu] = {} if (not defined @dat[$cpu]); - @dat[$cpu]->{hwCpuSpeed} = $mhz; + @hwCpuInfoENTRY[$cpu] = {} if (not defined @hwCpuInfoENTRY[$cpu]); + @hwCpuInfoENTRY[$cpu]->{hwCpuSpeed} = $mhz; } } } @@ -100,27 +97,27 @@ # hwCpuTemp $out = $self->{-ctx}->{-sys}->run("/usr/platform/$arch/sbin/prtdiag -v", "1m"); $raw = $out->{-stdout}; - if ($raw =~ m/\n=+ Environmental Status =+\n\nSystem Temperatures \(Celsius\):\n-+\n(.*?)\n=+/s) { + if ($raw =~ m/\n=+ Environmental Status =+\n.*\nSystem Temperatures \(Celsius\):\n-+\n(.*?)\n=+/s) { $raw = $1; foreach $line (split "\n", $raw) { my ($cpu,$temp) = split(" ", $line); if ($cpu =~ m/CPU(\d+)/) { $cpu = $1; - @dat[$cpu] = {} if (not defined @dat[$cpu]); - @dat[$cpu]->{hwCpuTemp} = $temp; + @hwCpuInfoENTRY[$cpu] = {} if (not defined @hwCpuInfoENTRY[$cpu]); + @hwCpuInfoENTRY[$cpu]->{hwCpuTemp} = $temp; } } } # hwCpuNum - $hwCpuNum = $#{@dat} + 1; + $hwCpuNum = $#{@hwCpuInfoENTRY} + 1; $obj->{-value} = $hwCpuNum if ($obj->{-name} =~ m/\.hwCpuNum$/); if ($obj->{-name} =~ m/\.hwCpuInfoENTRY\.([^.]+)\.(\d+)$/) { my $col = $1; my $row = ($2 > 0 ? $2 - 1 : 0); $self->{-ctx}->{-log}->printf(4, "col=%s row=%s", $col, $row); - $obj->{-value} = @dat[$row]->{$col} if (defined @dat[$row]->{$col}); + $obj->{-value} = @hwCpuInfoENTRY[$row]->{$col} if (defined @hwCpuInfoENTRY[$row]->{$col}); } } return;