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

轉載地址:http://www.cnblogs.com/chuanzhang053/p/9395306.html php

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

需求描述:linux

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

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

環境信息:apache

  操做系統版本:RedHat 7.0 x64windows

安裝過程:tcp

1.將SElinx設置爲disabled或者permissiveide

[root@testvm02 ~]# sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/configpost

[root@testvm02 ~]# 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

cd /usr/local/src

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.1.tar.gz#_ga=2.110152902.27871981.1533304858-616462593.1533304858

本例安裝的版本:

nagios-4.4.1.tar.gz

上傳軟件到指定的目錄中:


4.解壓,編譯,安裝

[root@testvm02 nagios-4.4.1]# tar zxf nagios-4.4.1.tar.gz

[root@testvm02 nagios-4.4.1]# cd nagios-4.4.1

[root@testvm02 nagios-4.4.1]# ./configure

[root@testvm02 nagios-4.4.1]# make all

5.建立用戶,用戶組

[root@testvm02 nagios-4.4.1]# make install-groups-users

groupadd -r nagios

useradd -g nagios nagios

[root@testvm02 nagios-4.4.1]# usermod -a -G nagios apache

[root@testvm02 nagios-4.4.1]# id nagios

uid=500(nagios) gid=499(nagios) groups=499(nagios)

[root@testvm02 nagios-4.4.1]# id apache

uid=48(apache) gid=48(apache) groups=48(apache),499(nagios

6.建立二進制命令,CGI,html文件

root@testvm02 nagios-4.4.1]# make install

7.安裝相關的進程文件(安裝啓動腳本),增長httpd開機啓動,nagios開機啓動


[root@testvm02 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 ***


[root@testvm02 nagios-4.4.1]# systemctl enable httpd.service

[root@testvm02 nagios-4.4.1]# systemctl list-unit-files  | grep httpd

httpd              0:off    1:off    2:on    3:on    4:on    5:on    6:off

[root@testvm02 nagios-4.4.1]# systemctl list-unit-files  | grep nagios

nagios             0:off    1:off    2:on    3:on    4:on    5:on    6:off

8.安裝外部命令文件


[root@testvm02 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.安裝配置文件


[root@testvm02 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 read

the documentation for more information on how to actually define

services, hosts, etc. to fit your particular needs.


備註:這些都是一些示例配置文件,同時好比nagios.cfg在啓動nagios的時候須要使用到.

10.安裝apache配置文件即httpd配置文件


[root@testvm02 nagios-4.4.1]# make install-webconf

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf

if [ 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 ACCEPT

service iptables save


關閉防火牆,關閉開機啓動:


service iptables stop

[root@testvm02 nagios-4.4.1]# chkconfig --level 2345 iptables off

[root@testvm02 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管理帳號


[root@testvm02 nagios-4.4.1]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

New password:                           #輸入新密碼

Re-type new password:                   #再次輸入密碼,進行確認

Adding password for user nagiosadmin

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


[root@testvm02 nagios-4.4.1]# service httpd start

[root@testvm02 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壓縮包


軟件包:nagios-plugins-2.2.1.tar.gz下載地址: https://www.nagios.org/downloads/nagios-plugins/

cd /usr/local/src

wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz#_ga=2.22070264.27871981.1533304858-616462593.1533304858

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

 tar zxf nagios-plugins-2.2.1.tar.gz 

 cd nagios-plugins-2.2.1

./configure 

make

make install

備註:插件安裝完成

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

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

Servies的狀態:

18.針對HTTP的檢查,在本地的/var/www/html中建立index.html文件就能夠解決這個警告

[root@testvm02 libexec]# cd /var/www/html/

[root@testvm02 html]# touch index.html

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

到此,全部的nagios-core,nagios-plugins已經安裝完成!


nagios core not running 解決

手工方式啓動nagios

# /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg(解決)


主要是apache沒有開啓cgi腳本的緣故

進入apache的主配置文件httpd.conf

#LoadModule cgid_module modules/mod_cgid.so

#LoadModule actions_module modules/mod_actions.so

相關文章
相關標籤/搜索