From f10a3a594ba48ac5b81d5f755e47b6807d06042d Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 12 Jun 2013 09:40:34 -0300 Subject: Updating munin plugin with upstream http://munin-monitoring.org/browser/munin/plugins/node.d/apc_nis.in --- files/munin/apc_nis | 279 ++++++++++++++++++++++++++++++++++++---------------- manifests/munin.pp | 2 - 2 files changed, 196 insertions(+), 85 deletions(-) diff --git a/files/munin/apc_nis b/files/munin/apc_nis index 0b8798a..0a7278d 100755 --- a/files/munin/apc_nis +++ b/files/munin/apc_nis @@ -1,87 +1,200 @@ -#!/usr/bin/perl -w -# -*- perl -*- + + + + -=head1 NAME -apc_nis - Plugin to monitor APC UPS via the nis port of apcupsd + + + apc_nis.in in munin/plugins/node.d + – Munin + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+

+ +source: +munin/plugins/node.d/apc_nis.in +
-=cut +

+
+
+
+ +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + + +
+
+
+
+ devel +
+ + + + + + + + + + + +
+ Last change + on this file was + 1c1624e, + checked in by Kenyon Ralph <kenyon@…>, 6 weeks ago +
+

+plugins/node.d/apc_nis: improve maximum limits
+

+

+Battery charge is a percentage, so can't be over 100. There's no
+reason to limit load, time left, or temperature; doing so just creates
+graphs with missing values when you have actual values over these
+arbitrary limits.
+

+
+
    +
  • + Property mode set to + 100644 +
  • +
