一、 安装环境
l 操作系统:Linux5.5或者更高版本操作系统
l 软件需求:Apache、GCC编译器、GD库与开发库、Opensll-devel
l Windows客户端需要安装NSClient++
l Nagios版本:nagios-3.2.1.tar.gz
l 需求插件:nagios-plugins-1.4.15.tar.gz、nrpe-2.8.1.tar.gz
l 创建用户:#useradd nagios //Linux5.5在创建用户的时候自动创建相应的组,有的操作系统 不是这样,需要#useradd –g nagios nagios
l 创建安装nagios安装目录:#mkdir /usr/local/nagios
l 安装nagios:#tar –zxvf nagios-3.2.1.tar.gz
#./configure –prefix=/usr/local/nagios --with-gd-lib=/usr/local/lib --with-gd-inc=/usr/local/include/
#make install //安装主程序,CGI和HTML文件
#make install-init //在 /etc/rc.d/init.d 安装启动脚本
#make install-commandmode //为外部命令文件配置目录权限
#make install-config //安装示例配置文件
l 安装nagios-plugins-1.4.15.tar.gz
#tar –zxvf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
#./configure --prefix=/usr/local/nagios
#tar –zxvf nrpe-2.8.1.tar.gz
#./configure --prefix=/usr/local/nagios
#make install-plugin //安装插件
#make install-daemon //安装 nrpe daemon
#make install-daemon-config //安装配置文件
#make install-xinetd //安装xinetd 脚本文件
添加 nrpe 服务到xinetd:vi /etc/services
添加如下内容:nrpe 5666/tcp # nrpe
重启xinetd服务:#service xinetd restart
#chown –R /usr/local/nagios
#vi /etc/httpd/conf/httpd.conf //编辑配置文件
Group apache //启用apache进程的用户和组
Group nagios //用nagios用户启用apache进程
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
Alias /nagios "/usr/local/nagios/share"
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
重启apache:#service httpd restart
#/usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd nagios //回车后提示输入密码
cfg_file=/usr/local/nagios/etc/contactgroups.cfg //联系组配置文件路径
cfg_file=/usr/local/nagios/etc/contacts.cfg //联系人配置文件路径
cfg_file=/usr/local/nagios/etc/services.cfg //服务配置文件路径
cfg_file=/usr/local/nagios/etc/timeperiods.cfg //监视时段配置文件路径
authorized_for_system_information=nagiosadmin,nagios
authorized_for_configuration_information=nagiosadmin,nagios
authorized_for_system_commands=nagios
authorized_for_all_services=nagiosadmin,nagios
authorized_for_all_hosts=nagiosadmin,nagios
authorized_for_all_service_commands=nagiosadmin,nagios
authorized_for_all_host_commands=nagiosadmin,nagios
#/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
#/etc/rc.d/init.d/nagios restart
#cd /usr/local/nagios/etc/objects
#cat localhost.cfg > {被监控机IP或域名}.cfg
#vi {被监控机IP或域名}.cfg (修改IP、计算机名)
#vi /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
#/etc/rc.d/init.d/nagios restart //重启nagios
1、[Settings] 部分设置'password'选项来设置密码,作用是在nagios连接过来时要求提供密码。这里不要密码!
| 1、[Settings] 部分'allowed_hosts'选项的注释去掉,并加上监控主机的IP。如:allowed_hosts=127.0.0.1,192.168.1.0/24,222.73.231.21/32
以逗号相隔. 如果这个地方是空白则表示所有的主机都可以连接上来.
注意是[Settings]部分的,因为[NSClient]部分也有这个选项.
| 3、[NSClient] 的'port'选项必须保证没有被注释,并且它的值是'12489',这是NSClient的默认监听端口
|
#cd /usr/local/nagios/etc/objects
#cat windows.cfg > {被监控机IP或域名}.cfg
#vi {被监控机IP或域名}.cfg (修改IP、计算机名)
#vi /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
#/etc/rc.d/init.d/nagios restart //重启nagios
http://ip/nagios访问nagios
|