在centos6.4系统中,安装与配置nagios3.5.0的方法。
一,安装环境的配置
复制代码代码示例:
[root@Nagios ~]# service iptables stop
iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules: [ OK ] [root@Nagios ~]# chkconfig iptables off
2,关闭SELinux
复制代码代码示例:
[root@Nagios ~]# vim /etc/selinux/config
将SELINUX=disabled # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
3,修改hosts文件
复制代码代码示例:
已知我们这台机器的主机名为Nagios,则修改/etc/hosts
127.0.0.1 Nagios localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
添加上面红色部分即可,否则启动apache服务的时候可能出现 做完以上3个步骤后,需要重启服务器。
二,软件的准备
复制代码代码示例:
[root@Nagios ~]# yum -y install wget make openssl openssl-devel httpd php gcc glibc \
> glibc-common gd gd-devel net-snmp mysql \ > mysql-server mysql-devel php-mysql perl perl-devel gnutls gnutls-devel
2,MySQL的配置(此步可省略)
复制代码代码示例:
[root@Nagios ~]# service mysqld start
接着设置更改MySQL root账户的密码
复制代码代码示例:
[root@Nagios ~]# mysqladmin -u root password 123456
三,软件的安装
复制代码代码示例:
[root@Nagios ~]# useradd nagios
[root@Nagios ~]# groupadd nagcmd [root@Nagios ~]# usermod -a -G nagcmd nagios [root@Nagios ~]# usermod -a -G nagcmd apache
2,软件的下载
复制代码代码示例:
Nagios软件的下载
[root@Nagios ~]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.0.tar.gz [root@Nagios ~]# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
3,Nagios软件的解压
复制代码代码示例:
[root@Nagios ~]# tar zxvf nagios-3.5.0.tar.gz
[root@Nagios ~]# tar zxvf nagios-plugins-1.4.16.tar.gz
4,Nagios的编译与安装
复制代码代码示例:
[root@Nagios ~]# cd nagios
[root@Nagios nagios]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
2)、测试nagios的配置文件
复制代码代码示例:
[root@Nagios nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果最后出现
Things look okay - No serious problems were detected during the pre-flight check
3)、启动Nagios服务:
复制代码代码示例:
[root@Nagios nagios]# service nagios start
Starting nagios: done.
复制代码代码示例:
[root@Nagios nagios]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName [ OK ]
4)、添加访问WEB服务的账户及密码
复制代码代码示例:
[root@Nagios nagios]# htpasswd -c /usr/local/nagios/etc/htpasswd.users admin
New password: Re-type new password: Adding password for user admin 此时已添加好了访问web网站的用户。
5,Nagios plugin的安装
复制代码代码示例:
[root@Nagios nagios]# cd ../nagios-plugins-1.4.16
复制代码代码示例:
[root@Nagios nagios-plugins-1.4.16]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-perl-modules --enable-libtap
编译成功后,会出现如下信息: --with-apt-get-command: --with-ping6-command: /bin/ping6 -n -U -w %d -c %d %s --with-ping-command: /bin/ping -n -U -w %d -c %d %s --with-ipv6: yes --with-mysql: /usr/bin/mysql_config --with-openssl: yes --with-gnutls: no --enable-extra-opts: yes --with-perl: /usr/bin/perl --enable-perl-modules: yes --with-cgiurl: /nagios/cgi-bin --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin --enable-libtap: yes
#-----插件的安装
复制代码代码示例:
[root@Nagios nagios-plugins-1.4.16]# make
[root@Nagios nagios-plugins-1.4.16]# make install
将nagios及httpd加入启动项,并自动启动:
复制代码代码示例:
[root@Nagios nagios-plugins-1.4.16]# chkconfig --add nagios
(责任编辑:IT)[root@Nagios nagios-plugins-1.4.16]# chkconfig --level 35 nagios on [root@Nagios nagios-plugins-1.4.16]# chkconfig --add httpd [root@Nagios nagios-plugins-1.4.16]# chkconfig --level 35 httpd on |