almost there

This commit is contained in:
Marius Pana 2018-09-05 23:52:16 +03:00
commit a76bc38054
9 changed files with 424 additions and 0 deletions

41
.vscode/tags vendored Normal file
View File

@ -0,0 +1,41 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
check_parameters.py ../web/plugins/wato/check_parameters.py 1;" kind:file line:1
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:103
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:12
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:19
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:26
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:33
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:40
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:47
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:54
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:61
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:68
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:75
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:82
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:89
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:96
elements ../web/plugins/wato/check_parameters.py /^ elements=[$/;" kind:variable line:8
match_type ../web/plugins/wato/check_parameters.py /^ match_type="dict",$/;" kind:variable line:113
nfsiostat.py ../web/plugins/metrics/nfsiostat.py 1;" kind:file line:1
optional_keys ../web/plugins/wato/check_parameters.py /^ optional_keys=True, $/;" kind:variable line:7
title ../web/plugins/wato/check_parameters.py /^ title=_("Operations"),$/;" kind:variable line:11
title ../web/plugins/wato/check_parameters.py /^ title=_("RPC Backlog"),$/;" kind:variable line:18
title ../web/plugins/wato/check_parameters.py /^ title=_("Read Average Executions (ms)"),$/;" kind:variable line:60
title ../web/plugins/wato/check_parameters.py /^ title=_("Read Average RTT (ms)"),$/;" kind:variable line:53
title ../web/plugins/wato/check_parameters.py /^ title=_("Read Operations"),$/;" kind:variable line:25
title ../web/plugins/wato/check_parameters.py /^ title=_("Read Retransmissions"),$/;" kind:variable line:46
title ../web/plugins/wato/check_parameters.py /^ title=_("Read kB\/op"),$/;" kind:variable line:39
title ../web/plugins/wato/check_parameters.py /^ title=_("Read"),$/;" kind:variable line:32
title ../web/plugins/wato/check_parameters.py /^ title=_("Write Avg RTT (ms)"),$/;" kind:variable line:95
title ../web/plugins/wato/check_parameters.py /^ title=_("Write Avg exe (ms)"),$/;" kind:variable line:102
title ../web/plugins/wato/check_parameters.py /^ title=_("Write B\/s"),$/;" kind:variable line:81
title ../web/plugins/wato/check_parameters.py /^ title=_("Write Bytes"),$/;" kind:variable line:74
title ../web/plugins/wato/check_parameters.py /^ title=_("Write Operations\/s"),$/;" kind:variable line:67
title ../web/plugins/wato/check_parameters.py /^ title=_("Write Retransmissions"),$/;" kind:variable line:88
title ../web/plugins/wato/check_parameters.py /^ title=_("NFS IO Statistics"),$/;" kind:variable line:111
title ../web/plugins/wato/check_parameters.py /^ title=_("NFS IO Statistics"),$/;" kind:variable line:6

View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
def bake_nfsiostat(opsys, conf, conf_dir, plugins_dir):
shutil.copy2(cmk.paths.local_agents_dir + "/plugins/mk_nfsiostat", plugins_dir + "/mk_nfsiostat")
bakery_info["mk_nfsiostat"] = {
"bake_function" : bake_nfsiostat,
"os" : [ "linux", ],
}

View File

@ -0,0 +1,6 @@
#!/bin/bash
if command nfsiostat > /dev/null ; then
echo '<<<nfsiostat>>>'
nfsiostat | paste -sd " " - | tr -s ' '
fi

144
checks/nfsiostat Normal file
View File

@ -0,0 +1,144 @@
#!/usr/bin/python
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2018 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# tails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
# example output
#
#y.y.y.y:/mount/name mounted on /var/log/da:
#
# op/s rpc bklog
#2579.20 0.00
#read: ops/s kB/s kB/op retrans avg RTT (ms) avg exe (ms)
# 0.000 0.000 0.000 0 (0.0%) 0.000 0.000
#write: ops/s kB/s kB/op retrans avg RTT (ms) avg exe (ms)
# 2578.200 165768.087 64.296 0 (0.0%) 21.394 13980.817
#
#x.x.x.x:/mount/name mounted on /data:
# ...
factory_settings["nfsiostat_default_levels"] = {
"op_s" : (70.00, 100.00),
"rpc_backlog" : (70.00, 100.00),
"read_ops" : (160.00, 200.00),
"read_b_s" : (200.00, 250.00),
"read_b_op" : (200.00, 250.00),
"read_retrans" : (10.0, 20.0),
"read_avg_rtt_ms" : (170.00, 200.00),
"read_avg_exe_ms" : (180.00, 200.00),
"write_ops_s" : (100.00, 200.00),
"write_b_s" : (200.00, 250.00),
"write_b_op" : (200.00, 250.00),
"write_retrans" : (10.0, 20.0),
"write_avg_rtt_ms" : (190.00, 200.00),
"write_avg_exe_ms" : (198.00, 200.0),
}
# we can convert once it is clear what the format/standards are
# count, (item (name), title, factor, fmt,)
param_name = {
"0" : ("op_s","Operations", 1, "%.2f/s"),
"1" : ("rpc_backlog", "RPC Backlog", 1, "%.2f"),
"2" : ("read_ops", "Read operations", 1, "%.3f/s"),
"3" : ("read_b_s", "Reads per second", 1000, "%.3fB/s"),
"4" : ("read_b_op", "Read bytes", 1000, "%.3fB/op"),
"5" : ("read_retrans", "Read Retransmission", 1, "%.1f%%"),
"6" : ("read_retrans", "Read Retransmission", 1, "%.1f%%"),
"7" : ("read_avg_rtt_ms", "Read average RTT", 1000, "%.3f/s",),
"8" : ("read_avg_exe_ms", "Read average EXE", 1000, "%.3f/s",),
"9" : ("write_ops_s", "Write operations", 1, "%.3f/s"),
"10" : ("write_b_s", "Writes per second", 1000, "%.3fkB/s"),
"11" : ("write_b_op", "Write bytes", 1000, "%.3fB/op"),
"12" : ("write_retrans", "Write Retransmission", 1, "%.1f%%"),
"13" : ("write_retrans", "Write Retransmission", 1, "%.3f%%"),
"14" : ("write_avg_rtt_ms", "Write Average RTT", 1, "%.3f/ms"),
"15" : ("write_avg_exe_ms", "Write Average EXE", 1, "%.3f/ms"),
}
def parse_nfsiostat(info):
#removes double list
[new_info] = info
import re
# provides a dictionary with mountpoint as key and a list of 16 metrics
# in exact order
parsed = {m[0]: m[1:] for m in re.findall(r'(\S+:/\S+)%s' % \
(r'.*?([\d.]+)' * 16), str(new_info).strip('[]'), flags=re.DOTALL)}
return parsed
def inventory_nfsiostat(parsed):
inventory = []
for mountname in parsed.keys():
yield mountname, "nfsiostat_default_levels"
def check_nfsiostat(item, params, parsed):
# check the value we recieved against our map of values
# assign appropriate type to value
def check_nfsiostat_params(count, value):
item = param_name[str(count)][0]
title = param_name[str(count)][1]
factor = param_name[str(count)][2]
fmt = param_name[str(count)][3]
value = float(value)
crit = float(params[item][1])
warn = float(params[item][0])
# convert
value = factor * value
# match on item or fmt
if item == "read_ops":
# if fmt == "%.3f/s":
value = value / factor
if value >= crit:
perfdata = [ (item, value, warn, crit ) ]
return(2, "%s: %s" % (title, fmt % value), perfdata)
elif value >= warn:
perfdata = [ (item, value, warn, crit ) ]
return(1, "%s: %s" % (title, fmt % value), perfdata)
else:
perfdata = [ (item, value, warn, crit ) ]
return(0, "%s: %s" % (title, fmt % value), perfdata)
for mountpoint, values in parsed.items():
# We have duplicate items at index 5 and 12. We exclude the dupes here
if mountpoint == item:
count = 0
for value in values:
if count != 5 and count != 12:
yield(check_nfsiostat_params(count, value))
count = count + 1
check_info['nfsiostat'] = {
'parse_function' : parse_nfsiostat,
'inventory_function' : inventory_nfsiostat,
'check_function' : check_nfsiostat,
'service_description' : 'NFS IO stats %s',
'group' : 'nfsiostats',
'default_levels_variable': 'nfsiostat_default_levels',
'has_perfdata' : True,
#'includes' : ['size_trend.include', 'df.include']
}

23
info Normal file
View File

@ -0,0 +1,23 @@
{'author': 'Marius Pana (mp@spearhead.systems)',
'description': 'The nfsiostat checks nfs IO statictics.',
'download_url': 'https://code.spearhead.cloud/Spearhead/check_mk-check-nfsiostat',
'files': {'agents': ['plugins/mk_nfsiostat', 'bakery/mk_nfsiostat],
'alert_handlers': [],
'bin': [],
'checkman': [],
'checks': ['nfsiostat'],
'doc': [],
'inventory': [],
'lib': [],
'locales': [],
'mibs': [],
'notifications': [],
'pnp-templates': [],
'web': ['plugins/metrics/nfsiostat.py',
'plugins/wato/check_parameters.py']},
'name': 'nfsiostat',
'num_files': 4,
'title': 'Check NFS IO stats',
'version': '1.0',
'version.min_required': '1.5.0',
'version.packaged': '1.5.0'}

BIN
nfsiostat-1.0.mkp Normal file

Binary file not shown.

View File

@ -0,0 +1,86 @@
metric_info['op_s'] = {
'title': _('Operations per second'),
'unit': 'count',
'color': '#90ee90',
}
metric_info['rpc_backlog'] = {
'title': _('RPC Backlog'),
'unit': 'count',
'color': '#90ee90',
}
metric_info['read_ops'] = {
'title': _('Read operations'),
'unit': '1/s',
'color': '34/a',
}
metric_info['read_b_s'] = {
'title': _('Read size per second'),
'unit': 'bytes/s',
'color': '#80ff20',
}
unit_info['bytes/op'] = {
'title': _('Read size per operation'),
'unit': 'bytes/op',
'color': '#4080c0',
"render" : bytes_human_readable,
}
metric_info['read_b_op'] = {
'title': _('Read size per operation'),
'unit': 'bytes/op',
'color': '#4080c0',
"render" : bytes_human_readable,
}
metric_info['read_retrans'] = {
'title': _('Read retransmission'),
'unit': '%',
'color': '#90ee90',
}
metric_info['read_avg_rtt_ms'] = {
'title': _('Read average rtt'),
'unit': 's',
'color': '#90ee90',
}
metric_info['read_avg_exe_ms'] = {
'title': _('Read average exe'),
'unit': 's',
'color': '#90ee90',
}
metric_info['write_ops_s'] = {
'title': _('Write operations'),
'unit': '1/s',
'color': '34/a',
}
metric_info['write_b_s'] = {
'title': _('Writes size per second'),
'unit': 'bytes/s',
'color': '#80ff20',
}
metric_info['write_b_op'] = {
'title': _('Writes size per operation'),
'unit': 'bytes/op',
'color': '#4080c0',
"render" : bytes_human_readable,
}
metric_info['write_avg_rtt_ms'] = {
'title': _('Write average rtt'),
'unit': 's',
'color': '#90ee90',
}
metric_info['write_avg_exe_ms'] = {
'title': _('Write average exe'),
'unit': 's',
'color': '#90ee90',
}

View File

@ -0,0 +1,114 @@
register_check_parameters(
subgroup_storage,
"nfsiostats",
_("NFS IO Statistics"),
Dictionary(
title=_("NFS IO Statistics"),
optional_keys=True,
elements=[
("op_s",
Tuple(
title=_("Operations"),
elements=[
Float(title=_("Warning at"), default_value=70.00, unit="1/s"),
Float(title=_("Critical at"), default_value=100.00, unit="1/s"),
])),
("rpc_backlog",
Tuple(
title=_("RPC Backlog"),
elements=[
Float(title=_("Warning below"), default_value=70.00, unit="queue"),
Float(title=_("Critical below"), default_value=100.00, unit="queue"),
])),
("read_ops",
Tuple(
title=_("Read Operations"),
elements=[
Float(title=_("Warning at"), default_value=150.000, unit="1/s"),
Float(title=_("Critical at"), default_value=200.000, unit="1/s"),
])),
("read_b_s",
Tuple(
title=_("Read Bytes"),
elements=[
Float(title=_("Warning at"), default_value=200.000, unit="bytes/s"),
Float(title=_("Critical at"), default_value=250.000, unit="bytes/s"),
])),
("read_b_op",
Tuple(
title=_("Read kB/op"),
elements=[
Float(title=_("Warning at"), default_value=200.000, unit="bytes/op"),
Float(title=_("Critical at"), default_value=250.000, unit="bytes/op"),
])),
("read_retrans",
Tuple(
title=_("Read Retransmissions"),
elements=[
Percentage(title=_("Warning at"), default_value=10.0),
Percentage(title=_("Critical at"), default_value=20.0),
])),
("read_avg_rtt_ms",
Tuple(
title=_("Read Average RTT (ms)"),
elements=[
Float(title=_("Warning at"), default_value=150.000, unit="ms"),
Float(title=_("Critical at"), default_value=200.000, unit="ms"),
])),
("read_avg_exe_ms",
Tuple(
title=_("Read Average Executions (ms)"),
elements=[
Float(title=_("Warning at"), default_value=15.000, unit="ms"),
Float(title=_("Critical at"), default_value=16.000, unit="ms"),
])),
("write_ops_s",
Tuple(
title=_("Write Operations/s"),
elements=[
Float(title=_("Warning at"), default_value=15.000, unit="1/s"),
Float(title=_("Critical at"), default_value=16.000, unit="1/s"),
])),
("write_b_s",
Tuple(
title=_("Write Bytes"),
elements=[
Float(title=_("Warning at"), default_value=200.000, unit="bytes/s"),
Float(title=_("Critical at"), default_value=250.000, unit="bytes/s"),
])),
("write_b_op",
Tuple(
title=_("Write B/s"),
elements=[
Float(title=_("Warning at"), default_value=200.000, unit="bytes/s"),
Float(title=_("Critical at"), default_value=250.000, unit="bytes/s"),
])),
("write_retrans",
Tuple(
title=_("Write Retransmissions"),
elements=[
Percentage(title=_("Warning at"), default_value=10.0),
Percentage(title=_("Critical at"), default_value=20.0),
])),
("write_avg_rtt_ms",
Tuple(
title=_("Write Avg RTT (ms)"),
elements=[
Float(title=_("Warning at"), default_value=10.000, unit="ms"),
Float(title=_("Critical at"), default_value=20.000, unit="ms"),
])),
("write_avg_exe_ms",
Tuple(
title=_("Write Avg exe (ms)"),
elements=[
Float(title=_("Warning at"), default_value=10.000, unit="ms"),
Float(title=_("Critical at"), default_value=20.000, unit="ms"),
])),
]
),
TextAscii(
title=_("NFS IO Statistics"),
),
match_type="dict",
)