-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
4,852 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env python3 | ||
# -*- encoding: utf-8; py-indent-offset: 4 -*- | ||
# +------------------------------------------------------------------+ | ||
# | ____ _ _ __ __ _ __ | | ||
# | / ___| |__ ___ ___| | __ | \/ | |/ / | | ||
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | | ||
# | | |___| | | | __/ (__| < | | | | . \ | | ||
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | | ||
# | | | ||
# +------------------------------------------------------------------+ | ||
# | ||
# This file is an addon for 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- | ||
# ails. 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. | ||
|
||
# Fans | ||
|
||
#.1.3.6.1.4.1.18928.1.2.2.1.9.1.1.1 = INTEGER: 1 | ||
#.1.3.6.1.4.1.18928.1.2.2.1.9.1.2.1 = STRING: "CPU Fan" | ||
#.1.3.6.1.4.1.18928.1.2.2.1.9.1.3.1 = INTEGER: 0 | ||
|
||
# snmp_info : oid(".1.3.6.1.4.1.18928.1.2.2.1.9.1"), [ "1", "2", "3" ] | ||
|
||
from cmk.plugins.lib.fan import check_fan | ||
|
||
from cmk.agent_based.v2 import ( | ||
CheckPlugin, | ||
CheckResult, | ||
DiscoveryResult, | ||
Service, | ||
SimpleSNMPSection, | ||
SNMPTree, | ||
startswith, | ||
) | ||
|
||
def areca_fan_name(desc): | ||
return desc.split()[0] | ||
|
||
def parse_areca_hba_fans(string_table): | ||
section = {} | ||
for desc, speed in string_table: | ||
speed = int(speed) | ||
if speed > 0: | ||
section[areca_fan_name(desc)] = speed | ||
return section | ||
|
||
def discover_areca_hba_fans(section) -> DiscoveryResult: | ||
for name in section.keys(): | ||
yield Service(item=name) | ||
|
||
def check_areca_hba_fans(item, params, section) -> CheckResult: | ||
if item in section: | ||
yield from check_fan(section[item], params) | ||
|
||
snmp_section_areca_hba_fans = SimpleSNMPSection( | ||
name = "areca_hba_fans", | ||
parse_function = parse_areca_hba_fans, | ||
detect = startswith(".1.3.6.1.2.1.1.2.0", ".1.3.6.1.4.1.18928.1"), | ||
fetch = SNMPTree( | ||
base = ".1.3.6.1.4.1.18928.1.2.2.1.9.1", | ||
oids = [ | ||
# "1", # hwControllerBoardFanIndex | ||
"2", # hwControllerBoardFanDesc | ||
"3", # hwControllerBoardFanSpeed | ||
] | ||
) | ||
) | ||
|
||
check_plugin_areca_hba_fans = CheckPlugin( | ||
name = "areca_hba_fans", | ||
sections = ["areca_hba_fans"], | ||
service_name = "Fan %s", | ||
discovery_function = discover_areca_hba_fans, | ||
check_function = check_areca_hba_fans, | ||
check_default_parameters = { | ||
"output_metrics": True, | ||
}, | ||
check_ruleset_name = "hw_fans", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/usr/bin/env python3 | ||
# -*- encoding: utf-8; py-indent-offset: 4 -*- | ||
# +------------------------------------------------------------------+ | ||
# | ____ _ _ __ __ _ __ | | ||
# | / ___| |__ ___ ___| | __ | \/ | |/ / | | ||
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | | ||
# | | |___| | | | __/ (__| < | | | | . \ | | ||
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | | ||
# | | | ||
# +------------------------------------------------------------------+ | ||
# | ||
# This file is an addon for Check_MK. | ||
# The official homepage for this check is at http://bitbucket.org/darkfader | ||
# | ||
# 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- | ||
# ails. 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. | ||
|
||
|
||
from cmk.agent_based.v2 import ( | ||
CheckPlugin, | ||
CheckResult, | ||
DiscoveryResult, | ||
Result, | ||
Service, | ||
SimpleSNMPSection, | ||
SNMPTree, | ||
State, | ||
startswith, | ||
) | ||
|
||
from cmk.utils import debug | ||
from pprint import pprint # type: ignore | ||
|
||
def parse_areca_hba_ldisks(string_table): | ||
section = {} | ||
for vsf_id, vsf_name, vsf_rsf, vsf_size, vsf_state, vsf_rbld in string_table: | ||
section[vsf_id] = { | ||
"name": vsf_name, | ||
"rsf": vsf_rsf, | ||
"size": int(vsf_size) / 1024.0, | ||
"state": vsf_state, | ||
"rbld": int(vsf_rbld) / 10.0, | ||
} | ||
if debug.enabled(): | ||
pprint(string_table) | ||
pprint(section) | ||
return section | ||
|
||
def discover_areca_hba_ldisks(section) -> DiscoveryResult: | ||
for id in section.keys(): | ||
yield Service(item=id) | ||
|
||
def check_areca_hba_ldisks(item, _no_params, section) -> CheckResult: | ||
if item in section: | ||
vsf = section[item] | ||
state = State.UNKNOWN | ||
msg = "%s is %s" % (vsf["name"], vsf["state"].lower()) | ||
if vsf["state"] == "Normal": | ||
state = State.OK | ||
elif vsf["state"] == "Rebuilding": | ||
state = State.WARN | ||
reb_gb = vsf["size"] * vsf["rbld"] / 100.0 | ||
msg += " - %d%% (%d/%d GB) done" % (vsf["rbld"], reb_gb, vsf["size"]) | ||
elif vsf["state"] == "Degraded": | ||
state = State.WARN | ||
else: | ||
msg += " - Unhandled state" | ||
yield Result(state=state, summary=msg) | ||
|
||
snmp_section_areca_hba_ldisks = SimpleSNMPSection( | ||
name = "areca_hba_ldisks", | ||
parse_function = parse_areca_hba_ldisks, | ||
detect = startswith(".1.3.6.1.2.1.1.2.0", ".1.3.6.1.4.1.18928.1"), | ||
fetch = SNMPTree( | ||
base = ".1.3.6.1.4.1.18928.1.2.5.1.1", | ||
oids = [ | ||
"1", # ARECA-SNMP-MIB::volNumber | ||
"2", # ARECA-SNMP-MIB::volName | ||
"3", # ARECA-SNMP-MIB::volRaidName | ||
"4", # ARECA-SNMP-MIB::volCapacity | ||
"5", # ARECA-SNMP-MIB::volState | ||
"6", # ARECA-SNMP-MIB::volProgress | ||
], | ||
), | ||
) | ||
|
||
check_plugin_areca_hba_ldisks = CheckPlugin( | ||
name = "areca_hba_ldisks", | ||
sections = ["areca_hba_ldisks"], | ||
service_name = "Volume set %s", | ||
discovery_function = discover_areca_hba_ldisks, | ||
check_function = check_areca_hba_ldisks, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#!/usr/bin/env python3 | ||
# -*- encoding: utf-8; py-indent-offset: 4 -*- | ||
# +------------------------------------------------------------------+ | ||
# | ____ _ _ __ __ _ __ | | ||
# | / ___| |__ ___ ___| | __ | \/ | |/ / | | ||
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | | ||
# | | |___| | | | __/ (__| < | | | | . \ | | ||
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | | ||
# | | | ||
# +------------------------------------------------------------------+ | ||
# | ||
# This file is an addon for Check_MK. | ||
# The official homepage for this check is at http://bitbucket.org/darkfader | ||
# | ||
# 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- | ||
# ails. 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. | ||
|
||
|
||
# hddEnclosure01Slots: | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.1.1 = 1 | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.1.20 = 20 | ||
# hddEnclosure01Desc: | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.2.1 = "SLOT 01" | ||
# hddEnclosure01Name: | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.3.20 = "WDC WD30EFRX-68AX9N0 " | ||
# hddEnclosure01Serial: | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.4.20 = "1234567 " | ||
# hddEnclosure01FirmVer: | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.5.20 = "CC1H " | ||
# hddEnclosure01Capacity: | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.6.1 = 0 | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.6.20 = 3000600 | ||
# hddEnclosure01Type: | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.7.1 = 0 | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.7.20 = 1 | ||
# hddEnclosure01State: | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.8.1 = "Empty Slot" | ||
#.1.3.6.1.4.1.18928.1.2.3.2.4.1.8.20 = "RaidSet Member" | ||
|
||
# How to grok: | ||
#.1.3.6.1.4.1.18928.1.2.3.E.4.1.F.D | ||
# | | | | ||
# | | +---enc disk id | ||
# | +-----field | ||
# +-------enclosure | ||
|
||
|
||
|
||
def inventory_areca_hba_pdisks(info): | ||
inventory = [] | ||
for enclosure_entry in info: | ||
for slot_entry in enclosure_entry: | ||
if len(slot_entry) == 8 and slot_entry[-1].split()[0] != "Empty": | ||
enc, slot = slot_entry[0].split(".") | ||
diskname = ("%d/%02d" % (int(enc), int(slot))) | ||
inventory.append((diskname, None)) | ||
return inventory | ||
|
||
def check_areca_hba_pdisks(item, _no_params, info): | ||
for enclosure_entry in info: | ||
for slot_entry in enclosure_entry: | ||
enc, slot = slot_entry[0].split(".") | ||
diskname = ("%d/%02d" % (int(enc), int(slot))) | ||
|
||
# We could do smarter by tracking the serial at inventory. | ||
# I decided to not get too smart, and so we're not following a disk | ||
# around if you put it somewhere else. | ||
if diskname == item: | ||
|
||
disk_descr = "(%s %s)" % (slot_entry[2], slot_entry[3]) | ||
|
||
# What I'm checking here is a field that SEEMS to be the right one. | ||
# Contact me if this seems wrong. Someone needs to test / adjust it | ||
# with some JBOD mode array and pull some disks. | ||
if slot_entry[7] == "Failed": | ||
return (2, "CRIT - Disk is failed. %s" % disk_descr) | ||
else: | ||
return (0, "OK - Disk is OK. %s" % disk_descr) | ||
|
||
return (3, "Disk not found in agent output") | ||
|
||
|
||
check_info["areca_hba_pdisks"] = { | ||
"check_function" : check_areca_hba_pdisks, | ||
"inventory_function" : inventory_areca_hba_pdisks, | ||
"has_perfdata" : False, | ||
"service_description" : "PDisk Enc/Sl %s", | ||
# Find Areca SAS MIB | ||
"snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.18928.1"), | ||
"snmp_info" : [(".1.3.6.1.4.1.18928.1.2.3", | ||
# unclear: how does it look in jbod mode? | ||
# where does i get pony? | ||
# There's up to 8 enclosures, "1" is hardcoded having 8 slots. | ||
# probably it's the ext. SAS connector. | ||
[ "1", "2", "3", "4", "5", "6", "7", "8" ], | ||
# Below each enclosure there's the following structure for disk data | ||
[ "4.1.1", # The slot ids | ||
"4.1.2", # The slot descrs | ||
"4.1.3", # The disk model | ||
"4.1.4", # The disk fw | ||
"4.1.5", # The disk size | ||
# The MIB seems wrong about the next ones | ||
"4.1.6", # | ||
"4.1.7", # | ||
"4.1.8", # Textual disk state | ||
] | ||
)], | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env python3 | ||
# -*- encoding: utf-8; py-indent-offset: 4 -*- | ||
# +------------------------------------------------------------------+ | ||
# | ____ _ _ __ __ _ __ | | ||
# | / ___| |__ ___ ___| | __ | \/ | |/ / | | ||
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | | ||
# | | |___| | | | __/ (__| < | | | | . \ | | ||
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | | ||
# | | | ||
# +------------------------------------------------------------------+ | ||
# | ||
# This file is an addon for Check_MK. | ||
# The official homepage for this check is at http://bitbucket.org/darkfader | ||
# | ||
# 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- | ||
# ails. 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. | ||
|
||
|
||
def inventory_areca_hba_raidsets(info): | ||
inventory = [] | ||
|
||
# not sure why i end up with my info double stacked | ||
# but i'm sure it's me. | ||
for line in info[0]: | ||
if len(line) == 5: | ||
rs_id, rs_name, rs_state, rs_mem_sz, rs_mem_names = line | ||
inventory.append((rs_id, None)) | ||
return inventory | ||
|
||
def check_areca_hba_raidsets(item, _no_params, info): | ||
for line in info[0]: | ||
rs_id, rs_name, rs_state, rs_mem_sz, rs_mem_names = line | ||
|
||
if rs_id == item: | ||
if rs_state == "Normal": | ||
state = 0 | ||
elif rs_state == "Rebuilding": | ||
state = 1 | ||
# I hope Offline is correct. | ||
elif rs_state in [ "Degraded", "Offline" ]: | ||
state = 2 | ||
# Any state we don't know. | ||
else: | ||
state = 3 | ||
|
||
msg = "%s is %s. (members: %s)" % (rs_name, rs_state, rs_mem_names) | ||
return (state, msg) | ||
|
||
return (3, "UNKW - Raidset not found in agent output") | ||
|
||
|
||
check_info["areca_hba_raidsets"] = { | ||
"check_function" : check_areca_hba_raidsets, | ||
"inventory_function" : inventory_areca_hba_raidsets, | ||
"has_perfdata" : False, | ||
"service_description" : "Raid set %s", | ||
# Find Areca SAS MIB | ||
"snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.18928.1"), | ||
"snmp_info" : [(".1.3.6.1.4.1.18928.1.2.4.1.1", | ||
# Below each enclosure there's the following structure for disk data | ||
[ #"2", "4" | ||
"1", # Raidset id | ||
"2", # Raidset name | ||
"4", # Raidset State | ||
"7", # Member disk size | ||
"8", # Member disk names and states | ||
] | ||
)], | ||
} | ||
|
Oops, something went wrong.