/usr/share/check_mk/checks/filerdisks.include is in check-mk-server 1.2.8p16-1ubuntu0.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | #!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 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.
# disks = [
# { "state" : "failed",
# "identifier" : "Enclosure: 2, Slot: 1, Type: SATA",
# "type" : "parity",
# "capacity" : 1000000000000,
# }
factory_settings["filer_disks_default_levels"] = {
"failed_spare_ratio" : ( 1.0, 50.0 ),
"offline_spare_ratio": ( 1.0, 50.0 ),
}
def check_filer_disks(disks, params):
state = {}
state['prefailed'] = []
state['failed'] = []
state['offline'] = []
state['spare'] = []
total_capacity = 0
prefaild_data_disk_count = 0
prefaild_parity_disk_count = 0
for disk in disks:
total_capacity += disk.get("capacity", 0)
for what in state.keys():
if disk['state'] == what:
state[what].append(disk)
yield 0, "Total raw capacity: %s" % get_bytes_human_readable(total_capacity), [("total_disk_capacity", total_capacity)]
# TODO: Is a prefailed disk unavailable?
unavail_disks = len(state['prefailed']) + len(state['failed']) + len(state['offline'])
yield 0, "Total disks: %d (%d Spare)" % (len(disks) - unavail_disks, len(state['spare'])), [
("total_disks", len(disks)),
("spare_disks", len(state['spare'])),
("failed_disks", unavail_disks) ]
parity_disks = [ disk for disk in disks if disk['type'] == 'parity' ]
prefailed_parity = [ disk for disk in parity_disks if disk['state'] == 'prefailed' ]
if len(parity_disks) > 0:
yield 0, "Parity disks: %d (%d prefailed)" % (len(parity_disks), len(prefailed_parity))
yield 0, "Failed disks: %d" % unavail_disks
for name, disk_type in [("Data", "data"),
("Parity", "parity")]:
total_disks = [ disk for disk in disks if disk['type'] == disk_type ]
prefailed_disks = [ disk for disk in total_disks if disk['state'] == 'prefailed' ]
if len(total_disks) > 0:
info_text = "%s disks" % len(total_disks)
if len(prefailed_disks) > 0:
info_text += " (%d prefailed)" % (prefailed_disks)
yield 0, info_text
info_texts = []
for disk in prefailed_disks:
info_texts.append(disk['identifier'])
if len(info_texts) > 0:
yield 0, "%s Disk Details: %s" % (name, " / ".join(info_texts))
for disk_state in [ "failed", "offline"]:
info_texts = []
for disk in state[disk_state]:
info_texts.append(disk['identifier'])
if len(info_texts) > 0:
yield 0, "%s Disk Details: %s" % (disk_state, " / ".join(info_texts))
warn, crit = params["%s_spare_ratio" % disk_state]
ratio = float(len(state[disk_state])) / (len(state[disk_state]) + len(state['spare'])) * 100
return_state = False
if ratio >= crit:
return_state = 2
elif ratio >= warn:
return_state = 1
if return_state:
yield return_state, "Too many %s disks (warn/crit at %.1f%%/%.1f%%)" % (disk_state, warn, crit)
|