Page 1 of 2

Need help configuring Nagios/OTRS intergration

Posted: Sun Jul 10, 2016 3:02 am
by nathanplatt
Hi Guys,

I've installed two VM's at home, Nagios Student and OTRS 5. I have downloaded the plugin from

Code: Select all

https://exchange.nagios.org/directory/Addons/Helpdesk-and-Ticketing/OTRS/Nagios-OTRS-Integration/details
. There isn't any instructions on how to use the scripts. So i've created a dummy host and attached the event handler to the host but nothing seems to be happening, any help would be appreciated.

FYI: This is a personal development project

Re: Need help configuring Nagios/OTRS intergration

Posted: Mon Jul 11, 2016 2:19 am
by Box293
Can you show us the command definition you've defined to use as the event handler.

Can you also show us the command being executed in an SSH session on your Nagios server (along with the output). This will help us understand what a "working" example of this plugin is.

Re: Need help configuring Nagios/OTRS intergration

Posted: Wed Jul 13, 2016 9:05 am
by nathanplatt
Box293 wrote:Can you show us the command definition you've defined to use as the event handler.

Can you also show us the command being executed in an SSH session on your Nagios server (along with the output). This will help us understand what a "working" example of this plugin is.
Hi,

Code: Select all

define command {
       command_name                             host-otrs-event-ok
       command_line                             $USER1$/eventhandlers/host_otrs_event_ok.sh
}

define command {
       command_name                             notify-host-by-email
       command_line                             /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTAT$
}

define command {
       command_name                             notify-otrs
       command_line                             $USER1$/eventhandlers/notify_otrs.sh
}

define command {
       command_name                             otrs-event-ok
       command_line                             $USER1$/eventhandlers/otrs_event_ok.sh#
}
These are the commands that've put into the commands.cfg from the gui.

Whenever i run any of the commands from the command line, i just get;

Code: Select all

[root@localhost libexec]# ./notify_otrs.sh
./notify_otrs.sh: line 12: /var/nagios/otrs.log: No such file or directory
[root@localhost libexec]# ./otrs_event_ok.sh
./otrs_event_ok.sh: line 16: /var/nagios/otrs.log: No such file or directory
[root@localhost libexec]#
So looking into the var directory I can see that log and folder doesn't exist

Code: Select all

[root@localhost libexec]# cd /var/
[root@localhost var]# ls
cache  db  empty  games  lib  local  lock  log  mail  nis  opt  preserve  run  spool  tmp  www  yp
[root@localhost var]#
So there must be a process somewhere that creates this folder, can you help me troubleshoot whats going on?

OTRS is on Centos7 and Nagios is the same, they run on seperate VM's but both on the same machine (this is just for testing and learning, so not worried about performance)

Thanks again

Re: Need help configuring Nagios/OTRS intergration

Posted: Wed Jul 13, 2016 1:10 pm
by ssax
The scripts actually just use it for logging, do this:

Code: Select all

mkdir -p /var/nagios
touch /var/nagios/otrs.log
chown -R nagios.nagios /var/nagios
Then try it again and let us know the results.

Re: Need help configuring Nagios/OTRS intergration

Posted: Wed Jul 13, 2016 1:25 pm
by nathanplatt

Code: Select all

[root@localhost libexec]# ./otrs_event_ok.sh
[root@localhost libexec]# nano /var/nagios/otrs.log
  GNU nano 2.0.9          File: /var/nagios/otrs.log

2016-07-13_15:23:17  /: State
2016-07-13_15:23:45 EVENTHANDLER /: State //
Okay so did as you said, it looks like it fills in the log file... So does that means the scripts are indeed working?

Re: Need help configuring Nagios/OTRS intergration

Posted: Wed Jul 13, 2016 1:43 pm
by ssax
The scripts AND your commands will need to be updated, let me try to get it sorted for you, it's a pretty old plugin.

Re: Need help configuring Nagios/OTRS intergration

Posted: Wed Jul 13, 2016 2:23 pm
by ssax
Replace your commands with these:
- Make sure to change [email protected] in both commands

Code: Select all

define command{
       command_name                             host-notify-otrs
       command_line                             $USER1$/eventhandlers/host_notify_otrs.sh '$NOTIFICATIONTYPE$' '$LONGDATETIME$' '$HOSTNAME$' '$HOSTSTATE$' '$HOSTADDRESS$' '$HOSTOUTPUT$' '$CONTACTEMAIL$'
}

define command {
       command_name                             host-otrs-event-ok
       command_line                             $USER1$/eventhandlers/host_otrs_event_ok.sh '$LONGDATETIME$' '$HOSTNAME$' '$HOSTSTATE$' '$HOSTATTEMPT$' '$HOSTSTATETYPE$' '$HOSTDURATION$' '$HOSTADDRESS$' '$HOSTOUTPUT$' '[email protected]'
}

