From 38b48dd77b57b116f633b1cf5d68cc70a44b1ea8 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 31 Mar 2018 22:28:26 +0200 Subject: Throw TG18-stuff over the wall --- web/api/public/ping | 4 ++-- web/api/public/switch-state | 12 ++++++------ web/api/read/switches-management | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'web/api') diff --git a/web/api/public/ping b/web/api/public/ping index 1928368..be37875 100755 --- a/web/api/public/ping +++ b/web/api/public/ping @@ -4,7 +4,7 @@ use strict; use warnings; use nms::web; -nms::web::setwhen('15s'); +nms::web::setwhen('25s'); my $q = $nms::web::dbh->prepare("SELECT DISTINCT ON (sysname) (" . $nms::web::now . " - time) as age,sysname, latency_ms FROM ping NATURAL JOIN switches WHERE time in (select max(time) from ping where " . $nms::web::when . " group by switch)"); @@ -37,5 +37,5 @@ while ( my $ref = $lq->fetchrow_hashref() ) { } $nms::web::cc{'max-age'} = "1"; -$nms::web::cc{'stale-while-revalidate'} = "15"; +$nms::web::cc{'stale-while-revalidate'} = "5"; finalize_output(); diff --git a/web/api/public/switch-state b/web/api/public/switch-state index 19bd771..919924e 100755 --- a/web/api/public/switch-state +++ b/web/api/public/switch-state @@ -14,9 +14,9 @@ my ($switch, $port) = split(/\//,$target,2); my $q; if (!defined($switch)) { - $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . ' and switches.deleted = false group by switch) and switches.deleted = false and not switches.tags \?& array[\'switchstateignore\'];'); + $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . ' group by switch) and switches.deleted = \'f\' and not switches.tags \?& array[\'ignoreswitchstate\'];'); } else { - $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch) and sysname = ' . $nms::web::dbh->quote($switch) . ' and switches.deleted = false and not switches.tags \?& array[\'switchstateignore\'];'); + $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch) and sysname = ' . $nms::web::dbh->quote($switch) . ';'); } $q->execute(); @@ -42,7 +42,7 @@ while ( my $ref = $q->fetchrow_hashref() ) { $json{'switches'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'}; } if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and - $data{'ports'}{$porti}{'ifAlias'} =~ m/LAG member/i) { + $data{'ports'}{$porti}{'ifAlias'} =~ m/Fysisk/i) { if ($port{'ifAdminStatus'} eq "up") { $json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; $json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; @@ -83,9 +83,9 @@ while ( my $ref = $q->fetchrow_hashref() ) { nms::web::setwhen('15m','10m'); my $q2; if (!defined($switch)) { - $q2 = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . ' and switches.deleted = false group by switch) and switches.deleted = false and not switches.tags \?& array[\'switchstateignore\'];'); + $q2 = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . ' group by switch) and switches.deleted = \'f\' and not switches.tags \?& array[\'ignoreswitchstate\'];'); } else { - $q2 = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch) and sysname = ' . $nms::web::dbh->quote($switch) . ' and switches.deleted = false and not switches.tags \?& array[\'switchstateignore\'];'); + $q2 = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch) and switches.deleted = \'f\' and not switches.tags \?& array[\'ignoreswitchstate\'] and sysname = ' . $nms::web::dbh->quote($switch) . ';'); } $q2->execute(); @@ -109,7 +109,7 @@ while ( my $ref = $q2->fetchrow_hashref() ) { $json{'then'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'}; } if ($data{'ports'}{$porti}{'ifType'} ne "propVirtual" and - $data{'ports'}{$porti}{'ifAlias'} =~ m/LAG member/i) { + $data{'ports'}{$porti}{'ifAlias'} =~ m/Fysisk/i) { if ($port{'ifAdminStatus'} eq "up") { $json{'then'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; $json{'then'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; diff --git a/web/api/read/switches-management b/web/api/read/switches-management index 77badf4..c734eef 100755 --- a/web/api/read/switches-management +++ b/web/api/read/switches-management @@ -20,7 +20,7 @@ $nms::web::cc{'max-age'} = "5"; $nms::web::cc{'stale-while-revalidate'} = "30"; if (!defined($switch)) { - $q2 = $nms::web::dbh->prepare('select switches.sysname, host(switches.mgmt_v4_addr) as mgmt_v4_addr, host(switches.mgmt_v6_addr) as mgmt_v6_addr, switches.mgmt_vlan, switches.traffic_vlan, switches.poll_frequency, switches.last_updated, switches.distro_name, switches.distro_phy_port, switches.community, traffic_net.subnet4, traffic_net.subnet6, mgmt_net.gw4 as mgmt_v4_gw, mgmt_net.gw6 as mgmt_v6_gw from switches left join networks as traffic_net on (switches.traffic_vlan = traffic_net.name) left join networks as mgmt_net on (switches.mgmt_vlan = mgmt_net.name) where switches.placement is not null and switches.deleted = false;'); + $q2 = $nms::web::dbh->prepare('select switches.sysname, host(switches.mgmt_v4_addr) as mgmt_v4_addr, host(switches.mgmt_v6_addr) as mgmt_v6_addr, switches.mgmt_vlan, switches.traffic_vlan, switches.poll_frequency, switches.last_updated, switches.distro_name, switches.distro_phy_port, switches.community, traffic_net.subnet4, traffic_net.subnet6, host(mgmt_net.gw4) as mgmt_v4_gw, host(mgmt_net.gw6) as mgmt_v6_gw from switches left join networks as traffic_net on (switches.traffic_vlan = traffic_net.name) left join networks as mgmt_net on (switches.mgmt_vlan = mgmt_net.name) where switches.placement is not null and switches.deleted = false;'); } else { $q2 = $nms::web::dbh->prepare('select sysname,host(mgmt_v4_addr) as mgmt_v4_addr,host(mgmt_v6_addr) as mgmt_v6_addr,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null and sysname = ' . $nms::web::dbh->quote($switch) . ' and switches.deleted = false;'); } -- cgit v1.2.3