* Updated scan-network to (hopefully, needs testing) not set a health score against unused/unconfigured network interfaces. Also silenced the purging of old RX/TX variables now that it appears to be working well.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent 2557fa454a
commit eeafefbe08
  1. 19
      notes
  2. 41
      scancore-agents/scan-network/scan-network

19
notes

@ -1121,6 +1121,20 @@ console(config)#interface out-of-band
console(config-if)#ip address 10.201.1.1 255.255.0.0 console(config-if)#ip address 10.201.1.1 255.255.0.0
console(config-if)#exit console(config-if)#exit
# Connect the Management interface of the stack ID 1 switch to one of the BCN ports.
console#ping 10.201.4.1
Pinging 10.201.4.1 with 0 bytes of data:
Reply From 10.201.4.1: icmp_seq = 0. time= 640 usec.
Reply From 10.201.4.1: icmp_seq = 1. time= 558 usec.
Reply From 10.201.4.1: icmp_seq = 2. time= 224 usec.
Reply From 10.201.4.1: icmp_seq = 3. time= 192 usec.
----10.201.4.1 PING statistics----
4 packets transmitted, 4 packets received, 0% packet loss
round-trip (msec) min/avg/max = 0/0/0
# Set a web user and password (obviously, use a better password) # Set a web user and password (obviously, use a better password)
console(config)#no passwords min-length console(config)#no passwords min-length
console(config)#username admin password admin privilege 15 console(config)#username admin password admin privilege 15
@ -1202,14 +1216,14 @@ oob Out-Of-Band Up
# Configure VLANs # Configure VLANs
rs-striker03(config)#vlan 100 rs-striker03(config)#vlan 100
rs-striker03(config-vlan100)#name BCN1 rs-striker03(config-vlan100)#name BCN1
rs-striker03(config-vlan100)#interface range gi1/0/1-12,gi2/0/1-12 rs-striker03(config-vlan100)#interface range gi1/0/1-14,gi2/0/1-14
rs-striker03(config-if)#switchport access vlan 100 rs-striker03(config-if)#switchport access vlan 100
rs-striker03(config-if)#no shutdown rs-striker03(config-if)#no shutdown
rs-striker03(config-if)#exit rs-striker03(config-if)#exit
rs-striker03(config)#interface vlan 300 rs-striker03(config)#interface vlan 300
rs-striker03(config)#name IFN rs-striker03(config)#name IFN
rs-striker03(config-if-vlan300)#interface range gigabitethernet1/0/13-24,gigabitethernet2/0/13-24 rs-striker03(config-if-vlan300)#interface range gigabitethernet1/0/15-24,gigabitethernet2/0/15-24
rs-striker03(config-if)#switchport access vlan 300 rs-striker03(config-if)#switchport access vlan 300
rs-striker03(config-if)#no shutdown rs-striker03(config-if)#no shutdown
rs-striker03(config-if)#exit rs-striker03(config-if)#exit
@ -1240,6 +1254,7 @@ rs-striker03#
# Firmware update # Firmware update
# Copy .stk file to striker's /var/lib/tftpboot/ directory
console#copy tftp://10.201.4.1/N2200v6.6.3.10.stk backup console#copy tftp://10.201.4.1/N2200v6.6.3.10.stk backup
==== ====