define command {
       command_name                             notify-otrs
       command_line                             $USER1$/eventhandlers/notify_otrs.sh '$NOTIFICATIONTYPE$' '$LONGDATETIME$' '$HOSTNAME$' '$SERVICEDESC$' '$SERVICESTATE$' '$HOSTADDRESS$' '$SERVICEOUTPUT$' '$SERVICEDURATION$' '$CONTACTEMAIL$'
}

define command {
       command_name                             otrs-event-ok
       command_line                             $USER1$/eventhandlers/otrs_event_ok.sh '$SERVICESTATETYPE$' '$SERVICEATTEMPT$' '$LONGDATETIME$' '$HOSTNAME$' '$SERVICEDESC$' '$SERVICESTATE$' '$HOSTADDRESS$' '$SERVICEOUTPUT$' '[email protected]' '$SERVICEDURATION$'
}
Then replace your event handlers with the ones attached:
otrs_eventhandlers_updated.zip
(2.87 KiB) Downloaded 220 times
Then try it out and let us know the results.

Re: Need help configuring Nagios/OTRS intergration

Posted: Thu Jul 14, 2016 2:33 am
by nathanplatt
ssax wrote:Replace your commands with these:
- Make sure to change [email protected] in both commands

Code: Select all

define command{
       command_name                             host-notify-otrs
       command_line                             $USER1$/eventhandlers/host_notify_otrs.sh '$NOTIFICATIONTYPE$' '$LONGDATETIME$' '$HOSTNAME$' '$HOSTSTATE$' '$HOSTADDRESS$' '$HOSTOUTPUT$' '$CONTACTEMAIL$'
}

define command {
       command_name                             host-otrs-event-ok
       command_line                             $USER1$/eventhandlers/host_otrs_event_ok.sh '$LONGDATETIME$' '$HOSTNAME$' '$HOSTSTATE$' '$HOSTATTEMPT$' '$HOSTSTATETYPE$' '$HOSTDURATION$' '$HOSTADDRESS$' '$HOSTOUTPUT$' '[email protected]'
}

define command {
       command_name                             notify-otrs
       command_line                             $USER1$/eventhandlers/notify_otrs.sh '$NOTIFICATIONTYPE$' '$LONGDATETIME$' '$HOSTNAME$' '$SERVICEDESC$' '$SERVICESTATE$' '$HOSTADDRESS$' '$SERVICEOUTPUT$' '$SERVICEDURATION$' '$CONTACTEMAIL$'
}

define command {
       command_name                             otrs-event-ok
       command_line                             $USER1$/eventhandlers/otrs_event_ok.sh '$SERVICESTATETYPE$' '$SERVICEATTEMPT$' '$LONGDATETIME$' '$HOSTNAME$' '$SERVICEDESC$' '$SERVICESTATE$' '$HOSTADDRESS$' '$SERVICEOUTPUT$' '[email protected]' '$SERVICEDURATION$'
}
Then replace your event handlers with the ones attached:
otrs_eventhandlers_updated.zip
Then try it out and let us know the results.
Thanks for the hard work, i've ammended all of these and saved the config. I'm not sure if I have them linked to the dummy host correctly... I'm not seeing anything at all... re-running the commands as before is just getting the same results. I've check OTRS and its receiving emails (a few Youtube emails by mistake, but proof its working)... ideas?

Re: Need help configuring Nagios/OTRS intergration

Posted: Thu Jul 14, 2016 2:04 pm
by tgriep
We would have to see how the contact and the host / service are configured on your system but below are some examples from the plugin tgz file you could use for reference.

Code: Select all

define contact{
        contact_name                    otrs
        contactgroups			admins
        use				generic-contact
        alias                           OTRS Ticket System
        email                           otrs@localhost
        service_notification_options    a
        host_notification_options       a
        service_notification_commands   notify-otrs
        host_notification_commands      host-notify-otrs
}

Code: Select all

define service{
	service_description NagiosTestDrive
	host_name	localhost
	check_command	check_dummy!3!should not do active checks
	use		local-service
	max_check_attempts 	1
	active_checks_enabled  	0
	passive_checks_enabled 	1
	# only for testing
	flap_detection_enabled	0
	event_handler	otrs-event-ok
}

Re: Need help configuring Nagios/OTRS intergration

Posted: Fri Jul 15, 2016 2:27 am
by nathanplatt
As requested
commands.cfg
(7.25 KiB) Downloaded 417 times
contacts.cfg
(1.38 KiB) Downloaded 399 times
commands.cfg
(7.25 KiB) Downloaded 417 times
Hopefully everything is correct!