diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2015-06-23 14:23:13 +0200 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2015-06-23 14:23:13 +0200 |
commit | c8a1ab2f825348969ffe72a20f562b329e271db1 (patch) | |
tree | 422e300247b38075ebd3c891fed498b6c4b3b603 | |
parent | 2c9231ff1b71e608b369df8666b3b1ec2f32bb74 (diff) |
NMS: Basic groundwork for public NMS
Hashing the interface names allows us to expose them to end-users without
too much effort. This still isn't quite finalized, but the backend work is
a good start.
-rwxr-xr-x | include/config.pm.dist | 3 | ||||
-rwxr-xr-x | web/nms.gathering.org/port-state.pl | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/include/config.pm.dist b/include/config.pm.dist index 8c29bf6..cce82df 100755 --- a/include/config.pm.dist +++ b/include/config.pm.dist @@ -10,6 +10,9 @@ our $db_host = "gerald.tg15.gathering.org"; our $db_username = "nms"; our $db_password = "<removed>"; +# NMS hash used for public NMS obfuscation of interface names +our $nms_hash = "<removed>"; + # DHCP-servers our $dhcp_server1 = "185.12.59.66"; # primary our $dhcp_server2 = "185.12.59.2"; # secondary diff --git a/web/nms.gathering.org/port-state.pl b/web/nms.gathering.org/port-state.pl index 9df31c0..81ce025 100755 --- a/web/nms.gathering.org/port-state.pl +++ b/web/nms.gathering.org/port-state.pl @@ -13,18 +13,21 @@ my $cgi = CGI->new; my $dbh = nms::db_connect(); my $cin = $cgi->param('time'); my $now = "now()"; -if ($cgi->param('now') != undef) { +if (defined($cgi->param('now'))) { $now = "'" . $cgi->param('now') . "'::timestamp "; } my $when =" time > " . $now . " - '5m'::interval and time < " . $now . " "; my %json = (); - +my $ifname = "ifname"; +if (defined($cgi->param('public'))) { + $ifname = "regexp_replace(ifname, 'ge-0/0/(([0-3][0-9])|(4[0-3])|([0-9]))\$',concat('ge-participant',sha1_hmac(ifname::bytea,'".$nms::config::nms_hash."'::bytea))) as ifname"; +} if (defined($cin)) { $when = " time < " . $now . " - '$cin'::interval and time > ". $now . " - ('$cin'::interval + '5m'::interval) "; } -my $query = 'select sysname,extract(epoch from date_trunc(\'second\',time)) as time, ifname,ifhighspeed,ifhcinoctets,ifhcoutoctets from polls natural join switches where time in (select max(time) from polls where ' . $when . ' group by switch,ifname);'; +my $query = 'select sysname,extract(epoch from date_trunc(\'second\',time)) as time, '.$ifname.',ifhighspeed,ifhcinoctets,ifhcoutoctets from polls natural join switches where time in (select max(time) from polls where ' . $when . ' group by switch,ifname);'; my $q = $dbh->prepare($query); $q->execute(); |