Skip to content

Commit

Permalink
Merge pull request #161 from jens-maus/infortend5
Browse files Browse the repository at this point in the history
Infortend plugin compatibility rework
  • Loading branch information
gurubert authored Jun 13, 2024
2 parents f3e4fdf + cfcad29 commit ad14d3c
Show file tree
Hide file tree
Showing 8 changed files with 353 additions and 156 deletions.
28 changes: 20 additions & 8 deletions infortrend/checks/infortrend_chassis
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
#
# (c) 2013 Heinlein Support GmbH
# Robert Sander <[email protected]>
# (c) 2024 Jens Maus <[email protected]>
#

from cmk.base.check_api import LegacyCheckDefinition, saveint
from cmk.base.config import check_info
from cmk.agent_based.v2 import all_of, contains, startswith, SNMPTree, StringTable

# This 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. This file is distributed
Expand Down Expand Up @@ -137,11 +142,18 @@ def check_infortrend_chassis(item, params, info):
adtl_status = status_info[type]['adtl_func'](status)
yield status_info[type]['adtl_info'][adtl_status][0], status_info[type]['adtl_info'][adtl_status][1]

check_info["infortrend_chassis"] = {
'check_function' : check_infortrend_chassis,
'service_description' : "IFT %s",
'has_perfdata' : False,
'inventory_function' : inventory_infortrend_chassis,
'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1714.1.2"),
'snmp_info' : ( ".1.3.6.1.4.1.1714.1.1.9.1", [ "8", "13", "6", "9", "10", "12" ] ),
}
def parse_infortrend_chassis(string_table: StringTable) -> StringTable | None:
return string_table or None

check_info["infortrend_chassis"] = LegacyCheckDefinition(
detect=startswith(".1.3.6.1.2.1.1.2.0", ".1.3.6.1.4.1.1714.1.2"),
parse_function=parse_infortrend_chassis,
fetch=SNMPTree(
base=".1.3.6.1.4.1.1714.1.1.9.1",
oids=["8", "13", "6", "9", "10", "12"],
),
service_name="IFT %s",
discovery_function=inventory_infortrend_chassis,
check_function=check_infortrend_chassis,
check_ruleset_name="infortend_chassis",
)
283 changes: 204 additions & 79 deletions infortrend/checks/infortrend_chassis1

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions infortrend/checks/infortrend_disks
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
#
# (c) 2013 Heinlein Support GmbH
# Robert Sander <[email protected]>
# (c) 2024 Jens Maus <[email protected]>
#

from cmk.base.check_api import LegacyCheckDefinition, saveint
from cmk.base.config import check_info
from cmk.agent_based.v2 import all_of, contains, startswith, exists, SNMPTree, StringTable

# This 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. This file is distributed
Expand Down Expand Up @@ -69,11 +74,18 @@ def check_infortrend_disks(item, params, info):
return (2, info + status_info[status])
return (1, info + status_info[status])

check_info["infortrend_disks"] = {
'check_function' : check_infortrend_disks,
'service_description' : "IFT Disk Slot %s",
'has_perfdata' : False,
'inventory_function' : inventory_infortrend_disks,
'snmp_scan_function' : lambda oid: oid(".1.3.6.1.4.1.1714.1.1.1.1.0"),
'snmp_info' : ( ".1.3.6.1.4.1.1714.1.6.1", [ "13", "11", "15", "16", "17", "7", "8" ] ),
}
def parse_infortrend_disks(string_table: StringTable) -> StringTable | None:
return string_table or None

check_info["infortrend_disks"] = LegacyCheckDefinition(
detect=exists(".1.3.6.1.4.1.1714.1.1.1.1.0"),
parse_function=parse_infortrend_disks,
fetch=SNMPTree(
base=".1.3.6.1.4.1.1714.1.6.1",
oids=["13", "11", "15", "16", "17", "7", "8"],
),
service_name="IFT Disk Slot %s",
discovery_function=inventory_infortrend_disks,
check_function=check_infortrend_disks,
check_ruleset_name="infortend_disks",
)
78 changes: 44 additions & 34 deletions infortrend/checks/infortrend_disks1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
#
# (c) 2013 Heinlein Support GmbH
# Robert Sander <[email protected]>
# (c) 2024 Jens Maus <[email protected]>
#

from cmk.base.check_api import LegacyCheckDefinition, saveint
from cmk.base.config import check_info
from cmk.agent_based.v2 import all_of, contains, startswith, SNMPTree, StringTable

# This 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. This file is distributed
Expand All @@ -18,17 +23,8 @@
# Boston, MA 02110-1301 USA.