@ -108,19 +108,19 @@ sub clear_old_variables
# Read in all interfaces and for each, delete historical records over the age-out time. # Read in all interfaces and for each, delete historical records over the age-out time.
my $age = $anvil->data->{scancore}{database}{age_out}; my $age = $anvil->data->{scancore}{database}{age_out};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { age => $age }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { age => $age }});
if ($age =~ /\D/) if ($age =~ /\D/)
{ {
# Age is not valid, set it to defaults. # Age is not valid, set it to defaults.
$age = 24; $age = 24;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { age => $age }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { age => $age }});
} }
# Get the timestamp to delete thermal and power records older than $age hours. # Get the timestamp to delete thermal and power records older than $age hours.
my $query = "SELECT now() - '".$age."h'::interval;"; my $query = "SELECT now() - '".$age."h'::interval;";
my $old_timestamp = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0]; my $old_timestamp = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
query => $query, query => $query,
old_timestamp => $old_timestamp, old_timestamp => $old_timestamp,
}}); }});
@ -128,7 +128,7 @@ sub clear_old_variables
# Read in all interface RX and TX variables. # Read in all interface RX and TX variables.
foreach my $uuid (keys %{$anvil->data->{cache}{database_handle}}) foreach my $uuid (keys %{$anvil->data->{cache}{database_handle}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
uuid => $uuid, uuid => $uuid,
db_host => $anvil->Get->host_name_from_uuid({host_uuid => $uuid}), db_host => $anvil->Get->host_name_from_uuid({host_uuid => $uuid}),
}}); }});
@ -146,7 +146,7 @@ OR
;"; ;";
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results}; my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results, results => $results,
count => $count, count => $count,
}}); }});
@ -154,18 +154,18 @@ OR
{ {
my $variable_uuid = $row->[0]; my $variable_uuid = $row->[0];
my $variable_name = $row->[1]; my $variable_name = $row->[1];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:variable_name' => $variable_name, 's1:variable_name' => $variable_name,
's2:variable_uuid' => $variable_uuid, 's2:variable_uuid' => $variable_uuid,
}}); }});
# Find out of there are any records to remove at all. # Find out of there are any records to remove at all.
my $query = "SELECT history_id FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid)." AND modified_date <= '".$old_timestamp."';"; my $query = "SELECT history_id FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid)." AND modified_date <= '".$old_timestamp."';";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
my $results = $anvil->Database->query({uuid => $uuid, query => $query, source => $THIS_FILE, line => __LINE__}); my $results = $anvil->Database->query({uuid => $uuid, query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results}; my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results, results => $results,
count => $count, count => $count,
}}); }});
@ -174,11 +174,11 @@ OR
{ {
# Find how many records will be left. If it's 0, we'll use an OFFSET 1. # Find how many records will be left. If it's 0, we'll use an OFFSET 1.
my $query = "SELECT history_id FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid)." AND modified_date > '".$old_timestamp."';"; my $query = "SELECT history_id FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid)." AND modified_date > '".$old_timestamp."';";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
my $results = $anvil->Database->query({uuid => $uuid, query => $query, source => $THIS_FILE, line => __LINE__}); my $results = $anvil->Database->query({uuid => $uuid, query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results}; my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results, results => $results,
count => $count, count => $count,
}}); }});
@ -186,7 +186,7 @@ OR
{ {
# At least one record will be left, we can do a simple delete. # At least one record will be left, we can do a simple delete.
my $query = "DELETE FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid)." AND modified_date <= '".$old_timestamp."';"; my $query = "DELETE FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid)." AND modified_date <= '".$old_timestamp."';";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
push @{$queries}, $query; push @{$queries}, $query;
} }
else else
@ -195,10 +195,10 @@ OR
foreach my $row (@{$results}) foreach my $row (@{$results})
{ {
my $history_id = $row->[0]; my $history_id = $row->[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { history_id => $history_id }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { history_id => $history_id }});
my $query = "DELETE FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid)." AND history_id = '".$history_id."';"; my $query = "DELETE FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid)." AND history_id = '".$history_id."';";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
push @{$queries}, $query; push @{$queries}, $query;
} }
} }
@ -206,7 +206,7 @@ OR
} }
my $commits = @{$queries}; my $commits = @{$queries};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { commits => $commits }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { commits => $commits }});
if ($commits) if ($commits)
{ {
# Commit the DELETEs. # Commit the DELETEs.
@ -3313,7 +3313,18 @@ AND
### TODO: Don't set / clear interfaces that appear down but aren't named ifn/bcn/sn as they're probably unconfigured/unusued interfaces. ### TODO: Don't set / clear interfaces that appear down but aren't named ifn/bcn/sn as they're probably unconfigured/unusued interfaces.
my $problem = 0; my $problem = 0;
if ((not $new_link_state) or ($new_operational eq "down") or ($new_duplex ne "full")) my $check = 0;
if (($network_interface_name =~ /ifn/i) or
($network_interface_name =~ /sn/i) or
($network_interface_name =~ /bcn/i) or
($network_interface_name =~ /mn/i))
{
# One we monitor
$check = 1;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { check => $check }});
if (($check) && ((not $new_link_state) or ($new_operational eq "down") or ($new_duplex ne "full")))
{ {
$problem = 1; $problem = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }});

Loading…
Cancel
Save