Difference between revisions of "Script Example: Setting node geolocation from SNMP"
m (Text replacement - "^" to "{{deprecated}}") |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{deprecated}} | |||
{| style="border-spacing: 20px; border: 20px solid red;" | |||
| | |||
'''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. | |||
|} | |||
Adjust the OIDs in ''SNMPGetValue'' as required. | Adjust the OIDs in ''SNMPGetValue'' as required. | ||
<syntaxhighlight lang="c | <syntaxhighlight lang="c"> | ||
transport = CreateSNMPTransport($node); | transport = CreateSNMPTransport($node); | ||
if (transport == null) { | if (transport == null) { | ||
Line 8: | Line 19: | ||
lat = SNMPGetValue(transport, ".1.2.3.4.1"); | lat = SNMPGetValue(transport, ".1.2.3.4.1"); | ||
lon = SNMPGetValue(transport, ".1.2.3.4.2"); | |||
if (lat == null || | if (lat == null || lon == null) { | ||
return null; | return null; | ||
} | } | ||
geoLoc = new GeoLocation(lat, | geoLoc = new GeoLocation(lat, lon); | ||
$node->setGeoLocation(geoLoc); | $node->setGeoLocation(geoLoc); | ||
return 0; | return 0; | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 18:13, 13 September 2022
This Wiki is deprecated and we are are currrently migrating remaining pages into product documentation (Admin Guide, NXSL Guide) |
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;