nagios 的配置總結

來源:互聯網
上載者:User

標籤:配置   nagios   總結   

所有都是yum安裝:

  1.  # vim /etc/nagios/nagios.cfg 

添加主機設定檔到主設定檔

cfg_file=/etc/nagios/objects/localhost.cfg

cfg_file=/etc/nagios/objects/172.16.1.1.cfg

2.  # vim /etc/nagios/objects/commands.cfg 

添加 check_nrpe 命令到 commands.cfg

define command{

        command_name    check_nrpe

        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

        }

3. 主機配置模版:

# cat  172.16.10.134.cfg

define host{

        use                     linux-server            

        host_name               172.16.1.1

        alias                   172.16.1.1

        address                 172.16.1.1

        }

define service{

        use                     generic-service

        host_name               172.16.1.1

        service_description     check_ping

        check_command           check_ping!100.0,20%!200.0,50%

        max_check_attempts      5

        normal_check_interval   1

        }

define service{

        use                     generic-service

        host_name               172.16.1.1

        service_description     check_ssh

        check_command           check_ssh

        max_check_attempts      5   

        normal_check_interval   1 

        notification_interval   60 

        }

define service{

        use                     generic-service

        host_name               172.16.1.1

        service_description     check_http

        check_command           check_http

        max_check_attempts      5

        normal_check_interval   1

        notification_interval   60  

}

define service{

        use                             generic-service         

        host_name                       172.16.1.1

        service_description             Root Partition

        check_command                   check_local_disk!20%!10%!/

        }

define service{

        use                             generic-service

        host_name                       172.16.1.1

        service_description             Current Users

        check_command                   check_local_users!20!50

        }

define service{

        use                             generic-service         

        host_name                       172.16.1.1

        service_description             Total Processes

        check_command                   check_local_procs!450!500!RSZDT

        }

define service{

        use                             generic-service        

        host_name                       172.16.1.1

        service_description             Current Load

        check_command                   check_local_load!5.0,4.0,3.0!10.0,6.0,4.0

        }

define service{

        use                             generic-service       

        host_name                       172.16.1.1

        service_description             Swap Usage

        check_command                   check_local_swap!20!10

        }

define service{

        use                             generic-service

        host_name                       172.16.1.1

        service_description             check_load

        check_command                   check_nrpe!check_load

        max_check_attempts              5

        normal_check_interval           1

}

define service{

        use                             generic-service

        host_name                       172.16.1.1

        service_description             check_disk_opt

        check_command                   check_nrpe!check_opt

        max_check_attempts              5

        normal_check_interval           1

}

define service{

        use                             generic-service         

        host_name                       172.16.1.1

        service_description             port 145 

        check_command                   check_tcp!145

        }


define service{

        use                             generic-service         

        host_name                       172.16.1.1

        service_description             port 110 

        check_command                   check_tcp!110

        }

define service{

        use                             generic-service

        host_name                       172.16.1.1

        service_description             port 106

        check_command                   check_tcp!106

        }

define service{

        use                             generic-service

        host_name                       172.16.1.1

        service_description             port 107

        check_command                   check_tcp!107

        }

define service{

        use                             generic-service

        host_name                       172.16.1.1

        service_description             check_mem

        check_command                   check_nrpe!check_mem

        max_check_attempts              5

        normal_check_interval           1

}

[[email protected] objects]# 


用戶端:

[root[email protected] plugins]# vim /etc/nagios/nrpe.cfg 

command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10

command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20

command[check_hda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1

command[check_opt]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/mapper/all--data-data01

command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z

command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200 

command[check_mem]=/usr/lib64/nagios/plugins/check_mem.sh -w 150 -c 100


# cat /usr/lib64/nagios/plugins/check_mem.sh

#!/bin/bash

TOTAL=`free -m | head -2 |tail -1 |gawk ‘{print $2}‘`

 

# Free memory 

 

FREE=`free -m | head -2 |tail -1 |gawk ‘{print $4}‘`

 

# to calculate free percent

 

# use the expression  free * 100 / total

 

FREETMP=`expr $FREE \* 100`

 

PERCENT=`expr $FREETMP / $TOTAL`

 

echo "$FREE MB ($PERCENT%) Free Memory"

 

exit 0


nagios 的配置總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.