[Resmon-devel] [resmon commit] r208 - trunk/lib/Resmon/Module

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Tue Aug 25 01:21:01 EDT 2009


Author: seriv
Date: 2009-08-25 01:21:01 -0400 (Tue, 25 Aug 2009)
New Revision: 208

Added:
   trunk/lib/Resmon/Module/SPARCTEMP.pm
Log:
fix sensor name parcing: #tid9703

Added: trunk/lib/Resmon/Module/SPARCTEMP.pm
===================================================================
--- trunk/lib/Resmon/Module/SPARCTEMP.pm	                        (rev 0)
+++ trunk/lib/Resmon/Module/SPARCTEMP.pm	2009-08-25 05:21:01 UTC (rev 208)
@@ -0,0 +1,32 @@
+package Resmon::Module::SPARKTEMP;
+use Resmon::ExtComm qw/cache_command/;
+use vars qw/@ISA/;
+ at ISA = qw/Resmon::Module/;
+
+sub handler {
+  my $DEBUG=0;
+  my $arg = shift;
+  my $sensor = $arg->{'object'};
+  print STDERR $sensor,"\n" if $DEBUG;
+  my $command = "/usr/sbin/prtpicl -v -c temperature-sensor";
+  print STDERR "command=$command\n" if $DEBUG;
+  my $output = cache_command($command, 30);
+ # my $output = `/usr/sbin/prtpicl -v -c temperature-sensor`;
+  print STDERR $output if $DEBUG>1;
+  my @lines = split(/\n/, $output);
+  print STDERR join("\nlines", @lines) if $DEBUG>1;
+  my ($temp,$warning, $critical,$name);
+  for (@lines) {
+    print STDERR "line: $_ \n" if $DEBUG;
+    $temp=$1 if /:Temperature\s*(\d*)/; 
+    $warning=$1 if /:HighWarningThreshold\s*(\d*)/i; 
+    $critical=$1 if /:HighShutdownThreshold\s*(\d*)/i;
+    $name=$1 if /:name\s*(\w*)/; 
+    print STDERR "temp: $temp warn: $warning crit: $critical name: $name\n" if $DEBUG;
+    last if $name =~ m/^$sensor/;
+  }
+  return "OK($temp)" if $temp <= $warning;
+  return "WARNING($temp)" if $temp < $critical;
+  return "BAD($temp)";
+}
+1;



More information about the Resmon-devel mailing list