nagios - (시스템 및 네트워크 모니터링) 로컬호스트 모니터링 설정하기




    이번에는 Nagios를 이용한 로컬호스트 모니터링을 설정방법을 알아보겠습니다



    APM 설치 관련글 :


    APM 컴파일 설치방법 - http://server-talk.tistory.com/59


    APM YUM 설치방법 - http://server-talk.tistory.com/174



    관련글 :


    오픈소스 서버 모니터링 툴 - http://server-talk.tistory.com/120


    Nagios 구성파일 알아보기 - http://server-talk.tistory.com/193




    이전 글 :


    nagios - (시스템 및 네트워크 모니터링) 설치하기 - http://server-talk.tistory.com/157



    Nagios 설치를 완료하면 로컬호스트(Nagios 서버)의 기본설정은 거의 되어 있으며, 로컬호스트(Nagios 서버) 설정 파일의 대하여 알아보도록 하겠습니다.






     Nagios 로컬 호스트 설정 방법



    1. Nagios 로컬호스트 설정파일

    [root@nagios ~]# vi /usr/local/nagios/etc/nagios.cfg
    			.
    			.
    cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
    			.
    			.
    


    Nagios 웹브라우저에서 출력하게될 로컬호스트 파일은 localhost.cfg 입니다 설치시 기본으로 설정되어 있는 부분이며, 로컬호스트 설정을 변경하시려면 localhost.cfg 파일을 변경하시면 됩니다

    또한 원격지 측 모니터링을 추가시 cfg_file=[모니터링측.cfg]로 추가하시면 됩니다



    2.  Nagios 로컬호스트 모니터링하기 위한 설정

    [root@nagios ~]# vi /usr/local/nagios/etc/objects/localhost.cfg 
    ###############################################################################
    # LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
    #
    #
    # 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               localhost
            alias                   localhost
            address                 127.0.0.1
            }
    
    
    
    ###############################################################################
    ###############################################################################
    #
    # 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     ; 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                       localhost
            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                       localhost
            service_description             Root Partition
    	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 processes.
    
    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                       localhost
            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                       localhost
            service_description             HTTP
    	check_command			check_http
    	notifications_enabled		0
            }
    


    Nagios 설치완료후 기본적인 모니링의 대한 설정은 localhost.cfg의 파일의 명시되어 있으며, 모니터링 서버의 IP변경, 모니터링 서버의 서비스 추가 설정을 하시면 됩니다



    3. Nagios 로컬호스 웹페이지 모니터링



    localhost.cfg의 파일에 있는 서비스들이 웹페이지 상에서 작동중인 과정이 표시된것을 확인할 수 있습니다




    Posted by Server-talk 서버이야기