+
+ File size: + 3.1 KB +
+
+ +
Line 
1#!@@PERL@@ -w
2# -*- perl -*-
3
4=head1 NAME
5
6apc_nis - Plugin to monitor APC UPS via the nis port of apcupsd
7
8=head1 CONFIGURATION
9
10The following configuration parameters are used by this plugin
11
12 [apc_nis]
13  env.host     - hostname to connect to
14  env.port     - port number to connect to
15
16=head2 DEFAULT CONFIGURATION
17
18 [apc_nis]
19  env.host 127.0.0.1
20  env.port 3551
21
22=head1 MAGIC MARKERS
23
24 #%# family=contrib
25 #%# capabilities=autoconf
26
27=cut
28
29use IO::Socket;
30use strict;
31
32if($ARGV[0] and $ARGV[0] eq "autoconf") {
33    print "yes\n";
34    exit 0;
35}
36
37my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1";
38my $port = exists $ENV{'port'} ? $ENV{'port'} : "3551";
39
40my $sock = new IO::Socket::INET (
41    PeerAddr => $host,
42    PeerPort => $port,
43    Proto => 'tcp'
44    );
45
46die "Could not create socket: $!\n" unless $sock;
47
48my $buf = pack("CC", 0, 6);
49print $sock $buf;
50print $sock "status\n";
51
52if($ARGV[0] and $ARGV[0] eq "config") {
53    # Test for some capabilities.
54    my $has_temperature = 0, my $line_volt_min, my $line_volt_max;
55    my $line;
56    do {
57        $line = <$sock>;
58        chomp($line);
59        if ($line =~ /\WITEMP /) {
60            $has_temperature = 1;
61        } elsif ($line =~ /\WLOTRANS /) {
62            $line =~ s/.* (\d+.\d+).*/$1/;
63            $line_volt_min = $line;
64        } elsif ($line =~ /\WHITRANS /) {
65            $line =~ s/.* (\d+.\d+).*/$1/;
66            $line_volt_max = $line;
67        }
68    } while(!($line =~ /END APC/));
69
70    close($sock);
71
72    print "graph_title APC UPS measurements\n";
73    print "graph_args -l 0 --base 1000\n";
74    print "graph_vlabel A bit of all (Volt, time, %)\n";
75    print "graph_info Values received for apcupsd available at $host:$port\n";
76    print "battery_volt.label batt volt (V)\n";
77    print "battery_volt.type GAUGE\n";
78    print "battery_volt.max 300\n";
79    print "battery_charge.label batt charge (%)\n";
80    print "battery_charge.type GAUGE\n";
81    print "battery_charge.max 100\n";
82    print "line_volt.label line (V)\n";
83    print "line_volt.type GAUGE\n";
84    print "line_volt.max 300\n";
85    print "line_volt.warning ${line_volt_min}:${line_volt_max}\n";
86    print "load.label ups load (%)\n";
87    print "load.type GAUGE\n";
88    print "time_left.label time left (min)\n";
89    print "time_left.type GAUGE\n";
90    if ($has_temperature) {
91        print "temperature.label internal temperature (°C)\n";
92        print "temperature.type GAUGE\n";
93    }
94    exit 0;
95}
96
97my $line;
98do {
99    $line = <$sock>;
100    chomp($line);
101    if($line =~ /\WBATTV /) {
102        $line =~ s/.* (\d+.\d+).*/$1/;
103        print "battery_volt.value $line\n";
104    } elsif($line =~ /\WLINEV /) {
105        $line =~ s/.* (\d+.\d+).*/$1/;
106        print "line_volt.value $line\n";
107    } elsif($line =~ /\WLOADPCT /) {
108        $line =~ s/.* (\d+.\d+).*/$1/;
109        print "load.value $line\n";
110    } elsif($line =~ /\WBCHARGE /) {
111        $line =~ s/.* (\d+.\d+).*/$1/;
112        print "battery_charge.value $line\n";
113    } elsif($line =~ /\WTIMELEFT /) {
114        $line =~ s/.* (\d+.\d+).*/$1/;
115        print "time_left.value $line\n";
116    } elsif($line =~ /\WITEMP /) {
117        $line =~ s/.* (\d+.\d+).*/$1/;
118        print "temperature.value $line\n";
119    }
120} while(!($line =~ /END APC/));
121
122close($sock);
-# -# -# Parameters: -# -# config (required) -# -# Magic markers (optional - used by munin-config and some installation -# scripts): -#%# family=contrib - -use IO::Socket; -use strict; - -if($ARGV[0] and $ARGV[0] eq "autoconfig") { - print "yes\n"; - exit 0; -} - -if($ARGV[0] and $ARGV[0] eq "config") { - print "graph_title apcupsd\n"; - print "graph_args -l 0 --base 1000\n"; - print "graph_vlabel A bit of all (Volt, time, %)\n"; - print "battery_volt.label batt volt (V)\n"; - print "battery_volt.type GAUGE\n"; - print "battery_volt.max 140\n"; - print "battery_charge.label batt charge (%)\n"; - print "battery_charge.type GAUGE\n"; - print "battery_charge.max 200\n"; - print "line_volt.label line (V)\n"; - print "line_volt.type GAUGE\n"; - print "line_volt.max 300\n"; - print "load.label ups load (%)\n"; - print "load.type GAUGE\n"; - print "load.max 200\n"; - print "time_left.label time left (min)\n"; - print "time_left.type GAUGE\n"; - print "time_left.max 200\n"; - exit 0; -} - -my $server = "localhost"; -my $port = "3551"; - -my $sock = new IO::Socket::INET ( - PeerAddr => $server, - PeerPort => $port, - Proto => 'tcp' - ); - -die "Could not create socket: $!\n" unless $sock; - -my $buf = pack("CC", 0, 6); -print $sock $buf; -print $sock "status\n"; - -my $line; -do { - $line = <$sock>; - chomp($line); - if($line =~ /\WBATTV /) { - $line =~ s/.* (\d+.\d+).*/$1/; - print "battery_volt.value $line\n"; - } elsif($line =~ /\WLINEV /) { - $line =~ s/.* (\d+.\d+).*/$1/; - print "line_volt.value $line\n"; - } elsif($line =~ /\WLOADPCT /) { - $line =~ s/.* (\d+.\d+).*/$1/; - print "load.value $line\n"; - } elsif($line =~ /\WBCHARGE /) { - $line =~ s/.* (\d+.\d+).*/$1/; - print "battery_charge.value $line\n"; - } elsif($line =~ /\WTIMELEFT /) { - $line =~ s/.* (\d+.\d+).*/$1/; - print "time_left.value $line\n"; - } -} while(!($line =~ /END APC/)); - -close($sock); +
+
+
+
+ + + + + +
+
+
+
Note: See TracBrowser + for help on using the repository browser.
+
+ +
+ + + \ No newline at end of file diff --git a/manifests/munin.pp b/manifests/munin.pp index df1e6a3..da5a372 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -6,8 +6,6 @@ class apcupsd::munin( ensure => $ensure, } - # We might want to replace the debian plugin with a newer one which better - # maximum limits: http://munin-monitoring.org/browser/munin/plugins/node.d/apc_nis.in munin::plugin { 'apc_nis': ensure => $ensure, } -- cgit v1.2.3