Monitoring System Dengan Nagios jilid 3

Artikel sebelumnya adalah : Bagaimana cara installasi  nagios pada OpenSUSE / SLES dan Konfigurasi Nagios pada OpenSUSE / SLES

Menambahkan host yang akan di monitoring

Pada konfigurasi default, nagios hanya memonitor sebuah host  yaitu localhost. Tentunya kita akan memonitor juga host lainnya. Untuk memonitor host lainnya anda harus membuat file konfigurasi monitoring host tersebut. sebagai contoh saya akan memonitor email server

1. Salin file konfigurasi untuk monitoring host localhost

cp /opt/nagios/etc/objects/localhost.cfg /opt/nagios/etc/objects/email.cfg

2. Kemudian edit dan sesuaikan konfigurasi yang Anda iniginkan untuk email.cfg, apa saja service yang akan Anda monitoring, contoh saya akan memonitoring email server dengan ip address 10.88.1.2, service yang akan dimonitoring adalah ping, ssh,smtp,imap,pop dan http.

vi /opt/nagios/etc/objects/email.cfg
Konfigurasi:
[global]

###############################################################################
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
#
# Last Modified: 05-31-2007
#
# NOTE: This config file is intended to serve as an *extremely* simple
#       example of how you can create configuration entries to monitor
#       the local (Linux) machine.
#
###############################################################################

###############################################################################
###############################################################################
#
# HOST DEFINITION
#
###############################################################################
###############################################################################

# Define a host for the local machine

define host{
use                     linux-server            ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name               email
alias                   email-server
address                 10.88.1.2
}

###############################################################################
###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################
###############################################################################

# Define an optional hostgroup for Linux machines
#
#define hostgroup{
#        hostgroup_name  linux-servers ; The name of the hostgroup
#       alias           Linux Servers ; Long name of the group
#       members         localhost, file-server     ; Comma separated list of hosts that belong to this group
#        }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Define a service to "ping" the local machine

define service{
use                             local-service         ; Name of service template to use
host_name                       email
service_description             PING
check_command            check_ping!100.0,20%!500.0,60%
}

# Define a service to check the disk space of the root partition
# on the local machine.  Warning if < 20% free, critical if
# < 10% free space on partition.

#define service{
#        use                             local-service         ; Name of service template to use
#        host_name                       file-server
#        service_description
#    check_command            check_local_disk!20%!10%!/
#        }

# Define a service to check the number of currently logged in
# users on the local machine.  Warning if > 20 users, critical
# if > 50 users.

#define service{
#        use                             local-service         ; Name of service template to use
#        host_name                       localhost
#        service_description             Current Users
#    check_command            check_local_users!20!50
#       }

# Define a service to check the number of currently running procs
# on the local machine.  Warning if > 250 processes, critical if
# > 400 users.

#define service{
#        use                             local-service         ; Name of service template to use
#        host_name                       localhost
#        service_description             Total Processes
#    check_command            check_local_procs!250!400!RSZDT
#        }

# Define a service to check the load on the local machine.

#define service{
#        use                             local-service         ; Name of service template to use
#        host_name                       localhost
#        service_description             Current Load
#    check_command            check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
#        }

# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free

#define service{
#        use                             local-service         ; Name of service template to use
#        host_name                       localhost
#        service_description             Swap Usage
#    check_command            check_local_swap!20!10
#        }

# Define a service to check SSH on the local machine.
# Disable notifications for this service by default, as not all users may have SSH enabled.

define service{
use                             local-service         ; Name of service template to use
host_name                       email
service_description             SSH
check_command            check_ssh
notifications_enabled        0
}

# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.

define service{
use                             local-service         ; Name of service template to use
host_name                       email
service_description             HTTP
check_command            check_http
notifications_enabled        0
}

define service{
use                             local-service         ; Name of service template to use
host_name                       email
service_description             SMTP
check_command            check_smtp
notifications_enabled        0
}
define service{
use                             local-service         ; Name of service template to use
host_name                       email
service_description             imap
check_command            check_imap
notifications_enabled        0
}

define service{
use                             local-service         ; Name of service template to use
host_name                       email
service_description             pop
check_command            check_pop
notifications_enabled        0
}

3. Edit file /opt/nagios/etc/nagios.cfg untuk menambahkan entri konfigurasi host email server yang akan di monitor

vi /opt/nagios/etc/nagios.cfg
# Definitions for monitoring the local (Linux) host
 
cfg_file=/opt/nagios/etc/objects/localhost.cfg
 
cfg_file=/opt/nagios/etc/objects/email.cfg

4. menambahkan email-server sebagai member dari hostgroup linux­server

vi /opt/nagios/etc/objects/localhost.cfg
# Define an optional hostgroup for Linux machines
#
define hostgroup{
        hostgroup_name  linux-servers ; The name of the hostgroup
       alias           Linux Servers ; Long name of the group
       members         localhost,email     ; Comma separated list of hosts that belong to this group
        }

5. Check apakah ada error dalam file hasil configurasi atau tidak

/opt/nagios/bin/nagios -v /opt/nagios/etc/nagios.cfg

6. Restart Nagios

service nagios restart
atau
/etc/init.d/nagios restart

7. Buka nagios pada web browser dan klik menu Hosts,Services, Host Groups

Catatan : Untuk menambahkan host lainnya yang akan dimonitor dapat melakukan hal yang sama dengan mengkopi file localhost.cfg, checking system apa saja yang bisa di monitor dapat dilihat pada folder /opt/nagios/libexec

Silakan dicoba dan semoga bermanfaat :-D

Pin It

7 thoughts on “Monitoring System Dengan Nagios jilid 3

  1. Pingback: Monitoring System Dengan Nagios jilid 2 | Migrasi Windows Linux

  2. sudah setahun lebih saya pakai nagios tapi gak tahu bisa gak nagios untuk monitoring koneksi IP camera?

    thx

  3. mas Ahmad…saya sudah coba untuk menjalani nagios ini tapi masih ada yang ga bisa terbuka nih yaitu status mapnya….apa mungkin karena settingan httpd.conf nya kah ?? thx sharingnya

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>