Nagios 4.x 安装教程

最近研究网络监控发现这个开源的好东东,所以安装后写了这篇教程。防火墙可关可不关,把相关端口加进入就行了。官方有个收费版,支持中文不过好贵啊。。。。

1.最小化安装CentOS并更新
yum -y update
yum -y install lrzsz telnet telnet-server
#开启telnet 方法一:
chkconfig telnet on
#开启telnet 方法二:
#vi /etc/xinetd.d/telnet 将”disable= yes”改成” disable=no”
service xinetd restart
#修改防火墙端口并重启防火墙
iptables -I INPUT -p tcp –dport 23 -jACCEPT
iptables -I INPUT -p udp –dport 23 -jACCEPT
service iptables save
service iptables restart
#临时关闭防火墙:service iptables stop
#永久关闭防火墙:chkconfig iptables off
2.安装所需组建
yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp unzip
3.下载最新版Nagios
cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
4.下载最新版插件
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

5.添加Nagios用户和用户组
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagios,nagcmd apache

 

6.解压文件
tar zxvf nagios-4.3.4.tar.gz
tar zxvf nagios-plugins-2.2.1.tar.gz

7.编译安装Nagios
cd nagios-4.3.4
./configure –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
chown -R nagios:nagios /usr/local/nagios/bin/nagios -v
chown -R nagios:nagios /usr/local/nagios/etc/nagios.cfg

 

8.开启服务
/etc/init.d/nagios start
/etc/init.d/httpd start
9.创建admin和密码
htpasswd -c /usr/local/nagios/etc/htpasswd.users admin

10.编译安装nagios-plugins
cd nagios-plugins-2.2.1

./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install
11.Nagion 服务设置
chkconfig –add nagios
chkconfig –level 35 nagios on
chkconfig –add httpd
chkconfig –level 35 httpd on
12.访问IP地址
http://IP/nagios

 

 

发表评论