* Created the new anvil-watch-power tool that shows the status of UPSes known on the system, including their "on battery" state, charge percentage, estimated hold up time, etc.

* Updated Database->get_power() and ->get_upses() to store both the time stamp and unix time stamps.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 2 years ago
parent 5bb1c631cf
commit c82bd9d73a
  1. 18
      Anvil/Tools/Database.pm
  2. 5
      share/words.xml

@ -6450,6 +6450,7 @@ SELECT
power_on_battery,
power_seconds_left,
power_charge_percentage,
modified_date,
round(extract(epoch from modified_date))
FROM
power
@ -6468,13 +6469,15 @@ FROM
my $power_on_battery = $row->[2];
my $power_seconds_left = $row->[3];
my $power_charge_percentage = $row->[4];
my $modified_date_unix = $row->[5];
my $modified_date = $row->[5];
my $modified_date_unix = $row->[6];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
power_uuid => $power_uuid,
power_ups_uuid => $power_ups_uuid,
power_on_battery => $power_on_battery,
power_seconds_left => $power_seconds_left,
power_charge_percentage => $power_charge_percentage,
modified_date => $modified_date,
modified_date_unix => $modified_date_unix,
}});
@ -6483,12 +6486,14 @@ FROM
$anvil->data->{power}{power_uuid}{$power_uuid}{power_on_battery} = $power_on_battery;
$anvil->data->{power}{power_uuid}{$power_uuid}{power_seconds_left} = $power_seconds_left;
$anvil->data->{power}{power_uuid}{$power_uuid}{power_charge_percentage} = $power_charge_percentage;
$anvil->data->{power}{power_uuid}{$power_uuid}{modified_date} = $modified_date;
$anvil->data->{power}{power_uuid}{$power_uuid}{modified_date_unix} = $modified_date_unix;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"power::power_uuid::${power_uuid}::power_ups_uuid" => $anvil->data->{power}{power_uuid}{$power_uuid}{power_ups_uuid},
"power::power_uuid::${power_uuid}::power_on_battery" => $anvil->data->{power}{power_uuid}{$power_uuid}{power_on_battery},
"power::power_uuid::${power_uuid}::power_seconds_left" => $anvil->data->{power}{power_uuid}{$power_uuid}{power_seconds_left},
"power::power_uuid::${power_uuid}::power_charge_percentage" => $anvil->data->{power}{power_uuid}{$power_uuid}{power_charge_percentage},
"power::power_uuid::${power_uuid}::modified_date" => $anvil->data->{power}{power_uuid}{$power_uuid}{modified_date},
"power::power_uuid::${power_uuid}::modified_date_unix" => $anvil->data->{power}{power_uuid}{$power_uuid}{modified_date_unix},
}});
@ -6496,12 +6501,14 @@ FROM
$anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{power_on_battery} = $power_on_battery;
$anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{power_seconds_left} = $power_seconds_left;
$anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{power_charge_percentage} = $power_charge_percentage;
$anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{modified_date} = $modified_date;
$anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{modified_date_unix} = $modified_date_unix;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"power::power_ups_uuid::${power_ups_uuid}::power_uuid" => $anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{power_uuid},
"power::power_ups_uuid::${power_ups_uuid}::power_on_battery" => $anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{power_on_battery},
"power::power_ups_uuid::${power_ups_uuid}::power_seconds_left" => $anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{power_seconds_left},
"power::power_ups_uuid::${power_ups_uuid}::power_charge_percentage" => $anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{power_charge_percentage},
"power::power_ups_uuid::${power_ups_uuid}::modified_date" => $anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{modified_date},
"power::power_ups_uuid::${power_ups_uuid}::modified_date_unix" => $anvil->data->{power}{power_ups_uuid}{$power_ups_uuid}{modified_date_unix},
}});
}
@ -6568,7 +6575,8 @@ SELECT
ups_name,
ups_agent,
ups_ip_address,
modified_date
modified_date,
round(extract(epoch from modified_date))
FROM
upses ";
if (not $include_deleted)
@ -6593,12 +6601,14 @@ WHERE
my $ups_agent = $row->[2];
my $ups_ip_address = $row->[3];
my $modified_date = $row->[4];
my $modified_date_unix = $row->[5];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
ups_uuid => $ups_uuid,
ups_name => $ups_name,
ups_agent => $ups_agent,
ups_ip_address => $ups_ip_address,
modified_date => $modified_date,
modified_date_unix => $modified_date_unix,
}});
# Record the data in the hash, too.
@ -6606,24 +6616,28 @@ WHERE
$anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_agent} = $ups_agent;
$anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_ip_address} = $ups_ip_address;
$anvil->data->{upses}{ups_uuid}{$ups_uuid}{modified_date} = $modified_date;
$anvil->data->{upses}{ups_uuid}{$ups_uuid}{modified_date_unix} = $modified_date_unix;
$anvil->data->{upses}{ups_uuid}{$ups_uuid}{power_uuid} = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"upses::ups_uuid::${ups_uuid}::ups_name" => $anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_name},
"upses::ups_uuid::${ups_uuid}::ups_agent" => $anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_agent},
"upses::ups_uuid::${ups_uuid}::ups_ip_address" => $anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_ip_address},
"upses::ups_uuid::${ups_uuid}::modified_date" => $anvil->data->{upses}{ups_uuid}{$ups_uuid}{modified_date},
"upses::ups_uuid::${ups_uuid}::modified_date_unix" => $anvil->data->{upses}{ups_uuid}{$ups_uuid}{modified_date_unix},
}});
$anvil->data->{upses}{ups_name}{$ups_name}{ups_uuid} = $ups_uuid;
$anvil->data->{upses}{ups_name}{$ups_name}{ups_agent} = $ups_agent;
$anvil->data->{upses}{ups_name}{$ups_name}{ups_ip_address} = $ups_ip_address;
$anvil->data->{upses}{ups_name}{$ups_name}{modified_date} = $modified_date;
$anvil->data->{upses}{ups_name}{$ups_name}{modified_date_unix} = $modified_date;
$anvil->data->{upses}{ups_name}{$ups_name}{power_uuid} = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"upses::ups_name::${ups_name}::ups_uuid" => $anvil->data->{upses}{ups_name}{$ups_name}{ups_uuid},
"upses::ups_name::${ups_name}::ups_agent" => $anvil->data->{upses}{ups_name}{$ups_name}{ups_agent},
"upses::ups_name::${ups_name}::ups_ip_address" => $anvil->data->{upses}{ups_name}{$ups_name}{ups_ip_address},
"upses::ups_name::${ups_name}::modified_date" => $anvil->data->{upses}{ups_name}{$ups_name}{modified_date},
"upses::ups_name::${ups_name}::modified_date_unix" => $anvil->data->{upses}{ups_name}{$ups_name}{modified_date_unix},
}});
# Collect power information from 'power'.

@ -1019,6 +1019,10 @@ resource #!variable!server!# {
<key name="header_0104">Host UUID</key>
<key name="header_0105">Machines</key>
<key name="header_0106">MN link #!variable!number!#</key>
<key name="header_0107">Charge %</key>
<key name="header_0108">On Battery</key>
<key name="header_0109">Estimated Runtime</key>
<key name="header_0110">Last Updated</key>
<!-- Strings used by jobs -->
<key name="job_0001">Configure Network</key>
@ -2384,6 +2388,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0735">The DR host: [#!variable!host!#] as been _unlinked_ to the Anvil! node: [#!variable!anvil!#].</key>
<key name="log_0736">The DR host: [#!variable!host!#] was not linked to the Anvil! node: [#!variable!anvil!#], nothing to do.</key>
<key name="log_0737">The job: [#!variable!command!#] (with job UUID: [#!variable!job_uuid!#]) is being skipped for now, already started a job (started job_uuid: [#!variable!started_job!#]) with this command on this loop.</key>
<key name="log_0738">There are no databases available at this time.</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>

Loading…
Cancel
Save