Nagios for VoIP
In this post I will try to provide step-by-step instruction for installing and configuring Nagios on Debian 8 for monitoring any VoIP end-point,
I will use Freeswitch(10.10.10.10:5060) with default config from my previous manual as destination host which we will monitor. All below steps should be executed on Nagios
server by root
user, I’m assuming VoIP endpoint is ready.
1) We will need to install LAMP:
2) Add user Nagios:
3) Install required packages:
4) Install Nagios Core:
5) Add user web server, www-data, to the nagcmd group
6) Install Nagios Plugins
7) Now find an uncomment this line, by removing #
:
#cfg_dir=/usr/local/nagios/etc/servers
in /usr/local/nagios/etc/nagios.cfg
8) Now we need to create directory where will store our configuration files of endpoints which we will monitor
9) Let’s create config file for our Freeswitch, which we will monitor: nano /usr/local/nagios/etc/servers/freeswitch.cfg
10) Now let’s edit file /usr/local/nagios/etc/objects/contacts.cfg
and find the email directive, and replace its value with your own email address:
11) Enable the Apache rewrite and cgi modules:
12) Use htpasswd to create an admin user, called “nagiosadmin”, that can access the Nagios web interface, enter password when prompted.
13) Now create a symbolic link of nagios.conf to the sites-enabled directory:
14) This point is optional. Here we will disable monitoring of Nagios server itself, I don’t like such info, cause I just need to know what is happening with my VoIP endpoint, but not with Nagios server, on other hand sometimes it useful to see some additional info regarding your Nagios server, for example when you are running out of space.
To switch off monitoring itself you need to edit /usr/local/nagios/etc/nagios.cfg
file and comment out this line: cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
15) On this point we are almost ready with our Nagios set-up, now we need to configure command or agent which will send OPTIONS request to our VoIP end-point. I will use this beautiful software: https://github.com/ibc/nagios-sip-plugin but you can use any other, like sipp or your own.
16) Now we need to add service description, please edit /usr/local/nagios/etc/objects/commands.cfg
and add following under check_ping:
17) Now let’s restart nagios and apache, additionally we will make sure that nagios will start after reboot.
18) To send notifications you will need mail application, run following commands to install it:
19) This point is optional, if you are using Digitalocean or any other VPS which do not allow to sends e-mails directly from server. We will use gmail account. First lets install ssmtp:
20) Now you need to edit /etc/ssmtp/ssmtp.conf
and uncomment FromLineOverride=YES
. At the end of file you will need to add following:
21) Now you need to allow to access to your account for less secure apps: http://www.google.com/settings/security/lesssecureapps
22) This point is optional, you might need to unlock captcha: https://accounts.google.com/b/0/DisplayUnlockCaptcha
23) Now you might try to send e-mail:
24) If you will receive e-mail this means that your set-up is ready and you can try to login to: http://YOUR_IP/nagios and use nagiosadmin and password which you created at point 12. Go to Services and you will see similar to this page: