2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/snmp/snmp__sfsnmp_temp
Diego Elio Pettenò 7da1b039c2 Put order in SNMP plugins by moving all of them together in snmp/
This makes it easier to find what should be used for SNMP monitoring.
2012-08-06 21:36:10 -07:00

112 lines
3.2 KiB
Perl
Executable File

#!/usr/bin/perl
# -*- perl -*-
#
# snmp__sfsnmp_temp - Munin plugin for measuring temperatures on a windowssystem running SpeedFan and sfsnmp
# Copyright (C) 2010 Nils Henrik Tvetene
#
# Author: Nils Henrik Tvetene <nils@tvetene.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=head1 NAME
snmp__sfsnmp_temp - Munin plugin for measuring temperatures on a windowssystem running SpeedFan and sfsnmp
=head1 APPLICABLE SYSTEMS
Windows-system running SpeedFan and the sfsnmp extension
=head1 CONFIGURATION
Example config:
[snmp_twinspark_sfsnmp_temp]
env.temp1 System
env.temp7.ignore true
Plugin is linked using hostname of monitored system:
ln -s /usr/share/munin/plugins/snmp__sfsnmp_temp /etc/munin/plugins/snmp_<hostname>_sfsnmp_temp
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 AUTHOR
Nils Henrik Tvetene <nils@tvetene.net>
=head1 LICENSE
GPLv2
=cut
use strict;
use warnings;
use Munin::Plugin::SNMP;
use vars qw($DEBUG);
$DEBUG = $ENV{'MUNIN_DEBUG'};
# OIDs used
# 1.3.6.1.4.1.30503.1.1.1 number of temperatures
# 1.3.6.1.4.1.30503.1.2.x where x is 1 => above number
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
print "number 1.3.6.1.4.1.30503.1.1.1\n";
print "index 1.3.6.1.4.1.30503.1.2.\n";
exit 0;
}
my $session = Munin::Plugin::SNMP->session();
my ($host, undef, undef, undef) = Munin::Plugin::SNMP->config_session();
my ($idx, $numTemps, @temp, @label);
$numTemps = $session->get_single('1.3.6.1.4.1.30503.1.1.1');
if (defined $ARGV[0] and $ARGV[0] eq "config") {
print "host_name $host\n" unless $host eq 'localhost';
print "graph_title $host temperatures\n";
print "graph_args --base 1000 --lower-limit 30\n";
print "graph_vlabel degrees Celcius\n";
print "graph_category sensors\n";
print "graph_info This graph shows the temperatures on host $host\n";
foreach $idx ( 0..$numTemps-1 ) {
$label[$idx] = exists $ENV{"temp".($idx+1)} ? $ENV{"temp".($idx+1)} : "temp".($idx+1);
print "temp".($idx+1).".info ".$label[$idx]." temperature in Celsius.\n";
print "temp".($idx+1).".graph no\n" if exists $ENV{"temp".($idx+1).".ignore"};
print "temp".($idx+1).".type GAUGE\n";
print "temp".($idx+1).".label $label[$idx]\n";
print "temp".($idx+1).".cdef temp".($idx+1).",100,/\n";
print "temp".($idx+1).".min 30\n";
}
exit 0;
}
foreach $idx ( 0..$numTemps-1 ) {
$temp[$idx] = $session->get_single('1.3.6.1.4.1.30503.1.2.'.($idx+1));
print "temp".($idx+1).".value $temp[$idx]\n";
}
exit 0;
__END__