Yogibaer75 / Check_MK-Things

From check plugins to website extensions
60 stars 19 forks source link

Redfish Restful API Checks - Discovery Crash #37

Closed robialbrecht closed 1 year ago

robialbrecht commented 1 year ago

Hi Andreas

Thanks again for your good work on the “Redfish Restful API Checks” Extension. It seems as if there is a little Bug in your extension.

Some of our servers unfortunately have only one power supply. This fact seems to create an issue when running the check on those servers within the "Check_MK Discovery."

image

Checking the crash report we have found an issue in the redfish_psu.py. This might be because we receive an NA if there is no second PSU.

image

I attached the crash report from checkMK:

Checkmk_Crash_main_e5cc5f7c-4195-11ee-b3a6-0050568dafd6_2023-08-23_13-14-52.tar.gz

Traceback:

  File "/omd/sites/main/lib/python3/cmk/base/cee/keepalive/checker.py", line 211, in _process_fetch_entry
    check_result = execute_check_discovery(
  File "/omd/sites/main/lib/python3/cmk/base/agent_based/discovery/_discovery.py", line 119, in execute_check_discovery
    services = get_host_services(
  File "/omd/sites/main/lib/python3/cmk/base/agent_based/discovery/autodiscovery.py", line 593, in get_host_services
    **_get_node_services(
  File "/omd/sites/main/lib/python3/cmk/base/agent_based/discovery/autodiscovery.py", line 625, in _get_node_services
    service_result = analyse_discovered_services(
  File "/omd/sites/main/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 42, in analyse_discovered_services
    discovered_services=_discover_services(
  File "/omd/sites/main/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 150, in _discover_services
    {
  File "/omd/sites/main/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 150, in <dictcomp>
    {
  File "/omd/sites/main/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 303, in _discover_plugins_services
    yield from (
  File "/omd/sites/main/lib/python3/cmk/base/agent_based/discovery/_discovered_services.py", line 303, in <genexpr>
    yield from (
  File "/omd/sites/main/lib/python3/cmk/base/api/agent_based/register/check_plugins.py", line 73, in filtered_generator
    for element in generator(*args, **kwargs):
  File "/omd/sites/main/local/lib/python3/cmk/base/plugins/agent_based/redfish_psu.py", line 39, in discovery_redfish_psu
    yield Service(item="%s-%s" % (count, entry["Name"]))

Local Variables

{'count': 1,
 'data': [{'FirmwareVersion': '2.00',
           'LastPowerOutputWatts': 221,
           'LineInputVoltage': 228,
           'LineInputVoltageType': 'ACHighLine',
           'Model': '720478-B21',
           'Name': 'HpServerPowerSupply',
           'Oem': {'Hp': {'@odata.type': 'Max recursion depth reached',
                          'AveragePowerOutputWatts': 'Max recursion depth '
                                                     'reached',
                          'BayNumber': 'Max recursion depth reached',
                          'HotplugCapable': 'Max recursion depth reached',
                          'MaxPowerOutputWatts': 'Max recursion depth reached',
                          'Mismatched': 'Max recursion depth reached',
                          'PowerSupplyStatus': 'Max recursion depth reached',
                          'iPDUCapable': 'Max recursion depth reached'}},
           'PowerCapacityWatts': 500,
           'PowerSupplyType': 'AC',
           'SerialNumber': '5DLUT0C8J191R5',
           'SparePartNumber': '754377-001',
           'Status': {'Health': 'OK', 'State': 'Enabled'}},
          {'Oem': {'Hp': {'@odata.type': 'Max recursion depth reached',
                          'BayNumber': 'Max recursion depth reached'}},
           'Status': {'Health': 'Warning', 'State': 'Absent'}}],
 'entry': {'Oem': {'Hp': {'@odata.type': '#HpServerPowerSupply.1.0.0.HpServerPowerSupply',
                          'BayNumber': 2}},
           'Status': {'Health': 'Warning', 'State': 'Absent'}},
 'section': {'@odata.context': '/redfish/v1/$metadata#Chassis/Members/1/Power$entity',
             '@odata.id': '/redfish/v1/Chassis/1/Power/',
             '@odata.type': '#Power.1.0.1.Power',
             'Id': 'Power',
             'Name': 'PowerMetrics',
             'Oem': {'Hp': {'@odata.type': '#HpPowerMetricsExt.1.2.0.HpPowerMetricsExt',
                            'Links': {'FastPowerMeter': 'Max recursion depth '
                                                        'reached',
                                      'FederatedGroupCapping': 'Max recursion '
                                                               'depth reached',
                                      'PowerMeter': 'Max recursion depth '
                                                    'reached'},
                            'SNMPPowerThresholdAlert': {'DurationInMin': 'Max '
                                                                         'recursion '
                                                                         'depth '
                                                                         'reached',
                                                        'ThresholdWatts': 'Max '
                                                                          'recursion '
                                                                          'depth '
                                                                          'reached',
                                                        'Trigger': 'Max '
                                                                   'recursion '
                                                                   'depth '
                                                                   'reached'}}},
             'PowerControl': [{'PowerCapacityWatts': 500,
                               'PowerConsumedWatts': 221,
                               'PowerLimit': {'LimitInWatts': 'Max recursion '
                                                              'depth reached'},
                               'PowerMetrics': {'AverageConsumedWatts': 'Max '
                                                                        'recursion '
                                                                        'depth '
                                                                        'reached',
                                                'IntervalInMin': 'Max '
                                                                 'recursion '
                                                                 'depth '
                                                                 'reached',
                                                'MaxConsumedWatts': 'Max '
                                                                    'recursion '
                                                                    'depth '
                                                                    'reached',
                                                'MinConsumedWatts': 'Max '
                                                                    'recursion '
                                                                    'depth '
                                                                    'reached'}}],
             'PowerSupplies': [{'FirmwareVersion': '2.00',
                                'LastPowerOutputWatts': 221,
                                'LineInputVoltage': 228,
                                'LineInputVoltageType': 'ACHighLine',
                                'Model': '720478-B21',
                                'Name': 'HpServerPowerSupply',
                                'Oem': {'Hp': 'Max recursion depth reached'},
                                'PowerCapacityWatts': 500,
                                'PowerSupplyType': 'AC',
                                'SerialNumber': '5DLUT0C8J191R5',
                                'SparePartNumber': '754377-001',
                                'Status': {'Health': 'Max recursion depth '
                                                     'reached',
                                           'State': 'Max recursion depth '
                                                    'reached'}},
                               {'Oem': {'Hp': 'Max recursion depth reached'},
                                'Status': {'Health': 'Max recursion depth '
                                                     'reached',
                                           'State': 'Max recursion depth '
                                                    'reached'}}]}}

best regards and thanks for your help.

Gruss Roberto

Yogibaer75 commented 1 year ago

This should be fixed with the latest commit. But only the new package generation is missing :)

Yogibaer75 commented 1 year ago

package https://github.com/Yogibaer75/Check_MK-Things/blob/master/check%20plugins%202.2/redfish/redfish-2.2.17.mkp now includes the fixes