mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
Fix for pull request munin-monitoring#798
This commit is contained in:
parent
32cd3f6045
commit
c9bd24bda7
1 changed files with 39 additions and 24 deletions
|
@ -18,10 +18,17 @@ Environment variables:
|
||||||
host - UPSMON PRO server host, default localhost
|
host - UPSMON PRO server host, default localhost
|
||||||
port - UPSMON PRO port, default 2601
|
port - UPSMON PRO port, default 2601
|
||||||
|
|
||||||
|
Example configuration (optional):
|
||||||
|
|
||||||
|
[upsmonpro_*]
|
||||||
|
env.host localhost
|
||||||
|
env.port 2601
|
||||||
|
|
||||||
=head1 MAGIC MARKERS
|
=head1 MAGIC MARKERS
|
||||||
|
|
||||||
#%# family=auto
|
#%# family=auto
|
||||||
#%# capabilities=autoconf
|
#%# capabilities=autoconf
|
||||||
|
#%# capabilities=suggest
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
@ -51,34 +58,36 @@ our %TYPES = (
|
||||||
temp => [q/temp/],
|
temp => [q/temp/],
|
||||||
status => [qw/power_failure low_battery voltage_status ups_status battery_test/]
|
status => [qw/power_failure low_battery voltage_status ups_status battery_test/]
|
||||||
);
|
);
|
||||||
our @TYPES = keys %TYPES;
|
our @TYPES = sort keys %TYPES;
|
||||||
|
my %DISPATCH_TABLE = ();
|
||||||
|
my $pkg = __PACKAGE__;
|
||||||
|
|
||||||
{
|
$DISPATCH_TABLE{"${pkg}::run_suggest"} = \&run_suggest;
|
||||||
no strict 'refs';
|
$DISPATCH_TABLE{"${pkg}::run_autoconf"} = \&run_autoconf;
|
||||||
for my $t (@TYPES) {
|
for my $t (@TYPES) {
|
||||||
for my $sub (qw/autoconf/) {
|
$DISPATCH_TABLE{"${pkg}::run_config_$t"} = \&{"run_config_$t"};
|
||||||
*{ __PACKAGE__ . "::run_${sub}_$t" } = "run_$sub";
|
$DISPATCH_TABLE{"${pkg}::run_autoconf_$t"} = \&run_autoconf;
|
||||||
}
|
$DISPATCH_TABLE{"${pkg}::run_default_$t"} = sub {
|
||||||
*{ __PACKAGE__ . "::run_default_$t" } = sub {
|
|
||||||
run_default(@{ $TYPES{$t} });
|
run_default(@{ $TYPES{$t} });
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
find_key($ARGV[0])->();
|
||||||
no strict 'refs';
|
|
||||||
find_key($ARGV[0])->();
|
|
||||||
}
|
|
||||||
|
|
||||||
sub find_key {
|
sub find_key {
|
||||||
my $p = shift || "";
|
my $argv = shift || '';
|
||||||
my $type_re = join '|', @TYPES;
|
my $type_re = join '|', @TYPES;
|
||||||
unless ($Munin::Plugin::me =~ /upsmonpro_{1,}($type_re)$/) {
|
my $key;
|
||||||
die "Could not determine script type [@TYPES] ? name=" . $Munin::Plugin::me . "\n";
|
if ($argv =~ /(suggest|autoconf)/i) {
|
||||||
}
|
$key = 'run_' . lc($1);
|
||||||
|
} elsif ($Munin::Plugin::me =~ /upsmonpro_{1,}($type_re)$/) {
|
||||||
my $graph = $1;
|
my $graph = $1;
|
||||||
|
$key = 'run_' . ((grep { $argv eq $_ } qw/autoconf config/) ? $argv : 'default') . "_$graph";
|
||||||
|
} else {
|
||||||
|
die "Could not determine script type [@TYPES] ? name=$Munin::Plugin::me\n";
|
||||||
|
}
|
||||||
|
|
||||||
return 'run_' . ((grep { $p eq $_ } qw/autoconf config/) ? $ARGV[0] : 'default') . "_$graph";
|
return $DISPATCH_TABLE{"${pkg}::$key"};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run_config_voltage {
|
sub run_config_voltage {
|
||||||
|
@ -86,7 +95,7 @@ sub run_config_voltage {
|
||||||
graph_title UPS Input/Output Voltage
|
graph_title UPS Input/Output Voltage
|
||||||
graph_vlabel volt
|
graph_vlabel volt
|
||||||
graph_scale no
|
graph_scale no
|
||||||
graph_category sensors
|
graph_category ups
|
||||||
input.label input
|
input.label input
|
||||||
input.info Input Voltage
|
input.info Input Voltage
|
||||||
input.type GAUGE
|
input.type GAUGE
|
||||||
|
@ -102,7 +111,7 @@ sub run_config_temp {
|
||||||
graph_title UPS Temperature
|
graph_title UPS Temperature
|
||||||
graph_vlabel celsius
|
graph_vlabel celsius
|
||||||
graph_scale no
|
graph_scale no
|
||||||
graph_category sensors
|
graph_category ups
|
||||||
temp.label temperature
|
temp.label temperature
|
||||||
temp.type GAUGE
|
temp.type GAUGE
|
||||||
END
|
END
|
||||||
|
@ -114,7 +123,7 @@ sub run_config_load {
|
||||||
graph_title UPS Battery Load/Capacity
|
graph_title UPS Battery Load/Capacity
|
||||||
graph_vlabel precent%
|
graph_vlabel precent%
|
||||||
graph_scale no
|
graph_scale no
|
||||||
graph_category sensors
|
graph_category ups
|
||||||
battery_load.label battery_load
|
battery_load.label battery_load
|
||||||
battery_load.type GAUGE
|
battery_load.type GAUGE
|
||||||
battery_capacity.label battery_capacity
|
battery_capacity.label battery_capacity
|
||||||
|
@ -128,7 +137,7 @@ sub run_config_status {
|
||||||
graph_title UPS Statuses
|
graph_title UPS Statuses
|
||||||
graph_vlabel status
|
graph_vlabel status
|
||||||
graph_scale no
|
graph_scale no
|
||||||
graph_category sensors
|
graph_category ups
|
||||||
power_failure.label power_failure
|
power_failure.label power_failure
|
||||||
power_failure.type GAUGE
|
power_failure.type GAUGE
|
||||||
low_battery.label low_battery
|
low_battery.label low_battery
|
||||||
|
@ -155,6 +164,12 @@ sub run_default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub run_suggest {
|
||||||
|
local $LIST_SEPARATOR = "\n";
|
||||||
|
say "@TYPES";
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
sub run_autoconf {
|
sub run_autoconf {
|
||||||
if (gather_data($DEFAULT_HOST, $DEFAULT_PORT)->{response} eq 'ok') {
|
if (gather_data($DEFAULT_HOST, $DEFAULT_PORT)->{response} eq 'ok') {
|
||||||
say "yes";
|
say "yes";
|
Loading…
Add table
Add a link
Reference in a new issue