* Updated scan-apc-pdu to only run on the active striker DB (as set during Database->connect()) to prevent contention from simultaneous scan agent runs from different machines.

Signed-off-by: digimer <digimer@gravitar.alteeve.com>
main
digimer 2 years ago
parent 5fcbb1643c
commit 76c8088aee
  1. 18
      scancore-agents/scan-apc-pdu/scan-apc-pdu
  2. 2
      scancore-agents/scan-apc-pdu/scan-apc-pdu.xml

@ -160,7 +160,7 @@ $anvil->Storage->read_config();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
$anvil->Get->switches;
$anvil->Get->switches({debug => 3, list => ["force", "purge"]});
# Handle start-up tasks
my $problem = $anvil->ScanCore->agent_startup({agent => $THIS_FILE});
@ -169,13 +169,17 @@ if ($problem)
$anvil->nice_exit({exit_code => 1});
}
# The PDUs don't allow multiple connections at the same time. This causes a lot of false alerts when many
# machines try to scan. As such, only Striker dashboards watch APC PDUs.
my $host_type = $anvil->Get->host_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_type => $host_type }});
if (($host_type ne "striker") && (not $anvil->data->{switches}{force}))
# The APC PDUs only allow one connection at a time. As such, we only run on the striker that is also the
# active DB.
my $host_uuid = $anvil->Get->host_uuid();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
host_uuid => $host_uuid,
"sys::database::active_uuid" => $anvil->data->{sys}{database}{active_uuid},
"switches::force" => $anvil->data->{switches}{force},
}});
if ((not $anvil->data->{switches}{force}) && ($anvil->data->{sys}{database}{active_uuid} ne $host_uuid))
{
# Exit.
# Don't run.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "scan_apc_pdu_message_0041", variables => { program => $THIS_FILE }});
$anvil->nice_exit({exit_code => 0});
}

@ -81,7 +81,7 @@ A new PDU: [#!variable!name!#] has been found
<key name="scan_apc_pdu_message_0038">- Phase: [#!variable!phase!#] current amperage draw: [#!variable!amps!#].</key>
<key name="scan_apc_pdu_message_0039">- Outlet: [#!variable!outlet!#], on phase: [#!variable!on_phase!#] is: [#!variable!state!#] (name: [#!variable!name!#]).</key>
<key name="scan_apc_pdu_message_0040">The PDU model: [#!variable!model!#] at the IP address: [#!variable!ip_address!#] has vanished! Did the network cable come unplugged?</key>
<key name="scan_apc_pdu_message_0041">APC PDUs only allow one connection at a time. To avoid contention, only Striker dashboards scan APC PDUs. If you want this to run, you can use '--force'. Exiting.</key>
<key name="scan_apc_pdu_message_0041">APC PDUs only allow one connection at a time. To avoid contention, only the Striker dashboards which is also the active database is allowed to run this agent. If you want this to run, you can use '--force'. Exiting.</key>
<!-- Units -->
<key name="scan_apc_pdu_unit_0001">Unknown</key>

Loading…
Cancel
Save