linux環境中nagios(nagios core)安裝?nagios安裝?

來源:互聯網
上載者:User

標籤:ati   des   ios   外掛程式   put   figure      mem   上傳   

需求描述:

  最近準備給線上生產環境部署監控平台,對各個系統的資源使用方式,服務進行監控,採用nagios core版本進行部署,

  nagios core是開源版本的軟體,是免費的nagios XI是上夜班.

環境資訊:

  作業系統版本:RedHat 6.6 x64

安裝過程:

1.將SElinx設定為disabled或者permissive

[[email protected] ~]# sed -i ‘s/SELINUX=.*/SELINUX=disabled/g‘ /etc/selinux/config
[[email protected] ~]# getenforce
Permissive

2.安裝依賴的軟體包

yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix

3.下載,上傳nagios-core的軟體包

:

https://www.nagios.org/downloads/nagios-core/thanks/?skip=1&product_download=nagioscore-source

本例安裝的版本:

nagios-4.4.1.tar.gz
上傳軟體到指定的目錄中:

[[email protected] ~]# cd /opt/softwares/;ls -l                     #實際情況中可以上傳軟體到自己指定的目錄中.total 11032-rw-r--r--. 1 root root 11296403 Jul 31 11:24 nagios-4.4.1.tar.gz

4.解壓,編譯,安裝

[[email protected] nagios-4.4.1]# tar zxf nagios-4.4.1.tar.gz[[email protected] nagios-4.4.1]# cd nagios-4.4.1[[email protected] nagios-4.4.1]# ./configure[[email protected] nagios-4.4.1]# make all

5.建立使用者,使用者組

[[email protected] nagios-4.4.1]# make install-groups-usersgroupadd -r nagiosuseradd -g nagios nagios[[email protected] nagios-4.4.1]# usermod -a -G nagios apache
[[email protected] nagios-4.4.1]# id nagios
uid=500(nagios) gid=499(nagios) groups=499(nagios)
[[email protected] nagios-4.4.1]# id apache
uid=48(apache) gid=48(apache) groups=48(apache),499(nagios

6.建立二進位命令,CGI,html檔案

[[email protected] nagios-4.4.1]# make install

7.安裝相關的進程檔案(安裝啟動指令碼),增加httpd開機啟動,nagios開機啟動

[[email protected] nagios-4.4.1]# make install-daemoninit/usr/bin/install -c -m 755 -d -o root -g root /etc/init.d/usr/bin/install -c -m 755 -o root -g root startup/default-init /etc/init.d/nagios*** Init script installed ***

[[email protected] nagios-4.4.1]# chkconfig --level 2345 httpd on
[[email protected] nagios-4.4.1]# chkconfig --list | grep httpd
httpd              0:off    1:off    2:on    3:on    4:on    5:on    6:off
[[email protected] nagios-4.4.1]# chkconfig --list | grep nagios
nagios             0:off    1:off    2:on    3:on    4:on    5:on    6:off

8.安裝外部命令檔案

[[email protected] nagios-4.4.1]# make install-commandmode
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw

*** External command directory configured ***

9.安裝設定檔

[[email protected] nagios-4.4.1]# make install-config/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg*** Config files installed ***Remember, these are *SAMPLE* config files.  You‘ll need to readthe documentation for more information on how to actually defineservices, hosts, etc. to fit your particular needs.

備忘:這些都是一些樣本設定檔,同時比如nagios.cfg在啟動nagios的時候需要使用到.

10.安裝apache設定檔即httpd設定檔

[[email protected] nagios-4.4.1]# make install-webconf/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.confif [ 0 -eq 1 ]; then         ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/nagios.conf;     fi*** Nagios/Apache conf file installed ***

11.配置防火牆或者關閉防火牆

配置允許8連接埠進入:
iptables -I INPUT -p tcp --destination-port 80 -j ACCEPTservice iptables save
關閉防火牆,關閉開機啟動:

service iptables stop
[[email protected] nagios-4.4.1]# chkconfig --level 2345 iptables off
[[email protected] nagios-4.4.1]# chkconfig --list | grep iptables
iptables           0:off    1:off    2:off    3:off    4:off    5:off    6:of

12.建立nagios管理帳號

[[email protected] nagios-4.4.1]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadminNew password:                           #輸入新密碼Re-type new password:                   #再次輸入密碼,進行確認Adding password for user nagiosadmin

13.啟動apache服務,nagios core服務

[[email protected] nagios-4.4.1]# service httpd start[[email protected] nagios-4.4.1]# service nagios start

14.通過頁面進行訪問測試

訪問地址:http://192.168.53.25/nagios    輸入nagios管理帳號,密碼進行登入.

 登入成功之後,頁面如下:

查看Hosts,Services有如下的報錯:

備忘:以上錯誤提示,表示沒有某些命令,即在/usrlocal/nagios/libexex中滅有命令,需要安裝nagios-plugins來安裝相應的命令

15.下載,上傳nagios-plugins壓縮包

:

https://www.nagios.org/downloads/nagios-plugins/

 軟體包:nagios-plugins-2.2.1.tar.gz

[[email protected] softwares]# cd /opt/softwares/;ls -l nagios-plugins*-rw-r--r--. 1 root root 2728818 Jul 31 12:25 nagios-plugins-2.2.1.tar.gz

16.安裝依賴的軟體包,解壓,編譯,安裝

yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
[[email protected] softwares]# tar zxf nagios-plugins-2.2.1.tar.gz [[email protected] softwares]# cd nagios-plugins-2.2.1[[email protected] nagios-plugins-2.2.1]# ./configure 
[[email protected] nagios-plugins-2.2.1]# make
[[email protected] nagios-plugins-2.2.1]# make install

備忘:外掛程式安裝完成

17.重新在nagios頁面進行測試,在HOSTS中的localhost的命令菜單中點擊."Re-schedule the next check",查看hosts狀態

備忘:說明命令已經成功,對於services中的檢查,也會在一定時間之後,達到調度時間進行狀態的修改.

Servies的狀態:

18.針對HTTP的檢查,在本地的/var/www/html中建立index.html檔案就可以解決這個警告

[[email protected] libexec]# cd /var/www/html/[[email protected] html]# touch index.html

 配置完成之後,http服務的狀態:

到此,所有的nagios-core,nagios-plugins已經安裝完成!

 

文檔建立時間:2018年7月31日12:58:55

linux環境中nagios(nagios core)安裝?nagios安裝?

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.