[Resmon-devel] [resmon commit] r207 - trunk/lib/Resmon/Module
svn-commit at lists.omniti.com
svn-commit at lists.omniti.com
Tue Aug 18 15:52:50 EDT 2009
Author: seriv
Date: 2009-08-18 15:52:50 -0400 (Tue, 18 Aug 2009)
New Revision: 207
Added:
trunk/lib/Resmon/Module/BSD_CHECK_TEMP.pm
trunk/lib/Resmon/Module/BSD_DISK_TEMP.pm
Log:
temperatures of the cpu, lm and disks for bsd
Added: trunk/lib/Resmon/Module/BSD_CHECK_TEMP.pm
===================================================================
--- trunk/lib/Resmon/Module/BSD_CHECK_TEMP.pm (rev 0)
+++ trunk/lib/Resmon/Module/BSD_CHECK_TEMP.pm 2009-08-18 19:52:50 UTC (rev 207)
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+use strict;
+package Resmon::Module::BSD_CHECK_TEMP;
+use Resmon::Module;
+use Resmon::ExtComm qw/cache_command/;
+use vars qw/@ISA/;
+ at ISA = qw/Resmon::Module/;
+my $DEBUG=1;
+
+
+sub handler {
+ my $arg = shift;
+ my ($sensor,$chip)=split('@', $arg->{'object'});
+ print STDERR "sensor=$sensor; chip=$chip\n" if $DEBUG;
+ $sensor =~s/\+/ /g;
+ my $warning = $arg->{'warning'};
+ my $critical = $arg->{'critical'};
+ $warning = $critical if not $warning;
+ my $output = cache_command("sysctl -n hw.sensors.$chip.$sensor", 30);
+ print STDERR $output if $DEBUG;
+ my $temp;
+ $output =~ m/(-?\d+\.?\d*)/;
+ $temp = $1;
+ return "OK($temp $sensor\@$chip)" if ($temp && ($temp<$warning));
+ return "WARNING($temp $sensor\@$chip)" if ($temp && ($temp<$critical));
+ return "BAD($temp $sensor@$chip)";
+};
+1;
Added: trunk/lib/Resmon/Module/BSD_DISK_TEMP.pm
===================================================================
--- trunk/lib/Resmon/Module/BSD_DISK_TEMP.pm (rev 0)
+++ trunk/lib/Resmon/Module/BSD_DISK_TEMP.pm 2009-08-18 19:52:50 UTC (rev 207)
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+use strict;
+package Resmon::Module::BSD_DISK_TEMP;
+use Resmon::Module;
+use Resmon::ExtComm qw/cache_command/;
+use vars qw/@ISA/;
+ at ISA = qw/Resmon::Module/;
+my $DEBUG=2;
+
+
+sub handler {
+ my $arg = shift;
+ my $disk=$arg->{'object'};
+ print STDERR "disk: $disk\n" if $DEBUG>1;
+ my $warning = $arg->{'warning'};
+ print STDERR "warning: $warning\n" if $DEBUG>1;
+ my $critical = $arg->{'critical'};
+ print STDERR "critical: $critical\n" if $DEBUG>1;
+ $warning = $critical if not $warning;
+ my $output = cache_command("/sbin/atactl /dev/$disk readattr", 30);
+ print STDERR "output:$output\n" if $DEBUG>1;
+ my ($line) = grep (/Temperature/, split(/\n/, $output));
+ print STDERR "line:$line\n" if $DEBUG>1;
+ print STDERR "arr:",join("|",split(/\s+/,$line)),"\n" if $DEBUG>1;
+ my $temp = (split(/\s+/,$line))[3];
+ return "OK($temp $disk)" if ($temp && ($temp<$warning));
+ return "WARNING($temp disk)" if ($temp && ($temp<$critical));
+ return "BAD($temp $disk)";
+};
+1;
More information about the Resmon-devel
mailing list