安装环境:centos 6.5 x86_64
在安装nagios之前,先解决依赖问题,直接使用yum安装
yum -y install gcc glibc glibc-common
yum -y install gd gd-devel # 用于pnp绘图
yum -y install mysql mysql-devel mysql-server # 如果要监控数据库,那么需安装mysql,否则mysql的相关插件不会被自动安装
yum -y install httpd php php-mysql php-gd
安装nagios-4.0.8
useradd -m nagios # 创建nagios用户
passwd nagios
groupadd nagcmd # 创建nagcmd组
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
tar xzf nagios-4.0.8.tar.gz
cd nagios-4.0.8
./configure --help
./configure --with-command-group=nagcmd --enable-event-broker
# 输出如下:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/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
IOBroker Method: epoll
make all
make install
make install-init # 安装启动脚本
make install-config # 安装config文件
make install-commandmode
make install-webconf # 在httpd/conf.d下创建nagios的web配置文件
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd restart
安装nagios插件以及nrpe
# 编译nagios插件
tar xzf nagios-plugins-2.1.1.tar.gz
cd nagios-plugins-2.1.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make && make install
chkconfig --add nagios
chkconfig nagios on
chkconfig --list nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg # 检查配置文件
service nagios start
# 如果开启了selinux,可通过以下方式将nagios的CGI程序运行于selinux/targeted模式而不用关闭selinux
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
# 安装nrpe
tar xzf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/toc.html