<?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[Alarms]]></title><description><![CDATA[<p dir="auto">i have created an snmp trap with 3 varbinds.<br />
i have created an event with those 3 varbinds and i have created a rule to display this alarm.<br />
i have tested it and the result was numbers.<br />
now...<br />
i want to convert those numbers to text and i have found the %[name] which is used to get value from script and what i do not understand is how i use the script to convert the varbinds to text</p>
<p dir="auto">varbind 1 = %2 in event and the output is "1" and i want it to show "test" instead of the number.</p>
<p dir="auto">10x,<br />
lindeamon</p>
]]></description><link>https://forum.netxms.org/topic/1520/alarms</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 16:09:02 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/1520.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Dec 2011 17:22:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Alarms on Tue, 27 Dec 2011 10:31:01 GMT]]></title><description><![CDATA[<p dir="auto">thank you very much</p>
<p dir="auto">Best Regards,<br />
Lindeamon</p>
]]></description><link>https://forum.netxms.org/post/6609</link><guid isPermaLink="true">https://forum.netxms.org/post/6609</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Tue, 27 Dec 2011 10:31:01 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Tue, 27 Dec 2011 09:53:02 GMT]]></title><description><![CDATA[<p dir="auto">No, it is not necessary. Empty main() will be created by script compiler if it was not defined explicitly.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/6607</link><guid isPermaLink="true">https://forum.netxms.org/post/6607</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Tue, 27 Dec 2011 09:53:02 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Tue, 27 Dec 2011 09:49:39 GMT]]></title><description><![CDATA[<p dir="auto">hi victor,</p>
<p dir="auto">thank you for the clarification although there is one thing i do not understand.<br />
do i have to begin the script with:<br />
sub main()<br />
{<br />
}</p>
<p dir="auto">and then write the other functions i want to use ?</p>
<p dir="auto">Best Regards,<br />
Lindeamon</p>
]]></description><link>https://forum.netxms.org/post/6606</link><guid isPermaLink="true">https://forum.netxms.org/post/6606</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Tue, 27 Dec 2011 09:49:39 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Tue, 27 Dec 2011 09:17:42 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">There are some confusion caused primarily by giving script itself and a function inside this script the same name. In "use" operator you should use script name (you can think of it as of virtual file name) - the one you see in script list in the library. Then, you can call functions from that script using their respective names - name of the function may or may not be identical to script name. Note that each script has it's own main() function, even if you do not declare it explicitly, so you cannot call main() function of another script. One script may provide multiple functions, like in this example:</p>
<p dir="auto">Script in the library called "MyScript":</p>
<pre><code>/* function 1 */
sub f1(p)
{
   println "f1 called with parameter " . p;
}


/* function 2 */
sub f2(p)
{
   println "f2 called with parameter " . p;
}
</code></pre>
<p dir="auto">and then you use it in some other script:</p>
<pre><code>use MyScript;  /* load script from library by it's name */

f1(1);  /* call function f1 */

