aboutsummaryrefslogtreecommitdiffstats
path: root/web/api
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2018-04-04 16:36:33 +0200
committerKristian Lyngstol <kly@kly.no>2018-04-04 16:36:33 +0200
commit0ad449caf997ec356bfb80e731460d0f7496fd5c (patch)
tree8ecd0d419ee7805758991986b6f4de7b14677cef /web/api
parent72a89af57f3ac235b9048bd7cd645b580b93d95b (diff)
Tweak DHCP/uplink/client-port logic
Diffstat (limited to 'web/api')
-rwxr-xr-xweb/api/public/switch-state18
-rwxr-xr-xweb/api/read/switches-management8
2 files changed, 17 insertions, 9 deletions
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";