@@ -, +, @@ --- plugins/node.d/apc_nis.in | 38 +++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 15 deletions(-) --- a/plugins/node.d/apc_nis.in +++ a/plugins/node.d/apc_nis.in @@ -5,17 +5,25 @@ apc_nis - Plugin to monitor APC UPS via the nis port of apcupsd -=cut +=head1 CONFIGURATION + +The following configuration parameters are used by this plugin + + [apc_nis] + env.host - hostname to connect to + env.port - port number to connect to + +=head2 DEFAULT CONFIGURATION + + [apc_nis] + env.host 127.0.0.1 + env.port 3551 -# -# -# Parameters: -# -# config (required) -# -# Magic markers (optional - used by munin-config and some installation -# scripts): -#%# family=contrib +=head1 MAGIC MARKERS + + #%# family=contrib + +=cut use IO::Socket; use strict; @@ -25,8 +33,11 @@ if($ARGV[0] and $ARGV[0] eq "autoconfig") { exit 0; } +my $host = exists $ENV{'host'} ? $ENV{'host'} : "127.0.0.1"; +my $port = exists $ENV{'port'} ? $ENV{'port'} : "3551"; + if($ARGV[0] and $ARGV[0] eq "config") { - print "graph_title apcupsd\n"; + print "graph_title apcupsd $host:$port\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"; @@ -50,11 +61,8 @@ if($ARGV[0] and $ARGV[0] eq "config") { exit 0; } -my $server = "localhost"; -my $port = "3551"; - my $sock = new IO::Socket::INET ( - PeerAddr => $server, + PeerAddr => $host, PeerPort => $port, Proto => 'tcp' ); --