CentOS 6.4上通过yum安装Nagios-3.5.0

来源:互联网 发布:c程序员面试宝典 pdf 编辑:程序博客网 时间:2024/05/22 15:42
原文见:http://sharadchhetri.com/2013/05/19/installing-nagios-3-5-0-in-centos-6-4-using-yum/
#安装:
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum install nagios nagios-devel nagios-plugins* gd gd-devel httpd php gcc glibc glibc-common openssl
#设置密码, 默认用户名和密码都是nagiosadmin
htpasswd -c /etc/nagios/passwd nagiosadmin #回车然后输入密码
#检查以下配置是否一样:vi /etc/nagios/cgi.cfg
=============================
    # AUTHENTICATION USAGE
    use_authentication=1
    # SYSTEM/PROCESS INFORMATION ACCESS
    authorized_for_system_information=nagiosadmin
    # CONFIGURATION INFORMATION ACCESS
    authorized_for_configuration_information=nagiosadmin
    # SYSTEM/PROCESS COMMAND ACCESS
    authorized_for_system_commands=nagiosadmin
    # GLOBAL HOST/SERVICE VIEW ACCESS
    authorized_for_all_services=nagiosadmin
    authorized_for_all_hosts=nagiosadmin
    # GLOBAL HOST/SERVICE COMMAND ACCESS
    authorized_for_all_service_commands=nagiosadmin
    authorized_for_all_host_commands=nagiosadmin
#========================================
#设置开机自启动:
chkconfig --level 3 nagios on
chkconfig --level 3 httpd on
#启动:
/etc/init.d/httpd start
/etc/init.d/nagios start
#注意SELINUX和IPTABLE 以及你的80端口是否被占用

安装完成,http://ip/nagios 就能看到效果

下面配置要管理的节点:

#新建这个文件,里面添加要监控的机器
#vi /etc/nagios/conf.d/hosts.cfg
#===================
define host{
use linux-server
host_name mysql-node01
alias mysql-node01
address 192.168.1.110  #这个IP是我mysql机器所的IP
}
#=================
#添加被监控机器需要被监控那些项目 
#vi /etc/nagios/conf.d/services.cfg
#===========================
define service{
use generic-service
host_name mysql-node01
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service
host_name mysql-node01
service_description Current Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name mysql-node01
service_description Total Processes
check_command check_nrpe!check_users
}
#===========================
#这里对mysql那台机器进行了3项监控: ping load totalProcesses
#其中ping没用到nrpe
#在末尾为nrpe添加命令
#vi /etc/nagios/objects/commands.cfg
#===========================
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
#===========================
#各种重启
/etc/init.d/nagios restart
/etc/init.d/nrpe restart
/etc/init.d/httpd restart

注意iptables,服务端和客户端均需要5666端口能被互相访问

参考此文配置客户端:

原文见:http://sharadchhetri.com/2013/03/02/how-to-install-and-configure-nagios-nrpe-in-centos-and-red-hat/

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#安装nrpe
rpm -ivh dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
 
yuminstall-y nrpe nagios-plugins-all openssl
 
#修改配置文件,先备份是好习惯
vi/etc/nagios/nrpe.cfg
#找到allowed_hosts=127.0.0.1,在后面加上server端的IP,这样server端才能监控这台机器,比如我加的:
allowed_hosts=127.0.0.1,192.168.1.103
 
#开机自启
chkconfig --level 3 on
 
#启动
/etc/init.d/nrpestart

配置完后,刷新nagios页面,就能看到mysql-node01了

0 0