Difference between revisions of "Script Example: Setting node geolocation from SNMP"

From NetXMS Wiki
Jump to navigation Jump to search
Line 1: Line 1:


{| style="border-spacing: 20px; border: 20px solid red;"
{| style="border-spacing: 20px; border: 20px solid red;"
|
|
'''WARNING''': This page is no longer updated. Please visit '''[https://www.netxms.org/documentation/nxsl-latest/ NetXMS Scripting Language]''' for current version of the documentation.  
'''WARNING''': This page is no longer updated. Please visit '''[https://www.netxms.org/documentation/nxsl-latest/#_examples_2 NetXMS Script examples]''' for current version of the documentation.  
|}
|}





Revision as of 16:19, 5 October 2020


WARNING: This page is no longer updated. Please visit NetXMS Script examples for current version of the documentation.



Adjust the OIDs in SNMPGetValue as required.

transport = CreateSNMPTransport($node);
if (transport == null) {
  return null;
}

lat = SNMPGetValue(transport, ".1.2.3.4.1");
lon = SNMPGetValue(transport, ".1.2.3.4.2");

if (lat == null || lon == null) {
  return null;
}

geoLoc = new GeoLocation(lat, lon);
$node->setGeoLocation(geoLoc);

return 0;