溫馨提示×

溫馨提示×

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

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

nagios 監控linux 主機

發布時間:2020-07-10 03:51:01 來源:網絡 閱讀:761 作者:乜波 欄目:移動開發

1.解決時間同步問題

 當然前提是你的服務器已經安裝了ntp的程序,如果沒有安裝可以:
 yum -y install ntp
 /usr/sbin/ntpdate pool.ntp.org

 uptime

2.安裝Nagios所需要的基礎包

 yum -y install gcc glibc glibc-common
 yum -y install gd gd-devdel

 yum -y install openssl-devel

3.創建nagios 用戶

useradd nagios

4.下載安裝最新nagios插件

wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

tar zxvf nagios-plugins-1.5.tar.gz

cd nagios-plugins-1.5

./configure --with-nagios-user=nagios --with-nagios-group=nagios

make && make install

5.更改目錄權限:

   chown nagios.nagios /usr/local/nagios

  chown -R nagios.nagios /usr/local/nagios/libexec

6.安裝nrpe插件

wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz/download

tar zxvf nrpe-2.15.tar.gz

cd nrpe-2.15

./configure

nagios 監控linux 主機

make all

make install-plugin

make install-daemon

make install-daemon-config


7.將NRPE deamon作為xinetd 下的一個服務運行

  yum -y install xinetd

  make install-xinetd

顯示如下

nagios 監控linux 主機

可以看到創建了這個文件/etc/xinetd.d/nrpe,編輯這個腳本:

  vim /etc/xinetd.d/nrpe

nagios 監控linux 主機

8.編輯/etc/services這個文件,添加nrpe服務

  vim /etc/services

在最后添加如下:

#Local services

nrpe 5666/tcp         #nrpe



重啟xinetd的服務:

service xinetd restart

查看nrpe是否已經啟動:

[root@wordpress nrpe-2.15]# netstat -at |grep nrpe

tcp        0      0 *:nrpe                      *:*                         LISTEN      

[root@wordpress nrpe-2.15]# netstat -an |grep 5666

tcp        0      0 :::5666                     :::*                        LIST

查看nrpe 是否正常工作 

/usr/local/nagios/libexec/check_nrpe -H localhost


8.查看nrpe的監控命令:

     vim /usr/local/nagios/etc/nrpe.cfg

nagios 監控linux 主機

上面這5行定義的命令分別是檢測登陸用戶數,cpu負載,sda1的容量,僵尸進程,總進程數


9.配置監控端:  

先安裝openssl-devel

   yum -y install openssl-devel

安裝nrpe

   tar -zxvf nrpe-2.8.1.tar.gz

   cd nrpe-2.8.1

   ./configure --enable-ssl --with-ssl-lib=/usr/lib/

   make all

   make install-plugin

只運行之一步就行了,因為只需要check_nrpe這個插件

測試與被監控機的通信:

     /usr/local/nagios/libexec/check_nrpe -H 192.168.1.243

返回nrpe的版本說明通信正常


10.在command.cfg里添加外部構件nrpe

    vi /usr/local/nagios/etc/objects/commands.cfg
   添加
    #check nrpe
    define command{
       command_name check_nrpe
       command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
       }

 配置被監控主機:

     vim /usr/local/nagios/etc/nagios.cfg

    添加:

     cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg

11.配置mylinux.cfg

     cd /usr/local/nagios/etc/objects/

    touch mylinux.cfg

   chown nagios.nagios mylinux.cfg

   vim mylinux.cfg

   寫入如下:

   define host{
         use             linux-server
         host_name     mylinux
         alias            mylinux
         address        192.168.1.243
       }
define service{
       use                      generic-service
       host_name             mylinux
       service_description     HTTP
       check_command       check_http
      }
define service{
       use                      generic-service
       host_name             mylinux
       service_description     SSH
       check_command       check_ssh
      }
define service{
       use                      generic-service
       host_name             mylinux
       service_description     check-swap
       check_command        check_nrpe!check_swap
              }
define service{
       use                      generic-service
       host_name             mylinux
       service_description     check-load
      check_command         check_nrpe!check_load
              }
define service{
       use                      generic-service
       host_name             mylinux
      service_description     check-disk
      check_command        check_nrpe!check_disk
 }
define service{
      use                      generic-service
     host_name             mylinux
      service_description     check-users
      check_command        check_nrpe!check_users
              }
define service{
       use                    generic-service
       host_name           mylinux
       service_description  otal_procs
       check_command     check_nrpe!check_total_procs
            }

檢查配置文件是否錯誤:

   /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

nagios 監控linux 主機

12.重啟nagios: service nagios restart

13.查看web

nagios 監控linux 主機

完成!







向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女