def inventory_infortrend_disks1(info):
# Debug: lets see how the data we get looks like
inventory = []
disknumber = 0
for slot, status in info:
if int(slot) != 0:
if int(slot) > int(disknumber):
disknumber = int(slot)
else:
disknumber = int(disknumber) + 1
inventory.append( (str(disknumber), int(status)) )
return inventory
yield slot, {}

def check_infortrend_disks1(item, params, info):
status_info = {
Expand All @@ -37,13 +33,13 @@ def check_infortrend_disks1(item, params, info):
2 : "Used Drive",
3 : "Spare Drive",
4 : "Drive Initialization in Progress",
5 : "Drive Rebuild in Progress",
5 : "Drive Rebuild in Progress (!)",
6 : "Add Drive to Logical Drive in Progress",
9 : "Global Spare Drive",
17 : "Drive is in process of Cloning another Drive",
18 : "Drive is a valid Clone of another Drive",
19 : "Drive is in process of Copying from another Drive (for Copy/Replace LD Expansion function)",
63 : "Drive Absent",
63 : "Drive Absent (!)",
128 : "SCSI Device (Type 0)",
129 : "SCSI Device (Type 1)",
130 : "SCSI Device (Type 2)",
Expand All @@ -60,37 +56,51 @@ def check_infortrend_disks1(item, params, info):
141 : "SCSI Device (Type 13)",
142 : "SCSI Device (Type 14)",
143 : "SCSI Device (Type 15)",
252 : "Missing Global Spare Drive",
253 : "Missing Spare Drive",
254 : "Missing Drive",
255 : "Failed Drive"
252 : "Missing Global Spare Drive (!)",
253 : "Missing Spare Drive (!)",
254 : "Missing Drive (!)",
255 : "Failed Drive (!!)"
}
disknumber = 0
new_info = []
for slot, status in info:
if int(slot) != 0:
if int(slot) > int(disknumber):
disknumber = int(slot)
else:
disknumber = int(disknumber) + 1
new_info.append([str(disknumber), str(status)])
for slot, status in new_info:
status = int(status)
if slot == item:
if status not in status_info.keys():
return (3, "Status is %d" % status)
if status == 1 or status == 3 or status == 9 or status == 63:
if status == 1 or status == 3 or status == 9 or status == 63 or status == 141:
return (0, status_info[status])
if status > 63:
return (2, status_info[status])
return (1, status_info[status])
return (3, "not yet implemented")

check_info["infortrend_disks1"] = {
'check_function' : check_infortrend_disks1,
'inventory_function' : inventory_infortrend_disks1,
'service_description' : 'IFT Disk Slot %s',
'has_perfdata' : False,
'snmp_info' : ( ".1.3.6.1.4.1.1714.1.1.6.1", [ "13", "11" ] ),
'snmp_scan_function' : lambda oid: "infortrend" in oid(".1.3.6.1.2.1.1.1.0").lower() and oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1714.1.1"),
}
def rename_dups(l):
d = {}
for i in range(len(l)):
lowl = l[i][0].lower()
if lowl in d:
d[lowl] += 1
else:
d[lowl] = 1

if l[i][0]:
l[i][0] = '[{}] Disk Slot {:02d}'.format(str(d[lowl]), int(l[i][0]))
return l

def parse_infortrend_disks1(string_table: StringTable) -> StringTable | None:
return rename_dups(string_table) or None

check_info["infortrend_disks1"] = LegacyCheckDefinition(
detect=all_of(
contains(".1.3.6.1.2.1.1.1.0", "Infortrend"),
startswith(".1.3.6.1.2.1.1.2.0", ".1.3.6.1.4.1.1714.1.1"),
),
parse_function=parse_infortrend_disks1,
fetch=SNMPTree(
base=".1.3.6.1.4.1.1714.1.1.6.1",
oids=["13", "11"],
),
service_name="IFT %s",
discovery_function=inventory_infortrend_disks1,
check_function=check_infortrend_disks1,
check_ruleset_name="infortend_disks1",
)
28 changes: 20 additions & 8 deletions infortrend/checks/infortrend_ldrives
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
#
# (c) 2013 Heinlein Support GmbH
# Robert Sander <[email protected]>
# (c) 2024 Jens Maus <[email protected]>
#

from cmk.base.check_api import LegacyCheckDefinition, saveint
from cmk.base.config import check_info
from cmk.agent_based.v2 import all_of, contains, startswith, exists, SNMPTree, StringTable

