溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Nagios 4.0.1版本安裝 適用于RHEL/Centos 5.x/6.x 或者Fedora 17/18/19(一)

發(fā)布時(shí)間:2020-07-13 07:43:25 來(lái)源:網(wǎng)絡(luò) 閱讀:450 作者:老K8 欄目:移動(dòng)開(kāi)發(fā)

我的環(huán)境如下:

Centos-6.2

Nagios 4.0.1

Nagios Plugin 1.5

Nagios是一個(gè)非常棒的免費(fèi)的開(kāi)源的監(jiān)控工具,它提供給你一個(gè)很全面的監(jiān)控環(huán)境,始終密切監(jiān)視你的機(jī)器或者網(wǎng)絡(luò),不管是在數(shù)據(jù)中心還是在你自己的一個(gè)小實(shí)驗(yàn)室。


步驟1:安裝需要的依賴包

   需要安裝Apache、PHP和一些庫(kù)像:gcc、glibc、glibc-common、gd、gd-devel、make、net-snmp

[root@taoteng ~]# yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp

步驟2:創(chuàng)建一個(gè)nagios用戶和組

創(chuàng)建一個(gè)新的nagios用戶和nagcmd組賬戶并設(shè)置密碼。

[root@taoteng ~]# useradd nagios
[root@taoteng ~]# groupadd nagcmd

接下來(lái),添加nagios和Apache用戶到nagcmd組。

[root@tecmint]# usermod -G nagcmd nagios

[root@tecmint]# usermod -G nagcmd apache


步驟3:下載Nagios-4.0.1和Nagios-plugin-1.5

 在/root目錄下創(chuàng)建一個(gè)安裝包以及后續(xù)需要下載的安裝包的目錄。

[root@taoteng ~]# mkdir /root/nagios

 [root@taoteng ~]# cd /root/nagios

 現(xiàn)在來(lái)下載最新版本的Nagio-4.0.1和Nagios-plugin-1.5通過(guò)wget命令

 [root@taoteng nagios]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.1.tar.gz

 [root@taoteng nagios]# wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz


步驟4:提取Nagios和nagios-plugins壓縮包

 我們需要通過(guò)tar命令來(lái)提取下載的壓縮包里面的文件:

 [root@taoteng nagios]# tar -zxvf nagios-4.0.1.tar.gz

 [root@taoteng nagios]# tar -zxvf nagios-plugins-1.5.tar.gz

緊接著nagios文件夾里面將會(huì)出現(xiàn)解壓之后的文件夾

[root@taoteng nagios]# ll

總用量 30668

drwxrwxr-x 18 root   root      4096  2月 20 21:22 nagios-4.0.1

-r-xr-xr-x  1 root   root   1696847  2月 20 20:58 nagios-4.0.1.tar.gz

drwxr-xr-x 15 nagios nagios    4096  2月 24 00:58 nagios-cn-3.2.3

-r-xr-xr-x  1 root   root   9638175  2月 20 20:58 nagios-cn-3.2.3.tar.bz2

drwxr-xr-x 15    200    300    4096  2月 20 22:04 nagios-plugins-1.5

-r-xr-xr-x  1 root   root   2428258  2月 20 20:58 nagios-plugins-1.5.tar.gz

配置nagios的核心

現(xiàn)在,首先我們將配置nagios核心,將進(jìn)入到nagios文件夾里面運(yùn)行configure命令,如果一切運(yùn)行順利將會(huì)出現(xiàn)下面的界面:

[root@taoteng nagios]# cd nagios-4.0.1

[root@taoteng nagios-4.0.1]# ./configure --with-command-group=nagcmd

輸出示例:

