====== 加裝 Nagios Plugin 增加監控能力 ======
* 返回 [[tech:librenms]]
===== 安裝語法 =====
* CentOS 7
yum install nagios-plugins-all
* Ubuntu 20.04
sudo apt install nagios-plugins
===== 進行設定 =====
==== CentOS 7 ====
* 更改設定檔 vi /opt/librenms/config.php
:
# nagios-plugins-all
$config['show_services'] = 1;
$config['nagios_plugins'] = "/usr/lib64/nagios/plugins";
chmod +x /usr/lib64/nagios/plugins/*
==== Ubuntu 20.04 ====
* 更改設定檔 vi /opt/librenms/config.php
:
# nagios-plugins
$config['show_services'] = 1;
$config['nagios_plugins'] = "/usr/lib/nagios/plugins";
chmod +x /usr/lib/nagios/plugins/*
===== 共同設定 =====
* 設定定時起動 services-wrapper.py vi /etc/cron.d/librenms
:
*/5 * * * * librenms /opt/librenms/services-wrapper.py 1
# Daily maintenance script. DO NOT DISABLE!
:
* CentOS 7
service crond restart
* Ubuntu 20.04
systemctl restart cron
* 可以透過 Add Service 增加設定檢查 SSL 憑證到期日, mail 服務運作是否正常...等等的設定
* {{:tech:2019010801.png}}
* {{:tech:2019010802.png}}
* {{:tech:2019010803.png}}
* {{:tech:2019010804.png}}
* 如果要研究所有 plugin 的語法, 可以直接到 /usr/lib64/nagios/plugins 目錄內下命令測試 Exp. ssmtp -> check_ssmtp
cd /usr/lib64/nagios/plugins/
./check_ssmtp --help
++++看結果|
[root@ct-librenms plugins]# ./check_ssmtp --help
check_ssmtp v2.2.1.git (nagios-plugins 2.2.1)
Copyright (c) 1999 Ethan Galstad
Copyright (c) 1999-2014 Nagios Plugin Development Team
This plugin tests SSMTP connections with the specified host (or unix socket).
Usage:
check_ssmtp -H host -p port [-w ] [-c ] [-s ]
[-e ] [-q ][-m ] [-d ]
[-t ] [-r ] [-M ] [-v] [-4|-6] [-j]
[-D [,]] [-S ++++
===== 檢查網站 SSL 憑證到期日 =====
* 因為網站大量使用 Web Virtual Host 方式設定, 但檢查 SSL 憑證到期日都只會回應預設的網址憑證到期日.. Exp. www.ichiayi.com 與 svn.ichiayi.com
./check_http -H www.ichiayi.com --ssl -C 30,10
SSL OK - Certificate 'www.ichiayi.com' will expire in 79 days on 2019-06-14 23:34 +0800/CST.
./check_http -H svn.ichiayi.com --ssl -C 30,10
SSL OK - Certificate 'www.ichiayi.com' will expire in 79 days on 2019-06-14 23:34 +0800/CST.
所以看到 svn.ichiayi.com 回應出來的結果會出現 www.ichiayi.com , 這問題可以**增加 --sni 參數**來解決
./check_http -H www.ichiayi.com --ssl --sni -C 30,10
SSL OK - Certificate 'www.ichiayi.com' will expire in 79 days on 2019-06-14 23:34 +0800/CST.
./check_http -H svn.ichiayi.com --ssl --sni -C 30,10
SSL WARNING - Certificate 'svn.ichiayi.com' expires in 29 day(s) (2019-04-26 15:26 +0800/CST).
===== 檢查網址回應效率與關鍵字 =====
* 檢查特定網址的回應效率與正確性 .. Exp. https://172.16.1.32/erptools/Tracing_material.php
* 參考網址 - https://raymii.org/s/tutorials/Service_checks_in_LibreNMS_nagios_plugins.html
* {{:tech:2019090301.png}}
* 參數說明
* -E : 額外的效能資料
* -I : 指定特定的 IP (Exp. 網站內部外部 IP 不同)
* -S : 使用 SSL 加密協定 (https) **如有出現 Cannot make SSL connection 錯誤訊息可加上 --sni** Exp. --sni -S
* -p 443 : 使用連線埠 443
* -u : 要進行效能檢核的網址
* -s : 網頁內容必須出現的關鍵字串 Exp. Jonathan
* 檢核的結果可能類似以下的訊息 :
HTTP OK: HTTP/1.1 200 OK - 1073685 bytes in 0.536 second response time
===== 參考網址 =====
* 參考相關參數的意義 - https://www.monitoring-plugins.org/doc/man/index.html
* https://www.monitoring-plugins.org/doc/man/check_http.html
* https://www.monitoring-plugins.org/doc/man/check_ping.html
{{tag>librenms_agent nagios}}