Skip to content

Commit

Permalink
Merge pull request #179 from agabellini/agabellini-dell_sc
Browse files Browse the repository at this point in the history
New dell_sc plugins for CheckMK 2.3
  • Loading branch information
gurubert authored Nov 18, 2024
2 parents 599729a + 8396eb0 commit 2d51948
Show file tree
Hide file tree
Showing 13 changed files with 1,098 additions and 0 deletions.
Binary file added dell_sc/dell_sc-3.3.1.mkp
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*-

# (c) 2017 Heinlein Support GmbH
# Robert Sander <[email protected]>

#
# 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. 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.checkengine.checkresults import state_markers

from cmk.agent_based.v2 import (
CheckPlugin,
Service,
Result,
SimpleSNMPSection,
SNMPTree,
State,
all_of,
contains,
exists,
)


def parse_dell_sc_alert(string_table):
print(string_table)
return {}
#return string_table

def discover_dell_sc_alert(section):
yield Service()

def check_dell_sc_alert(section):
state = {
1 : ('complete', State.OK),
2 : ('critical', State.CRIT),
3 : ('degraded', State.WARN),
4 : ('down', State.CRIT),
5 : ('emergency', State.CRIT),
6 : ('inform', State.OK),
7 : ('okay', State.OK),
8 : ('unavailable', State.CRIT),
9 : ('unknown', State.UNKNOWN),
}
category = {
0 : 'connectivity',
1 : 'disk',
2 : 'hardware',
3 : 'storage',
4 : 'system',
5 : 'unknown',
}
atype = {
0 : 'alert',
1 : 'indication',
2 : 'unknown',
}

alerts = []
res = State.OK
for nbr, istate, definition, icat, ctime, message, itype, ack, act in section:
if act == "1" and ack == "2":
alert_state = state.get(int(istate), ('unknown', State.UNKNOWN))
if int(alert_state[1]) > int(res):
res = alert_state[1]
alerts.append("%s %s %s on %s: %s%s" % (
alert_state[0],
category.get(int(icat), 'unknown'),
definition,
ctime,
message,
state_markers[int(alert_state[1])]))

if not alerts:
alerts = ['No Alerts']

yield Result(state=res, summary="%s" % alerts[0], details="%s\n%s" % (alerts[0],"\n".join(alerts[1:])))


check_plugin_dell_sc_alert = CheckPlugin(
name="dell_sc_alert",
sections = [ "dell_sc_alert" ],
service_name="Dell SC Alert",
discovery_function=discover_dell_sc_alert,
check_function=check_dell_sc_alert,
)


