目录:
一、Nagios安装
二、Nagios配置
系统信息:Centos5.8X86 需要预先安装好apapche服务和PHP环境
软件信息:
nagios-3.5.0.tar.gz
nagios-plugins-1.4.16.tar.gz
sendmail-8.13.8-8.el5
一、Nagios安装
1. 安装Nagios
-
[root@cacti-nagios ~]# wget http://softlayer-ams.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz
-
[root@cacti-nagios ~]# tar -zxvf nagios-3.5.0.tar.gz
-
[root@cacti-nagios ~]# cd nagios
-
[root@cacti-nagios nagios]# ./configure --prefix=/usr/local/nagios
-
[root@cacti-nagios nagios]# useradd nagios -s /bin/false
-
[root@cacti-nagios nagios]# make all
-
[root@cacti-nagios nagios]# make install
-
[root@cacti-nagios nagios]# make install-init
-
[root@cacti-nagios nagios]# make install-commandmode
-
[root@cacti-nagios nagios]# make install-config
-
[root@cacti-nagios nagios]# make install-webconf
-
[root@cacti-nagios nagios]# grep AuthUserFile /etc/httpd/conf.d/nagios.conf
-
AuthUserFile /usr/local/nagios/etc/htpasswd.users
-
[root@cacti-nagios nagios]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
-
New password: 123456
-
Re-type new password: 123456
-
Adding password for user nagios
-
[root@cacti-nagios nagios]# cat /usr/local/nagios/etc/htpasswd.users
-
nagios:FPuu/F25jQpac
2. 安装Nagios插件
-
root@cacti-nagios ~]# wget http://nagios-plugins.org/download/nagios-plugins-1.4.16.tar.gz
-
[root@cacti-nagios ~]# tar -zxvf nagios-plugins-1.4.16.tar.gz
-
[root@cacti-nagios ~]# cd nagios-plugins-1.4.16
-
[root@cacti-nagios nagios-plugins-1.4.16]# ./configure --prefix=/usr/local/nagios/
-
[root@cacti-nagios nagios-plugins-1.4.16]# make
-
[root@cacti-nagios nagios-plugins-1.4.16]# make install
-
[root@cacti-nagios ~]# /etc/init.d/httpd restart
3. 通过浏览器访问nagios
可以访问页面,但是点击内页时会有报错:Error: Could not read object configuration data!
这是因为没有设置配置文件导致,完成下一步配置文件的操作后便可以正常点击
二、Nagios配置
1. 编辑cgi.cfg文件,修改控制脚本
-
[root@cacti-nagios ~]# cd /usr/local/nagios/etc/
-
[root@cacti-nagios etc]# vi cgi.cfg
-
#:107行取消注释并修改:
-
default_user_name=nagios
-
#:119行:
-
authorized_for_system_information=nagios
-
#:131行:
-
authorized_for_configuration_information= nagios
-
#:144行:
-
authorized_for_system_commands=nagios
-
#:157行:
-
authorized_for_all_services= nagios
-
#:158行:
-
authorized_for_all_hosts= nagios
-
#:171行:
-
authorized_for_all_service_commands= nagios
-
#:172行:
-
authorized_for_all_host_commands= nagios
2. 编辑主配置文件nagios.cfg
-
[root@cacti-nagios etc]# vi nagios.cfg
-
# :34行添加:
-
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
-
cfg_file=/usr/local/nagios/etc/objects/services.cfg
3. 编辑timeperiods.cfg文件,定义监控时间段
-
[root@cacti-nagios etc]# vi objects/timeperiods.cfg
-
define timeperiod{
-
timeperiod_name all_days
-
alias 24 Hours A Day, 7 Days A Week
-
sunday 00:00-24:00
-
monday 00:00-24:00
-
tuesday 00:00-24:00
-
wednesday 00:00-24:00
-
thursday 00:00-24:00
-
friday 00:00-24:00
-
saturday 00:00-24:00
-
}
定义主机与服务 以linux-server为模板,服务以generic-service为模板
vim host.cfg
-
define host{
-
use linux-server
-
host_name SZ149
-
address 192.168.88.149
-
}
-
define service{
-
use generic-service
-
host_name web253
-
service_description CPU Load
-
check_command check_nrpe!check_load
-
}
测试配置文件是否正确
-
[root@cacti-nagios etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
-
Total Warnings: 0
-
Total Errors: 0
阅读(887) | 评论(0) | 转发(0) |