<?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[NXSL: Casting problems]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">i'am trying to realize a filtering script that when an interface goes down get an snmp value from the switch, using the IfIndex of the interface.</p>
<p dir="auto">Here is my filtering script:</p>
<p dir="auto">sub main() {<br />
 <br />
   transport = CreateSNMPTransport($node);    // Create SNMP transport for node<br />
    <br />
    ifIndex= %5;<br />
     <br />
    value = SNMPGetValue(transport, ".1.3.6.1.4.1.9.2.2.1.1.28.".ifIndex);<br />
 <br />
 <br />
 <br />
   CUSTOM_MESSAGE = "Description: ".value;<br />
 <br />
 <br />
 <br />
  return true;<br />
}</p>
<p dir="auto">The IfIndex of the interface is rapresented by the %5 special variable, because the filtering script is relative to "SYS_IF_DOWN" event which has as parameter:</p>
<p dir="auto">"<br />
   1) Interface object ID<br />
   2) Interface name<br />
   3) Interface IP address<br />
   4) Interface netmask<br />
   5) Interface index<br />
"</p>
<p dir="auto">But when the script is executed i get the following error code:</p>
<p dir="auto"> Error in line 5: syntax error, unexpected T_INT32, expecting '('.</p>
<p dir="auto">I have tryed to cast the value -&gt; ifIndex = string(%5);</p>
<p dir="auto">or</p>
<p dir="auto">I have tryed to use a switch case to convert the value:</p>
<p dir="auto">switch(%5):<br />
   case "10134": etc</p>
<p dir="auto">but nothing works <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--disappointed" style="height:1.4em;width:auto;vertical-align:middle" title=":(" alt="😞" /></p>
<p dir="auto">Can you help me?</p>
<p dir="auto">Tnx</p>
]]></description><link>https://forum.netxms.org/topic/2691/nxsl-casting-problems</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 11:41:37 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/2691.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Oct 2013 12:36:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to NXSL: Casting problems on Fri, 01 Nov 2013 18:04:41 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">There is an area in wiki for NXSL script examples: <a href="http://wiki.netxms.org/wiki/SG:Script_Examples" rel="nofollow ugc">http://wiki.netxms.org/wiki/SG:Script_Examples</a>. Feel free to add your own!</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/11676</link><guid isPermaLink="true">https://forum.netxms.org/post/11676</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Fri, 01 Nov 2013 18:04:41 GMT</pubDate></item><item><title><![CDATA[Reply to NXSL: Casting problems on Thu, 31 Oct 2013 09:17:59 GMT]]></title><description><![CDATA[<p dir="auto">Yes, it works!</p>
<p dir="auto">Here is a working filtering script that get the interface description from the switch and put it in the alarm mail when interface goes down/up:</p>
<p dir="auto">sub main() {<br />
 <br />
   transport = CreateSNMPTransport($node);    // Create SNMP transport for node<br />
    <br />
    ifIndex = $5 ;<br />
    trace(0,"ifIndex =".ifIndex);<br />
    <br />
    value = SNMPGetValue(transport, ".1.3.6.1.4.1.9.2.2.1.1.28.".ifIndex);<br />
 <br />
 <br />
 <br />
   CUSTOM_MESSAGE = "Description: ".value;<br />
 <br />
 <br />
 <br />
  return true;<br />
}</p>
<p dir="auto">Works on Cisco. For other switch, just change the base OID in SNMPGetValue.</p>
<p dir="auto">Is it possible to create a topic in forum in which share our NXSL script?<br />
Sharing and example are so useful for nxsl devoloper ^^</p>
<p dir="auto">Thank you <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://forum.netxms.org/post/11654</link><guid isPermaLink="true">https://forum.netxms.org/post/11654</guid><dc:creator><![CDATA[tivanni]]></dc:creator><pubDate>Thu, 31 Oct 2013 09:17:59 GMT</pubDate></item><item><title><![CDATA[Reply to NXSL: Casting problems on Wed, 30 Oct 2013 20:14:30 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">It should be $5. It's a bit confusing, but macros in message texts, etc. and NXSL scripts uses a bit different syntax. In macro expansion, % denotes a macro. In NXSL, parameters comes as $1, $2, etc., and % sign is a division remainder operation.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/11650</link><guid isPermaLink="true">https://forum.netxms.org/post/11650</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Wed, 30 Oct 2013 20:14:30 GMT</pubDate></item></channel></rss>