Nagios executable:  nagios        Nagios user/group:  nagios,nagios       Command user/group:  nagios,nagcmd             Event Broker:  yes        Install ${prefix}:  /usr/local/nagios    Install ${includedir}:  /usr/local/nagios/include/nagios                Lock file:  ${prefix}/var/nagios.lock   Check result directory:  ${prefix}/var/spool/checkresults           Init directory:  /etc/rc.d/init.d  Apache conf.d directory:  /etc/httpd/conf.d             Mail program:  /bin/mail                  Host OS:  linux-gnu Web Interface Options: ------------------------                 HTML URL:  http://localhost/nagios/                  CGI URL:  http://localhost/nagios/cgi-bin/ Traceroute (used by WAP):  /bin/tracerouteReview the options above for accuracy.  If they look okay,type 'make all' to compile the main program and CGIs.

隨后配置和編譯所有的的二進(jìn)制文件,make和make install將會(huì)在你的機(jī)器上安裝所需的二進(jìn)制文件然后才能繼續(xù)安裝,

[root@taoteng nagios-4.0.1]# make

[root@taoteng nagios-4.0.1]# make install


輸出樣例:

*** Main program, CGIs and HTML files installed ***You can continue with installing Nagios as follows (type 'make'without any arguments for a list of all possible options):  make install-init     - This installs the init script in /etc/rc.d/init.d  make install-commandmode     - This installs and configures permissions on the       directory for holding the external command file  make install-config     - This installs sample config files in /usr/local/nagios/etc

其實(shí)從上面的樣例上可以看出下步我們需要的操作步驟,接著執(zhí)行make install-init去安裝初始化腳本。

[root@taoteng nagios-4.0.1]# make install-init

從輸出的命令行上可以看出我們需要安裝外部命令文件(libxce)

[root@taoteng nagios-4.0.1]# make install-commandmode

接下來(lái)安裝nagios示例文件,運(yùn)行下面的命令:

[root@taoteng nagios-4.0.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.

步驟5:自定義nagios配置文件

打開(kāi)“contacts.cfg”文件編輯當(dāng)出現(xiàn)報(bào)警狀態(tài)時(shí)候的nagios管理員的電子郵箱

[root@taoteng nagios-4.0.1]# vi /usr/local/nagios/etc/objects/contacts.cfg

輸出樣例:

###############################################################################

#

# CONTACTS

#

###############################################################################

###############################################################################


# Just one contact defined by default - the Nagios admin (that's you)

# This contact definition inherits a lot of default values from the 'generic-contact'

# template which is defined elsewhere.


define contact{

       contact_name                    nagiosadmin             ; Short name of user

       use                             generic-contact         ; Inherit default values from generic-contact template (defined above)

       alias                           Nagios Admin            ; Full name of user


       email                          xiantao412@sina.com      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

       }

步驟6:安裝和配置Nagios的web接口

到目前為止,我們已經(jīng)完成了所有的配置,接下來(lái)將用下面的命令來(lái)配置Nagios的web接口。

下面的命令將配置web接口并同時(shí)創(chuàng)建一個(gè)“nagiosadmin”管理用戶。


[root@taoteng nagios-4.0.1]# make install-webconf

接下來(lái)的這步將會(huì)創(chuàng)建一個(gè)密碼為“nagiosadmin”記住這個(gè)密碼,因?yàn)榇龝?huì)兒在瀏覽器中登錄的時(shí)候?qū)?huì)用到這個(gè)密碼。

[root@taoteng nagios-4.0.1]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

重啟Apache服務(wù)使新的配置生效。

[root@taoteng nagios-4.0.1]# service httpd restart (On RedHat/CentOS)

[root@taoteng nagios-4.0.1]# systemctl start httpd.service (On Fedora)


步驟7:編譯和安裝nagios插件。

這兒已經(jīng)下載了nagios插件在/root/nagios目錄下面,直接進(jìn)去編譯和安裝即可:

[root@taoteng nagios]# tar -zxvf nagios-plugins-1.5

[root@taoteng nagios]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

[root@taoteng nagios]# make

[root@taoteng nagios]# make install


步驟8:驗(yàn)證nagios配置文件的是否有錯(cuò)誤(這就是nagios其中的一個(gè)很不錯(cuò)的地方,可以很清晰的告訴你是否有錯(cuò)誤)如果沒(méi)有什么錯(cuò)誤就輸出下面的語(yǔ)句:

