how use configuration poll hook
-
Configuration poll hook is new feature of NetXMS 1.2.3
How it use?- create script in script library with Hook::ConfigurationPoll name.
- write your script.
This script will be executed for node after each configuration poll
simple script example
//rename node after configuration poll to snmp sysLocation //if sysLocation is null then rename to node ip address //also 3 custom attributes will be setted // you can use this attributes in events with %{attribute_name} macros //uncomment trace line and run netxmsd with -D1 param for logging sub main() { if ($node->isSNMP) { //trace(1,"hook executed for ".$node->ipAddr); transport = CreateSNMPTransport($node); if (transport == null) { //trace(1,"snmp transport error on ".$node->ipAddr); return -1; } location = SNMPGetValue(transport, ".1.3.6.1.2.1.1.6.0"); // sysLocation sysname = SNMPGetValue(transport, ".1.3.6.1.2.1.1.5.0"); // sysname uptime = SNMPGetValue(transport, ".1.3.6.1.2.1.1.3.0"); // uptime //trace(1,"[".location."], [".sysname."], [".uptime."]"); if (location != null && location !="" && location!=" ") { //trace(1,"attr location changed to ".location); RenameObject($node, location); } else { //trace(1,"error in location block"); RenameObject($node, $node->ipAddr); //change name to node ip address } if (sysname != null && sysname !="" && sysname !=" ") { SetCustomAttribute($node, "sysname", sysname); //set custom attribute for node snmp sysName //trace(1,"attr sysname changed to ".location); } else { //trace(1,"error in sysname block"); } if (uptime != null) { SetCustomAttribute($node, "uptime", SecondsToUptime(uptime/100)); //set custom attribute uptime for node //trace(1,"attr uptime changed to ".SecondsToUptime(uptime/100)); } else { //trace(1,"error in uptime block"); } //trace(1,"end execution"); SetCustomAttribute($node, "last_update",localtime(time())->mday.".".localtime(time())->mon.".".localtime(time())->year.", ".localtime(time())->hour.":".localtime(time())->min.":".localtime(time())->sec); } }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login