LoginSignup
9
13

More than 5 years have passed since last update.

Zabbix監視テンプレート(nginx)

Last updated at Posted at 2016-12-27

nginxおよびnginx StubStatus向けのZabbix監視テンプレート(nginx)を作成しました。
Zabbix 3.0、nginx 1.10.2(HttpStubStatusModuleを含む)で検証しています。

前提条件

  • /etc/logrotate.dの設定がrestartではなく、reloadを使用している事。
  • Zabbixエージェントの設定ファイルにパラメータ"Include=/etc/zabbix/zabbix_agentd.d/"を設定している事。

nginx Service

Proxy_Cache(キャッシュ機能)を使用しない場合は、"cache manager process"の監視およびトリガーは無効にする事。

テンプレート

  • Template App nginx Service(テンプレートとのリンク: なし)

アプリケーション

  • nginx service

アイテム

# アイテム名 トリガー キー データ型 単位 乗数の使用 更新間隔(秒) ヒストリ トレンド タイプ アプリケーション 内容 備考
1 HTTP service is running 1 net.tcp.service[tcp,,80] 数値 - - 30 90 365 Zabbixエージェント nginx service TCP80ポート(http)のステータス取得 TCP80ポート(http)を使用しない場合は不要
2 HTTPS service is running 1 net.tcp.service[tcp,,443] 数値 - - 30 90 365 Zabbixエージェント nginx service TCP443ポート(https)のステータス取得 TCP443ポート(https)を使用しない場合は不要
3 Version of nginx 0 custom.nginx.version 文字列 - - 86400 90 - Zabbixエージェント nginx service nginxのバージョン取得
4 Checksum of /usr/sbin/nginx 1 vfs.file.cksum[/usr/sbin/nginx] 数値 - - 3600 90 365 Zabbixエージェント nginx service nginxのハッシュ値取得 prelinkが無効にされている事
5 Number of running processes nginx cache manager process 1 proc.num[nginx,,,cache manager process] 数値 - - 30 90 365 Zabbixエージェント nginx service cache manager processの個数取得 Proxy_Cache(キャッシュ機能)を使用しない場合は不要
6 Number of running processes nginx master process 1 proc.num[nginx,,,master process] 数値 - - 30 90 365 Zabbixエージェント nginx service master processの個数取得
7 Number of running processes nginx worker process 1 proc.num[nginx,,,worker process] 数値 - - 30 90 365 Zabbixエージェント nginx service worker processの個数取得
  • ヒストリとは各収集値の保持期間
  • トレンドとは数値データタイプの1時間あたりの最低値、最高値、平均値および合計値の保持期間
  • Zabbixにリトライ回数、リトライ間隔、タイムアウト時間は存在しない

トリガー

# 深刻度 トリガー 条件式 種別 内容 備考
1 軽度の障害 HTTP service is down on {HOST.NAME} net.tcp.service[tcp,,80].max(#3)=0 ポート 直近3回のTCP80ポート(http)のステータス取得時の戻り値(最大値)が0(Close)だった場合 TCP80ポート(http)を使用しない場合は不要
2 軽度の障害 HTTPS service is down on {HOST.NAME} net.tcp.service[tcp,,443].max(#3)=0 ポート 直近3回のTCP443ポート(https)のステータス取得時の戻り値(最大値)が0(Close)だった場合 TCP443ポート(https)を使用しない場合は不要
3 警告 /usr/sbin/nginx has been changed on {HOSTNAME} vfs.file.cksum[/usr/sbin/nginx].diff(0)>0 バージョン /usr/sbin/nginxのハッシュ値の最新値と前回値に差があった場合 prelinkが無効にされている事
4 重度の障害 cache manager process is not running on {HOST.NAME} proc.num[nginx,,,cache manager process].last(0)<1 プロセス 稼働中のcache manager processの最新個数が1未満だった場合 Proxy_Cache(キャッシュ機能)を使用しない場合は不要
5 重度の障害 master process is not running on {HOST.NAME} proc.num[nginx,,,master process].last(0)<1 プロセス 稼働中のmaster processの最新個数が1未満だった場合
6 重度の障害 worker process is not running on {HOST.NAME} proc.num[nginx,,,worker process].last(0)<1 プロセス 稼働中のworker processの最新個数が1未満だった場合

コンフィグの設置

/etc/zabbix/zabbix_agentd.d/userparameter_nginx.conf
# Custom Monitoring Items
UserParameter=custom.nginx.version,/usr/sbin/nginx -v 2>&1 | cut -d '/' -f 2

zabbix-agentの再起動(CentOS 5, 6)

[root@localhost ~]# /etc/init.d/zabbix-agent restart

zabbix-agentの再起動(CentOS 7)

[root@localhost ~]# systemctl restart zabbix-agent

nginx StubStatus

HttpStubStatusModuleを使用する場合に適用する事。

テンプレート

  • Template App nginx StubStatus Service(テンプレートとのリンク: なし)

アプリケーション

  • nginx StubStatus

アイテム

# アイテム名 トリガー キー データ型 単位 乗数の使用 更新間隔(秒) ヒストリ トレンド タイプ アプリケーション 内容 備考
1 nginx active connection 0 custom.nginx.stubstatus.activeconnection 数値 - - 30 90 365 Zabbixエージェント nginx StubStatus オープンされているコネクション数取得
2 nginx reading 0 custom.nginx.stubstatus.reading 数値 - - 30 90 365 Zabbixエージェント nginx StubStatus リクエストヘッダを読取中のコネクション数取中
3 nginx writing 0 custom.nginx.stubstatus.writing 数値 - - 30 90 365 Zabbixエージェント nginx StubStatus リクエストボディ読取中、リクエスト処理中、クライアントへレスポンス書込中のコネクション数取得
4 nginx waiting 0 custom.nginx.stubstatus.waiting 文字列 - - 30 90 365 Zabbixエージェント nginx StubStatus keepaliveコネクション数取得
  • ヒストリとは各収集値の保持期間
  • トレンドとは数値データタイプの1時間あたりの最低値、最高値、平均値および合計値の保持期間
  • Zabbixにリトライ回数、リトライ間隔、タイムアウト時間は存在しない

トリガー

なし

コンフィグの設置

/etc/zabbix/zabbix_agentd.d/userparameter_nginx-stubstatus.conf
# Custom Monitoring Items
UserParameter=custom.nginx.stubstatus.activeconnection,curl -s 127.0.0.1/nginx_stub_status | head -n 1 | cut -d ' ' -f 3
UserParameter=custom.nginx.stubstatus.reading,curl -s 127.0.0.1/nginx_stub_status | tail -n 1 | cut -d ' ' -f 2
UserParameter=custom.nginx.stubstatus.writing,curl -s 127.0.0.1/nginx_stub_status | tail -n 1 | cut -d ' ' -f 4
UserParameter=custom.nginx.stubstatus.waiting,curl -s 127.0.0.1/nginx_stub_status | tail -n 1 | cut -d ' ' -f 6

zabbix-agentの再起動(CentOS 5, 6)

[root@localhost ~]# /etc/init.d/zabbix-agent restart

zabbix-agentの再起動(CentOS 7)

[root@localhost ~]# systemctl restart zabbix-agent
9
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
13