系統(tǒng)版本
[root@localhost ~]# cat /etc/issue
CentOS release 6.9 (Final)
- Nagios主程序
https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.3.2/ - nagios-plugins-1.4.13.tar.gz Nagios 的插件
https://www.nagios.org/downloads/nagios-plugins/ - nrpe-2.12.tar.gz 代理檢測(cè)程序
https://sourceforge.net/projects/nagios/files/nrpe-3.x/nrpe-3.2.0/
在此演示安裝版本為nagios-4.3.2休里,nagios-plugins-2.2.1呀伙,nrpe-3.2.0(未安裝)
一、nagios-4.3.2 安裝
1.安裝前的依賴檢查
[root@localhost ~]# yum install httpd php gcc glibc glibc-common gd gd-devel
[root@localhost ~]# useradd -m nagios
[root@localhost ~]# groupadd nagcmd
[root@localhost ~]# usermod -a -G nagcmd nagios
[root@localhost ~]# usermod -a -G nagcmd apache
2.解壓
[root@localhost ~]# cd usr/local/src/
[root@localhost src]# tar xvf nagios-4.3.2.tar.gz
[root@localhost src]# cd nagios-4.3.2
3.安裝
[root@localhost nagios-4.3.2]# ./configure --prefix=/usr/local/nagios --with-command-group=nagcmd --with-nagios-user=nagios --with-nagios-group=Nagios
[root@localhost nagios-4.3.2]# make all
[root@localhost nagios-4.3.2]# make install
[root@localhost nagios-4.3.2]# make install-init (生成init啟動(dòng)腳本)
[root@localhost nagios-4.3.2]# make install-config (生成一些模板配置文件)
[root@localhost nagios-4.3.2]# make install-commandmode (設(shè)置相應(yīng)的權(quán)限)
[root@localhost nagios-4.3.2]# make install-webconf (生成Apache配置文件nagios.conf)
4.為Nagios設(shè)置Web驗(yàn)證的密碼派敷。(注意第一次添加用戶用-c選項(xiàng),以后再添加千萬別在用這個(gè)選項(xiàng)了押赊,會(huì)覆蓋以前的所有用戶的抠刺。)
[root@localhost nagios-4.3.2]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
5.設(shè)置nagios的開機(jī)啟動(dòng)
[root@localhost nagios-4.3.2]# chkconfig --add nagios
[root@localhost nagios-4.3.2]# chkconfig nagios on
[root@localhost nagios-4.3.2]# chkconfig httpd on
6.關(guān)閉SELinux
[root@localhost nagios-4.3.2]# vi /etc/sysconfig/selinux
SELINUX=disabled
二、安裝Nagios的插件nagios-plugin
[root@localhost src]# pwd
/usr/local/src
[root@localhost src]# tar xvf nagios-plugins-2.2.1.tar.gz
[root@localhost src]# cd nagios-plugins-2.2.1
[root@localhost nagios-plugins-2.2.1]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=Nagios
[root@localhost nagios-plugins-2.2.1]# make && make install
三等孵、驗(yàn)證Nagios的樣例配置文件
[root@localhost nagios-plugins-2.2.1]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.3.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2017-05-09
License: GPL
Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 8 services.
Checked 1 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
如果沒有報(bào)錯(cuò)稚照,可以啟動(dòng)Nagios服務(wù)
service nagios start
使用http://localhost/nagios/來訪問
ps:如果遇到問題!8┟取9肌!
如果遇到關(guān)于cgi什么權(quán)限問題咐熙!察看下/usr/local/nagios的屬主組權(quán)限弱恒,
包括里面的內(nèi)容,
尤其是/usr/local/nagios/etc/htpasswd.users這個(gè)文件的權(quán)限棋恼!都應(yīng)該是nagios:nagios
另外嘗試編輯
vi /usr/local/nagios/etc/cgi.cfg
把
use_authentication=1
修改為
use_authentication=0