Centos 环境下,安装部署nagios监控
运维技术交流群:30733661,欢迎各位朋友加入。
系统环境:centos6.2_X86_64
一:应用组件
Apache自带rpm包,
二:监控端部署
1:配置yum本地源
mkdir -p /data/Centos/X64
mount -o loop /home/CentOS-6.2-x86_64-bin-DVD1.iso /mnt
cp -rf /mnt/Packages/ /data/Centos/X64/
cp -rf /mnt/repodata/ /data/Centos/X64/Packages/
cd /mnt/Packages/
rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
createrepo -g /mnt/repodata/repomd.xml /data/Centos/X64
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
cd /etc/yum.repos.d/
cp CentOS-Base.repo CentOS-Base.repobak
vim CentOS-Base.repo
[base]
name=centos
baseurl=file:///data/Centos/X64/
enable=1
gpgcheck=1
yum clean all
yum list availabel
yum install gcc*
yum install glibc*
umount /mnt ; rm -f /home/CentOS-6.2-x86_64-bin-DVD1.iso
2::apche的安装:
rpm -qa|grep gd
rpm -qa|grep gd-devel
安装gd库
#yum install gd*
建立nagios用户
useradd nagios -s /sbin/nologin
useradd apache -s /sbin/nologin
id nagios
passwd nagios
id apache
usermod -a -G nagios apache
#vim /etc/passwd 修改登录nagios
nagios:x:500:500::/home/nagios:/sbin/nologin修改为
nagios:x:500:500::/home/nagios:/bin/bash
#yum install http*
# vim /etc/httpd/conf/httpd.conf
添加、修改以下内容
User apache
Group apache
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php
启动apache
# service httpd start
# ps aux|grep httpd
修改完后启动apache,在浏览器中输入http://服务器地址/index.php出现下图表示工作正常。
2:nagios的安装
[root@localhost ~]# vim /etc/httpd/conf.d/nagios.conf
创建用户登录帐号
[root@localhost ~]# service httpd restart
Nagios插件安装
[root@localhost nagios-plugins-1.4.15]# cd /usr/local/nagios/libexec/
[root@localhost libexec]# ls
[root@localhost libexec]# chkconfig --add nagios
[root@localhost libexec]# chkconfig nagios on
检查下配置文件是否有问题
[root@localhost libexec]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
启动nagios
#service nagios start
在ie浏览器输入路径
输入创建的nagiosadmin帐号密码
启动查看nrpe
3:配置
1》.commands.cfg定义外部构件nrpe
#vi /usr/local/nagios/etc/objects/commands.cfg
#添加
#check nrpe
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
2》.配置要监控的linux主机
#vi /usr/local/nagios/etc/nagios.cfg
#中间添加
cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg
3》.新建mylinux.cfg 设置监控内容
#vi /usr/local/nagios/etc/objects/mylinux.cfg
define host{
use linux-server
host_name mylinux
alias mylinux
address 192.168.0.21(???IP?????IP)
}
define service{
use generic-service
host_name mylinux
service_description check-swap
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name mylinux
service_description check-load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name mylinux
service_description check-disk
check_command check_nrpe!check_had1
define service{
use generic-service
host_name mylinux
service_description check-users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name mylinux
service_description otal_procs
check_command check_nrpe!check_total_proc
三:被监控端部署
四:测试
五:指标阀值设定
六:故障记录
1:监控resion的脚本
http://blog.csdn.net/xingfujie/article/details/7469286
2:一篇还可以的使用文档说明