f2(2); /* call function f2 */
</code></pre>
<p dir="auto">Script above will produce output</p>
<pre><code>f1 called with parameter 1
f2 called with parameter 2
</code></pre>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/6603</link><guid isPermaLink="true">https://forum.netxms.org/post/6603</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Tue, 27 Dec 2011 09:17:42 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Sun, 25 Dec 2011 15:48:18 GMT]]></title><description><![CDATA[<p dir="auto">hi victor,</p>
<p dir="auto">it worked.<br />
now, i do not understand why i had to do it like this,can you break down the syntax for me ?<br />
for exm., i understand that "use XXXXX" will use the XXXXX script and the "return XXXX" is transferring what ever is in the () to the script but what i do not understand is why i had to do the last change you recommended ?<br />
when i do this configuration the used script become the name of the function ?</p>
<p dir="auto">Best Regards,<br />
Lindeamon</p>
]]></description><link>https://forum.netxms.org/post/6598</link><guid isPermaLink="true">https://forum.netxms.org/post/6598</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Sun, 25 Dec 2011 15:48:18 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Sun, 25 Dec 2011 15:33:35 GMT]]></title><description><![CDATA[<p dir="auto">You should not have function main() in library script. Try to change it like this:</p>
<pre><code>sub CISCO_Config_Event_Config(e)
{
    switch(e)
    {
    case 3: return "running";
    case 4: return "startup";
    }
}
</code></pre>
<p dir="auto">It is strange that server crashes. I'll try to reproduce it myself.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/6597</link><guid isPermaLink="true">https://forum.netxms.org/post/6597</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Sun, 25 Dec 2011 15:33:35 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Sun, 25 Dec 2011 12:32:17 GMT]]></title><description><![CDATA[<p dir="auto">and i forgot to mention that once i have tried the above configuration the server crashed.</p>
]]></description><link>https://forum.netxms.org/post/6596</link><guid isPermaLink="true">https://forum.netxms.org/post/6596</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Sun, 25 Dec 2011 12:32:17 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Sun, 25 Dec 2011 12:25:54 GMT]]></title><description><![CDATA[<p dir="auto">hi victor,</p>
<p dir="auto">no luck.<br />
i have created 2 scripts:</p>
<ol>
<li>the main script for converting called "CISCO_Config_Event_Config" and it's syntax is:<br />
    sub main(e)<br />
    {<br />
    switch(e)<br />
    {<br />
    case 3: return "running";<br />
    case 4: return "startup";<br />
    }<br />
    }</li>
<li>the event #3 param script called "CISCO_Config_Event_Source" and it's syntax is:<br />
    use CISCO_Config_Event_Config;<br />
    return CISCO_Config_Event_Config($event-&gt;parameters[3]);</li>
</ol>
<p dir="auto">in the event i have configured like this:<br />
%[CISCO_Config_Event_Source]</p>
<p dir="auto">and nothing works.where is my problem ?</p>
<p dir="auto">Best Regards,<br />
Lindeamon</p>
]]></description><link>https://forum.netxms.org/post/6595</link><guid isPermaLink="true">https://forum.netxms.org/post/6595</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Sun, 25 Dec 2011 12:25:54 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Sun, 25 Dec 2011 11:51:04 GMT]]></title><description><![CDATA[<p dir="auto">hi victor,</p>
<p dir="auto">i think i understand.i will give it a try.<br />
b.t.w - a feature request regarding this subject - the ability to copy/paste scripts.</p>
<p dir="auto">Best Regards,<br />
Lindeamon</p>
]]></description><link>https://forum.netxms.org/post/6594</link><guid isPermaLink="true">https://forum.netxms.org/post/6594</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Sun, 25 Dec 2011 11:51:04 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Sun, 25 Dec 2011 11:42:24 GMT]]></title><description><![CDATA[<p dir="auto">Parameters can be passed to subroutines like that:</p>
<pre><code>sub main()
{
   f(1, 2);
   f(3, 4);
}

