diff options
Diffstat (limited to 'web/api/read')
-rwxr-xr-x | web/api/read/distro-management | 31 | ||||
-rwxr-xr-x | web/api/read/distro-tree | 25 | ||||
-rwxr-xr-x | web/api/read/oplog | 4 | ||||
-rwxr-xr-x | web/api/read/switches-management | 4 |
4 files changed, 37 insertions, 27 deletions
diff --git a/web/api/read/distro-management b/web/api/read/distro-management new file mode 100755 index 0000000..2aa3273 --- /dev/null +++ b/web/api/read/distro-management @@ -0,0 +1,31 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +use CGI qw(fatalsToBrowser); +use DBI; +use lib '/opt/gondul/include'; +use nms; +use nms::web; +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 $q2; + +$nms::web::cc{'max-age'} = "5"; +$nms::web::cc{'stale-while-revalidate'} = "30"; + +$q2 = $nms::web::dbh->prepare('SELECT distro_name,sysname,subnet4,subnet6,traffic_vlan,distro_phy_port FROM switches WHERE placement is not null AND distro_name is not null AND distro_phy_port is not null'); + +$q2->execute(); +while (my $ref = $q2->fetchrow_hashref()) { + my $sysname = $ref->{'sysname'}; + my $distro = $ref->{'distro_name'}; + $nms::web::json{'distros'}{$distro}{$sysname} = $ref; +} + +finalize_output(); diff --git a/web/api/read/distro-tree b/web/api/read/distro-tree deleted file mode 100755 index 5d93e1b..0000000 --- a/web/api/read/distro-tree +++ /dev/null @@ -1,25 +0,0 @@ -#! /usr/bin/perl -# vim:ts=8:sw=8 - -use CGI qw(fatalsToBrowser); -use DBI; -use lib '/opt/gondul/include'; -use nms; -use nms::web; -use strict; -use warnings; -use Data::Dumper; - -$nms::web::cc{'max-age'} = "20"; - -my $q2 = $nms::web::dbh->prepare('select sysname,distro_phy_port,distro_name from switches where placement is not null and distro_name is not null and distro_phy_port is not null'); - -$q2->execute(); -while (my $ref = $q2->fetchrow_hashref()) { - my $sysname = $ref->{'sysname'}; - my $phy = $ref->{'distro_phy_port'}; - my $distro = $ref->{'distro_name'}; - $nms::web::json{'distro-tree'}{$distro}{$phy} = $sysname; -} - -finalize_output(); diff --git a/web/api/read/oplog b/web/api/read/oplog index 92511bb..fb187ea 100755 --- a/web/api/read/oplog +++ b/web/api/read/oplog @@ -16,6 +16,10 @@ while (my $ref = $query->fetchrow_hashref()) { $meh{'id'} = $ref->{'id'}; $meh{'systems'} = $ref->{'systems'}; $meh{'timestamp'} = $ref->{'timestamp'}; + $meh{'timestamp'} =~ s/ /T/; + $meh{'timestamp'} =~ s/\+00$/Z/; + $meh{'timestamp'} =~ s/\+(\d\d)$/+\1:00/; + push @{$nms::web::json{'oplog'}},\%meh; } diff --git a/web/api/read/switches-management b/web/api/read/switches-management index 425262e..9d8bc53 100755 --- a/web/api/read/switches-management +++ b/web/api/read/switches-management @@ -20,9 +20,9 @@ $nms::web::cc{'max-age'} = "5"; $nms::web::cc{'stale-while-revalidate'} = "30"; if (!defined($switch)) { - $q2 = $nms::web::dbh->prepare('select sysname,mgmt_v4_addr,subnet4,subnet6,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null'); + $q2 = $nms::web::dbh->prepare('select sysname,host(mgmt_v4_addr) as mgmt_v4_addr,subnet4,subnet6,host(mgmt_v6_addr) as mgmt_v6_addr,host(mgmt_v4_gw) as mgmt_v4_gw,host(mgmt_v6_gw) as mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null'); } else { - $q2 = $nms::web::dbh->prepare('select sysname,mgmt_v4_addr,subnet4,subnet6,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null and sysname = ' . $nms::web::dbh->quote($switch) . ';'); + $q2 = $nms::web::dbh->prepare('select sysname,host(mgmt_v4_addr) as mgmt_v4_addr,subnet4,subnet6,host(mgmt_v6_addr) as mgmt_v6_addr,host(mgmt_v4_gw) as mgmt_v4_gw,host(mgmt_v6_gw) as mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null and sysname = ' . $nms::web::dbh->quote($switch) . ';'); } $q2->execute(); |