root / plugins / sensors / snmp__sfsnmp_fan @ ea6afd78
Historique | Voir | Annoter | Télécharger (3,1 ko)
| 1 | ff5e18fa | Nils Henrik Tvetene | #!/usr/bin/perl |
|---|---|---|---|
| 2 | # -*- perl -*- |
||
| 3 | # |
||
| 4 | # snmp__sfsnmp_fan - Munin plugin for measuring fan on a windowssystem running SpeedFan and sfsnmp |
||
| 5 | # Copyright (C) 2010 Nils Henrik Tvetene |
||
| 6 | # |
||
| 7 | # Author: Nils Henrik Tvetene <nils@tvetene.net> |
||
| 8 | # |
||
| 9 | # This program is free software; you can redistribute it and/or modify |
||
| 10 | # it under the terms of the GNU General Public License as published by |
||
| 11 | # the Free Software Foundation; either version 2 of the License, or |
||
| 12 | # (at your option) any later version. |
||
| 13 | # |
||
| 14 | # This program is distributed in the hope that it will be useful, |
||
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 17 | # GNU General Public License for more details. |
||
| 18 | # |
||
| 19 | # You should have received a copy of the GNU General Public License along |
||
| 20 | # with this program; if not, write to the Free Software Foundation, Inc., |
||
| 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
| 22 | |||
| 23 | =head1 NAME |
||
| 24 | |||
| 25 | snmp__sfsnmp_fan - Munin plugin for measuring fanspeed on a windowssystem running SpeedFan and sfsnmp |
||
| 26 | |||
| 27 | =head1 APPLICABLE SYSTEMS |
||
| 28 | |||
| 29 | Windows-system running SpeedFan and the sfsnmp extension |
||
| 30 | |||
| 31 | =head1 CONFIGURATION |
||
| 32 | |||
| 33 | Example config: |
||
| 34 | [snmp_twinspark_sfsnmp_*] |
||
| 35 | env.fan1 CPU |
||
| 36 | env.fan7.ignore true |
||
| 37 | |||
| 38 | Plugin is linked using hostname of monitored system: |
||
| 39 | |||
| 40 | ln -s /usr/share/munin/plugins/snmp__sfsnmp_fan /etc/munin/plugins/snmp_<hostname>_sfsnmp_fan |
||
| 41 | |||
| 42 | =head1 MAGIC MARKERS |
||
| 43 | |||
| 44 | #%# family=snmpauto |
||
| 45 | #%# capabilities=snmpconf |
||
| 46 | |||
| 47 | |||
| 48 | =head1 AUTHOR |
||
| 49 | |||
| 50 | Nils Henrik Tvetene <nils@tvetene.net> |
||
| 51 | |||
| 52 | =head1 LICENSE |
||
| 53 | |||
| 54 | GPLv2 |
||
| 55 | |||
| 56 | =cut |
||
| 57 | |||
| 58 | use strict; |
||
| 59 | use warnings; |
||
| 60 | use Munin::Plugin::SNMP; |
||
| 61 | use vars qw($DEBUG); |
||
| 62 | |||
| 63 | $DEBUG = $ENV{'MUNIN_DEBUG'};
|
||
| 64 | |||
| 65 | # OIDs used |
||
| 66 | # 1.3.6.1.4.1.30503.1.1.2 number of fans |
||
| 67 | # 1.3.6.1.4.1.30503.1.3.x where x is 1 => above number |
||
| 68 | |||
| 69 | if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
|
||
| 70 | print "number 1.3.6.1.4.1.30503.1.1.2\n"; |
||
| 71 | print "index 1.3.6.1.4.1.30503.1.3.\n"; |
||
| 72 | exit 0; |
||
| 73 | } |
||
| 74 | |||
| 75 | my $session = Munin::Plugin::SNMP->session(); |
||
| 76 | my ($host, undef, undef, undef) = Munin::Plugin::SNMP->config_session(); |
||
| 77 | my ($idx, $numFans, @fan, @label); |
||
| 78 | |||
| 79 | $numFans = $session->get_single('1.3.6.1.4.1.30503.1.1.2');
|
||
| 80 | |||
| 81 | if (defined $ARGV[0] and $ARGV[0] eq "config") {
|
||
| 82 | print "host_name $host\n" unless $host eq 'localhost'; |
||
| 83 | print "graph_title $host fan\n"; |
||
| 84 | print "graph_args --base 1000 --lower-limit 1000\n"; |
||
| 85 | print "graph_scale no\n"; |
||
| 86 | print "graph_printf %3.0lf\n"; |
||
| 87 | print "graph_vlabel fan RPM\n"; |
||
| 88 | print "graph_category sensors\n"; |
||
| 89 | print "graph_info This graph shows the fans on host $host\n"; |
||
| 90 | foreach $idx ( 0..$numFans-1 ) {
|
||
| 91 | $label[$idx] = exists $ENV{"fan".($idx+1)} ? $ENV{"fan".($idx+1)} : "fan".($idx+1);
|
||
| 92 | print "fan".($idx+1).".info ".$label[$idx]." fan in RPM's.\n"; |
||
| 93 | |||
| 94 | print "fan".($idx+1).".graph no\n" if exists $ENV{"fan".($idx+1).".ignore"};
|
||
| 95 | |||
| 96 | print "fan".($idx+1).".type GAUGE\n"; |
||
| 97 | print "fan".($idx+1).".label $label[$idx]\n"; |
||
| 98 | print "fan".($idx+1).".min 1000\n"; |
||
| 99 | } |
||
| 100 | |||
| 101 | exit 0; |
||
| 102 | } |
||
| 103 | |||
| 104 | foreach $idx ( 0..$numFans-1 ) {
|
||
| 105 | $fan[$idx] = $session->get_single('1.3.6.1.4.1.30503.1.3.'.($idx+1));
|
||
| 106 | print "fan".($idx+1).".value $fan[$idx]\n"; |
||
| 107 | } |
||
| 108 | |||
| 109 | exit 0; |
||
| 110 | |||
| 111 | __END__ |
