CentOS 6.3_Nagios安装笔记
1、安装前准备
Nagios安装前,首先安装相关软件包,对于RHEL / CentOS系统: (依赖包的安装:wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp openssl openssl-devel)
检看一下是否安装相关软件包:
# rpm -qa |grep *****(略)
# yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp openssl openssl-devel
Nagios源代码程序和插件
监控主机下载:
# wget http://nchc.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.4/nagios-3.4.4.tar.gz
# wget http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz
被监控Linux 主机下载:
# wget http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz
被监控Windows 主机下载:
http://nsclient.org/nscp/downloads
http://files.nsclient.org/0.3.x/NSClient%2B%2B-0.3.9-Win32.zip
http://files.nsclient.org/0.3.x/NSClient%2B%2B-0.3.9-x64.zip
2、添加Nagios用户和组
# useradd nagios
# passwd nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
3、编译与安装Nagios
# tar -zxvf nagios-3.4.4.tar.gz
# cd nagios
#./configure --with-command-group=nagcmd //编译Nagios 配置脚本并使用先前开设的用户及用户组
#make all //编译Nagios 程序包源码
安装二进制运行程序、初始化脚本、配置文件样本并设置运行目录权限
#make install
#make install-init
#make install-config
#make install-commandmode
#make install-webconf
复制nagios/contrib/eventhandlers目录下所有文件到/usr/local/nagios/libexec下:
#cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
修改用户和主权限
#chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
验证Nagios配置文件,验证配置是否有误
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
重启httpd
# /etc/init.d/httpd start
# chkconfig httpd on
修改配置文件
# vim /usr/local/nagios/etc/objects/contacts.cfg
修改nagiosadmin(这里修改为你自己创建的帐号) 注:nagiosadmin是配置文件默认,可以不用修改。
创建一个默认用户登录Web界面访问: 创建HTTP认证用户登录Nagios,用户名nagiosadmin,密码123456
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: 123456
Re-type new password: 123456
验证程序是否被正确安装:
切换目录到安装路径(这里是/usr/local/nagios),看是否存在 bin etc libexec sbin share var这六个目录,如果存在则可以表明程序被正确的安装到系统了。后表是六个目录功能的简要说明:
bin |
Nagios执行程序所在目录,nagios文件即为主程序 |
etc |
Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件 |
libexec |
Nagios 系统库文件 |
sbin |
Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录 |
Share |
Nagios网页文件所在的目录 |
Var |
Nagios日志文件、spid 等文件所在的目录 |
var/archives |
Empty directory for the archived logs |
var/rw |
Empty directory for the external command file |
4、编译并安装Nagios 插件
# tar zxvf nagios-plugins-1.4.16.tar.gz
# cd nagios-plugins-1.4.16
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make;make install
会显示安装的插件文件,即所有的插件都安装在libexec这个目录下
# ls /usr/local/nagios/libexec/
验证Nagios 配置文件
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
5、启动Nagios
#/etc/init.d/nagios start
# chkconfig nagios on
6、登录到WEB界面
输入用户名密码:nagiosadmin 123456
7、防火墙配置
service iptables stop
配置完毕
本文链接:http://www.showerlee.com/archives/601
继续浏览:NAGIOS
还没有评论,快来抢沙发!