差異處
這裏顯示兩個版本的差異處。
下次修改 | 前次修改 | ||
tech:librenms:nagios_agent [2020/07/05 12:14] – 建立 jonathan_tsai | tech:librenms:nagios_agent [2023/04/08 11:05] (目前版本) – [檢查網址回應效率與關鍵字] jonathan | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== 加裝 Nagios Plugin 增加監控能力 ====== | ||
+ | * 返回 [[tech: | ||
+ | |||
+ | ===== 安裝語法 ===== | ||
+ | * CentOS 7 <cli> | ||
+ | yum install nagios-plugins-all | ||
+ | </ | ||
+ | * Ubuntu 20.04 <cli> | ||
+ | sudo apt install nagios-plugins | ||
+ | </ | ||
+ | |||
+ | ===== 進行設定 ===== | ||
+ | ==== CentOS 7 ==== | ||
+ | * 更改設定檔 <code sh>vi / | ||
+ | : | ||
+ | # nagios-plugins-all | ||
+ | $config[' | ||
+ | $config[' | ||
+ | </ | ||
+ | chmod +x / | ||
+ | </ | ||
+ | |||
+ | ==== Ubuntu 20.04 ==== | ||
+ | * 更改設定檔 <code sh>vi / | ||
+ | : | ||
+ | # nagios-plugins | ||
+ | $config[' | ||
+ | $config[' | ||
+ | </ | ||
+ | chmod +x / | ||
+ | </ | ||
+ | |||
+ | ===== 共同設定 ===== | ||
+ | * 設定定時起動 services-wrapper.py <code sh>vi / | ||
+ | : | ||
+ | */5 * * * * | ||
+ | |||
+ | # Daily maintenance script. DO NOT DISABLE! | ||
+ | : | ||
+ | </ | ||
+ | * CentOS 7<code sh> | ||
+ | service crond restart | ||
+ | </ | ||
+ | * Ubuntu 20.04 <cli> | ||
+ | systemctl restart cron | ||
+ | </ | ||
+ | * 可以透過 Add Service 增加設定檢查 SSL 憑證到期日, | ||
+ | * {{: | ||
+ | * {{: | ||
+ | * {{: | ||
+ | * {{: | ||
+ | |||
+ | < | ||
+ | * 如果要研究所有 plugin 的語法, 可以直接到 / | ||
+ | cd / | ||
+ | ./ | ||
+ | </ | ||
+ | ++++看結果|< | ||
+ | [root@ct-librenms plugins]# ./ | ||
+ | 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 <warning time>] [-c < | ||
+ | [-e <expect string>] [-q <quit string> | ||
+ | [-t <timeout seconds> | ||
+ | [-D <warn days cert expire> | ||
+ | [-N <server name indication> | ||
+ | |||
+ | Options: | ||
+ | -h, --help | ||
+ | Print detailed help screen | ||
+ | -V, --version | ||
+ | Print version information | ||
+ | | ||
+ | Read options from an ini file. See | ||
+ | https:// | ||
+ | for usage and examples. | ||
+ | -H, --hostname=ADDRESS | ||
+ | Host name, IP Address, or unix socket (must be an absolute path) | ||
+ | -p, --port=INTEGER | ||
+ | Port number (default: none) | ||
+ | -4, --use-ipv4 | ||
+ | Use IPv4 connection | ||
+ | -6, --use-ipv6 | ||
+ | Use IPv6 connection | ||
+ | -E, --escape | ||
+ | Can use \n, \r, \t or \\ in send or quit string. Must come before send or quit option | ||
+ | Default: nothing added to send, \r\n added to end of quit | ||
+ | -s, --send=STRING | ||
+ | String to send to the server | ||
+ | -e, --expect=STRING | ||
+ | String to expect in server response (may be repeated) | ||
+ | -A, --all | ||
+ | All expect strings need to occur in server response. Default is any | ||
+ | -q, --quit=STRING | ||
+ | String to send server to initiate a clean close of the connection | ||
+ | -r, --refuse=ok|warn|crit | ||
+ | Accept TCP refusals with states ok, warn, crit (default: crit) | ||
+ | -M, --mismatch=ok|warn|crit | ||
+ | Accept expected string mismatches with states ok, warn, crit (default: warn) | ||
+ | -j, --jail | ||
+ | Hide output from TCP socket | ||
+ | -m, --maxbytes=INTEGER | ||
+ | Close connection once more than this number of bytes are received | ||
+ | -d, --delay=INTEGER | ||
+ | Seconds to wait between sending string and polling for response | ||
+ | -D, --certificate=INTEGER[, | ||
+ | Minimum number of days a certificate has to be valid. | ||
+ | 1st is #days for warning, 2nd is critical (if not specified - 0). | ||
+ | -S, --ssl | ||
+ | Use SSL for the connection. | ||
+ | -w, --warning=DOUBLE | ||
+ | Response time to result in warning status (seconds) | ||
+ | -c, --critical=DOUBLE | ||
+ | Response time to result in critical status (seconds) | ||
+ | -t, --timeout=INTEGER:< | ||
+ | Seconds before connection times out (default: 10) | ||
+ | Optional ":< | ||
+ | -v, --verbose | ||
+ | Show details for command-line debugging (Nagios may truncate output) | ||
+ | |||
+ | Send email to [email protected] if you have questions regarding use | ||
+ | of this software. To submit patches or suggest improvements, | ||
+ | [email protected] | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== 檢查網站 SSL 憑證到期日 ===== | ||
+ | * 因為網站大量使用 Web Virtual Host 方式設定, | ||
+ | ./ | ||
+ | SSL OK - Certificate ' | ||
+ | |||
+ | ./ | ||
+ | SSL OK - Certificate ' | ||
+ | </ | ||
+ | ./ | ||
+ | SSL OK - Certificate ' | ||
+ | |||
+ | ./ | ||
+ | SSL WARNING - Certificate ' | ||
+ | </ | ||
+ | |||
+ | ===== 檢查網址回應效率與關鍵字 ===== | ||
+ | * 檢查特定網址的回應效率與正確性 .. Exp. https:// | ||
+ | * 參考網址 - https:// | ||
+ | * {{: | ||
+ | * 參數說明 | ||
+ | * -E : 額外的效能資料 | ||
+ | * -I : 指定特定的 IP (Exp. 網站內部外部 IP 不同) | ||
+ | * -S : 使用 SSL 加密協定 (https) **如有出現 Cannot make SSL connection 錯誤訊息可加上 --sni** Exp. < | ||
+ | * -p 443 : 使用連線埠 443 | ||
+ | * -u : 要進行效能檢核的網址 | ||
+ | * -s : 網頁內容必須出現的關鍵字串 Exp. Jonathan | ||
+ | * 檢核的結果可能類似以下的訊息 : < | ||
+ | HTTP OK: HTTP/1.1 200 OK - 1073685 bytes in 0.536 second response time | ||
+ | </ | ||
+ | |||
+ | ===== 參考網址 ===== | ||
+ | * 參考相關參數的意義 - https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | {{tag> |