Cleanup config.nodes_of
[check_mk.git] / checks / statgrab_disk
blob9e385639a202ebb22f36c7e5e76e4c24fb50772d
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # <<<statgrab_disk>>>
28 # 1/md0.disk_name 1/md0
29 # 1/md0.read_bytes 611352576
30 # 1/md0.systime 1471423620
31 # 1/md0.write_bytes 39462400
32 # 1/md1.disk_name 1/md1
33 # 1/md1.read_bytes 611352576
34 # 1/md1.systime 1471423620
35 # 1/md1.write_bytes 39462400
36 # 1/md2.disk_name 1/md2
37 # 1/md2.read_bytes 611351552
40 def parse_statgrab_disk(info):
41 parsed = {}
42 now = time.time()
43 for line in info:
44 disk_name = line[0].split(".")[0]
45 parsed.setdefault(disk_name, {})
47 if line[0].endswith('read_bytes'):
48 parsed[disk_name]["read_throughput"] = get_rate("statgrab_disk.read.%s" % disk_name,
49 now, int(line[1]))
51 elif line[0].endswith('write_bytes'):
52 parsed[disk_name]["write_throughput"] = get_rate("statgrab_disk.write.%s" % disk_name,
53 now, int(line[1]))
55 elif line[0].endswith("systime"):
56 parsed[disk_name]["systime"] = int(line[1])
58 return parsed
61 def inventory_statgrab_disk(parsed):
62 return inventory_diskstat_generic([[None, item] for item in parsed])
65 def check_statgrab_disk(item, params, parsed):
66 return check_diskstat_dict(item, params, parsed)
69 check_info["statgrab_disk"] = {
70 'parse_function': parse_statgrab_disk,
71 'inventory_function': inventory_statgrab_disk,
72 'check_function': check_statgrab_disk,
73 'service_description': 'Disk IO %s',
74 'has_perfdata': True,
75 'group': 'diskstat',
76 'includes': ["diskstat.include"],