From 0ad449caf997ec356bfb80e731460d0f7496fd5c Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Wed, 4 Apr 2018 16:36:33 +0200 Subject: Tweak DHCP/uplink/client-port logic --- web/api/public/switch-state | 18 ++++++++++-------- web/api/read/switches-management | 8 +++++++- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'web/api') diff --git a/web/api/public/switch-state b/web/api/public/switch-state index 919924e..528bf7d 100755 --- a/web/api/public/switch-state +++ b/web/api/public/switch-state @@ -7,17 +7,19 @@ use strict; use warnings; use Data::Dumper; -my $target = $ENV{REQUEST_URI}; -$target =~ s/$ENV{SCRIPT_NAME}//; -$target =~ s/^\///; -my ($switch, $port) = split(/\//,$target,2); +#my $target = $ENV{REQUEST_URI}; +#$target =~ s/$ENV{SCRIPT_NAME}//; +#$target =~ s/^\///; +#my ($switch, $port) = split(/\//,$target,2); +my $port; +my $switch; my $q; -if (!defined($switch)) { +#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 . ' 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) . ';'); -} +#} 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) . ';'); +#} $q->execute(); while ( my $ref = $q->fetchrow_hashref() ) { diff --git a/web/api/read/switches-management b/web/api/read/switches-management index c734eef..b42c84b 100755 --- a/web/api/read/switches-management +++ b/web/api/read/switches-management @@ -13,7 +13,13 @@ use Data::Dumper; my $target = $ENV{REQUEST_URI}; $target =~ s/$ENV{SCRIPT_NAME}//; $target =~ s/^\///; -my ($switch, $port) = split(/\//,$target,2); +my $switch; +my $port; + +if ($target !~ m/now=/) { + ($switch, $port) = split(/\//,$target,2); +} + my $q2; $nms::web::cc{'max-age'} = "5"; -- cgit v1.2.3