<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[how use configuration poll hook]]></title><description><![CDATA[<p dir="auto">Configuration poll hook is new feature of NetXMS 1.2.3<br />
How it use?</p>
<ol>
<li>create script in script library with Hook::ConfigurationPoll name.</li>
<li>write your script.</li>
</ol>
<p dir="auto">This script will be executed for node after each configuration poll</p>
<p dir="auto">simple script example</p>
<pre><code>//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-&gt;isSNMP)
   {
  //trace(1,"hook executed for ".$node-&gt;ipAddr);
   transport = CreateSNMPTransport($node);
    if (transport == null)
    {
    //trace(1,"snmp transport error on ".$node-&gt;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 &amp;&amp; location !="" &amp;&amp; location!=" ")
     {
         //trace(1,"attr location changed to ".location);
         RenameObject($node, location);
     }
    else
    {
         //trace(1,"error in location block");
         RenameObject($node, $node-&gt;ipAddr); //change name to node ip address
    }
    if (sysname != null &amp;&amp; sysname !="" &amp;&amp; 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())-&gt;mday.".".localtime(time())-&gt;mon.".".localtime(time())-&gt;year.", ".localtime(time())-&gt;hour.":".localtime(time())-&gt;min.":".localtime(time())-&gt;sec);
  }
}
</code></pre>
]]></description><link>https://forum.netxms.org/topic/1927/how-use-configuration-poll-hook</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 16:05:27 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/1927.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Sep 2012 14:00:09 GMT</pubDate><ttl>60</ttl></channel></rss>