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

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


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


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


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


return 0;
return 0;
</syntaxhighlight>
</syntaxhighlight>

Revision as of 15:17, 21 December 2018

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;