前提, rhel6.2 环境
安装 lamp 架构,支持 GD 库
www.nagios.org 下载 nagios-3.5.0.tar.gz
配置前初始化用户及建立目录
useradd nagios
mkdir /tmp/nagios /tmp/nagios-temp /var/run/nagios
chown nagios:nagios /tmp/nagios /tmp/nagios-temp /var/run/nagios
注: 官方推荐用户与执行命令组不一样 ./configure --with-command-group=nagcmd
编译参数
./configure --enable-nanosleep --enable-event-broker --enable-embedded-perl --enable-cygwin --enable-libtap --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagios --with-httpd-conf=/usr/local/apache2/conf/extra/ --with-checkresult-dir=/tmp/nagios --with-temp-dir=/tmp/nagios-temp --with-init-dir=/etc/rc.d/init.d --with-lockfile=/var/run/nagios --with-gd-lib=/usr/local/lib --with-perlcache --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios
编译提示
General Options:
-------------------------
Nagios executable: nagios.exe
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Embedded Perl: yes, with caching
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Lock file: /var/run/nagios
Check result directory: /tmp/nagios
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /usr/local/apache2/conf/extra/
Mail program: /bin/mail
Host OS: linux-gnu
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute
安装过程
make all
make install
( cd base ; cp nagios nagios.exe ; cp nagiostat nagiostat.exe )
( cd /usr/local/nagios/bin ; cp nagios.exe nagios ; cp nagiostat.exe nagiostat )
make install-init
make install-commandmode
make install-config
make install-webconf
make install-exfoliation
make install-classicui
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
检测安装是否成功,同样可以用下面方法检测配置文件是否具有错误
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start
创建 nagios 登陆用户
htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
安装参数帮助
make install
- This installs the main program, CGIs, and HTML files
make install-init
- This installs the init script in /etc/rc.d/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
make install-webconf
- This installs the Apache config file for the Nagios
web interface
make install-exfoliation
- This installs the Exfoliation theme for the Nagios
web interface
make install-classicui
- This installs the classic theme for the Nagios
web interface
安装过程需要注意的目录
command dir
/usr/local/nagios/bin
html dir
/usr/local/nagios/share
daemon dir
/etc/rc.d/init.d/nagios
commandmode dir
/usr/local/nagios/var/rw
web config file
/usr/local/apache2/conf/extra//nagios.conf
exfoliation dir (theme)
/usr/local/nagios/share/stylesheets
/usr/local/nagios/share/images
sample config file
/usr/local/nagios/etc/nagios.cfg
/usr/local/nagios/etc/cgi.cfg
/usr/local/nagios/etc/resource.cfg
/usr/local/nagios/etc/objects/templates.cfg
/usr/local/nagios/etc/objects/commands.cfg
/usr/local/nagios/etc/objects/contacts.cfg
/usr/local/nagios/etc/objects/timeperiods.cfg
/usr/local/nagios/etc/objects/localhost.cfg
/usr/local/nagios/etc/objects/windows.cfg
/usr/local/nagios/etc/objects/printer.cfg
/usr/local/nagios/etc/objects/switch.cfg
可参考 http://support.nagios.com/ 中 nagios core 的安装文档
也可以参考 http://nagios.sourceforge.net/docs/3_0/toc.html 中的配置文档