From c66f50b2e09f9d9bd234f1af56ece475b422f34e Mon Sep 17 00:00:00 2001 From: Tim Connors <1707595+spacelama@users.noreply.github.com> Date: Tue, 17 Oct 2023 04:39:47 +1100 Subject: [PATCH] Nutups2 multiplier (#1313) * add multiplier_fetch that's much like common_fetch * moved multiplier_fetch functionality to common_fetch * power_emulated_multiplier env var added and Documented --------- Co-authored-by: Tim Connors --- plugins/power/nutups2_ | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/plugins/power/nutups2_ b/plugins/power/nutups2_ index 1cb217bd..23aebe95 100755 --- a/plugins/power/nutups2_ +++ b/plugins/power/nutups2_ @@ -36,10 +36,11 @@ You can also control individual fields like: =head1 FEATURES The plugin supports reporting battery charge, UPS load, input/output -frequencies/currents/voltages, apparent and real power output, humidity and -temperature readings. Note however that different UPS models report different -levels of detail; the plugin reports whatever information the NUT UPS driver -(and in turn the UPS itself) provides. +frequencies/currents/voltages, apparent and real power output, as well +as emulated power output if only % load is available, humidity and +temperature readings. Note however that different UPS models report +different levels of detail; the plugin reports whatever information +the NUT UPS driver (and in turn the UPS itself) provides. Although the 'suggest' command will only offer UPSes for which the local host is the master, you can also monitor remote UPSes if you include the host name @@ -49,6 +50,19 @@ in the symlink, like: etc. +If your UPS only outputs % load instead of an actual power value, you +can emulate it based on readings you can manually make such as by +comparing against a power meter. Configure the plugin via with +settings like these: + +[nutups2_powershield-commander*] +# powershield commander 1000: 400 watts at 63% load on powershield commander 1000: 400/63 +env.power_emulated_multiplier 6.349 + +[nutups2_powershield-centurion*] +# powershield centurion 1000: 445 watts at 48% load on powershield centurion 1000: 445/49 +env.power_emulated_multiplier 9.294 + =head1 AUTHOR Gábor Gombás @@ -141,6 +155,15 @@ my %config = ( config => \&common_config, fetch => \&common_fetch, }, + power_emulated => { + filter => qr/^(.*)\.load$/, + title => 'UPS emulated power', + args => '--base 1000 -l 0', + vlabel => 'Watt', + config => \&common_config, + multiplier => $ENV{'power_emulated_multiplier'} || 1, + fetch => \&common_fetch, + }, ); sub read_ups_values { @@ -265,7 +288,9 @@ sub common_fetch { $field .= $nominal if $nominal; my $id = clean_fieldname($field); - print $id . ".value " . $values->{$key} . "\n"; + print $id . ".value " . $values->{$key}* + (defined $config{$func}->{'multiplier'} ? $config{$func}->{'multiplier'} : 1) + . "\n"; } }