NXSL script help

Started by tivanni, October 01, 2012, 02:18:30 PM

Previous topic - Next topic

tivanni

Hi,

when I add a filtering script to the event processing policy, where i can found the output of the print/println command?
If i add a print or a println command to the filter script, when the event occuor i can't find the output in the remote console server or in the server console or in other way.

Another questions...in the filtering script of event processing policy, can i put directly the code?Or, have I to add the declaration of the main (sub main(){etc )

I have to create a filter script that send the alarm's mail for an interface down for only specific interface...
I tried to insert in the event processing police as source the specific interface, but did'nt work; so i use as source the switch and i wanna to add a filter script that select for which interface the alarm's mail have to start. Any suggestion?



Victor Kirhenshtein

Hi!

Quote from: tivanni on October 01, 2012, 02:18:30 PM
when I add a filtering script to the event processing policy, where i can found the output of the print/println command?
If i add a print or a println command to the filter script, when the event occuor i can't find the output in the remote console server or in the server console or in other way.

You should use trace() function to write messages to server's log.

Quote from: tivanni on October 01, 2012, 02:18:30 PM
Another questions...in the filtering script of event processing policy, can i put directly the code?Or, have I to add the declaration of the main (sub main(){etc )

Yes, you can write code directly. Defining main() is not necessary. Also, the following code is also valid:


trace(0, "main() starts here");

sub someFunction()
{
}

trace(0, "main() continues here");


Quote from: tivanni on October 01, 2012, 02:18:30 PM
I have to create a filter script that send the alarm's mail for an interface down for only specific interface...
I tried to insert in the event processing police as source the specific interface, but did'nt work; so i use as source the switch and i wanna to add a filter script that select for which interface the alarm's mail have to start. Any suggestion?

Source of interface down event is the node. You can filter events using script by interface name or index. For example, to pass SYS_IF_DOWN events only for interface named "eth2", you can use the following script:


return $2 == "eth2";


We use $2 here because interface name passed as second parameter with SYS_IF_DOWN event. You can see this from event description:

Generated when interface goes down.
Please note that source of event is node, not an interface itself.
Parameters:
  1) Interface object ID
  2) Interface name
  3) Interface IP address
  4) Interface netmask
  5) Interface index

Best regards,
Victor