Page 3 of 4
Re: System Monitoring OTRS/NAGIOS
Posted: Wed Jan 20, 2016 5:59 pm
by rkennedy
Ah, happens to the best of us once and a while!
This plugin really should of had instructions..
Where is mail compiled on your system? You might need to change the path in all of the bash scripts.
Code: Select all
/usr/bin/mail -s "** Event - $NAGIOS_HOSTNAME is $NAGIOS_HOSTSTATE **" $OTRS_EMAIL
I also noticed this line at the top of
host_otrs_event_ok.sh-
Code: Select all
if [ -z "$OTRS_EMAIL" ]; then
OTRS_EMAIL=otrs@localhost
fi
Which I assume you will need to set to your OTRS email.
Re: System Monitoring OTRS/NAGIOS
Posted: Thu Jan 21, 2016 12:32 am
by nathanplatt
I've not configured mail on this system as it was just for a sake of quick test, i was hoping that the system was using a pass thru rather than an email setup. Rather than using an external email can i setup linux as its own mailserver (something I've never done before?)
Re: System Monitoring OTRS/NAGIOS
Posted: Thu Jan 21, 2016 10:09 am
by rkennedy
Your system should have something built in already to send mail out on your Core machine. Is your OTRS fully setup with an email?
Re: System Monitoring OTRS/NAGIOS
Posted: Thu Jan 21, 2016 11:01 am
by nathanplatt
Haven't configured it yet, i'm on ubuntu 14.04 server edition
Re: System Monitoring OTRS/NAGIOS
Posted: Thu Jan 21, 2016 1:01 pm
by rkennedy
Ah, I understand. I would recommend getting your OTRS environment setup and then come to us with any further questions you have on the Nagios part of it.
Re: System Monitoring OTRS/NAGIOS
Posted: Fri Jan 22, 2016 7:25 am
by nathanplatt
Right back in the office, have copied what we learned from the home system to the work one, and no luck. Here's what i now know;
Code: Select all
root@nagios:/usr/local/nagios/libexec/eventhandlers# tail /usr/local/nagios/var/nagios.log
[1453464305] EXTERNAL COMMAND: SCHEDULE_FORCED_HOST_CHECK;IT;1453464304
[1453464309] HOST ALERT: IT;UP;HARD;10;PING OK - Packet loss = 0%, RTA = 0.89 ms
[1453464328] SERVICE ALERT: IT;Toner Supply;OK;HARD;3;TK-3100 is at 6% - OK! Waste Toner Box is OK!
[1453464328] SERVICE FLAPPING ALERT: IT;Toner Supply;STARTED; Service appears to have started flapping (23.8% change >= 20.0% threshold)
[1453464328] SERVICE EVENT HANDLER: IT;Toner Supply;OK;HARD;3;otrs-event-ok
[1453464395] HOST ALERT: TS7-V;DOWN;SOFT;1;PING CRITICAL - Packet loss = 100%
[1453464400] HOST ALERT: TS7-V;UP;SOFT;2;PING OK - Packet loss = 0%, RTA = 24.56 ms
[1453464934] SERVICE ALERT: IT;Toner Supply;WARNING;SOFT;1;WARNING: No SNMP response from 192.168.1.199! Make sure host is up and SNMP is configured properly.
[1453464934] SERVICE EVENT HANDLER: IT;Toner Supply;WARNING;SOFT;1;otrs-event-ok
[1453464943] HOST ALERT: IT;DOWN;SOFT;1;PING CRITICAL - Packet loss = 100%
root@nagios:/usr/local/nagios/libexec/eventhandlers#
You can see the event is being handled now, I modified the sh as follows;
Code: Select all
#!/bin/bash
# ---
# $Id: host_otrs_event_ok.sh 6 2008-09-08 14:13:52Z wob $
# ---
if [ -z "$WEBSERVER" ]; then
WEBSERVER=`hostname -f`
fi
if [ -z "$OTRS_EMAIL" ]; then
[email protected]
fi
LOGFILE=/var/nagios/otrs.log
DATUM=`date "+%Y-%m-%d_%H:%M:%S"`
echo "$DATUM EVENTHANDLER $NAGIOS_HOSTNAME: State $NAGIOS_HOSTSTATE/$NAGIOS_HOSTSTATETYPE/$NAGIOS_HOSTATTEMPT" >> $$
case "$NAGIOS_HOSTSTATE" in
OK)
I tested my email into OTRS and it works from OUTLOOK. Also that script says it keeps a log in var/ but when i check;
root@nagios:/usr/local/nagios/var# ls
archives nagios.lock nagios.tmpylkeD6 objects.precache rw status.dat
nagios.configtest nagios.log objects.cache retention.dat spool
root@nagios:/usr/local/nagios/var#
Any more ideas?
Re: System Monitoring OTRS/NAGIOS
Posted: Fri Jan 22, 2016 8:35 am
by nathanplatt
I've found this page about the subject but it looks a little out of date, it does seem to confirm the command part thou;
http://lists.otrs.org/pipermail/dev/200 ... 00883.html
Installation Instructions:
A Configuration of the Nagios Server
------------------------------------
1) copy the script otrs_ticket_handler.pl to (e.g.) /usr/lib/nagios/ and make this script executable for the nagios-user
2) define commands that are used for notifications to OTRS (e.g. in /etc/nagios/misccommands.cfg)
# for service notifications
define command{
command_name notify-by-email_otrs
command_line /usr/lib/nagios/otrs_ticket_handler.pl -T s -H $HOSTNAME$ -S '$SERVICEDESC$' -s '$SERVICESTATE$' -N '$NOTIFICATIONTYPE$' -n '$NOTIFICATIONNUMBER$' -o '$OUTPUT$' -C '$CONTACTALIAS$' -a '$HOSTADDRESS$'
}
# for host notifications
define command{
command_name host-notify-by-email_otrs
command_line /usr/lib/nagios/otrs_ticket_handler.pl -T h -H $HOSTNAME$ -S '__' -s '$HOSTSTATE$' -N '$NOTIFICATIONTYPE$'-n '$NOTIFICATIONNUMBER$' -o '$OUTPUT$' -C '$CONTACTALIAS$' -a '$HOSTADDRESS$'
}
3) Define a contact (or several contacts) for OTRS notifications (e.g. in /etc/nagios/contacts.cfg)
# alias must be the otrs-queue where the notifications for this contact should go to!!
# 'OTRS' contact definition
define contact {
contact_name OTRS
alias my_nagios_queue
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r,w,u
host_notification_options d,u,r
service_notification_commands notify-by-email_otrs
host_notification_commands host-notify-by-email_otrs
email dummy at email.address
}
4) Configure the otrs_ticket_handler.pl script (look at the comments in the script)
5) Allow the NAGIOS server to execute the NagiosGenericAgengt.pl script on the OTRS host:
- create a ssh key pair for the nagios user (e.g. with ssh-keygen)
- add the public key to the ~/.ssh/authorized_keys file of the otrs user on the OTRS host. (if it's not the create the directory and create the authorized_keys file)
Re: System Monitoring OTRS/NAGIOS
Posted: Fri Jan 22, 2016 10:36 am
by rkennedy
You may need to modify the log file directory, as seen in the script you posted - it's logging to /var/nagios/otrs.log, not /usr/local/nagios/var. Make sure the directories exist, and check permissions.
Can you run through those official instructions, and make sure you're executing it as it says?
One thing that I don't believe is setup is -
5) Allow the NAGIOS server to execute the NagiosGenericAgengt.pl script on the OTRS host:
- create a ssh key pair for the nagios user (e.g. with ssh-keygen)
- add the public key to the ~/.ssh/authorized_keys file of the otrs user on the OTRS host. (if it's not the create the directory and create the authorized_keys file)
Re: System Monitoring OTRS/NAGIOS
Posted: Fri Jan 22, 2016 11:49 am
by nathanplatt
Code: Select all
# 'host-notify-otrs' command definition
define command{
command_name host-notify-otrs
command_line $USER1$/eventhandlers/host_notify_otrs.sh -T s -H $HOSTNAME$ -S '$SERVICEDESC$' -s '$SERVICESTATE$' -N '$NOTIFICATIONTYPE$'$
}
# 'host-otrs-event-ok' command definition
define command{
command_name host-otrs-event-ok
command_line $USER1$/eventhandlers/host_otrs_event_ok.sh -T s -H $HOSTNAME$ -S '$SERVICEDESC$' -s '$SERVICESTATE$' -N '$NOTIFICATIONTYPE$
}
# 'notify-otrs' command definition
define command{
command_name notify-otrs
command_line $USER1$/eventhandlers/notify_otrs.sh
}
# 'otrs-event-ok' command definition
define command{
command_name otrs-event-ok
command_line $USER1$/eventhandlers/otrs_event_ok.sh
}
So i've added these into the commands.cfg but wasn't sure where i need to add which ones? I shouldn't need to do 5 as its on the same server. What do you think, configured those correctly?
Re: System Monitoring OTRS/NAGIOS
Posted: Fri Jan 22, 2016 12:06 pm
by rkennedy
To clarify, I just looked over those instructions and I believe that's a separate script entirely (otrs_ticket_handler.pl). The package that you originally started on is with bash scripts.
Those 4 should be fine for your commands.cfg.