diff options
Diffstat (limited to 'web')
| -rwxr-xr-x | web/api/public/ping | 20 | ||||
| -rw-r--r-- | web/js/nms-map-handlers.js | 31 | 
2 files changed, 38 insertions, 13 deletions
diff --git a/web/api/public/ping b/web/api/public/ping index 36e3334..1928368 100755 --- a/web/api/public/ping +++ b/web/api/public/ping @@ -11,20 +11,24 @@ my $q = $nms::web::dbh->prepare("SELECT DISTINCT ON (sysname) (" . $nms::web::no  $q->execute();  while (my $ref = $q->fetchrow_hashref()) { -    $nms::web::json{'switches'}{$ref->{'sysname'}}{'latency'} = $ref->{'latency_ms'}; +    $nms::web::json{'switches'}{$ref->{'sysname'}}{'latency4'} = $ref->{'latency_ms'};      # Get seconds, without decimlas, from timestamp.      # '00:01:01.435601' => 61 seconds.      my ( $h, $m, $s ) = split( ':|\.', $ref->{'age'} ); -    $nms::web::json{'switches'}{$ref->{'sysname'}}{'age'} = ($h*60*60) + ($m*60) + $s; # $$ref->{'age'}; +    $nms::web::json{'switches'}{$ref->{'sysname'}}{'age4'} = ($h*60*60) + ($m*60) + $s; # $$ref->{'age'};  } -my $qs = $nms::web::dbh->prepare("SELECT DISTINCT ON (switch) switch, latency_ms FROM ping_secondary_ip WHERE " -        . $nms::web::when .  " ORDER BY switch, time DESC;"); -$qs->execute(); -while ( my $ref = $qs->fetchrow_hashref() ) { -    $nms::web::json{'switches'}{$ref->{'switch'}}{'latency_secondary'} = $ref->{'latency_ms'}; -} +my $q2 = $nms::web::dbh->prepare("SELECT DISTINCT ON (sysname) (" . $nms::web::now . " - time) as age,sysname, latency_ms FROM ping_secondary_ip NATURAL JOIN switches WHERE time in (select max(time) from ping where " +        . $nms::web::when . " group by switch)"); +$q2->execute(); +while (my $ref = $q2->fetchrow_hashref()) { +    $nms::web::json{'switches'}{$ref->{'sysname'}}{'latency6'} = $ref->{'latency_ms'}; +    # Get seconds, without decimlas, from timestamp. +    # '00:01:01.435601' => 61 seconds. +    my ( $h, $m, $s ) = split( ':|\.', $ref->{'age'} ); +    $nms::web::json{'switches'}{$ref->{'sysname'}}{'age6'} = ($h*60*60) + ($m*60) + $s; # $$ref->{'age'}; +}  my $lq = $nms::web::dbh->prepare("SELECT DISTINCT ON (linknet) linknet, latency1_ms, latency2_ms FROM linknet_ping WHERE "          . $nms::web::when . " ORDER BY linknet, time DESC;");  $lq->execute(); diff --git a/web/js/nms-map-handlers.js b/web/js/nms-map-handlers.js index 09d2525..b863ab2 100644 --- a/web/js/nms-map-handlers.js +++ b/web/js/nms-map-handlers.js @@ -86,6 +86,7 @@ var handlerInfo = function(tag,desc) {  	 * Short name, typically matching the url anchor.  	 */  	this.tag = tag; +	this.description = desc || "Unknown";  	this.data = [  		{   			value: undefined, @@ -329,13 +330,33 @@ function pingInfo(sw)  	var ret = new handlerInfo("ping","Latency(ms)");  	ret.why = "Latency";  	try { -		ret.data[0].value = nmsData.ping.switches[sw].latency; -		ret.score = parseInt(ret.data[0].value) * 10; -		if (nmsData.ping.switches[sw].age > 5) { +		var v4 = nmsData.ping.switches[sw].latency4; +		var v6 = nmsData.ping.switches[sw].latency6; +		ret.data[0].value = v4; +		ret.data[0].description = "IPv4 latency(ms)"; +		ret.data[1] = {}; +		ret.data[1].value = v6; +		ret.data[1].description = "IPv6 latency(ms)"; +		if (v4 == v6 == undefined) { +			ret.score = 1000; +			ret.why = "No IPv4 or IPv6 ping reply"; +		} else if(v6 == undefined) { +			ret.score = 200; +			ret.why = "No IPv6 ping reply"; +		} else if (v4 == undefined) { +			ret.score = 199; +			ret.why = "No IPv4 ping reply"; +		} else { +			v4 = parseInt(v4); +			v6 = parseInt(v6); +			ret.score = (v4 > v6 ? v4 : v6) * 10; +		} +		if (nmsData.ping.switches[sw].age4 > 5 || nmsData.ping.switches[sw].age6 > 5) {  			ret.why = "Old ping";  			ret.score = 900;  		}  	} catch(e) { +		console.log(e);  		ret.data[0].value = "N/A - no ping replies";  		ret.why = "No ping replies";  		ret.score = 999; @@ -566,7 +587,7 @@ function cpuInit() {  }  function comboInfo(sw) { -	var worst = new handlerInfo("combo"); +	var worst = new handlerInfo("combo", "Combo");  	worst.score = -1;  	for (var h in handlers) {  		try { @@ -579,7 +600,7 @@ function comboInfo(sw) {  		} catch(e) { }  	}  	worst.data = [{ -		description: "Worst: " + worst.data[0].description, +		description: "Worst: " + worst.description,  		value: worst.why  	}];  	return worst;  | 