# This 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. This file is distributed
Expand Down Expand Up @@ -54,11 +59,18 @@ def check_infortrend_ldrives(item, params, info):
return (rc, ", ".join(output))
return (3, "not yet implemented")

check_info["infortrend_ldrives"] = {
'check_function' : check_infortrend_ldrives,
'service_description' : "IFT Logical Drive %s",
'has_perfdata' : False,
'inventory_function' : inventory_infortrend_ldrives,
'snmp_info' : ( ".1.3.6.1.4.1.1714.1.2.1", [ "2", "6" ] ),
'snmp_scan_function' : lambda oid: oid(".1.3.6.1.4.1.1714.1.1.1.1.0"),
}
def parse_infortrend_ldrives(string_table: StringTable) -> StringTable | None:
return string_table or None

check_info["infortrend_ldrives"] = LegacyCheckDefinition(
detect=exists(".1.3.6.1.4.1.1714.1.1.1.1.0"),
parse_function=parse_infortrend_ldrives,
fetch=SNMPTree(
base=".1.3.6.1.4.1.1714.1.2.1",
oids=["2", "6"],
),
service_name="IFT Logical Drive %s",
discovery_function=inventory_infortrend_ldrives,
check_function=check_infortrend_ldrives,
check_ruleset_name="infortend_ldrives",
)
64 changes: 45 additions & 19 deletions infortrend/checks/infortrend_ldrives1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
#
# (c) 2013 Heinlein Support GmbH
# Robert Sander <[email protected]>
# (c) 2024 Jens Maus <[email protected]>
#

from cmk.base.check_api import LegacyCheckDefinition, saveint
from cmk.base.config import check_info
from cmk.agent_based.v2 import all_of, contains, startswith, exists, SNMPTree, StringTable

# This 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. This file is distributed
Expand All @@ -18,22 +23,20 @@
# Boston, MA 02110-1301 USA.

def inventory_infortrend_ldrives1(info):
inventory = []
for id, status in info:
inventory.append( (id, int(status)) )
return inventory
yield id, {}

def check_infortrend_ldrives1(item, params, info):
status_info = {
0 : "Good",
1 : "Rebuilding",
2 : "Initializing",
3 : "Degraded",
4 : "Dead",
5 : "Invalid",
6 : "Incomplete",
7 : "Drive Missing",
64 : "Good"
1 : "Rebuilding (!)",
2 : "Initializing (!)",
3 : "Degraded (!)",
4 : "Dead (!!)",
5 : "Invalid (!!)",
6 : "Incomplete (!!)",
7 : "Drive Missing (!!)",
64 : "Good"
}
for slot, status in info:
status = int(status)
Expand All @@ -55,11 +58,34 @@ def check_infortrend_ldrives1(item, params, info):
return (rc, ", ".join(output))
return (3, "not yet implemented")

check_info["infortrend_ldrives1"] = {
'check_function' : check_infortrend_ldrives1,
'inventory_function' : inventory_infortrend_ldrives1,
'service_description' : 'IFT Logical Drive %s',
'has_perfdata' : False,
'snmp_info' : ( ".1.3.6.1.4.1.1714.1.1.2.1", [ "2", "6" ] ),
'snmp_scan_function' : lambda oid: "infortrend" in oid(".1.3.6.1.2.1.1.1.0").lower() and oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.1714.1.1"),
}
def rename_dups(l):
d = {}
for i in range(len(l)):
lowl = l[i][0].lower()
if lowl in d:
d[lowl] += 1
else:
d[lowl] = 1

if l[i][0]:
l[i][0] = '[{}] Logical Drive [{}]'.format(str(d[lowl]), l[i][0])
return l

def parse_infortrend_ldrives1(string_table: StringTable) -> StringTable | None:
return rename_dups(string_table) or None

check_info["infortrend_ldrives1"] = LegacyCheckDefinition(
detect=all_of(
contains(".1.3.6.1.2.1.1.1.0", "Infortrend"),
startswith(".1.3.6.1.2.1.1.2.0", ".1.3.6.1.4.1.1714.1.1"),
),
parse_function=parse_infortrend_ldrives1,
fetch=SNMPTree(
base=".1.3.6.1.4.1.1714.1.1.2.1",
oids=["2", "6"],
),
service_name="IFT %s",
discovery_function=inventory_infortrend_ldrives1,
check_function=check_infortrend_ldrives1,
check_ruleset_name="infortend_ldrives1",
)
Binary file removed infortrend/infortrend-4.5.mkp
Binary file not shown.
Binary file added infortrend/infortrend-5.0.0.mkp
Binary file not shown.

0 comments on commit ad14d3c

Please sign in to comment.