diff options
| -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(); | 
