Difference between revisions of "Script Example: Setting node geolocation from SNMP"
Jump to navigation
Jump to search
Tomas Kirnak (talk | contribs) (Created page with "Adjust the OIDs in ''SNMPGetValue'' as required. <syntaxhighlight lang="c"> transport = CreateSNMPTransport($node); if (transport == null) { return null; } lat = SNMPGetVa...") |
|||
Line 1: | Line 1: | ||
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 14: | Line 14: | ||
} | } | ||
geoLoc = GeoLocation(lat, long); | geoLoc = new GeoLocation(lat, long); | ||
$node->setGeoLocation(geoLoc); | $node->setGeoLocation(geoLoc); | ||
return 0; | return 0; | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 15:16, 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");
long = SNMPGetValue(transport, ".1.2.3.4.2");
if (lat == null || long == null) {
return null;
}
geoLoc = new GeoLocation(lat, long);
$node->setGeoLocation(geoLoc);
return 0;