您好,登錄后才能下訂單哦!
前提先自行安裝好Apache+php
測(cè)試環(huán)境
主監(jiān)控機(jī):CentOS 6.2 172.16.1.8
被監(jiān)控機(jī):CentOS 6.2 172.16.5.11
主監(jiān)控機(jī)設(shè)置:
1、安裝epel
# cat /etc/issue
CentOS release 6.2 (Final)
Kernel \r on an \m
# rpm -ivh rpm -ivh http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm 這里應(yīng)該對(duì)應(yīng)你服務(wù)器的版本
2、安裝nagios、nagios-plugin與nrpe (nagios 3.3.1版本)
# yum install nagios nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe
3、創(chuàng)建一個(gè)nagiosadmin 的用戶(hù)用于Nagios的WEB接口登錄,用戶(hù)認(rèn)證配置useradd nagiosadmin
# htpasswd -c /etc/nagios/passwd nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
4、修改cgi.cfg文件,找到use_authentication=1 這行,把1改成0
#find -name cgi.cfg -print 查找
#vi /etc/nagios/cgi.cfg
5、啟動(dòng)apache與nagios
# /etc/init.d/httpd restart
# /etc/init.d/nagios start
6、登陸http://localhost/nagios/,輸入用戶(hù)密碼后查看是否正常運(yùn)行
注:別忘記了nagios后面那個(gè)/
被監(jiān)控機(jī)設(shè)置:
1、安裝需要軟件
# yum install nagios-plugins nagios-plugins-nrpe nrpe
2、配置nrpe
# vi /etc/nagios/nrpe.cfg 修改監(jiān)控機(jī)的地址或域名
allowed_hosts=127.0.0.1,192.168.1.8
3、修改/etc/hosts.allow增加監(jiān)控機(jī)ip
# echo ‘nrpe:192.168.1.8′ >> /etc/hosts.allow
4、檢查 NRPE 是否正常:
監(jiān)控機(jī)上:
# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.5.11
NRPE v2.12
查看相應(yīng)的端口:netstat -an |grep 5666
防火墻開(kāi)啟5666 允許局域網(wǎng)IP或固定IP連接
5、啟動(dòng) NRPE 守護(hù)進(jìn)程:
# /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg –d 或者
#/etc/init.d/nrpe start
6、關(guān)閉selinux:
#setenforce 0
在回到監(jiān)控機(jī):
添加nrpe的定義
# vi commands.cfg
# ‘check_nrpe’ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
增加主機(jī)監(jiān)控配置項(xiàng)www.cfg
- ###### define hosts ###################################
- define host {
- host_name cancer-ts4
- address 172.16.5.4
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-ts11
- address 172.16.5.11
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-ts12
- address 172.16.5.12
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-hz4
- address 172.16.3.4
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-hz5
- address 172.16.3.5
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-hz12
- address 172.16.3.12
- check_command check-host-alive
- check_interval 5
- max_check_attempts 2
- contact_groups admins
- }
- define host {
- host_name cancer-hz13
- address 172.16.3.13
- check_command check-host-alive
- check_interval 1
- max_check_attempts 2
- contact_groups admins
- }
- ######## define service ######################
- define service{
- host_name cancer-ts4,cancer-ts11,cancer-ts12,cancer-hz4,cancer-hz5,cancer-hz12,cancer-hz13
- service_description Users
- check_period 24x7
- normal_check_interval 5
- retry_check_interval 2
- max_check_attempts 5
- notification_period 24x7
- contact_groups admins
- check_command check_nrpe!check_users
- }
- define service{
- host_name cancer-ts4,cancer-ts11,cancer-ts12,cancer-hz4,cancer-hz5,cancer-hz12,cancer-hz13
- service_description Load
- check_period 24x7
- normal_check_interval 5
- retry_check_interval 2
- max_check_attempts 5
- notification_period 24x7
- contact_groups admins
- check_command check_nrpe!check_load
- }
- define service{
- host_name cancer-ts4,cancer-ts11,cancer-ts12,cancer-hz4,cancer-hz5,cancer-hz12,cancer-hz13
- service_description disk
- check_period 24x7
- normal_check_interval 5
- retry_check_interval 2
- max_check_attempts 5
- notification_period 24x7
- contact_groups admins
- check_command check_nrpe!check_hda1
- }
- define service{
- host_name cancer-ts11,cancer-ts12,cancer-ts4,cancer-hz4,cancer-hz5,cancer-hz13,cancer-hz12
- service_description nginx
- check_period 24x7
- normal_check_interval 5
- retry_check_interval 2
- max_check_attempts 5
- notification_period 24x7
- contact_groups admins
- check_command check_nrpe!check_nginx
- }
并把www.cfg添加到nagios主配置項(xiàng)
# echo “cfg_file=/etc/nagios/objects/www.cfg” >> /etc/nagios/nagios.cfg
其他機(jī)器如法炮制即可
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。