Script SNMP on event processing policy

Started by Stardust, April 24, 2015, 04:19:11 PM

Previous topic - Next topic

Stardust

Hi,

I'm monitoring my backup servers with netxms by SNMP and I well receive the result of jobs on the event monitor but they are catched by SNMP_UNMATCHED_TRAP.
But I don't know if that matters to do what I want to do;

I would like to apply severity on the job results like:

  • Success -> Normal
  • Failed -> critical

'Failed' and 'success' are in 3rd position on parameters varbind (I think):

.1.3.6.1.4.1.31023.1.1.1.0.1   .1.3.6.1.4.1.31023.1.1.101 == '1109f400-0d24-4895-abb8-d298211314b2'; .1.3.6.1.4.1.31023.1.1.102 == 'BAckup Zabbix Serveur'; .1.3.6.1.4.1.31023.1.1.103 == 'Failed'; .1.3.6.1.4.1.31023.1.1.104 == ''

What is the script that could catch the word 'Failed', 'Success' or else on Event Processing Policy?

Or what is the simplest way to do that?

Thanks

tomaskir

Here is how I would do it:

1) Create SNMP Trap with trap OID .1.3.6.1.4.1.31023.1.1.1.0.1
    From the trap, pass parameter from the OID .1.3.6.1.4.1.31023.1.1.103

2) Create event for the SNMP trap. In event, you will get that parameter as %2
    You can use %2 to interpret job completion in the event message.

3) Create 2x Event processing policy for this event (one for fail, one for success)
    In filtering script filter for the fail or success from event message.

Stardust

Thanks but I would like to filtering the snmp containing the string ' Failed ' be marked as ' critical' (in red) and ' succeess ' in green in the event monitor. Is that possible?

Moreover in the the Event processing policy I wanted a script that catch the word 'Failed' and send an email.

What I've done:

sub main()
{

if(%3 == 'Failed') return 1;

else return 0;

}


-> I receive an email on the both cases (Fail or success)

tomaskir

As I mentioned, create 2 Event Processing policies.

1st will catch the event with 'Fail' in Event message; and create a critical alarm on the node and send the email.
2nd will catch the event with 'Success' in Event message; terminate/resolve the previous alarm, and also send email.

Stardust

#4
Quote from: tomaskir on April 24, 2015, 06:27:33 PM
As I mentioned, create 2 Event Processing policies.

1st will catch the event with 'Fail' in Event message; and create a critical alarm on the node and send the email.
2nd will catch the event with 'Success' in Event message; terminate/resolve the previous alarm, and also send email.

Thank you for your help but i'm stuck right here.
How can I catch the event with 'Fail' in the event? What is the script code?

What I've done:
sub main()
{
transport = CreateSNMPTransport(FindObject(".1.3.6.1.4.1.31023.1.1.1.0.1"));    // Create SNMP transport for node

value = SNMPGetValue(transport, ".1.3.6.1.4.1.31023.1.1.103");

if(value == "Failed") return 1;

else retun 0;

}

PS: I forgot to mention that I couldn't find the OID by the MIB Browser, that's why that OID is catch by the trap 'SNMP_UNMATCHED_TRAP' (is that important for that I want to do?)

tomaskir

Create your own event for your SNMP trap.
In that event %2 and %3 will be accessible for the parameters you map from your Trap.

Dont use the default SNMP_UNMATCHED_TRAP event.

Then create your own EPP to catch that event.
You can test and just see if you catch it properly without filtering for FAIL/SUCCESS.

Then when you have that working, you can start playing with the scripting.

Do it step-by-step, dont do everything at once, because you then dont know what isnt working.

tomaskir

Come and visit us in the support IRC channel, it will be much faster to get this resolved :)


Stardust

That script worked for me:


sub main()
{
   if ( index($event->message, "Success"))return 1;
      else return 0;
}