diff options
-rwxr-xr-x | clients/ping.pl | 2 | ||||
-rwxr-xr-x | clients/snmpfetchng.pl | 2 | ||||
-rwxr-xr-x | include/nms/web.pm | 4 | ||||
-rwxr-xr-x | web/nms-public.gathering.org/api/public/dhcp-summary | 7 | ||||
-rwxr-xr-x | web/nms-public.gathering.org/api/public/ping | 6 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/public/dhcp | 2 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/public/dhcp-summary | 7 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/public/ping | 6 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/public/switch-state | 6 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-info-box.js | 10 |
10 files changed, 27 insertions, 25 deletions
diff --git a/clients/ping.pl b/clients/ping.pl index 1ad7b95..d945917 100755 --- a/clients/ping.pl +++ b/clients/ping.pl @@ -16,7 +16,7 @@ $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; my $q = $dbh->prepare("SELECT switch,host(mgmt_v4_addr) as ip,host(mgmt_v6_addr) as secondary_ip FROM switches WHERE mgmt_v4_addr is not null ORDER BY random()"); -my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets"); +my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets WHERE addr1 is not null and addr2 is not null"); while (1) { # ping loopbacks diff --git a/clients/snmpfetchng.pl b/clients/snmpfetchng.pl index bbdb00d..2f5e785 100755 --- a/clients/snmpfetchng.pl +++ b/clients/snmpfetchng.pl @@ -10,9 +10,9 @@ use lib '../include'; use nms; SNMP::initMib(); -SNMP::addMibDirs("/srv/tgmanage/mibs"); SNMP::addMibDirs("/srv/tgmanage/mibs/StandardMibs"); SNMP::addMibDirs("/srv/tgmanage/mibs/JuniperMibs"); +SNMP::addMibDirs("/srv/tgmanage/mibs"); SNMP::loadModules('ALL'); our $dbh = nms::db_connect(); diff --git a/include/nms/web.pm b/include/nms/web.pm index c9f7236..889e774 100755 --- a/include/nms/web.pm +++ b/include/nms/web.pm @@ -57,7 +57,7 @@ sub db_safe_quote { # endpoints it is better to return no data than old data (e.g.: ping). sub setwhen { $now = "now()"; - my $window = '15m'; + my $window = '8m'; my $offset = '0s'; if (@_ > 0) { $window = $_[0]; @@ -86,6 +86,8 @@ sub finalize_output { printcc; print "Etag: $hash\n"; + print "Access-Control-Allow-Origin: *\n"; + print "Access-Control-Allow-Methods: HEAD, GET\n"; print "Content-Type: text/json; charset=utf-8\n\n"; print JSON::XS::encode_json(\%json); print "\n"; diff --git a/web/nms-public.gathering.org/api/public/dhcp-summary b/web/nms-public.gathering.org/api/public/dhcp-summary index dd643b2..a0e5609 100755 --- a/web/nms-public.gathering.org/api/public/dhcp-summary +++ b/web/nms-public.gathering.org/api/public/dhcp-summary @@ -5,16 +5,11 @@ use warnings; use nms::web; nms::web::setwhen('2h'); -my $q = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp;"); -$q->execute(); -while (my $ref = $q->fetchrow_hashref()) { - $nms::web::json{'dhcp'}{'total'} = $ref; -} my $q2 = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp where $nms::web::when;"); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { - $nms::web::json{'dhcp'}{'recent'} = $ref; + $nms::web::json{'dhcp'} = $ref; } $nms::web::cc{'max-age'} = "10"; $nms::web::cc{'stale-while-revalidate'} = "15"; diff --git a/web/nms-public.gathering.org/api/public/ping b/web/nms-public.gathering.org/api/public/ping index ba572af..db46b00 100755 --- a/web/nms-public.gathering.org/api/public/ping +++ b/web/nms-public.gathering.org/api/public/ping @@ -4,7 +4,7 @@ use strict; use warnings; use nms::web; -#nms::web::setwhen('1s'); +nms::web::setwhen('10s'); my $q = $nms::web::dbh->prepare("SELECT DISTINCT ON (sysname) (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)"); @@ -32,6 +32,6 @@ while ( my $ref = $lq->fetchrow_hashref() ) { $nms::web::json{'linknets'}{$ref->{'linknet'}} = [ $ref->{'latency1_ms'}, $ref->{'latency2_ms'} ]; } -$nms::web::cc{'max-age'} = "1"; -$nms::web::cc{'stale-while-revalidate'} = "5"; +$nms::web::cc{'max-age'} = "2"; +$nms::web::cc{'stale-while-revalidate'} = "15"; finalize_output(); diff --git a/web/nms.gathering.org/api/public/dhcp b/web/nms.gathering.org/api/public/dhcp index 91d52af..7b048d1 100755 --- a/web/nms.gathering.org/api/public/dhcp +++ b/web/nms.gathering.org/api/public/dhcp @@ -15,6 +15,6 @@ while ( my $ref = $q->fetchrow_hashref() ) { $json{'dhcp'}{$ref->{'sysname'}} = $ref->{'time'}; } -$nms::web::cc{'max-age'} = "5"; +$nms::web::cc{'max-age'} = "10"; $nms::web::cc{'stale-while-revalidate'} = "30"; finalize_output(); diff --git a/web/nms.gathering.org/api/public/dhcp-summary b/web/nms.gathering.org/api/public/dhcp-summary index dd643b2..a0e5609 100755 --- a/web/nms.gathering.org/api/public/dhcp-summary +++ b/web/nms.gathering.org/api/public/dhcp-summary @@ -5,16 +5,11 @@ use warnings; use nms::web; nms::web::setwhen('2h'); -my $q = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp;"); -$q->execute(); -while (my $ref = $q->fetchrow_hashref()) { - $nms::web::json{'dhcp'}{'total'} = $ref; -} my $q2 = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp where $nms::web::when;"); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { - $nms::web::json{'dhcp'}{'recent'} = $ref; + $nms::web::json{'dhcp'} = $ref; } $nms::web::cc{'max-age'} = "10"; $nms::web::cc{'stale-while-revalidate'} = "15"; diff --git a/web/nms.gathering.org/api/public/ping b/web/nms.gathering.org/api/public/ping index ba572af..db46b00 100755 --- a/web/nms.gathering.org/api/public/ping +++ b/web/nms.gathering.org/api/public/ping @@ -4,7 +4,7 @@ use strict; use warnings; use nms::web; -#nms::web::setwhen('1s'); +nms::web::setwhen('10s'); my $q = $nms::web::dbh->prepare("SELECT DISTINCT ON (sysname) (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)"); @@ -32,6 +32,6 @@ while ( my $ref = $lq->fetchrow_hashref() ) { $nms::web::json{'linknets'}{$ref->{'linknet'}} = [ $ref->{'latency1_ms'}, $ref->{'latency2_ms'} ]; } -$nms::web::cc{'max-age'} = "1"; -$nms::web::cc{'stale-while-revalidate'} = "5"; +$nms::web::cc{'max-age'} = "2"; +$nms::web::cc{'stale-while-revalidate'} = "15"; finalize_output(); diff --git a/web/nms.gathering.org/api/public/switch-state b/web/nms.gathering.org/api/public/switch-state index 0e28cfd..a6caea9 100755 --- a/web/nms.gathering.org/api/public/switch-state +++ b/web/nms.gathering.org/api/public/switch-state @@ -19,6 +19,9 @@ while ( my $ref = $q->fetchrow_hashref() ) { for my $porti (keys %{$data{'ports'}}) { my %port = %{$data{'ports'}{$porti}}; my $smallport = $porti; + if ($porti =~ m/\.0$/) { + next; + } if (not $smallport =~ m/^ae/ and not $smallport =~ m/^et/) { $smallport =~ s/[0-9-].*$//; } else { @@ -59,6 +62,9 @@ while ( my $ref = $q2->fetchrow_hashref() ) { for my $porti (keys %{$data{'ports'}}) { my %port = %{$data{'ports'}{$porti}}; my $smallport = $porti; + if ($porti =~ m/\.0$/) { + next; + } if (not $smallport =~ m/^ae/ and not $smallport =~ m/^et/) { $smallport =~ s/[0-9-].*$//; } else { diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index 1728d81..03d0838 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -618,6 +618,7 @@ nmsInfoBox._searchSmart = function(id, sw) { return true; } } catch (e) {} + try { if (id.match("active")) { var limit = id; limit = limit.replace("active>",""); @@ -625,21 +626,24 @@ nmsInfoBox._searchSmart = function(id, sw) { limit = limit.replace("active=",""); var operator = id.replace("active","")[0]; if (limit == parseInt(limit)) { + var ports = parseInt(nmsData.switchstate.switches[sw].ifs.ge.live); + limit = parseInt(limit); if (operator == ">" ) { - if (nmsData.switchstate.switches[sw]['totals'].live > limit) { + if (ports > limit) { return true; } } else if (operator == "<") { - if (nmsData.switchstate.switches[sw]['totals'].live < limit) { + if (ports < limit) { return true; } } else if (operator == "=") { - if (nmsData.switchstate.switches[sw]['totals'].live == limit) { + if (ports == limit) { return true; } } } } + } catch (e) {} try { if (nmsData.smanagement.switches[sw].mgmt_v4_addr.match(id)) { return true; |