Lately we have been asked by lot of customers about how they can monitor their asterisk server. Follow these simple steps to monitor asterisk or freeswitch server. Actually you can monitor any SIP Server with these steps. We strongly suggest running this on a server other that Asterisk or freeswitch.
Install Nagios Core : Download latest source from

./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-group=nagios
make; make install

Install nagios plugins

./configure –prefix=/usr/local/nagios/
make; make install

Download the check_sip file from*-VoIP/SIP/check_sip/details

cd /usr/local/nagios/libexec/

To make sure if this works fine, run this command.
./check_sip -u sip:102@asterisk_ip -H asterisk_ip
Output will be like this
SIP/2.0 200 OK 0.001121 seconds response time|’rtt’=0.001121s;0.5s;1s;0:10;

Configure Nagios

cd /usr/local/nagios/etc/objects
Create a new command, add the below code to command.cfg
define command{
command_name   check_sip
command_line   $USER1$/check_sip -u $ARG1$@$HOSTADDRESS$ -H $HOSTADDRESS$

Remember the name check_sip, we will use this name later to configure the service.

Add asterisk/freeswitch host to monitor.
cd /usr/local/nagios/etc/objects/hosts/linuxservers
Linux servers is the directory I created, you can name it anything you want.


vi asteriskservers.cfg

define host{
use                     production-host
host_name               ast1
alias                   Asterisk_server1
cd /usr/local/nagios/etc/objects/services/linuxservices

vi sip-services.cfg

define service{
use                             production-master-service
host_name                       ast1
service_description             SIP_Service_Check
check_command                   check_sip!sip:102

Here is my production-master-service template.

From file /usr/local/nagios/etc/objects/template.cfg
define service{

name                           production-master-service
is_volatile                     0
initial_state                   o
max_check_attempts             2
check_interval                 3
retry_interval                 1
active_checks_enabled           1
passive_checks_enabled         1
check_period                   24×7
obsess_over_service             0
check_freshness                 0
freshness_threshold             30
event_handler                   process-service-perfdata
event_handler_enabled           1
flap_detection_enabled         0
process_perf_data               1
retain_status_information       1
retain_nonstatus_information   1
notification_interval           3
first_notification_delay       0
notification_period             24×7
notification_options           w,u,c,r,s
notifications_enabled           1
contact_groups                 on-call
contacts                       nagios-warnings
notes                           $SERVICECHECKCOMMAND$
register                       0


102 can be anything that your asterisk/freeswitch can respond to. Username or DID Number. Reload Nagios and have happy sleep. Nagios will wake you up before your customers. Send emails to a special email address where you add a filter on your phone to make some sound.