Ubuntu 24.04

Nagios : 監視対象項目を追加する2026/03/13

 

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

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

total 1888
drwxr-xr-x 2 root root  4096 Mar 13 00:31 ./
drwxr-xr-x 3 root root  4096 Apr 23  2024 ../
-rwxr-xr-x 1 root root 35624 Apr  1  2024 check_apt*
-rwxr-xr-x 1 root root  2337 Apr  1  2024 check_breeze*
-rwxr-xr-x 1 root root 36008 Apr  1  2024 check_by_ssh*
lrwxrwxrwx 1 root root     9 Apr  1  2024 check_clamd -> check_tcp*
-rwxr-xr-x 1 root root 31336 Apr  1  2024 check_cluster*
-rwxr-xr-x 1 root root 85864 Apr  1  2024 check_curl*
.....
.....

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

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 管理サイトにログインすると確認できます。
関連コンテンツ