diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2015-04-14 16:53:41 +0200 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2015-04-14 16:53:41 +0200 |
commit | 7337ac7e744e978ae93a9cd28a08fea728627287 (patch) | |
tree | ce6872884feec738eef5862df0f7135e4277eaf9 | |
parent | e082f5ddb4735ec783a499b6b0066c3459e14618 (diff) |
NMS: ooops. Re-fix SQL that I broke to fix
-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(); |