nagios:using check_http to monitor the url

here is a sample  to monitor the specific http url address in nagios conf file.

you can use the direct cmd to test if it works under shell

[root@cent libexec]# ./check_http -u /accounts/login/ -H 121.xx.10.xx
HTTP OK: HTTP/1.1 200 OK - 9555 bytes in 0.055 second response time |time=0.054723s;;;0.000000 size=9555B;;;0

that means that your cmd works well and detect the http service and feedback 200 ok.

edit the cfg file to add a config section

define service{
use                                     local-service
host_name                               seafile
service_description                     web http service for seafile portal login page
check_command check_http! -H 12x.xx.160.xx -u /accounts/login/
notifications_enabled                   1


nagios mail notify

There are lots of services monitor in your nagios,what if the service is down?
The most important issue is that the admin should be notified by the first time,email is great tool on it.

edit the contact.cfg file to tell the nagios who is the admin to receieve all the mail

# template which is defined elsewhere.

define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (de
fined above)
        alias                           Nagios Admin            ; Full name of user

        email                   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******


nothing need to be changed in the commands.cfg,the sample is marked below:

# 'notify-host-by-email' command definition
define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME
$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTI

# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SER
VICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Inf

3.using the sendmail in linux to sending mail

vi the /etc/mail.rc which is the config file of sendmail

# add by admin

set smtp-auth-password=pwd_email_account smtp-auth=login
enable the function of mail notification by add option “notifications_enabled 1”

# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service
        host_name               COS360,PRINTER_SRV_BJ,MENJIN,VM_BJ
        service_description     C:\ Drive Space
        check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c 90
        notifications_enabled   1

//add  notifications_enabled in services will open the notification


bring down one of the service,you will get the email notification



you can use nagios to monitor your infrastructure of basic IT resources.

you should first define a host to be monitored then use the define service to do the action,it’s the OO thinking mind.

taking the NT platform as a example,install the NSClient++ plugin as agent to the hosts you want to monitor.

define host{
        use             windows-server  ; Inherit default values from a template
        host_name       host1  ; The name we're giving to this host
        alias           COS Security Server     ; A longer name associated with the host
        address   ; IP address of the host

define service{
        use                     generic-service
        host_name               host1
        service_description     NSClient++ Version
        check_command           check_nt!CLIENTVERSION


check_command is the bin action of monitoring the resource,there are lots of monitor action in $nagios/bin and you add