aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/api/private
diff options
context:
space:
mode:
Diffstat (limited to 'web/nms.gathering.org/api/private')
-rwxr-xr-xweb/nms.gathering.org/api/private/comment-add24
-rwxr-xr-xweb/nms.gathering.org/api/private/comment-change24
-rwxr-xr-xweb/nms.gathering.org/api/private/comments15
-rwxr-xr-xweb/nms.gathering.org/api/private/snmp30
-rwxr-xr-xweb/nms.gathering.org/api/private/switch-add92
-rwxr-xr-xweb/nms.gathering.org/api/private/switch-update122
-rwxr-xr-xweb/nms.gathering.org/api/private/switches-management30
-rwxr-xr-xweb/nms.gathering.org/api/private/which-switch-am-i-on40
8 files changed, 0 insertions, 377 deletions
diff --git a/web/nms.gathering.org/api/private/comment-add b/web/nms.gathering.org/api/private/comment-add
deleted file mode 100755
index 26ff734..0000000
--- a/web/nms.gathering.org/api/private/comment-add
+++ /dev/null
@@ -1,24 +0,0 @@
-#! /usr/bin/perl
-# vim:ts=8:sw=8
-use lib '../../../../include';
-use utf8;
-use nms::web qw($dbh db_safe_quote get_input finalize_output);
-use strict;
-use warnings;
-
-my $in = get_input();
-my %tmp = %{JSON::XS::decode_json($in)};
-
-my $data = $dbh->quote($tmp{'comment'});
-my $switch = $dbh->quote($tmp{'switch'});
-my $user = $dbh->quote($ENV{'REMOTE_USER'} || "undefined");
-
-my $q = $nms::web::dbh->prepare("INSERT INTO switch_comments (time,username,switch,comment) values (now(),$user,(select switch from switches where sysname = $switch limit 1),$data)");
-$q->execute();
-
-$nms::web::cc{'max-age'} = '0';
-$nms::web::cc{'stale-while-revalidate'} = '0';
-$nms::web::json{'state'} = 'ok';
-
-print "X-ban: /api/private/comments\n";
-finalize_output();
diff --git a/web/nms.gathering.org/api/private/comment-change b/web/nms.gathering.org/api/private/comment-change
deleted file mode 100755
index fb7da54..0000000
--- a/web/nms.gathering.org/api/private/comment-change
+++ /dev/null
@@ -1,24 +0,0 @@
-#! /usr/bin/perl
-# vim:ts=8:sw=8
-use lib '../../../../include';
-use utf8;
-use nms;
-use nms::web qw($dbh db_safe_quote get_input finalize_output);
-
-use strict;
-use warnings;
-
-my $in = get_input();
-my %tmp = %{JSON::XS::decode_json($in)};
-
-my $id = $dbh->quote($tmp{'comment'});
-my $state = $dbh->quote($tmp{'state'});
-
-my $q = $nms::web::dbh->prepare("UPDATE switch_comments SET state = " . $state . " WHERE id = " . $id . ";");
-$q->execute();
-
-$nms::web::cc{'max-age'} = '0';
-$nms::web::cc{'stale-while-revalidate'} = '0';
-$nms::web::json{'state'} = 'ok';
-
-finalize_output();
diff --git a/web/nms.gathering.org/api/private/comments b/web/nms.gathering.org/api/private/comments
deleted file mode 100755
index 4adfb2b..0000000
--- a/web/nms.gathering.org/api/private/comments
+++ /dev/null
@@ -1,15 +0,0 @@
-#! /usr/bin/perl
-# vim:ts=8:sw=8
-
-use lib '../../../../include';
-use nms::web;
-use strict;
-use warnings;
-
-my $query = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,state,username,id,comment from switch_comments natural join switches where state != \'delete\' order by time desc');
-$query->execute();
-while (my $ref = $query->fetchrow_hashref()) {
- push @{$nms::web::json{'comments'}{$ref->{'sysname'}}{'comments'}},$ref;
-}
-
-nms::web::finalize_output();
diff --git a/web/nms.gathering.org/api/private/snmp b/web/nms.gathering.org/api/private/snmp
deleted file mode 100755
index f69ca62..0000000
--- a/web/nms.gathering.org/api/private/snmp
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/perl
-# vim:ts=8:sw=8
-
-use CGI qw(fatalsToBrowser);
-use DBI;
-use lib '../../../../include';
-use nms;
-use nms::web;
-use strict;
-use warnings;
-use JSON;
-use Data::Dumper;
-
-$nms::web::cc{'max-age'} = "10";
-
-my $q = $nms::web::dbh->prepare('select sysname,data from snmp natural join switches where id in (select max(id) from snmp where '
- . $nms::web::when . 'group by switch);');
-
-$q->execute();
-while (my $ref = $q->fetchrow_hashref()) {
- my $sysname = $ref->{'sysname'};
-
- # This is, strictly speaking, redundant. But by doing this, we can
- # re-use the standard methods of finalize_output() and whatnot.
- my $data = JSON::XS::decode_json($ref->{'data'});
-
- $nms::web::json{'snmp'}{$ref->{'sysname'}} = $data;
-}
-
-finalize_output();
diff --git a/web/nms.gathering.org/api/private/switch-add b/web/nms.gathering.org/api/private/switch-add
deleted file mode 100755
index 48f62fc..0000000
--- a/web/nms.gathering.org/api/private/switch-add
+++ /dev/null
@@ -1,92 +0,0 @@
-#! /usr/bin/perl
-# vim:ts=8:sw=8
-
-#use CGI qw(fatalsToBrowser);
-use DBI;
-use lib '../../../../include';
-use nms;
-use nms::web qw(%get_params %json finalize_output get_input $dbh);
-use nms::util qw(guess_placement);
-use strict;
-use warnings;
-use JSON;
-use Data::Dumper;
-
-$nms::web::cc{'max-age'} = "0";
-
-my $in = get_input();
-my @tmp = @{JSON::XS::decode_json($in)};
-
-my @added;
-my @dups;
-
-my $sth = $nms::web::dbh->prepare("SELECT sysname FROM switches WHERE sysname=?");
-
-my @fields = ('ip', 'sysname', 'last_updated', 'locked', 'poll_frequency', 'community', 'lldp_chassis_id', 'secondary_ip', 'subnet4', 'subnet6', 'placement', 'distro', 'secondary_ip');
-
-sub convertplace
-{
- my %in = %{$_[0]};
- my %out = ();
-
- if (not defined $in{'x1'} and defined($in{'x'})) {
- $out{'x1'} = int($in{'x'});
- $out{'y1'} = int($in{'y'});
- $out{'xx'} = int($in{'x'} + $in{'width'});
- $out{'yy'} = int($in{'y'} + $in{'height'});
- } else {
- return \%in;
- }
- return \%out;
-}
-
-foreach my $tmp2 (@tmp) {
- my %switch = %{$tmp2};
- my $affected = 0;
- my %template = ();
- map { $template{$_} = 'DEFAULT' } @fields;
- if (not defined($switch{'sysname'})) {
- next;
- }
-
- $sth->execute( $switch{'sysname'});
- while ( my @row = $sth->fetchrow_array ) {
- $affected += 1;
- }
-
- if ($affected == 0) {
- my %placement;
- if (not defined ($switch{'placement'})) {
- %placement = guess_placement($switch{'sysname'});
- } else {
- %placement = %{convertplace($switch{'placement'})};
- }
- if (not defined($switch{'ip'}) and defined($switch{'mgtmt4'})) {
- $switch{'ip'} = $switch{'mgtmt4'};
- }
- if (not defined($switch{'secondary_ip'}) and defined($switch{'mgtmt6'})) {
- $switch{'secondary_ip'} = $switch{'mgtmt6'};
- }
- my ($x1,$x2,$y1,$y2);
- $x1 = $placement{'x1'};
- $y1 = $placement{'y1'};
- $x2 = $placement{'xx'};
- $y2 = $placement{'yy'};
- $switch{'placement'} = "(($x1,$y1),($x2,$y2))";
-
- map {
- if (defined ($template{$_})) {
- $template{$_} = $dbh->quote($switch{$_});
- }
- } keys %switch;
-
-
- $nms::web::dbh->do("INSERT INTO SWITCHES (ip, sysname, last_updated, locked, poll_frequency, community, lldp_chassis_id, secondary_ip, placement,subnet4,subnet6,distro) VALUES ($template{'ip'}, $template{'sysname'}, $template{'last_updated'}, $template{'locked'}, $template{'poll_frequency'}, $template{'community'}, $template{'lldp_chassis_id'}, $template{'secondary_ip'}, $template{'placement'},$template{'subnet4'},$template{'subnet6'},$template{'distro'});");
- push @added, $switch{'sysname'};
- }
-}
-
-$json{'switches_addded'} = \@added;
-
-print "X-ban: /api/.*switches.*\n";
-finalize_output();
diff --git a/web/nms.gathering.org/api/private/switch-update b/web/nms.gathering.org/api/private/switch-update
deleted file mode 100755
index 6507d2b..0000000
--- a/web/nms.gathering.org/api/private/switch-update
+++ /dev/null
@@ -1,122 +0,0 @@
-#! /usr/bin/perl
-# vim:ts=8:sw=8
-
-#use CGI qw(fatalsToBrowser);
-use DBI;
-use lib '../../../../include';
-use nms;
-use nms::web qw(%get_params %json finalize_output get_input $dbh);
-use nms::util qw(guess_placement);
-use strict;
-use warnings;
-use JSON;
-use Data::Dumper;
-
-$nms::web::cc{'max-age'} = "0";
-
-my $in = get_input();
-my @tmp = @{JSON::XS::decode_json($in)};
-
-my @added;
-my @dups;
-
-my $sth = $nms::web::dbh->prepare("SELECT sysname FROM switches WHERE sysname=?");
-
-my @fields = ('ip', 'sysname', 'last_updated', 'locked', 'poll_frequency', 'community', 'lldp_chassis_id', 'secondary_ip', 'subnet4', 'subnet6', 'placement', 'distro', 'secondary_ip');
-
-sub convertplace
-{
- my %in = %{$_[0]};
- my %out = ();
-
- if (not defined $in{'x1'} and defined($in{'x'})) {
- $out{'x1'} = int($in{'x'});
- $out{'y1'} = int($in{'y'});
- $out{'xx'} = int($in{'x'} + $in{'width'});
- $out{'yy'} = int($in{'y'} + $in{'height'});
- } else {
- return \%in;
- }
- return \%out;
-}
-
-foreach my $tmp2 (@tmp) {
- my %switch = %{$tmp2};
- my $affected = 0;
- my %template = ();
- map { $template{$_} = 'DEFAULT' } @fields;
- if (not defined($switch{'sysname'})) {
- next;
- }
-
- $sth->execute( $switch{'sysname'});
- while ( my @row = $sth->fetchrow_array ) {
- $affected += 1;
- }
-
- if ($affected == 0) {
- my %placement;
- if (not defined ($switch{'placement'})) {
- %placement = guess_placement($switch{'sysname'});
- } else {
- %placement = %{convertplace($switch{'placement'})};
- }
- if (not defined($switch{'ip'}) and defined($switch{'mgtmt4'})) {
- $switch{'ip'} = $switch{'mgtmt4'};
- }
- if (not defined($switch{'secondary_ip'}) and defined($switch{'mgtmt6'})) {
- $switch{'secondary_ip'} = $switch{'mgtmt6'};
- }
- my ($x1,$x2,$y1,$y2);
- $x1 = $placement{'x1'};
- $y1 = $placement{'y1'};
- $x2 = $placement{'xx'};
- $y2 = $placement{'yy'};
- $switch{'placement'} = "(($x1,$y1),($x2,$y2))";
-
- map {
- if (defined ($template{$_})) {
- $template{$_} = $dbh->quote($switch{$_});
- }
- } keys %switch;
-
-
- $nms::web::dbh->do("INSERT INTO SWITCHES (ip, sysname, last_updated, locked, poll_frequency, community, lldp_chassis_id, secondary_ip, placement,subnet4,subnet6,distro) VALUES ($template{'ip'}, $template{'sysname'}, $template{'last_updated'}, $template{'locked'}, $template{'poll_frequency'}, $template{'community'}, $template{'lldp_chassis_id'}, $template{'secondary_ip'}, $template{'placement'},$template{'subnet4'},$template{'subnet6'},$template{'distro'});");
- push @added, $switch{'sysname'};
- } else {
- if (defined($switch{'placement'})) {
- my %placement;
- if ($switch{'placement'} eq "reset") {
- %placement = guess_placement($switch{'sysname'});
- } else {
- %placement = %{convertplace($switch{'placement'})};
- }
- my ($x1,$x2,$y1,$y2);
- $x1 = $placement{'x1'};
- $y1 = $placement{'y1'};
- $x2 = $placement{'xx'};
- $y2 = $placement{'yy'};
- $switch{'placement'} = "(($x1,$y1),($x2,$y2))";
- push @dups, "not really, but: " . $switch{'placement'};
- }
- if (not defined($switch{'ip'}) and defined($switch{'mgtmt4'})) {
- $switch{'ip'} = $switch{'mgtmt4'};
- }
- if (not defined($switch{'secondary_ip'}) and defined($switch{'mgtmt6'})) {
- $switch{'secondary_ip'} = $switch{'mgtmt6'};
- }
- my @set;
- map {
- if (defined($template{$_})) {
- push @set, "$_=" . $dbh->quote($switch{$_});
- }
- } keys %switch;
- $nms::web::dbh->do("UPDATE SWITCHES SET " . join(", ", @set) . "WHERE sysname=" . $dbh->quote($switch{'sysname'}) . ";");
- push @dups, $switch{'sysname'};
- }
-}
-$json{'switches_addded'} = \@added;
-$json{'switches_updated'} = \@dups;
-
-print "X-ban: /api/.*switches.*\n";
-finalize_output();
diff --git a/web/nms.gathering.org/api/private/switches-management b/web/nms.gathering.org/api/private/switches-management
deleted file mode 100755
index 6b5fdcd..0000000
--- a/web/nms.gathering.org/api/private/switches-management
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/perl
-# vim:ts=8:sw=8
-
-use CGI qw(fatalsToBrowser);
-use DBI;
-use lib '../../../../include';
-use nms;
-use nms::web;
-use strict;
-use warnings;
-use Data::Dumper;
-
-$nms::web::cc{'max-age'} = "60";
-
-my $q2 = $nms::web::dbh->prepare('select sysname,ip,poll_frequency,community,subnet4,subnet6,distro,last_updated from switches ');
-
-$q2->execute();
-while (my $ref = $q2->fetchrow_hashref()) {
- my $sysname = $ref->{'sysname'};
- $nms::web::json{'switches'}{$ref->{'sysname'}} = $ref;
-}
-
-my $q4 = $nms::web::dbh->prepare('select linknet, (select sysname from switches where switch = switch1) as sysname1, addr1, (select sysname from switches where switch = switch2) as sysname2,addr2 from linknets');
-
-$q4->execute();
-while (my $ref = $q4->fetchrow_hashref()) {
- $nms::web::json{'linknets'}{$ref->{'linknet'}} = $ref;
-}
-
-finalize_output();
diff --git a/web/nms.gathering.org/api/private/which-switch-am-i-on b/web/nms.gathering.org/api/private/which-switch-am-i-on
deleted file mode 100755
index 0d3f2b4..0000000
--- a/web/nms.gathering.org/api/private/which-switch-am-i-on
+++ /dev/null
@@ -1,40 +0,0 @@
-#! /usr/bin/perl
-# vim:ts=8:sw=8
-
-use lib '../../../../include';
-use nms::web;
-use strict;
-use warnings;
-use Data::Dumper;
-
-#my $query = $nms::web::dbh->prepare("select * from switches where '185.110.150.7' << subnet4");
-my $query = $nms::web::dbh->prepare("select * from switches where '88.92.5.67' << subnet4");
-$query->execute();
-
-print "Cache-Control: max-age=0";
-print "Content-Type: text/html";
-print "\n\n";
-
-# get user ip from somewhere.
-# HTTP_X_FORWARDED_FOR is set by varnish. When using varnish, the REMOTE_ADDR will always be localhost.
-my $addr = $ENV{HTTP_X_FORWARDED_FOR} // $ENV{REMOTE_ADDR};
-
-# add start html: header + body etc.
-print "
-<html>
- <body style=\"text-align: center; font-size: 50pt;\">
-";
-
-# print address
-print "" . $addr ."<br \>";
-
-# print switch name and distroname.
-while ( my $ref = $query->fetchrow_hashref() ) {
- print $ref->{sysname}. " @ " . $ref->{distro};
-}
-
-# add end html
-print "
- </body>
-</html>
-";