diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/nms/snmp.pm | 4 | ||||
| -rw-r--r-- | include/nms/util.pm | 17 | ||||
| -rwxr-xr-x | include/nms/web.pm | 13 | 
3 files changed, 24 insertions, 10 deletions
| diff --git a/include/nms/snmp.pm b/include/nms/snmp.pm index b1354ae..26ada44 100644 --- a/include/nms/snmp.pm +++ b/include/nms/snmp.pm @@ -15,7 +15,9 @@ BEGIN {  	# cd /usr/share/mibs/site  	# wget -O- ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz | sudo tar --strip-components=3 -zxvvf -  	SNMP::initMib(); -	SNMP::addMibDirs("../mibs"); +	SNMP::addMibDirs("/srv/tgmanage/mibs/StandardMibs"); +	SNMP::addMibDirs("/srv/tgmanage/mibs/JuniperMibs"); +	  	SNMP::loadModules('SNMPv2-MIB');  	SNMP::loadModules('ENTITY-MIB');  	SNMP::loadModules('IF-MIB'); diff --git a/include/nms/util.pm b/include/nms/util.pm index 79598d7..64637b8 100644 --- a/include/nms/util.pm +++ b/include/nms/util.pm @@ -15,10 +15,9 @@ sub parse_switch {  		'sysname' => "$switch",  		'subnet4' => "$subnet4",  		'subnet6' => "$subnet6", -		'mgtmt4' => "$mgtmt4", -		'mgtmt6' => "$mgtmt6", -		'lolid' => "$lolid", -		'ip' => "$mgtmt4", +		'mgmt_v4_addr' => "$mgtmt4", +		'mgmt_v6_addr' => "$mgtmt6", +		'traffic_vlan' => "$lolid",  		'distro' => "$distro"  	);  	%{$ret{'placement'}} = guess_placement($switch); @@ -91,7 +90,7 @@ sub guess_placement {  		$yy -= 20 if ($e >= 79 and $s == 1);  		$yy -= 30 if ($e >= 81 and $s == 1); -	} elsif ($name =~ /^sw(\d+)-creativia$/) { +	} elsif ($name =~ /^creativia(\d+)$/) {  		my ($s) = ($1);  		$src = "creativia";  		$x = 1535; @@ -114,7 +113,13 @@ sub guess_placement {  		$y = int(759 + 20.5 * $s);  		$xx = $x + 65;  		$yy = $y + 14; - +	} elsif ($name =~ /^distro(\d)/) { +		my $d = ($1); +		$src = "distro"; +		$x = 292 + $d * 165; +		$y = 415; +		$xx = $x + 130; +		$yy = $y + 20;  	} else {  		# Fallback to have _some_ position  		$src = "random"; diff --git a/include/nms/web.pm b/include/nms/web.pm index 2a5e132..889e774 100755 --- a/include/nms/web.pm +++ b/include/nms/web.pm @@ -57,14 +57,19 @@ sub db_safe_quote {  # endpoints it is better to return no data than old data (e.g.: ping).  sub setwhen {  	$now = "now()"; -	my $window = '15m'; -	if (@_ == 1) { +	my $window = '8m'; +	my $offset = '0s'; +	if (@_ > 0) {  		$window = $_[0];  	} +	if (@_ > 1) { +		$offset = $_[1]; +	}  	if (defined($get_params{'now'})) {  		$now = db_safe_quote('now') . "::timestamp ";  		$cc{'max-age'} = "3600";  	} +	$now = "(" . $now . " - '" . $offset . "'::interval)";  	$when = " time > " . $now . " - '".$window."'::interval and time < " . $now . " ";  } @@ -81,7 +86,9 @@ sub finalize_output {  	printcc;  	print "Etag: $hash\n"; -	print "Content-Type: text/jso; charset=utf-8\n\n"; +	print "Access-Control-Allow-Origin: *\n"; +	print "Access-Control-Allow-Methods: HEAD, GET\n"; +	print "Content-Type: text/json; charset=utf-8\n\n";  	print JSON::XS::encode_json(\%json);  	print "\n";  } | 