[root@taoteng nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgs

輸出示例:

Running pre-flight check on configuration data...


Checking services...

       Checked 34 services.

Checking hosts...

       Checked 14 hosts.

Checking host groups...

       Checked 4 host groups.

Checking service groups...

       Checked 2 service groups.

Checking contacts...

       Checked 1 contacts.

Checking contact groups...

       Checked 1 contact groups.

Checking service escalations...

       Checked 0 service escalations.

Checking service dependencies...

       Checked 0 service dependencies.

Checking host escalations...

       Checked 0 host escalations.

Checking host dependencies...

       Checked 0 host dependencies.

Checking commands...

       Checked 25 commands.

Checking time periods...

       Checked 5 time periods.

Checking for circular paths between hosts...

Checking for circular host and service dependencies...

Checking global event handlers...

Checking obsessive compulsive processor commands...

Checking misc settings...


Total Warnings: 0

Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

步驟9:讓Nagios服務(wù)隨計(jì)算機(jī)開(kāi)機(jī)啟動(dòng)

為了是Nagios和httpd在重啟之后工作,我們需要把這兩個(gè)服務(wù)chkconfig一下:

[root@taoteng ~]# chkconfig --add nagios

[root@taoteng ~]#chkconfig --level 35 nagios on

[root@taoteng ~]#chkconfig --add httpd

[root@taoteng ~]#chkconfig --level 35 httpd on

重啟Nagios使更改生效!

[root@taoten ~]#service nagios restart

步驟10:通過(guò)瀏覽器來(lái)登錄到Nagios

我們的Nagios已經(jīng)可以開(kāi)始工作了,瀏覽器中輸入http://192.168.162.153/nagios;輸入“nagiosadmin”然后輸入密碼就okay了!

Nagios Login

Nagios 4.0.1版本安裝 適用于RHEL/Centos 5.x/6.x 或者Fedora 17/18/19(一)

主機(jī)概述:

Nagios 4.0.1版本安裝 適用于RHEL/Centos 5.x/6.x 或者Fedora 17/18/19(一)

Nagios Overview

Nagios 4.0.1版本安裝 適用于RHEL/Centos 5.x/6.x 或者Fedora 17/18/19(一)

Nagios Overview

所有的服務(wù)概述:

Nagios 4.0.1版本安裝 適用于RHEL/Centos 5.x/6.x 或者Fedora 17/18/19(一)

進(jìn)程概述:

Nagios 4.0.1版本安裝 適用于RHEL/Centos 5.x/6.x 或者Fedora 17/18/19(一)

Congratulations! You’ve successfully installed and configured Nagios and its Plugins. You’ve just begin your journey into monitoring.

??!升級(jí)nagios到新版本??!

如果你已經(jīng)安裝了一個(gè)老版本的nagios,那么你可以直接下載最新版本的nagios,按照下面的命令直接編譯安裝即可

[root@taoteng ~]# service nagios stop
[root@taoteng ~]# tar –zxvf nagios-4.0.1.tar.gz
[root@taoteng ~]# cd nagios-4.0.1
[root@taoteng ~]# ./configure
[root@taoteng ~]# make all
[root@taoteng ~]# make install
[root@taoteng ~]# service nagios start

到這里,nagios的基本配置已經(jīng)完成,當(dāng)然安裝過(guò)程中n難免會(huì)出現(xiàn)錯(cuò)誤的~會(huì)在后續(xù)的過(guò)程中更新出來(lái)當(dāng)然也非常歡迎友友聯(lián)系我一起來(lái)交流解決您碰見(jiàn)的問(wèn)題。

后續(xù)的博客也會(huì)跟進(jìn)nagios如何添加Linux主機(jī)、windows主機(jī)、交換機(jī)、打印機(jī)等等一些設(shè)備到Nagios監(jiān)視服務(wù)器中。


              -------------第一次 發(fā)博文,錯(cuò)誤之處,歡迎指出,敬請(qǐng)?jiān)?------------

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI