LoginSignup
0
2

More than 5 years have passed since last update.

Zabbix監視テンプレート(GlusterFS Client)

Last updated at Posted at 2017-07-18

Zabbix監視テンプレート(GlusterFS Client)を作成しました。
Zabbix 3.0、GlusterFS(クライアント側) 3.7.8で検証しています。

前提条件

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

GlusterFS Client

テンプレート

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

アプリケーション

  • GlusterFS Client service

アイテム

# アイテム名 トリガー キー データ型 単位 乗数の使用 更新間隔(秒) ヒストリ トレンド タイプ アプリケーション 内容 備考
1 Version of glusterfs 0 custom.glusterfs.version 文字列 - - 86400 90 - Zabbixエージェント GlusterFS Client service glusterfsのバージョン取得
2 Checksum of /usr/sbin/glusterfs 1 vfs.file.cksum[/usr/sbin/glusterfs] 数値 - - 3600 90 365 Zabbixエージェント GlusterFS Client service glusterfsのハッシュ値取得 prelinkが無効にされている事
3 Number of running processes glusterfs 1 proc.num[glusterfs] 数値 - - 30 90 365 Zabbixエージェント GlusterFS Client service glusterfsプロセスの個数取得
  • ヒストリとは各収集値の保持期間
  • トレンドとは数値データタイプの1時間あたりの最低値、最高値、平均値および合計値の保持期間
  • Zabbixにリトライ回数、リトライ間隔、タイムアウト時間は存在しない

トリガー

# 深刻度 トリガー 条件式 種別 内容 備考
1 警告 /usr/sbin/glusterfs has been changed on {HOST.NAME} vfs.file.cksum[/usr/sbin/glusterfs].diff(0)>0 バージョン /usr/sbin/glusterfsのハッシュ値の最新値と前回値に差があった場合 prelinkが無効にされている事
2 重度の障害 glusterfs process is not running on {HOST.NAME} proc.num[glusterfs].last(0)<1 プロセス 稼働中のglusterfsプロセスの最新個数が1未満だった場合 マウントの個数とプロセスの個数は比例するため、閾値はマウントの個数に合わせて適宜調整する事

ディスカバリ

ディスカバリルール

# 名前 タイプ キー 更新間隔(秒) 例外の更新間隔 存在しなくなったリソースの保持期間(日) 説明 備考
1 Custom glusterfs.fuse mounted filesystems for discovery Zabbixエージェント custom.vfs.fs.glusterfs.fuse.discovery 3600 - 30 Discovery of custom file systems of different types as defined in global regular expression "Custom file systems for discovery".

フィルター

  • なし

アイテムのプロトタイプ

# 名前 トリガー キー データ型 単位 乗数の使用 更新間隔(秒) ヒストリ トレンド タイプ アプリケーション 内容 備考
1 GlusterFS Client service {#FSNAME} is mounted 1 custom.glusterfs.fuse.mountpoint[{#FSNAME}] 数値 - - 30 90 365 Zabbixエージェント GlusterFS Client service 特定ボリュームのマウント状況結果(0: OK, 1: NG)
  • ヒストリとは各収集値の保持期間
  • トレンドとは数値データタイプの1時間あたりの最低値、最高値、平均値および合計値の保持期間
  • Zabbixにリトライ回数、リトライ間隔、タイムアウト時間は存在しない

トリガーのプロトタイプ

# 深刻度 トリガー 条件式 種別 内容 備考
1 重度の障害 GlusterFS Client service {#FSNAME} is unmounted on {HOST.NAME} custom.glusterfs.fuse.mountpoint[{#FSNAME}].min(#3)<>0 ファイルシステム 直近3回の特定ボリュームのマウント状況結果の戻り値(最小値)が0ではない場合

スクリプトの設置

/usr/local/bin/lld-glusterfs-fuse.py
#!/usr/bin/python
# coding: utf-8
# ------------------------------------------------------------------------------
# Script Name  : lld-glusterfs-fuse.py
# Tool Version : 1.0.0
# Argument     : -
# Option       : -h, --help     show this help message and exit
#              : -v, --version  show version and exit
#              : -t, --fstype   select virtual file system type
#              : -n, --fsname   select virtual file system name
# Usage        : $0 [Option]
# Return       : -
# -------------+-------------------------------------------+--------------------
# Date         | Changes                                   | Author
# -------------+-------------------------------------------+--------------------
# 2017/07/18   | New Creation                              | @bloodia
# ------------------------------------------------------------------------------
# --+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8

import json
import subprocess
import re
import argparse

parser = argparse.ArgumentParser()
parser.add_argument(
                       '-v', '--version',
                       action='version',
                       version='1.0.0',
                       help='show version and exit'
                   )
parser.add_argument(
                       '-t', '--fstype',
                       action='store',
                       help='select virtual file system type'
                   )
parser.add_argument(
                       '-n', '--fsname',
                       action='store',
                       help='select virtual file system name'
                   )
args = parser.parse_args()

if __name__ == '__main__':
    p1 = subprocess.Popen(['cat', '/proc/mounts'], stdout=subprocess.PIPE)
    p2 = subprocess.Popen(['awk', '{print $2,$3}'],stdin=p1.stdout,stdout=subprocess.PIPE)
    p3 = subprocess.Popen(['grep', '-v',  'sr|loop|ram'], stdin=p2.stdout, stdout=subprocess.PIPE)
    stdout, stderr = p3.communicate()
    data = list()
    for line in stdout.split('\n'):
        if line:
            fs = line.split(" ")
            fsname = fs[0]
            fstype = fs[1]
            if args.fstype:
                if fstype == args.fstype:
                    if args.fsname:
                        m = re.match(r"(%s)" % args.fsname, fsname)
                        if m:
                            data.append({"{#FSNAME}": fsname, "{#FSTYPE}": fstype})
                    else:
                        data.append({"{#FSNAME}": fsname, "{#FSTYPE}": fstype})
            else:
                data.append({"{#FSNAME}": fsname, "{#FSTYPE}": fstype})
    print(json.dumps({"data": data}, indent=4))

コンフィグの設置

/etc/zabbix/zabbix_agentd.d/userparameter_glusterfs-fuse.conf
# Custom Discovery Rules
UserParameter=custom.vfs.fs.glusterfs.fuse.discovery,/usr/local/bin/lld-glusterfs-fuse.py -t 'fuse.glusterfs'

# Custom Monitoring Items
UserParameter=custom.glusterfs.version,/usr/sbin/glusterfs --version | head -n 1 | cut -d ' ' -f 1-2
UserParameter=custom.glusterfs.fuse.mountpoint[*],mountpoint -q $1 && echo 0 || echo 1

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

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

zabbix-agentの再起動(CentOS 7)

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

関連記事

Zabbix監視テンプレート(GlusterFS Node)

0
2
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
0
2