sub f(p1, p2)
{
   println "parameter 1 is " . p1;
   println "parameter 2 is " . p2;
}
</code></pre>
<p dir="auto">If you have multiple parameters which needs to be converted using same function, you can create separate script in the library containing this function, and call it from different small scripts. For example, create script called "convert" with function "convert":</p>
<pre><code>convert(p)
{
   // do conversion here
   return converted_value;
}
</code></pre>
<p dir="auto">then create scripts like that for each parameter:</p>
<p dir="auto">convert_p1:</p>
<pre><code>use convert;
return convert($event-&gt;parameters[1]);
</code></pre>
<p dir="auto">convert_p2:</p>
<pre><code>use convert;
return convert($event-&gt;parameters[2]);
</code></pre>
<p dir="auto">and so on.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/6593</link><guid isPermaLink="true">https://forum.netxms.org/post/6593</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Sun, 25 Dec 2011 11:42:24 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Sun, 25 Dec 2011 11:33:42 GMT]]></title><description><![CDATA[<p dir="auto">hi victor,</p>
<p dir="auto">thank you very much.this is not urgent but it would make things more tidy.<br />
how do i transfer parameters to a sub function ?<br />
my last 2 parameters of the event can use the same function so i can use the same script but as you figured out the $event-parameters will be differnt and will have to be transfered as variables,how do i do that ?</p>
<p dir="auto">Best Regards,<br />
Lindeamon</p>
]]></description><link>https://forum.netxms.org/post/6591</link><guid isPermaLink="true">https://forum.netxms.org/post/6591</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Sun, 25 Dec 2011 11:33:42 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Sun, 25 Dec 2011 11:25:17 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">Currently it is not possible - server always calls main() subroutine when expanding %[] macro. I can add an option to specify parameters and/or entry points to these scripts - in 1.1.8 or 1.1.9, depending on how fast I will fix other things from to-do list.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/6590</link><guid isPermaLink="true">https://forum.netxms.org/post/6590</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Sun, 25 Dec 2011 11:25:17 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Sun, 25 Dec 2011 09:15:48 GMT]]></title><description><![CDATA[<p dir="auto">hi victor,</p>
<p dir="auto">i have another question on the subject.<br />
i receive an alarm with 3 parameters where all of them are numbers that i want to convert to text.<br />
as a test for the 1st one i have used your script and it worked fine so now i want to upgrade it.<br />
i want to write 2 sub's where the 1st one will receive event parameter 1 (and this i know how to do with the script you gave me) and the 2nd one will check parameters 2 and 3.<br />
i have tried it myself but i do not know the correct syntax and parameter placing to subroutines.<br />
i want the above in 1 script file.</p>
<p dir="auto">Best Regards,<br />
lindeamon</p>
]]></description><link>https://forum.netxms.org/post/6588</link><guid isPermaLink="true">https://forum.netxms.org/post/6588</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Sun, 25 Dec 2011 09:15:48 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Thu, 22 Dec 2011 17:56:05 GMT]]></title><description><![CDATA[<p dir="auto">hi victor,</p>
<p dir="auto">this is what i was looking for.when i thought about the solution myself i have remembered that you helped me once with the $node parameters but i would have never guessed the $event parameter.</p>
<p dir="auto">sorry to be a nag but this is another good example for why the documentation has to be updated.</p>
<p dir="auto">thank u and best Regards,<br />
Lindeamon</p>
]]></description><link>https://forum.netxms.org/post/6584</link><guid isPermaLink="true">https://forum.netxms.org/post/6584</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Thu, 22 Dec 2011 17:56:05 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Thu, 22 Dec 2011 17:24:33 GMT]]></title><description><![CDATA[<p dir="auto">If I understand you need correctly, you need script which will convert numeric codes into strings, right? Then you can do the following:</p>
<p dir="auto">Create script in script library, with some name, let's say "convert" (here I assume that you need to convert event's parameter %2 into text - otherwise change index in parameters[] accordingly):</p>
<pre><code>switch($event-&gt;parameters[2])
{
   case 1: return "test";
   case 2: return "test2";
   // and so on...
}
return "unknown"; // default value
</code></pre>
<p dir="auto">and then use it in a message like %[convert]</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/6583</link><guid isPermaLink="true">https://forum.netxms.org/post/6583</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Thu, 22 Dec 2011 17:24:33 GMT</pubDate></item><item><title><![CDATA[Reply to Alarms on Thu, 22 Dec 2011 16:51:12 GMT]]></title><description><![CDATA[<p dir="auto">let me clear things up.<br />
i want to have some kind of transformation script in the event.</p>
]]></description><link>https://forum.netxms.org/post/6582</link><guid isPermaLink="true">https://forum.netxms.org/post/6582</guid><dc:creator><![CDATA[lindeamon]]></dc:creator><pubDate>Thu, 22 Dec 2011 16:51:12 GMT</pubDate></item></channel></rss>