Page 4 of 4

Re: Nagios Core 4.08 don't send traps in order.

Posted: Fri Aug 05, 2016 5:23 pm
by Nagios_Admin_M
I used the $HOSTNAME$ macro and I saw an entry in the log file, but when I typed $SERVICEOUTPUT$ the script doesn't work.

Re: Nagios Core 4.08 don't send traps in order.

Posted: Mon Aug 08, 2016 2:12 pm
by ssax
Ok, let's get a fresh copy of all the things needed so that we can figure out what is going on, please attach:

1. Your send-service-trap script
2. Your command definition that calls the script
3. Your service config for an example service

Then I can point you in the right direction.

Thank you

Re: Nagios Core 4.08 don't send traps in order.

Posted: Fri Aug 12, 2016 3:14 am
by Nagios_Admin_M

Code: Select all

|||||||||||||||||||||||||||||||||||||||||||
define command{
      command_name send-service-trap
      command_line /usr/bin/send-service-trap host_name public "$HOSTNAME$" "$HOSTSTATEID$" "$SERVICEDESC$" "$SERVICESTATEID$" "$SERVICEATTEMPT$" "$LASTSERVICESTATECHANGE$" "$SERVICEDURATIONSEC$" "$LASTSERVICECHECK$" "$SERVICEOUTPUT$"
}

define command{
command_name send-host-trap
command_line /usr/bin/send-host-trap IP public "$HOSTNAME$" "$HOSTSTATEID$" "$HOSTATTEMPT$" "$HOSTDURATIONSEC$" "$LASTHOSTCHECK$" "$LASTHOSTSTATECHANGE$" "$HOSTOUTPUT$"
}


|||||||||||||||||||||||||||||||||||||||||||

/usr/bin/snmptrap -v 2c -c $1 IP '' NAGIOS-NOTIFY-MIB::nHostEvent nHostName s $2 nHostStateID i $3 nHostAttempt i $4 nHostDurationSec i $5  nHostGroupName s "$6" nHostLastCheck i $7 nHostLastChange i $8 nHostOutput s "${9}"    

/usr/bin/snmptrap -v 2c -c $1 IP '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "$2" nHostStateID i $3 nSvcDesc s "$4" nSvcStateID i $5 nSvcAttempt i $6 nSvcDurationSec i $7 nSvcGroupName s "$8" nSvcLastCheck i $9 nSvcLastChange i ${10}          nSvcOutput s "${11}"

|||||||||||||||||||||||||||||||||||||||||||

service_notification_options    w,u,c,r
host_notification_options       d,u,r
service_notification_commands   send-service-trap
host_notification_commands      send-host-trap
		
define contactgroup{
        contactgroup_name       linuxadmins
        alias                   Linux Servers Administrators
        members                 me, managementstation
}

|||||||||||||||||||||||||||||||||||||||||||

traplogfile output
  ,,,,  
  EOF
  ,,,,
  EOF
  /usr/bin/snmptrap -v 2c -c host... '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "hname" nSvcDesc s "0" nSvcStateID i PING nSvcOutput s "0"
  /usr/bin/snmptrap -v 2c -c host... '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "hname" nSvcDesc s "0" nSvcStateID i PING nSvcOutput s "0"

Re: Nagios Core 4.08 don't send traps in order.

Posted: Fri Aug 12, 2016 12:42 pm
by tgriep
The only thing I see different is that the send-service-trap command, you are using the host_name instead of the IP address, is the host_name resolvable to an IP address on the nagios server?

Re: Nagios Core 4.08 don't send traps in order.

Posted: Wed Aug 17, 2016 9:37 am
by Nagios_Admin_M
I can share the kind of way I accomplished the task with you.

I stared the command_line by assigning the values to my variables:

" command_line var0=$HOSTNAME$ etc... "

I created a send.trap script:
/usr/bin/send.trap
/usr/bin/send_trap .......................... var0

and populated vars to:
/usr/bin/sendtrap ............................. nHostname etc...

I finally got the traps sent.

ALTHOUGH your solutions send values directly to /usr/bin/sendtrap Net-snmp script and uses only one file instead of 2 as my,
I took this approach because I couldn't get all the values wright the the script.

Re: Nagios Core 4.08 don't send traps in order.

Posted: Wed Aug 17, 2016 1:41 pm
by tgriep
Glad that you have it working now. Shall I close and lock the post as solved?

Re: Nagios Core 4.08 don't send traps in order.

Posted: Wed Sep 07, 2016 9:57 am
by Nagios_Admin_M
Yes, you can.