root/lib/Core/BSD/Sensor.pm

Revision 3c5ec81e33223afc0a6b8129dec7a2ec60ff8568, 1.3 kB (checked in by Eric Sproul <esproul@omniti.com>, 3 years ago)

Returning check_name is a waste too

git-svn-id: https://labs.omniti.com/resmon/trunk@436 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

  • Property mode set to 100644
Line 
1 package Core::BSD::Sensor;
2
3 use strict;
4 use warnings;
5
6 use base 'Resmon::Module';
7
8 use Resmon::ExtComm qw(run_command cache_command);
9
10 =pod
11
12 =head1 NAME
13
14 Core::BSD::Sensor - Check values of OpenBSD hardware sensors
15
16 =head1 SYNOPSIS
17
18  Core::BSD::Sensor {
19      cpu_temp: chip => admtm0, sensor => temp1
20      sys_temp: chip => admtm0, sensor => temp2
21      cpu_fan: chip => fins0, sensor => fan0
22  }
23
24 =head1 DESCRIPTION
25
26 This module reads values from hardware sensors using sysctl on OpenBSD.
27
28 =head1 CONFIGURATION
29
30 =over
31
32 =item check_name
33
34 The check name is a short description of what the particular sensor monitors.
35
36 =item chip
37
38 Specifies the desired sensor chip.  This argument is mandatory.
39
40 =item sensor
41
42 The sensor on the specified chip whose value should be read.  This argument is mandatory.
43
44 =back
45
46 =head1 METRICS
47
48 =over
49
50 =item value
51
52 The value of the specified sensor.
53
54 =back
55
56 =cut
57
58 sub handler {
59     my $self = shift;
60     my $config = $self->{config}; # All configuration is in here
61     my $check_name = $self->{check_name}; # The check name is in here
62     my $chip = $config->{chip};
63     my $sensor = $config->{sensor};
64
65     my $output = run_command("sysctl -n hw.sensors.$chip.$sensor");
66     $output =~ m/(-?\d+\.?\d*)\s+\S+/;
67     my $value = $1;
68
69     return {
70         "value" => [$value, "n"]
71     };
72 };
73
74 1;
Note: See TracBrowser for help on using the browser.