aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms-public.gathering.org/api/public
diff options
context:
space:
mode:
Diffstat (limited to 'web/nms-public.gathering.org/api/public')
-rwxr-xr-xweb/nms-public.gathering.org/api/public/dhcp20
-rwxr-xr-xweb/nms-public.gathering.org/api/public/switch-state8
-rwxr-xr-xweb/nms-public.gathering.org/api/public/switches2
3 files changed, 27 insertions, 3 deletions
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()) {