diff --git a/plugins/other/snmp__sfsnmp_fan b/plugins/other/snmp__sfsnmp_fan new file mode 100755 index 00000000..fac3751d --- /dev/null +++ b/plugins/other/snmp__sfsnmp_fan @@ -0,0 +1,112 @@ +#!/usr/bin/perl +# -*- perl -*- +# +# snmp__sfsnmp_fan - Munin plugin for measuring fan on a windowssystem running SpeedFan and sfsnmp +# Copyright (C) 2010 Nils Henrik Tvetene +# +# Author: Nils Henrik Tvetene +# +# 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_fan - Munin plugin for measuring fanspeed 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_*] + env.fan1 CPU + env.fan7.ignore true + +Plugin is linked using hostname of monitored system: + +ln -s /usr/share/munin/plugins/snmp__sfsnmp_fan /etc/munin/plugins/snmp__sfsnmp_fan + +=head1 MAGIC MARKERS + +#%# family=snmpauto +#%# capabilities=snmpconf + + +=head1 AUTHOR + +Nils Henrik Tvetene + +=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.2 number of fans +# 1.3.6.1.4.1.30503.1.3.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.2\n"; + print "index 1.3.6.1.4.1.30503.1.3.\n"; + exit 0; +} + +my $session = Munin::Plugin::SNMP->session(); +my ($host, undef, undef, undef) = Munin::Plugin::SNMP->config_session(); +my ($idx, $numFans, @fan, @label); + +$numFans = $session->get_single('1.3.6.1.4.1.30503.1.1.2'); + +if (defined $ARGV[0] and $ARGV[0] eq "config") { + print "host_name $host\n" unless $host eq 'localhost'; + print "graph_title $host fan\n"; + print "graph_args --base 1000 --lower-limit 1000\n"; + print "graph_scale no\n"; + print "graph_printf %3.0lf\n"; + print "graph_vlabel fan RPM\n"; + print "graph_category sensors\n"; + print "graph_info This graph shows the fans on host $host\n"; + foreach $idx ( 0..$numFans-1 ) { + $label[$idx] = exists $ENV{"fan".($idx+1)} ? $ENV{"fan".($idx+1)} : "fan".($idx+1); + print "fan".($idx+1).".info ".$label[$idx]." fan in RPM's.\n"; + + print "fan".($idx+1).".graph no\n" if exists $ENV{"fan".($idx+1).".ignore"}; + + print "fan".($idx+1).".type GAUGE\n"; + print "fan".($idx+1).".label $label[$idx]\n"; + print "fan".($idx+1).".min 1000\n"; + } + + exit 0; +} + +foreach $idx ( 0..$numFans-1 ) { + $fan[$idx] = $session->get_single('1.3.6.1.4.1.30503.1.3.'.($idx+1)); + print "fan".($idx+1).".value $fan[$idx]\n"; +} + +exit 0; + +__END__ +