服务器先安装好Apache。
从 下载以下软件:
nagios-3.2.3.tar.gz nagios-plugins-1.4.15.tar.gz nrpe-2.12.tar.gz安装Nagios Core
#切换到root用户 su -l #添加nagios用户 useradd -m nagios passwd nagios #创建nagcmd组,允许用户在web上执行命令. groupadd nagcmd usermod -a -G nagcmd nagios usermod -a -G nagcmd apache tar xzvf nagios-3.2.3.tar.gz cd nagios-3.2.3 ./configure --with-command-group=nagcmd make all make install make install-init make install-config make install-commandmode
configure完成后会显示如下提示
General Options: ------------------------- Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagcmd Embedded Perl: no Event Broker: yes Install ${prefix}: /usr/local/nagios Lock file: ${prefix}/var/nagios.lock Check result directory: ${prefix}/var/spool/checkresults Init directory: /etc/rc.d/init.d Apache conf.d directory: /etc/httpd/conf.d Mail program: /bin/mail Host OS: linux-gnu Web Interface Options: ------------------------ HTML URL: CGI URL: Traceroute (used by WAP): /bin/traceroute
配置文件目录/usr/local/nagios/etc
修改/usr/local/nagios/etc/objects/contacts.cfg中的邮箱地址为 nagios@xxx.edu.cn。该邮箱设置了过滤规则,所有信件转发到 xxx@139.com
将/root/nagios-3.2.3/sample-config/httpd.conf中的片段拷贝到/usr/local/apache2/conf/httpd.conf中
添加nagiosadmin用户
/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin安装Nagios Plugins
tar xzvf nagios-plugins-1.4.15.tar.gz cd nagios-plugins-1.4.15 ./configure --with-nagios-user=nagios --with-nagios-group=nagios make make install
命令安装在/usr/local/nagios/libexec/目录下
启动Nagios
chkconfig --add nagios #将nagios添加到服务中 chkconfig nagios on #开启该服务 chkconfig --list nagios #查看服务启动状态 #检查脚本正确性 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg service nagios start
访问
安装NRPE
先安装Nagios Plugins,如果是在被监控主机上安装,需要先添加nagios用户。