[iyunv@bogon ~]# tar -zxvf nagios-4.0.1.tar.gz -C /usr/src/
[iyunv@bogon ~]# cd /usr/src/nagios-4.0.1/
[iyunv@bogon nagios-4.0.1]# ./configure --prefix=/usr/local/nagios/
[iyunv@bogon nagios-4.0.1]# make all && make install && make install-init && make install commandmode && make install-config
[iyunv@bogon nagios-4.0.1]# chkconfig --add nagios
[iyunv@bogon nagios-4.0.1]# chkconfig nagios on
2、安装nagios-plugins
[iyunv@bogon ~]# tar -zxvf nagios-plugins-1.5.tar.gz -C /usr/src/
[iyunv@bogon ~]# cd /usr/src/nagios-plugins-1.5/
[iyunv@bogon nagios-plugins-1.5]# ./configure --prefix=/usr/local/nagios/ && make && make install
注意:
nrpe的作用Nagios的监测服务器能够远程对被监测主机系统上的信息进行获取,比如远程系统上的进程数、磁盘空间使用状况、所运行的服务等等这些必须要登录远程主机系统上才能了解的信息的话,就必须要依靠NRPE这个核心扩展插件程序,NRPE作为中间的代理程序,扮演着一手接受着Nagios监测服务器发来的请求,另一手在远程主机系统上获取指定的信息的中间人角色。
设置httpd服务
[iyunv@bogon ~]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin //yum自动安装httpd的位置,最好是编译安装或者用shell脚本
New password: 123
Re-type new password: 123 //不显示密码
Adding password for user nagiosadmin
[iyunv@bogon ~]# vim /etc/httpd/conf/httpd.conf //具体路径看自己的
末尾添加
ScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin/"
<Directory "/usr/local/nagios/sbin">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagiosi access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
</Directory>
[iyunv@bogon ~]# service httpd stop
[iyunv@bogon ~]# service httpd start //重启服务
[iyunv@bogon ~]# vim /usr/local/nagios/etc/cgi.cfg
修改
use_authentication=0 (0:允许访问所有页面。1:禁止)
[iyunv@bogon ~]# vim /usr/local/nagios/etc/objects/webserver.cfg
修改
define host{
use linux-server ; Name of host template to use
host_name webserver
alias ftp-server
address 192.168.1.2
}
define service{
use local-service ; Name of service template to use
host_name webserver
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
[iyunv@bogon ~]# vim /usr/local/nagios/etc/nagios.cfg
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/webserver.cfg //添加的一行
[iyunv@bogon ~]# tar -zxvf nagios-plugins-1.5.tar.gz -C /usr/src/
[iyunv@bogon ~]# cd /usr/src/nagios-plugins-1.5/
[iyunv@bogon nagios-plugins-1.5]# ./configure --prefix=/usr/local/nagios
[iyunv@bogon nagios-plugins-1.5]# make && make install
[iyunv@bogon nagios-plugins-1.5]# chown -R nagios:nagios /usr/local/nagios/
2.安装nrpe
[iyunv@bogon ~]# tar -zxvf nrpe-2.15.tar.gz -C /usr/src/
[iyunv@bogont ~]# cd /usr/src/nrpe-2.15/
[iyunv@bogont nrpe-2.15]# ./configure --prefix=/usr/local/nagios/
[iyunv@bogon nrpe-2.15]# make all
[iyunv@bogon nrpe-2.15]# make install-plugin
[iyunv@bogon nrpe-2.15]# make install-daemon
[iyunv@bogon nrpe-2.15]# make install-daemon-config