Zabbix监控模板(nginx)

我已经为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服务

如果不使用代理缓存功能,则应禁用“缓存管理进程”的监控和触发。

模板。

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

应用程序 xù)

    nginx service

物品

#アイテム名トリガーキーデータ型単位乗数の使用更新間隔(秒)ヒストリトレンドタイプアプリケーション内容備考1HTTP service is running1net.tcp.service[tcp,,80]数値–3090365Zabbixエージェントnginx serviceTCP80ポート(http)のステータス取得TCP80ポート(http)を使用しない場合は不要2HTTPS service is running1net.tcp.service[tcp,,443]数値–3090365Zabbixエージェントnginx serviceTCP443ポート(https)のステータス取得TCP443ポート(https)を使用しない場合は不要3Version of nginx0custom.nginx.version文字列–8640090-Zabbixエージェントnginx servicenginxのバージョン取得
4Checksum of /usr/sbin/nginx1vfs.file.cksum[/usr/sbin/nginx]数値–360090365Zabbixエージェントnginx servicenginxのハッシュ値取得prelinkが無効にされている事5Number of running processes nginx cache manager process1proc.num[nginx,,,cache manager process]数値–3090365Zabbixエージェントnginx servicecache manager processの個数取得Proxy_Cache(キャッシュ機能)を使用しない場合は不要6Number of running processes nginx master process1proc.num[nginx,,,master process]数値–3090365Zabbixエージェントnginx servicemaster processの個数取得
7Number of running processes nginx worker process1proc.num[nginx,,,worker process]数値–3090365Zabbixエージェントnginx serviceworker processの個数取得
    • ヒストリとは各収集値の保持期間

 

    • トレンドとは数値データタイプの1時間あたりの最低値、最高値、平均値および合計値の保持期間

 

    Zabbixにリトライ回数、リトライ間隔、タイムアウト時間は存在しない

引发 or 触发

#深刻度トリガー条件式種別内容備考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未満だった場合

配置配置文件

# 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

物品

#アイテム名トリガーキーデータ型単位乗数の使用更新間隔(秒)ヒストリトレンドタイプアプリケーション内容備考1nginx active connection0custom.nginx.stubstatus.activeconnection数値–3090365Zabbixエージェントnginx StubStatusオープンされているコネクション数取得
2nginx reading0custom.nginx.stubstatus.reading数値–3090365Zabbixエージェントnginx StubStatusリクエストヘッダを読取中のコネクション数取中
3nginx writing0custom.nginx.stubstatus.writing数値–3090365Zabbixエージェントnginx StubStatusリクエストボディ読取中、リクエスト処理中、クライアントへレスポンス書込中のコネクション数取得
4nginx waiting0custom.nginx.stubstatus.waiting文字列–3090365Zabbixエージェントnginx StubStatuskeepaliveコネクション数取得
    • ヒストリとは各収集値の保持期間

 

    • トレンドとは数値データタイプの1時間あたりの最低値、最高値、平均値および合計値の保持期間

 

    Zabbixにリトライ回数、リトライ間隔、タイムアウト時間は存在しない

触发 (chū fā)

没有

配置配置資料

# 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

在CentOS 5和6上重启zabbix-agent。

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

重新启动Zabbix-Agent(CentOS 7)

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