In this tutorial you will learn about adding sound alert to Nagios Core. Nagios is a monitoring system that can help you to predict problems on your servers, switches, applications and services.
Step 1: Install dependencies
Install required packages.
yum install alsa alsa-base alsa-utils -y
Step 2: Configure commands.cfg
Edit the commands.cfg then add the command for sound alert script.
vi /usr/local/nagios/etc/objects/commands.cfg
define command {
command_name play_siren
command_line /bin/bash /usr/local/nagios/
etc/objects/play_siren.sh
}
[Esc] :wq – to save it then quit
Step 3: Create a script for the sound alert
Put the .wav file into /usr/local/nagios/share/media
vi /usr/local/nagios/etc/objects/play_siren.sh
# !/bin/bash
/usr/bin/aplay -q /usr/local/share/nagios/share/
media/siren.wav
[Esc] :wq
Set the ownership of the file to nagios.
chown nagios.nagios /usr/local/nagios/etc
/objects/play_siren.sh
cd /usr/local/nagios/etc/objects
chmod a+x play_siren.sh
Step 4: Configure contacts.cfg
Edit the contacts.cfg and add play_siren as notification commands under the nagiosadmin.
vi contacts.cfg
service_notification_options w,u,c,r,s,f
host_notification_options d,u,r,f,s
service_notification_commands play_siren
host_notification_commands play_siren
[Esc] :wq
Add the contact group for each services and into
the host in localhost.cfg.
vi localhost.cfg
contact_groups admins
Last uncomment and edit in cgi.cfg and change the .wav file to desired file to use.
vi /usr/local/nagios/etc/cgi.cfg
host_unreachable_sound=alert.wav
host_down_sound=alert.wav
service_critical_sound=alert.wav
service_warning_sound=alert.wav
service_unknown_sound=alert.wav
[Esc] :wq
Restart apache and nagios.
service httpd restart
service nagios restart
No comments:
Post a Comment