diff options
-rwxr-xr-x | web/nms.gathering.org/ping-json2.pl | 2 | ||||
-rwxr-xr-x | web/nms.gathering.org/port-state.pl | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/web/nms.gathering.org/ping-json2.pl b/web/nms.gathering.org/ping-json2.pl index e2b29ae..e46140a 100755 --- a/web/nms.gathering.org/ping-json2.pl +++ b/web/nms.gathering.org/ping-json2.pl @@ -16,7 +16,7 @@ my $when =" updated > " . $now . " - '15 secs'::interval and updated < " . $now my %json = (); -my $q = $dbh->prepare("SELECT DISTINCT updated,switch,sysname, latency_ms FROM ping NATURAL JOIN switches WHERE $when ORDER BY updated DESC;"); +my $q = $dbh->prepare("SELECT DISTINCT ON (updated, sysname) updated,sysname, latency_ms FROM ping NATURAL JOIN switches WHERE $when ORDER BY updated DESC;"); $q->execute(); while (my $ref = $q->fetchrow_hashref()) { $json{'switches'}{$ref->{'sysname'}}{'latency'} = $ref->{'latency_ms'}; diff --git a/web/nms.gathering.org/port-state.pl b/web/nms.gathering.org/port-state.pl index 9cc186f..76dd7d8 100755 --- a/web/nms.gathering.org/port-state.pl +++ b/web/nms.gathering.org/port-state.pl @@ -24,7 +24,7 @@ if (defined($cin)) { $when = " time < " . $now . " - '$cin'::interval and time > ". $now . " - ('$cin'::interval + '15m'::interval) "; } -my $query = 'select distinct extract(epoch from date_trunc(\'second\',time)) as time,ifname,ifhighspeed,ifhcinoctets,ifhcoutoctets,sysname from polls natural join switches where ' . $when . ' order by time desc'; +my $query = 'select sysname,extract(epoch from date_trunc(\'second\',time)) as time, ifname,ifhighspeed,ifhcinoctets,ifhcoutoctets from polls natural join switches where time in (select max(time) from polls where ' . $when . ' group by switch,ifname);'; my $q = $dbh->prepare($query); $q->execute(); |