您好,登錄后才能下訂單哦!
Nagios是一款開源的免費網絡監視工具,能有效監控Windows、Linux和Unix的主機狀態,交換機路由器等網絡設置,打印機等。在系統或服務狀態異常時發出郵件或短信報警第一時間通知網站運維人員,在狀態恢復后發出正常的郵件或短信通知。
一.安裝環境的配置
1.關閉防火墻
為了防止因為防火墻的原因影響我們安裝的環境,我們對防火墻進行關閉,如果在實際的生產環境中,我們是不建議關閉防火墻的。
[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
如果未關閉SELinux,則可能在安裝完成后,會出現Internal Server Error錯誤
編輯/etc/selinux/config
[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服務的時候可能出現
Starting httpd: httpd: apr_sockaddr_info_get() failed for Nagios
做完以上3個步驟后,我們需要重新啟動服務器。
二.軟件的準備
1.安裝必要的軟件
[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的配置(此步可省略)
雖然現在還并未使用MySQL,但是在以后的配置需要用到。
首先啟動MySQL服務器
[root@Nagios ~]# service mysqld start
接著設置更改MySQL root賬戶的密碼
[root@Nagios ~]# mysqladmin -u root password 123456
三.軟件的安裝
1.Nagios賬戶及組的添加
[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的編譯與安裝
首先進入Nagios解壓后所在的目錄
[root@Nagios ~]# cd nagios
[root@Nagios nagios]# ./configure --with-command-group=nagcmd
[root@Nagios nagios]# make all
[root@Nagios nagios]# make install
[root@Nagios nagios]# make install-init
[root@Nagios nagios]# make install-config
[root@Nagios nagios]# make install-commandmode
[root@Nagios nagios]# make install-webconf
[root@Nagios nagios]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
[root@Nagios nagios]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers/
測試nagios的配置文件
[root@Nagios nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果最后出現
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
就證明nagios配置無誤可正常啟動!
啟動Nagios服務:
[root@Nagios nagios]# service nagios start
Starting nagios: done.
啟動httpd服務:
[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 ]
添加訪問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的安裝
首先進入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
[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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。