diff --git a/agent_based/cisco_asa_sensors.py b/agent_based/cisco_asa_sensors.py index e13699aa93fa06e86ef4f912cdedaff965505760..386cc9752dcf55662bf18811e871c726945a4e54 100644 --- a/agent_based/cisco_asa_sensors.py +++ b/agent_based/cisco_asa_sensors.py @@ -102,13 +102,17 @@ # ] # # sample section -# {'fan': {'Chassis Sensor 1': CiscoAsaSensor(value=7680, status=<State.OK: 0>, state_readable='Ok', unit='rpm'), -# 'Chassis Sensor 2': CiscoAsaSensor(value=7936, status=<State.OK: 0>, state_readable='Ok', unit='rpm'), -# 'Chassis Sensor 3': CiscoAsaSensor(value=7680, status=<State.OK: 0>, state_readable='Ok', unit='rpm')}, -# 'temp': {'CPU Sensor 0/0': CiscoAsaSensor(value=34.0, status=<State.OK: 0>, state_readable='Ok', unit='celsius'), -# 'Chassis Ambient Sensor 1': CiscoAsaSensor(value=32.0, status=<State.OK: 0>, state_readable='Ok', unit='celsius'), -# 'Chassis Ambient Sensor 2': CiscoAsaSensor(value=30.0, status=<State.OK: 0>, state_readable='Ok', unit='celsius'), -# 'Chassis Ambient Sensor 3': CiscoAsaSensor(value=33.0, status=<State.OK: 0>, state_readable='Ok', unit='celsius')}, +# {'fan': { +# 'Chassis Sensor 1': CiscoAsaSensor(value=7680, status=<State.OK: 0>, state_readable='Ok', unit='rpm'), +# 'Chassis Sensor 2': CiscoAsaSensor(value=7936, status=<State.OK: 0>, state_readable='Ok', unit='rpm'), +# 'Chassis Sensor 3': CiscoAsaSensor(value=7680, status=<State.OK: 0>, state_readable='Ok', unit='rpm') +# }, +# 'temp': { +# 'CPU Sensor 0/0': CiscoAsaSensor(value=34.0, status=<State.OK: 0>, state_readable='Ok', unit='celsius'), +# 'Chassis Ambient Sensor 1': CiscoAsaSensor(value=32.0, status=<State.OK: 0>, state_readable='Ok', unit='celsius'), +# 'Chassis Ambient Sensor 2': CiscoAsaSensor(value=30.0, status=<State.OK: 0>, state_readable='Ok', unit='celsius'), +# 'Chassis Ambient Sensor 3': CiscoAsaSensor(value=33.0, status=<State.OK: 0>, state_readable='Ok', unit='celsius') +# }, # 'power': {}} # @@ -140,7 +144,7 @@ from .agent_based_api.v1 import ( class CiscoAsaSensor(NamedTuple): value: float - status: int + status: State state_readable: str unit: str @@ -162,7 +166,7 @@ def parse_cisco_asa_sensors(string_table: List[StringTable]) -> Dict: } return states.get(st, State.CRIT) - sensors = { + sensors: dict = { 'fan': {}, 'temp': {}, 'power': {}, @@ -170,38 +174,28 @@ def parse_cisco_asa_sensors(string_table: List[StringTable]) -> Dict: for sensorname, sensortype, sensorvalue, sensorstatus, sensorunits in string_table[0]: if sensorname != '': # for asa context, there are no real sensors. - if sensorstatus.isdigit(): - state_readable = get_state_readable(sensorstatus) - sensorstatus = get_sensor_status(sensorstatus) - if sensortype == '8': # Temperature - sensorname = sensorname.replace('Temperature ', '') - - sensors['temp'].update({sensorname: CiscoAsaSensor( + sensors['temp'].update({sensorname.replace('Temperature ', ''): CiscoAsaSensor( value=to_celsius(float(sensorvalue), sensorunits), unit=sensorunits, - status=sensorstatus, - state_readable=state_readable, + status=get_sensor_status(sensorstatus), + state_readable=get_state_readable(sensorstatus), )}) if sensortype == '10': # Fan - sensorname = sensorname.replace('Fan ', '') - - sensors['fan'].update({sensorname: CiscoAsaSensor( + sensors['fan'].update({sensorname.replace('Fan ', ''): CiscoAsaSensor( value=int(sensorvalue), unit=sensorunits, - status=sensorstatus, - state_readable=state_readable, + status=get_sensor_status(sensorstatus), + state_readable=get_state_readable(sensorstatus), )}) if sensortype == '12': # Power supply - sensorname = sensorname.replace('Power ', '') - - sensors['power'].update({sensorname: CiscoAsaSensor( + sensors['power'].update({sensorname.replace('Power ', ''): CiscoAsaSensor( value=0, unit='', - status=sensorstatus, - state_readable=state_readable, + status=get_sensor_status(sensorstatus), + state_readable=get_state_readable(sensorstatus), )}) return sensors @@ -299,7 +293,7 @@ def check_cisco_asa_fan(item, params, section) -> CheckResult: levels_lower=params.get('levels_lower', None), levels_upper=params.get('levels_upper', None), metric_name='fan' if params.get('output_metrics') else None, - render_func=lambda v: render_rpm(v), + render_func=render_rpm, ) except KeyError: @@ -345,4 +339,4 @@ register.check_plugin( discovery_function=discovery_cisco_asa_power, check_function=check_cisco_asa_power, check_default_parameters={}, -) \ No newline at end of file +) diff --git a/checkman/cisco_asa_fan b/checkman/cisco_asa_fan new file mode 100644 index 0000000000000000000000000000000000000000..fd36a185296f38000ff8e43f448e19b7dcb6a368 --- /dev/null +++ b/checkman/cisco_asa_fan @@ -0,0 +1,12 @@ +title: Cisco ASA Fan sesnors +agents: snmp +catalog: hw/network/cisco +license: GPL +distribution: check_mk +description: + This check monitors the state of fan sensors on Cisco ASA devices. + The check supports the sensor status. This Check has configurable levels for {WARN}/{CRIT} (upper/lower). +item: + The description of the sensor as provided by the device. +discovery: + One service is created for each sensor. \ No newline at end of file diff --git a/checkman/cisco_asa_power b/checkman/cisco_asa_power new file mode 100644 index 0000000000000000000000000000000000000000..f4200dfcda0c1a345bda9486eefec3e1992c5f33 --- /dev/null +++ b/checkman/cisco_asa_power @@ -0,0 +1,12 @@ +title: Cisco ASA Power supply sesnors +agents: snmp +catalog: hw/network/cisco +license: GPL +distribution: check_mk +description: + This check monitors the state of power supply sensors on Cisco ASA devices. + The check supports the sensor status. This Check is not configurable. +item: + The description of the sensor as provided by the device. +discovery: + One service is created for each sensor. \ No newline at end of file diff --git a/checkman/cisco_asa_temp b/checkman/cisco_asa_temp new file mode 100644 index 0000000000000000000000000000000000000000..39d7a000884f2d0e21134b6830de3df80a793d0d --- /dev/null +++ b/checkman/cisco_asa_temp @@ -0,0 +1,12 @@ +title: Cisco ASA Temperature sesnors +agents: snmp +catalog: hw/network/cisco +license: GPL +distribution: check_mk +description: + This check monitors the state of temperature sensors on Cisco ASA devices. + The check supports the sensor status. This Check has configurable levels for {WARN}/{CRIT} (upper/lower). +item: + The description of the sensor as provided by the device. +discovery: + One service is created for each sensor. \ No newline at end of file diff --git a/cisco_asa_sensors.mkp b/cisco_asa_sensors.mkp index 41987e5fd8761009cd26dda965c04516c6642432..f7337ac511930f3f4e49675cf48c3c3232878e00 100644 Binary files a/cisco_asa_sensors.mkp and b/cisco_asa_sensors.mkp differ diff --git a/packages/cisco_asa_sensors b/packages/cisco_asa_sensors index e89a24ebe94f4e3231d78d21c2e26a10bec06efe..39e62e176658cc74cf51a45236ed7ff6fb1bdb95 100644 --- a/packages/cisco_asa_sensors +++ b/packages/cisco_asa_sensors @@ -2,9 +2,10 @@ 'description': 'This plugin contains checks for Cisco ASA fan, temperature ' 'and power supply\n', 'download_url': 'https://thl-cmk.hopto.org', - 'files': {'agent_based': ['cisco_asa_sensors.py']}, + 'files': {'agent_based': ['cisco_asa_sensors.py'], + 'checkman': ['cisco_asa_fan', 'cisco_asa_power', 'cisco_asa_temp']}, 'name': 'cisco_asa_sensors', - 'num_files': 1, + 'num_files': 4, 'title': 'Cisco ASA Sensors', 'version': '20210318_v0.0.1', 'version.min_required': '2.0.0',