snmp_section_dell_sc_alert = SimpleSNMPSection(
name = "dell_sc_alert",
parse_function = parse_dell_sc_alert,
detect = all_of(
contains(".1.3.6.1.2.1.1.1.0", "compellent"),
exists(".1.3.6.1.4.1.674.11000.2000.500.1.2.1.0"),
),
fetch = SNMPTree(
base = '.1.3.6.1.4.1.674.11000.2000.500.1.2.46.1',
oids = [
'2', # scAlertNbr
'3', # scAlertStatus
'5', # scAlertDefinition
'6', # scAlertCategory
'7', # scAlertCreateTime
'8', # scAlertMessage
'9', # scAlertType
'10', # scAlertAcknowledged
'11', # scAlertActive
],
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*-

# (c) 2017 Heinlein Support GmbH
# Robert Sander <[email protected]>

#
# 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. 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,
Service,
Result,
SimpleSNMPSection,
SNMPTree,
State,
all_of,
contains,
exists,
)


def parse_dell_sc_cache(string_table):
return string_table

def discover_dell_sc_cache(section):
for line in section:
name=line[0]
yield Service(item=name)

def check_dell_sc_cache(item, section):
state = {
1 : ('up', State.OK),
2 : ('down', State.CRIT),
3 : ('degraded', State.WARN),
}
batt = {
0 : 'no battery',
1 : 'normal',
2 : 'expiration pending',
3 : 'expired',
}

for line in section:
if line[0] == item:
cache_state = state.get(int(line[1]), ('unknown', State.UNKNOWN))

yield Result(state=cache_state[1], summary="%s, Battery Expiration: %s (%s), State is %s" % (
line[2],
line[4],
batt.get(int(line[3]), line[3]),
cache_state[0])
)


check_plugin_dell_sc_cache = CheckPlugin(
name="dell_sc_cache",
sections = [ "dell_sc_cache" ],
service_name="Dell SC Cache %s",
discovery_function=discover_dell_sc_cache,
check_function=check_dell_sc_cache,
)


snmp_section_dell_sc_cache = SimpleSNMPSection(
name = "dell_sc_cache",
parse_function = parse_dell_sc_cache,
detect = all_of(
contains(".1.3.6.1.2.1.1.1.0", "compellent"),
exists(".1.3.6.1.4.1.674.11000.2000.500.1.2.1.0"),
),
fetch = SNMPTree(
base = '.1.3.6.1.4.1.674.11000.2000.500.1.2.28.1',
oids = [
'2', # scCacheNbr
'3', # scCacheStatus
'4', # scCacheName
'5', # scCacheBatStat
'6', # scCacheBatExpr
],
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*-

# (c) 2017 Heinlein Support GmbH
# Robert Sander <[email protected]>

#
# 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. 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.plugins.lib.fan import check_fan

from cmk.agent_based.v2 import (
CheckPlugin,
Service,
Result,
SimpleSNMPSection,
SNMPTree,
OIDEnd,
State,
all_of,
contains,
exists,
)


def item_dell_sc_ctlrfan(line):
ctlr, fan = line[0].split('.')
return "Ctlr %s Fan %s" % (ctlr, fan)

def parse_dell_sc_ctlrfan(string_table):
return string_table

def discover_dell_sc_ctlrfan(section):
for line in section:
name = item_dell_sc_ctlrfan(line)
yield Service(item=name)

def check_dell_sc_ctlrfan(item, params, section):
state = {
1 : ('up', State.OK),
2 : ('down', State.CRIT),
3 : ('degraded', State.WARN),
}
for line in section:
if item_dell_sc_ctlrfan(line) == item:
ctlrfan_state = state.get(int(line[1]), ('unknown', State.UNKNOWN))
rpm = int(line[3] or 0)
norm_max = int(line[4]) if line[4] else None
norm_min = int(line[5]) if line[5] else None
warn_lower = int(line[6]) if line[6] else None
warn_upper = int(line[7]) if line[7] else None
crit_lower = int(line[8]) if line[8] else None
crit_upper = int(line[9]) if line[9] else None

params_local = dict(params)
if "lower" not in params and (warn_lower is not None and crit_lower is not None):
params_local["lower"] = (warn_lower, crit_lower)
if "upper" not in params and (warn_upper is not None and crit_upper is not None):
params_local["upper"] = (warn_upper, crit_upper)

yield from check_fan(rpm, params_local)
if norm_max is not None and norm_min is not None:
yield Result(state=State.OK, summary="Range: %d/%d" % (norm_min, norm_max))
yield Result(state=ctlrfan_state[1], summary="State is %s" % ctlrfan_state[0])


check_plugin_dell_sc_ctlrfan = CheckPlugin(
name="dell_sc_ctlrfan",
sections = [ "dell_sc_ctlrfan" ],
service_name="Dell SC %s",
discovery_function=discover_dell_sc_ctlrfan,
check_function=check_dell_sc_ctlrfan,
check_default_parameters={
"output_metrics": True
},
check_ruleset_name="hw_fans",
)


snmp_section_dell_sc_ctlrfan = SimpleSNMPSection(
name = "dell_sc_ctlrfan",
parse_function = parse_dell_sc_ctlrfan,
detect = all_of(
contains(".1.3.6.1.2.1.1.1.0", "compellent"),
exists(".1.3.6.1.4.1.674.11000.2000.500.1.2.1.0"),
),
fetch = SNMPTree(
base = '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1',
oids = [
OIDEnd(), # scCtlrFanNbr
'3', # scCtlrFanStatus
'4', # scCtlrFanName
'5', # scCtlrFanCurrentRpm
'6', # scCtlrFanNormMaxRpm
'7', # scCtlrFanNormMinRpm
'8', # scCtlrFanWarnLwrRpm
'9', # scCtlrFanWarnUprRpm
'10', # scCtlrFanCritLwrRpm
'11', # scCtlrFanCritUprRpm
],
)
)
Loading

0 comments on commit 2d51948

Please sign in to comment.