Debian 13 trixie

Nagios : 監視対象項目を追加する2025/10/03

 

デフォルトの監視対象項目以外にも、様々な項目を監視対象として追加できます。
チェックプログラムを自身で作成して追加することも可能ですが、プラグインとしてパッケージで提供されているものも多数あるため、主要な項目は容易に監視対象として追加可能です。
以下のサイトではパッケージで提供されていないプラグインも多数提供されています。
⇒ https://www.nagios.org/downloads/nagios-plugins/

[1] プラグインは多数提供されています。
root@dlp:~#
ll /usr/lib/nagios/plugins

total 2708
-rwxr-xr-x 1 root root  60168 Apr 22 23:25 check_apt
-rwxr-xr-x 1 root root   2337 Apr 22 23:25 check_breeze
-rwxr-xr-x 1 root root  60552 Apr 22 23:25 check_by_ssh
lrwxrwxrwx 1 root root      9 Apr 22 23:25 check_clamd -> check_tcp
-rwxr-xr-x 1 root root  43592 Apr 22 23:25 check_cluster
-rwxr-xr-x 1 root root 110472 Apr 22 23:25 check_curl
-rwxr-xr-x 1 root root  60200 Apr 22 23:25 check_dbi
-rwxr-xr-x 1 root root  64168 Apr 22 23:25 check_dhcp
.....
.....

# 下記パッケージをインストールすることで追加プラグインも利用可

root@dlp:~#
apt search monitoring-plugins-contrib

monitoring-plugins-contrib/stable 48.20250420 amd64
  Plugins for nagios compatible monitoring systems
[2] 例として、NTP サーバーとの時間のずれを監視項目として追加します。
# [check_ntp_time] プラグインの使用方法

root@dlp:~#
/usr/lib/nagios/plugins/check_ntp_time -h

.....
.....

 -w, --warning=THRESHOLD
    Offset to result in warning status (seconds)
 -c, --critical=THRESHOLD
    Offset to result in critical status (seconds)

.....
.....

root@dlp:~#
vi /etc/nagios4/objects/commands.cfg
# 最終行にコマンド定義を追記
define command{
    command_name    check_ntp_time
    command_line    $USER1$/check_ntp_time -H $ARG1$ -w $ARG2$ -c $ARG3$
}

root@dlp:~#
vi /etc/nagios4/objects/localhost.cfg
# 最終行に追記
# NTP サーバー [10.0.0.10] との時間が 1秒差で Warning, 2秒差で Critical
define service{
    use                             generic-service
    host_name                       localhost
    service_description             NTP_TIME
    check_command                   check_ntp_time!10.0.0.10!1!2
}

root@dlp:~#
systemctl reload nagios4

[3] 追加設定した監視項目は Nagios 管理サイトにログインすると確認できます。
関連コンテンツ