[Resmon-devel] [resmon commit] r434 - in trunk/lib/Core: . BSD

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Sat Jan 29 14:28:34 EST 2011


Author: esproul
Date: 2011-01-29 14:28:34 -0500 (Sat, 29 Jan 2011)
New Revision: 434

Added:
   trunk/lib/Core/BSD/
   trunk/lib/Core/BSD/Sensor.pm
Log:
Core::BSD::Sensor for reading hardware sensors under OpenBSD (and maybe other BSDs as well.)  Based on CHECK_BSD_TEMP from resmon1.

Added: trunk/lib/Core/BSD/Sensor.pm
===================================================================
--- trunk/lib/Core/BSD/Sensor.pm	                        (rev 0)
+++ trunk/lib/Core/BSD/Sensor.pm	2011-01-29 19:28:34 UTC (rev 434)
@@ -0,0 +1,77 @@
+package Core::BSD::Sensor;
+
+use strict;
+use warnings;
+
+use base 'Resmon::Module';
+
+use Resmon::ExtComm qw(run_command cache_command);
+
+=pod
+
+=head1 NAME
+
+Core::BSD::Sensor - Check values of OpenBSD hardware sensors
+
+=head1 SYNOPSIS
+
+ Core::BSD::Sensor {
+     cpu_temp: chip => admtm0, sensor => temp1
+     sys_temp: chip => admtm0, sensor => temp2
+     cpu_fan: chip => fins0, sensor => fan0
+ }
+
+=head1 DESCRIPTION
+
+This module reads values from hardware sensors using sysctl on OpenBSD.
+
+=head1 CONFIGURATION
+
+=over
+
+=item check_name
+
+The check name is a short description of what the particular sensor monitors.
+
+=item chip
+
+Specifies the desired sensor chip.  This argument is mandatory.
+
+=item sensor
+
+The sensor on the specified chip whose value should be read.  This argument is mandatory.
+
+=back
+
+=head1 METRICS
+
+=over
+
+=item value
+
+The value of the specified sensor.
+
+=back
+
+=cut
+
+sub handler {
+    my $self = shift;
+    my $config = $self->{config}; # All configuration is in here
+    my $check_name = $self->{check_name}; # The check name is in here
+    my $chip = $config->{chip};
+    my $sensor = $config->{sensor};
+
+    my $output = run_command("sysctl -n hw.sensors.$chip.$sensor");
+    $output =~ m/(-?\d+\.?\d*)\s+\S+/;
+    my $value = $1;
+
+    return {
+        "check_name" => [$self->{check_name}, "s"],
+        "chip" => [$config->{chip}, "s"],
+        "sensor" => [$config->{sensor}, "s"],
+        "value" => [$value, "n"]
+    };
+};
+
+1;



More information about the Resmon-devel mailing list