From 727e4ab31aa6d1a754711d4cd29dbcefae2e952a Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 21 Mar 2016 20:11:55 +0100 Subject: NMS: NMS Public --- .../api/public/dhcp-summary | 21 ++++++++++ web/nms-public.gathering.org/api/public/ping | 37 +++++++++++++++++ .../api/public/switch-state | 47 ++++++++++++++++++++++ web/nms-public.gathering.org/api/public/switches | 35 ++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100755 web/nms-public.gathering.org/api/public/dhcp-summary create mode 100755 web/nms-public.gathering.org/api/public/ping create mode 100755 web/nms-public.gathering.org/api/public/switch-state create mode 100755 web/nms-public.gathering.org/api/public/switches (limited to 'web/nms-public.gathering.org/api/public') diff --git a/web/nms-public.gathering.org/api/public/dhcp-summary b/web/nms-public.gathering.org/api/public/dhcp-summary new file mode 100755 index 0000000..dd643b2 --- /dev/null +++ b/web/nms-public.gathering.org/api/public/dhcp-summary @@ -0,0 +1,21 @@ +#! /usr/bin/perl +use lib '../../../../include'; +use strict; +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::cc{'max-age'} = "10"; +$nms::web::cc{'stale-while-revalidate'} = "15"; +finalize_output(); diff --git a/web/nms-public.gathering.org/api/public/ping b/web/nms-public.gathering.org/api/public/ping new file mode 100755 index 0000000..ba572af --- /dev/null +++ b/web/nms-public.gathering.org/api/public/ping @@ -0,0 +1,37 @@ +#! /usr/bin/perl +use lib '../../../../include'; +use strict; +use warnings; +use nms::web; + +#nms::web::setwhen('1s'); + +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)"); + +$q->execute(); +while (my $ref = $q->fetchrow_hashref()) { + $nms::web::json{'switches'}{$ref->{'sysname'}}{'latency'} = $ref->{'latency_ms'}; + # Get seconds, without decimlas, from timestamp. + # '00:01:01.435601' => 61 seconds. + my ( $h, $m, $s ) = split( ':|\.', $ref->{'age'} ); + $nms::web::json{'switches'}{$ref->{'sysname'}}{'age'} = ($h*60*60) + ($m*60) + $s; # $$ref->{'age'}; +} + +my $qs = $nms::web::dbh->prepare("SELECT DISTINCT ON (switch) switch, latency_ms FROM ping_secondary_ip WHERE " + . $nms::web::when . " ORDER BY switch, time DESC;"); +$qs->execute(); +while ( my $ref = $qs->fetchrow_hashref() ) { + $nms::web::json{'switches'}{$ref->{'switch'}}{'latency_secondary'} = $ref->{'latency_ms'}; +} + +my $lq = $nms::web::dbh->prepare("SELECT DISTINCT ON (linknet) linknet, latency1_ms, latency2_ms FROM linknet_ping WHERE " + . $nms::web::when . " ORDER BY linknet, time DESC;"); +$lq->execute(); +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"; +finalize_output(); diff --git a/web/nms-public.gathering.org/api/public/switch-state b/web/nms-public.gathering.org/api/public/switch-state new file mode 100755 index 0000000..6f7573c --- /dev/null +++ b/web/nms-public.gathering.org/api/public/switch-state @@ -0,0 +1,47 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +use lib '../../../../include'; +use nms::web qw (%json finalize_output); +use strict; +use warnings; +use Data::Dumper; + +my $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);'); + +$q->execute(); +while ( my $ref = $q->fetchrow_hashref() ) { + my $sysname = $ref->{'sysname'}; + + my %data = %{JSON::XS::decode_json($ref->{'data'})}; + + for my $porti (keys %{$data{'ports'}}) { + my %port = %{$data{'ports'}{$porti}}; + my $smallport = $porti; + $smallport =~ s/[0-9-].*$//; + if ($porti =~ /ge-0\/0\/4[4-7]/) { + $json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + if ($port{'ifOperStatus'} eq "up") { + $json{'switches'}{$sysname}{'uplinks'}{'live'} += 1; + } + $json{'switches'}{$sysname}{'uplinks'}{'total'} += 1; + } + + $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + $json{'switches'}{$sysname}{totals}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'switches'}{$sysname}{totals}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + if ($port{'ifOperStatus'} eq "up") { + $json{'switches'}{$sysname}{ifs}{$smallport}{'live'} += 1; + $json{'switches'}{$sysname}{totals}{'live'} += 1; + } + $json{'switches'}{$sysname}{totals}{'total'} += 1; + } + $json{'switches'}{$sysname}{'time'} = $ref->{'time'}; +} + +$nms::web::cc{'max-age'} = "5"; +$nms::web::cc{'stale-while-revalidate'} = "30"; +finalize_output(); diff --git a/web/nms-public.gathering.org/api/public/switches b/web/nms-public.gathering.org/api/public/switches new file mode 100755 index 0000000..7e7f10b --- /dev/null +++ b/web/nms-public.gathering.org/api/public/switches @@ -0,0 +1,35 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +use CGI qw(fatalsToBrowser); +use DBI; +use lib '../../../../include'; +use nms; +use nms::web; +use strict; +use warnings; +use Data::Dumper; + +$nms::web::cc{'max-age'} = "60"; + +my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,ip,poll_frequency,community,last_updated from switches where placement is not null'); + +$q2->execute(); +while (my $ref = $q2->fetchrow_hashref()) { + $ref->{'placement'} =~ /\((-?\d+),(-?\d+)\),\((-?\d+),(-?\d+)\)/; + my ($x1, $y1, $x2, $y2) = ($1, $2, $3, $4); + my $sysname = $ref->{'sysname'}; + $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'x'} = $x2; + $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'y'} = $y2; + $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'width'} = $x1 - $x2; + $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'height'} = $y1 - $y2; +} + +my $q4 = $nms::web::dbh->prepare('select linknet, (select sysname from switches where switch = switch1) as sysname1, (select sysname from switches where switch = switch2) as sysname2 from linknets'); + +$q4->execute(); +while (my $ref = $q4->fetchrow_hashref()) { + $nms::web::json{'linknets'}{$ref->{'linknet'}} = $ref; +} + +finalize_output(); -- cgit v1.2.3 From 05fedaa7461c6fd67c402671f0e129b3d1772fbf Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Tue, 22 Mar 2016 19:53:30 +0100 Subject: NMS: Tweak NMS public API and draw linknets --- web/nms-public.gathering.org/api/public/dhcp | 20 ++++++++++++++++++++ web/nms-public.gathering.org/api/public/switch-state | 8 ++++++-- web/nms-public.gathering.org/api/public/switches | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100755 web/nms-public.gathering.org/api/public/dhcp (limited to 'web/nms-public.gathering.org/api/public') diff --git a/web/nms-public.gathering.org/api/public/dhcp b/web/nms-public.gathering.org/api/public/dhcp new file mode 100755 index 0000000..91d52af --- /dev/null +++ b/web/nms-public.gathering.org/api/public/dhcp @@ -0,0 +1,20 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +use lib '../../../../include'; +use nms::web qw (%json finalize_output); +use strict; +use warnings; +use Data::Dumper; + +nms::web::setwhen('60m'); +my $q = $nms::web::dbh->prepare('select distinct on (sysname) extract(epoch from date_trunc(\'second\',time)) as time,sysname from dhcp join switches on dhcp.switch = switches.switch where ' . $nms::web::when . ' order by sysname,time desc;'); +$q->execute(); +while ( my $ref = $q->fetchrow_hashref() ) { + my $sysname = $ref->{'sysname'}; + $json{'dhcp'}{$ref->{'sysname'}} = $ref->{'time'}; +} + +$nms::web::cc{'max-age'} = "5"; +$nms::web::cc{'stale-while-revalidate'} = "30"; +finalize_output(); diff --git a/web/nms-public.gathering.org/api/public/switch-state b/web/nms-public.gathering.org/api/public/switch-state index 6f7573c..7fa6ff5 100755 --- a/web/nms-public.gathering.org/api/public/switch-state +++ b/web/nms-public.gathering.org/api/public/switch-state @@ -19,8 +19,12 @@ while ( my $ref = $q->fetchrow_hashref() ) { for my $porti (keys %{$data{'ports'}}) { my %port = %{$data{'ports'}{$porti}}; my $smallport = $porti; - $smallport =~ s/[0-9-].*$//; - if ($porti =~ /ge-0\/0\/4[4-7]/) { + if (not $smallport =~ m/^ae/) { + $smallport =~ s/[0-9-].*$//; + } else { + $json{'switches'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'}; + } + if ($porti =~ /ge-0\/0\/4[4-7]$/) { $json{'switches'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; $json{'switches'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; if ($port{'ifOperStatus'} eq "up") { diff --git a/web/nms-public.gathering.org/api/public/switches b/web/nms-public.gathering.org/api/public/switches index 7e7f10b..3aa8af8 100755 --- a/web/nms-public.gathering.org/api/public/switches +++ b/web/nms-public.gathering.org/api/public/switches @@ -12,7 +12,7 @@ use Data::Dumper; $nms::web::cc{'max-age'} = "60"; -my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,ip,poll_frequency,community,last_updated from switches where placement is not null'); +my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,mgmt_v4_addr,mgmt_v6_addr,mgmt_v4_gw,mgmt_v4_netsize,mgmt_v6_gw,mgmt_v6_netsize,mgmt_vlan,traffic_vlan,last_config_fetch,current_mac,poll_frequency,community,last_updated,switchtype from switches where placement is not null'); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { -- cgit v1.2.3 From 20c3bd1289c518768eb66a8245ac616ee3c43a07 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Wed, 23 Mar 2016 00:57:35 +0100 Subject: NMS: Update public API too! --- .../api/public/switch-state | 39 ++++++++++++++++++++++ web/nms-public.gathering.org/api/public/switches | 3 +- 2 files changed, 41 insertions(+), 1 deletion(-) (limited to 'web/nms-public.gathering.org/api/public') diff --git a/web/nms-public.gathering.org/api/public/switch-state b/web/nms-public.gathering.org/api/public/switch-state index 7fa6ff5..32cf9a6 100755 --- a/web/nms-public.gathering.org/api/public/switch-state +++ b/web/nms-public.gathering.org/api/public/switch-state @@ -46,6 +46,45 @@ while ( my $ref = $q->fetchrow_hashref() ) { $json{'switches'}{$sysname}{'time'} = $ref->{'time'}; } +nms::web::setwhen('15m','10m'); +my $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);'); + +$q2->execute(); +while ( my $ref = $q2->fetchrow_hashref() ) { + my $sysname = $ref->{'sysname'}; + + my %data = %{JSON::XS::decode_json($ref->{'data'})}; + + for my $porti (keys %{$data{'ports'}}) { + my %port = %{$data{'ports'}{$porti}}; + my $smallport = $porti; + if (not $smallport =~ m/^ae/) { + $smallport =~ s/[0-9-].*$//; + } else { + $json{'then'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'}; + } + if ($porti =~ /ge-0\/0\/4[4-7]$/) { + $json{'then'}{$sysname}{'uplinks'}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'then'}{$sysname}{'uplinks'}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + if ($port{'ifOperStatus'} eq "up") { + $json{'then'}{$sysname}{'uplinks'}{'live'} += 1; + } + $json{'then'}{$sysname}{'uplinks'}{'total'} += 1; + } + + $json{'then'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'then'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + $json{'then'}{$sysname}{totals}{'ifHCInOctets'} += $port{'ifHCInOctets'}; + $json{'then'}{$sysname}{totals}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; + if ($port{'ifOperStatus'} eq "up") { + $json{'then'}{$sysname}{ifs}{$smallport}{'live'} += 1; + $json{'then'}{$sysname}{totals}{'live'} += 1; + } + $json{'then'}{$sysname}{totals}{'total'} += 1; + } + $json{'then'}{$sysname}{'time'} = $ref->{'time'}; +} $nms::web::cc{'max-age'} = "5"; $nms::web::cc{'stale-while-revalidate'} = "30"; finalize_output(); diff --git a/web/nms-public.gathering.org/api/public/switches b/web/nms-public.gathering.org/api/public/switches index 3aa8af8..890b7d7 100755 --- a/web/nms-public.gathering.org/api/public/switches +++ b/web/nms-public.gathering.org/api/public/switches @@ -12,7 +12,7 @@ use Data::Dumper; $nms::web::cc{'max-age'} = "60"; -my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,mgmt_v4_addr,mgmt_v6_addr,mgmt_v4_gw,mgmt_v4_netsize,mgmt_v6_gw,mgmt_v6_netsize,mgmt_vlan,traffic_vlan,last_config_fetch,current_mac,poll_frequency,community,last_updated,switchtype from switches where placement is not null'); +my $q2 = $nms::web::dbh->prepare('select switch,sysname,distro_name,placement,mgmt_v4_addr,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,last_config_fetch,current_mac,poll_frequency,community,last_updated,switchtype from switches where placement is not null'); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { @@ -23,6 +23,7 @@ while (my $ref = $q2->fetchrow_hashref()) { $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'y'} = $y2; $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'width'} = $x1 - $x2; $nms::web::json{'switches'}{$ref->{'sysname'}}{'placement'}{'height'} = $y1 - $y2; + $nms::web::json{'switches'}{$ref->{'sysname'}}{'distro_name'} = $ref->{'distro_name'}; } my $q4 = $nms::web::dbh->prepare('select linknet, (select sysname from switches where switch = switch1) as sysname1, (select sysname from switches where switch = switch2) as sysname2 from linknets'); -- cgit v1.2.3 From 904196acc73603ab48b7f4d5a8ba276f00d64222 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Wed, 23 Mar 2016 17:52:31 +0100 Subject: NMS: Public temp map --- web/nms-public.gathering.org/api/public/switch-state | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'web/nms-public.gathering.org/api/public') diff --git a/web/nms-public.gathering.org/api/public/switch-state b/web/nms-public.gathering.org/api/public/switch-state index 32cf9a6..2a2b5b6 100755 --- a/web/nms-public.gathering.org/api/public/switch-state +++ b/web/nms-public.gathering.org/api/public/switch-state @@ -32,7 +32,6 @@ while ( my $ref = $q->fetchrow_hashref() ) { } $json{'switches'}{$sysname}{'uplinks'}{'total'} += 1; } - $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCInOctets'} += $port{'ifHCInOctets'}; $json{'switches'}{$sysname}{ifs}{$smallport}{'ifHCOutOctets'} += $port{'ifHCOutOctets'}; $json{'switches'}{$sysname}{totals}{'ifHCInOctets'} += $port{'ifHCInOctets'}; @@ -43,6 +42,7 @@ while ( my $ref = $q->fetchrow_hashref() ) { } $json{'switches'}{$sysname}{totals}{'total'} += 1; } + $json{'switches'}{$sysname}{'temp'} = $data{'misc'}{'enterprises.2636.3.1.13.1.7.7.1.0.0'}{''}; $json{'switches'}{$sysname}{'time'} = $ref->{'time'}; } @@ -83,6 +83,7 @@ while ( my $ref = $q2->fetchrow_hashref() ) { } $json{'then'}{$sysname}{totals}{'total'} += 1; } + $json{'then'}{$sysname}{'temp'} = $data{'misc'}{'enterprises.2636.3.1.13.1.7.7.1.0.0'}{''}; $json{'then'}{$sysname}{'time'} = $ref->{'time'}; } $nms::web::cc{'max-age'} = "5"; -- cgit v1.2.3 From 2f08210fde3f168facc06327ec05a20467f4fe1b Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 24 Mar 2016 00:44:56 +0100 Subject: NMS: Update public API for temperature --- web/nms-public.gathering.org/api/public/switch-state | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/nms-public.gathering.org/api/public') diff --git a/web/nms-public.gathering.org/api/public/switch-state b/web/nms-public.gathering.org/api/public/switch-state index 2a2b5b6..2fff681 100755 --- a/web/nms-public.gathering.org/api/public/switch-state +++ b/web/nms-public.gathering.org/api/public/switch-state @@ -42,7 +42,7 @@ while ( my $ref = $q->fetchrow_hashref() ) { } $json{'switches'}{$sysname}{totals}{'total'} += 1; } - $json{'switches'}{$sysname}{'temp'} = $data{'misc'}{'enterprises.2636.3.1.13.1.7.7.1.0.0'}{''}; + $json{'switches'}{$sysname}{'temp'} = $data{'misc'}{'jnxOperatingTemp'}{'7.1.0.0'}; $json{'switches'}{$sysname}{'time'} = $ref->{'time'}; } -- cgit v1.2.3 From 7c6589dd177deaba473fdde3fd48c283f5e369bc Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 24 Mar 2016 21:12:08 +0100 Subject: NMS: Expose ET-interfaces and more --- web/nms-public.gathering.org/api/public/switch-state | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/nms-public.gathering.org/api/public') diff --git a/web/nms-public.gathering.org/api/public/switch-state b/web/nms-public.gathering.org/api/public/switch-state index 2fff681..62e497c 100755 --- a/web/nms-public.gathering.org/api/public/switch-state +++ b/web/nms-public.gathering.org/api/public/switch-state @@ -19,7 +19,7 @@ while ( my $ref = $q->fetchrow_hashref() ) { for my $porti (keys %{$data{'ports'}}) { my %port = %{$data{'ports'}{$porti}}; my $smallport = $porti; - if (not $smallport =~ m/^ae/) { + if (not $smallport =~ m/^ae/ and not $smallport =~ m/^et/) { $smallport =~ s/[0-9-].*$//; } else { $json{'switches'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'}; -- cgit v1.2.3 From 7ac4551ed94c1f1393bc69e595a90dbe15bc8f6c Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 24 Mar 2016 21:15:50 +0100 Subject: NMS: Update public api --- web/nms-public.gathering.org/api/public/switch-state | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/nms-public.gathering.org/api/public') diff --git a/web/nms-public.gathering.org/api/public/switch-state b/web/nms-public.gathering.org/api/public/switch-state index 62e497c..0e28cfd 100755 --- a/web/nms-public.gathering.org/api/public/switch-state +++ b/web/nms-public.gathering.org/api/public/switch-state @@ -59,7 +59,7 @@ while ( my $ref = $q2->fetchrow_hashref() ) { for my $porti (keys %{$data{'ports'}}) { my %port = %{$data{'ports'}{$porti}}; my $smallport = $porti; - if (not $smallport =~ m/^ae/) { + if (not $smallport =~ m/^ae/ and not $smallport =~ m/^et/) { $smallport =~ s/[0-9-].*$//; } else { $json{'then'}{$sysname}{ifs}{$smallport}{'ifAlias'} = $port{'ifAlias'}; -- cgit v1.2.3 From 004f4efcfd0779f4307b90fed139dc87d01ad0b9 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 26 Mar 2016 03:48:12 +0100 Subject: NMS: Various performance tweaks --- web/nms-public.gathering.org/api/public/dhcp-summary | 7 +------ web/nms-public.gathering.org/api/public/ping | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'web/nms-public.gathering.org/api/public') 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(); -- cgit v1.2.3