Nagios 3 的設定、架設等等,可以參考此篇:Nagios 安裝設定 於 Debian、Ubuntu Linux
上述是使用 Debian、Ubuntu Linux 官方包的 APT 套件架設,此篇介紹的是直接下載 Source code 來編譯架設。
Nagios Core 4 於 Debian Linux Stretch 架設
首先先說明為何要這麼費工手動編譯 Source code...
因為 Debian Linux Stretch 的 Nagios 3 不見了,而且要裝回 jessie 版的 Nagios 3 也因為套件衝突無法安裝,所以只好手動編譯來架設 Nagios 4。
先來看看 Nagios 3 和 Nagios 4 的差異
Nagios 架設需要下述幾個套件:
- Nagios Core
- Nagios Plugins # 可以想成是 client,都是 check script
- Nagios NRPE # 監控遠端機器會需要這個套件
Nagios 4 Core 下載
Nagios 4 Core 安裝架設
下述步驟參考自此篇:Nagios 4 安裝架設參考文件 PDF:Installing Nagios Core From Source
- wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.0.tar.gz # 可自行於官網下載最新版
- sudo apt-get install build-essential libgd-dev php-gd
- sudo useradd nagios
- sudo groupadd nagcmd
- sudo usermod -a -G nagcmd nagios
- sudo usermod -a -G nagios,nagcmd www-data
- tar zxvf nagios-4.2.0.tar.gz
- cd nagios-4.2.0
- ./configure --with-command-group=nagios --with-mail=/usr/sbin/sendmail --with-httpd-conf=/etc/apache2/
- Nagios executable: nagios
- Nagios user/group: nagios,nagios
- Command user/group: nagios,nagios
- 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/init.d
- Apache conf.d directory: /etc/apache2/
- Mail program: /usr/sbin/sendmail
- IOBroker Method: epoll
- Web Interface Options:
- HTML URL: http://localhost/nagios/
- CGI URL: http://localhost/nagios/cgi-bin/
- Traceroute (used by WAP): /usr/bin/traceroute
- config
- /usr/local/nagios/etc
- /etc/apache2/conf.d/nagios.conf
Nagios 4 Plugins 安裝架設
- wget http://nagios-plugins.org/download/nagios-plugins-2 .1.2.tar.gz # 可自行於官網下載最新版
- tar zxvf nagios-plugins-2.1.2.tar.gz
- cd nagios-plugins-2.1.2
- ./configure
- make
- # make check # 這個步驟可以跳過,此步驟要輸入很多東西,大概會花掉1hr
- sudo make install
- make installcheck
Nagios 4 NRPE 安裝架設
下述架設參考自下述:
- Nagios Enterprises NRPE 安裝文件 PDF:nrpe/NRPE.pdf at master · NagiosEnterprises/nrpe
- 官網:GitHub - NagiosEnterprises/nrpe: NRPE Agent
NRPE 安裝步驟
- apt install libssl-dev # ./configure 遇到 configure: error: Cannot find ssl headers
- git clone https://github.com/NagiosEnterprises/nrpe/
- cd nrpe
- ./configure
- make all
- make install-groups-users
- make install
- make install-config
- make install-inetd
- make install-init
- systemctl enable nrpe
- systemctl start nrpe
- netstat -at | egrep "nrpe|5666"
- /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v3.0 - cat /etc/systemd/system/multi-user.target.wants/nrpe.service # 確認 systemd 有 nrpe.service
- sudo systemctl restart nrpe.service # 重新啟動看看
- sudo ln -s /usr/local/nagios/etc /etc/nagios # 將設定檔丟到 /etc/nagios 方便 Debian 以前的設定習慣
測試
- /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
- /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_load
Nagios 幾個參數設定
增加 check_nrpe_1arg 的參數
- vim /etc/nagios/object/commands.cfg # 最下面增加下述
define command {
command_name check_nrpe_1arg
command_line $USER1$/check_nrpe $ARG1$
}
設定通知人、Email (ops)
- sudo vim /etc/nagios/objects/contacts.cfg # 找到 email 修改即可
Nagios 3 與 Nagios 4 Client V2 與 V3 版本相容的設定
- tail -f /var/log/syslog # 可見到下述訊息
Sep 1 08:31:01 yotta check_nrpe: Remote 192.168.1.108 accepted a Version 2 Packet
Sep 1 08:31:05 yotta check_nrpe: Remote 192.168.1.101 does not support Version 3 Packets
Sep 1 08:31:05 yotta check_nrpe: Remote 192.168.1.101 accepted a Version 2 Packet - 參考自:'check_nrpe' command definition
- vim /etc/nagios/object/commands.cfg # 最下面增加下述# Remote 192.168.1.108 does not support Version 3 Packets
define command {
command_name check_nrpe_v2
command_line $USER1$/check_nrpe -2 -H $HOSTADDRESS$ -p 5666 -c $ARG1$
}
Nagios Remote Client 的架設、設定
Nagios 要監控的機器,需要安裝下述:
- Nagios Plugins # 可以想成是 client,都是 check script
- Nagios NRPE # 監控遠端機器會需要這個套件
- 這兩個套件的安裝步驟與上述都一樣(./configure、make ... 即可)
- 其它設定可參考內部設定檔的範例,或者此篇最上面的連結(Debian、Ubuntu Linux 架設那篇)
相關網頁
- Monitoring Linux Remote Hosts with nagios NRPE...
- Nagios - check host status with NRPE
- Nagios NRPE Addon Installation and Configuration - Debian Clusters
- How To Install Nagios On CentOS 6
- GitHub - NagiosEnterprises/nrpe: NRPE Agent
- NRPE - Nagios Remote Plugin Executor - Nagios Exchange
- How to Monitor Linux Server Using Nagios Core And NRPE
- network monitoring - nagios- nrpe installation error(configure: error: Cannot find ssl libraries)