doodah/web/netadmin.js
// Loop through LibreNMS update response and pass them to the nodes

Loop through LibreNMS update response and pass them to the nodes
Loop through LibreNMS update response and pass them to the nodes
function LibreNMS_Update( data ) {
	for (var key in data) {
		var host = data[key];
		var hostname = host.sysName.toUpperCase();
		var state;
		var dot = hostname.indexOf(".");
		if( dot>0 ) hostname = hostname.substring(0,dot);
		var node, autohide;
		if( host.status=="1" ) {
			autohide = true;
			state = 1;
		} else {
			autohide = false;
			state = 3;
		}
		if( !(hostname in Nodes) ) {
			node = new Node( hostname, state, "unknown", autohide );
		} else {
			node = node = Nodes[hostname];
		}
		var msg;
		msg = { "subtitle":"Last Ping", "status":state, "errcode":0, "errtext":host.last_ping, "autohide":autohide };
		node.addState( host.device_id+".ping", msg);
		msg = { "subtitle":"Last Poll", "status":state, "errcode":0, "errtext":host.last_polled, "autohide":autohide };
		node.addState( host.device_id+".poll", msg);
		msg = { "subtitle":"Cause: "+host.status_reason, "status":state, "errcode":0, "errtext":"", "autohide":true };
		node.addState( host.device_id+".status", msg);
	}
}
function LibreNMS_Update ( data ) { for ( var key in data ) { var host = data [ key ] ; var hostname = host . sysName . toUpperCase ( ) ; var state ; var dot = hostname . indexOf ( "." ) ; if ( dot > 0 ) hostname = hostname . substring ( 0 , dot ) ; var node , autohide ; if ( host . status == "1" ) { autohide = true ; state = 1 ; } else { autohide = false ; state = 3 ; } if ( ! ( hostname in Nodes ) ) { node = new Node ( hostname , state , "unknown" , autohide ) ; } else { node = node = Nodes [ hostname ] ; } var msg ; msg = { "subtitle" : "Last Ping" , "status" : state , "errcode" : 0 , "errtext" : host . last_ping , "autohide" : autohide } ; node . addState ( host . device_id + ".ping" , msg ) ; msg = { "subtitle" : "Last Poll" , "status" : state , "errcode" : 0 , "errtext" : host . last_polled , "autohide" : autohide } ; node . addState ( host . device_id + ".poll" , msg ) ; msg = { "subtitle" : "Cause: " + host . status_reason , "status" : state , "errcode" : 0 , "errtext" : "" , "autohide" : true } ; node . addState ( host . device_id + ".status" , msg ) ; } }
Loop through LibreNMS update response and pass them to the nodes
Loop through LibreNMS update response and pass them to the nodes
//	console.log( "updateing.." );
 //console.log( hostname + ", " + state );
 //			console.log( "-- New Node" );
 // Node doesn't exist, Create a new node:
 // Add this new state to the node.
 //console.log( data );
 // ADD JSON for debugging
 //		msg	= { "subtitle":"LibreNMS", "status":state, "errcode":0, "errtext":JSON.stringify(host), "autohide":false };
 //		node.addState( host.device_id, msg);
 // LAST PING
 // LAST POLL
 // STATUS
 // DEBUGGING
 //		if( hostname=="LBB_CIV_SDC_APM01" ) console.log( JSON.stringify(host) );
