利用Rpmforge更新centos yum源快速安装nagios

http://heipark.iteye.com/blog/1190929

# 更新yum库

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

rpm -ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm

#安装nagios

yum -y install nagios nagios-nrpe nagios-plugins nagios-plugins-nrpe check_logfiles

#添加nagios到系统自动运行

chkconfig --add nagios

chkconfig nagios on

nagios相关路径:

/etc/nagios #配置文件目录:

/etc/nagios/objects #模板相关配置

/usr/bin/nagios # nagios程序

配置Apache密码访问

# nagiosadmin为用户名,配置这个用户名为省很多事

htpasswd -c /etc/nagios/htpasswd.users nagiosadmin

启动并测试

service nagios start

service httpd start

#打开浏览器,输入密码,在host里面应该有“localhost”这台机器

http://{your_ip_address}/nagios

添加被监控设备

安装(client端)

# 更新yum库

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

#安装nagios

yum -y install nagios-nrpe nagios-plugins nagios-plugins-nrpe

配置(client端)

vi /etc/nagios/nrpe.cfg

# 下列配置表示允许127.0.0.1, 192.168.121.55(Server)这两台机器访问当前机器的信息

allowed_hosts=127.0.0.1,192.168.121.55

测试(client端)

#启动nrpe (Nagios Remote Plugin Executor)

service nrpe start

chkconfig --add nrpe

chkconfig nrpe on

#查看端口是否启动

netstat -an | grep 5666

#本机测试服务是否正常

/usr/lib/nagios/plugins/check_nrpe -H 127.0.0.1 -c check_load

/usr/lib64/nagios/plugins/check_nrpe -H 127.0.0.1 -c check_load # 64 bit 命令

#服务器端测试访问是否正常。**在Server上执行**

/usr/lib/nagios/plugins/check_nrpe -H {client_ip} -c check_load

#64bit /usr/lib64/nagios/plugins/check_nrpe -H {client_ip} -c check_load

配置(Server端)

# 创建client配置(192.168.121.4为client ip)

vi /etc/nagios/objects/192.168.121.4.cfg

define host{

use linux-server

host_name client-1

alias client-1

address 192.168.121.4

}

define service{

use generic-service

host_name client-1

service_description Current Load

check_command check_nrpe!check_load

}

# 将上面配置加到系统

vi /etc/nagios/nagios.cfg

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

运行和测试(Server端)

/usr/bin/nagios -v /etc/nagios/nagios.cfg #Server端验证配置

service nagios start

FAQ:

Q: HTTP WARNING: HTTP/1.1 403Forbidden

A: nagios找不到监控文件,执行 "touch /var/www/html/index.html"

Q: 64bit下错误“Service check command 'check_nrpe' specified in service”

A: 发现commands.cfg里面居然没有“check_nrpe”这个命令定义,加上后OK

define command {

command_name check_nrpe

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

}

附录

Nagios的发音:[ˈnædʒiɔs]

参考:

CentOS下nagios报警飞信部署四步走

http://www.elain.org/?tag=nagios

Nagios/监控linux客户端

http://xiwi.org/index.php/Nagios/%E7%9B%91%E6%8E%A7linux%E5%AE%A2%E6%88%B7%E7%AB%AF

nagios详细配置

http://lilinqing.blog.51cto.com/1122687/483604

ganglia和nagios监控企业集群

http://www.ibm.com/developerworks/cn/linux/l-ganglia-nagios-1/

http://www.ibm.com/developerworks/cn/linux/l-ganglia-nagios-2/

-- end --

http://zaofei.blog.51cto.com/317566/628858

系统运维中的常用到的两大利器nagios与cacti,相信用的人不在少数,功能也很强大.不过前期环境的搭建有些麻烦,今天我们用rpmforge包更新centos的软件包源,从而可以在几分钟内搭建起一个完整可用的运维系统.

系统环境:centos 5.6(i386)

首先下载安装最新的rpmforge软件包

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

rpm -ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm

开始安装nagios

yum install nagios nagios-nrpe nagios-plugins nagios-plugins-nrpe check_logfiles

(会安装依赖包如gd,httpd,php,php-cli,php-common及一些perl组件)

设置nagios系统登录密码

htpasswd -c /etc/nagios/htpasswd.users nagiosadmin

(用户名最好设置nagiosadmin,否则会用一些权限问题)

启动apache

service httpd start

http://ip地址/nagios

输入用户名和密码,nagios的web界面已经可以访问

chkconfig --level 35 on nagios

server nagios start

上述命令启动服务和设置开机自启

接下来开始安装cacti

yum install cacti cacti-spine

(会安装依赖包如mysql,net-snmp,php-mysql,php-pdo,rrdtool等)

修改访问权限,默认为拒绝访问

vi /etc/httpd/conf.d/cacti.conf

修改allow from all

安装mysql-server

yum install mysql-server

修改mysql的root密码

/usr/bin/mysqladmin -u root password ‘new-password’

创建cacti数据库

mysqladmin --user=root -p create cacti

从cacti的sql文件中导入cacti系统表结构

cd /var/www/cacti

mysql -uroot -p cacti < cacti.sql

建立cacti数据库的使用帐号cactiuser及其密码

下面这条命令登陆数据库后执行

GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser';

更新crontab任务

*/5 * * * * cactiuser php /var/www/cacti/poller.php > /dev/null 2>&1

WEB界面配置安装

http://ip地址/cacti/install/

安装成功后登录修改密码,默认为admin,密码同