Error with SNMP with verity UPS-Crash Report

Im not sure why this warning is coming up. Ive added a Vertiv UPS for monitoring.

CMK version: 2.2.0p9
**OS version:Ubuntu 22.04

Error message:
WARNING: Parsing of section ups_power failed - please submit a crash report!

Crash Report

ValueError (invalid literal for int() with base 10: ‘’)

File “/omd/sites/checkmk/lib/python3/cmk/base/agent_based/data_provider.py”, line 106, in _parse_raw_data
return parse_function(list(raw_data))
File “/omd/sites/checkmk/lib/python3/cmk/base/plugins/agent_based/ups_power.py”, line 22, in parse_ups_power
power = int(power_str)

{‘idx’: ‘1’,
‘power_str’: ‘’,
‘section’: {},
‘string_table’: [[[‘1’, ‘122’, ‘’]]],
‘voltage_str’: ‘122’}

Python Version 3.11.2 (main, Jun 29 2023, 23:11:33) [GCC 12.2.0]
Python Module Paths /opt/omd/versions/2.2.0p9.cee/bin
/omd/sites/checkmk/local/lib/python3
/omd/sites/checkmk/lib/python3/cloud
/omd/sites/checkmk/lib/python311.zip
/omd/sites/checkmk/lib/python3.11
/omd/sites/checkmk/lib/python3.11/lib-dynload
/omd/sites/checkmk/lib/python3.11/site-packages
/omd/sites/checkmk/lib/python3
Section Name ups_power
Inline-SNMP Unknown
Section Content [[[‘1’, ‘122’, ‘’]]]

the check plugin is expecting a value for power_str but our USV delivers none (the ‘’)

‘string_table’: [[[‘1’, ‘122’, ‘’]]],

Not shure why your USV is not delivering this value, on the other hand not checking the input values is a bug in the check plugin. The Plugin checks only voltage_str what it never uses…

/omd/sites/checkmk/lib/python3/cmk/base/plugins/agent_based/ups_power.py

def parse_ups_power(
    string_table: list[StringTable],
) -> dict[str, int]:
    section: dict[str, int] = {}
    for idx, voltage_str, power_str in string_table[0]:
        if not voltage_str or not int(voltage_str):
            continue

        power = int(power_str)
        # Some "RPS SpA" systems are not RFC conform in this value.
        # The values can get negative but should never be.
        if power < 0:
            power *= -1

        section[idx] = power
    return section

you could fix this by chaning the parse function like this

def parse_ups_power(
    string_table: list[StringTable],
) -> dict[str, int]:
    section: dict[str, int] = {}
    for idx, voltage_str, power_str in string_table[0]:
        try:
            power = int(power_str)
        except ValueError:
            continue
        # Some "RPS SpA" systems are not RFC conform in this value.
        # The values can get negative but should never be.
        if power < 0:
            power *= -1

        section[idx] = power
    return section

It got rid of the error but on our other Vertiv UPS it is not able to find Power Phase 1 and 2 service checks now and it was able to prior to this change.

can you do a snmpwalk over this oid .1.3.6.1.2.1.33.1.4.4.1?

What would be the command for that?

as site user you can run

cmk --snmpwalk --oid .1.3.6.1.2.1.33.1.4.4.1 <your-host-as-in-cmk>

on the CLI. The result is stored under

 /omd/sites/<your-site-name>/var/check_mk/snmpwalks/<your-host-as-in-cmk>

And for the Linux snmpwalk command you get help by running snmpwlak without any parameters on the CLI :wink:

Error in agent based plugin ups_power: expected parse function argument annotation ‘List[StringTable]’, got list[typing.List[typing.List[str]]]

can you restore the original version of the ups_power.py check and try again?

Restored it, but I’m getting the same error

can you show the complete output form the CLI (incl. your cmk --snmpwalk command)?

cmk --snmpwalk --oid .1.3.6.1.2.1.33.1.4.4.1 Libert-UPS-1

Error in agent based plugin ups_power: expected parse function argument annotation ‘List[StringTable]’, got list[typing.List[typing.List[str]]]

output from snmpwalks

.1.3.6.1.2.1.33.1.4.4.1.2.1 121
.1.3.6.1.2.1.33.1.4.4.1.3.1 23

ups_power.py

from cmk.base.plugins.agent_based.utils.ups import DETECT_UPS_GENERIC

from .agent_based_api.v1 import OIDEnd, register, SNMPTree
from .agent_based_api.v1.type_defs import StringTable

def parse_ups_power(
string_table: list[StringTable],
) → dict[str, int]:
section: dict[str, int] = {}
for idx, voltage_str, power_str in string_table[0]:
if not voltage_str or not int(voltage_str):
continue

    power = int(power_str)
    # Some "RPS SpA" systems are not RFC conform in this value.
    # The values can get negative but should never be.
    if power < 0:
        power *= -1

    section[idx] = power
return section

register.snmp_section(
name=“ups_power”,
parsed_section_name=“epower”,
detect=DETECT_UPS_GENERIC,
parse_function=parse_ups_power,
fetch=[
SNMPTree(
base=“.1.3.6.1.2.1.33.1.4.4.1”,
oids=[
OIDEnd(),
“2”, # voltage
“4”, # power
],
)
],
)

You are sure ths is the original ups_power.py file? Can you check the parse function? The list needs to be a List with a capital L. My code is from the actual master bracnch there it is changed to a lowercase list

def parse_ups_power(
    string_table: list[StringTable],
) -> dict[str, int]:

in 2.2.0 it should look like this:

def parse_ups_power(
    string_table: List[StringTable],
) -> dict[str, int]:
    section: dict[str, int] = {}
    for idx, voltage_str, power_str in string_table[0]:
        if not voltage_str or not int(voltage_str):
            continue

        power = int(power_str)
        # Some "RPS SpA" systems are not RFC conform in this value.
        # The values can get negative but should never be.
        if power < 0:
            power *= -1

        section[idx] = power
    return section

if this is fixed, you could try again by only changing

        if not voltage_str or not int(voltage_str):
            continue

        power = int(power_str)

to

        try:
            power = int(power_str)
        except ValueError:
            continue

in the parse function. Btw. do not modify the original file. Just copy it to
~/local/lib/check_mk/base/plugins/agent_based and modify it there. This way you can restore the original by removing the file from the local directory.

Here the OID .1.3.6.1.2.1.33.1.4.4.1.4.1 is missing (the actual power value). So the check will not work with this UPS. Perhaps a new/different firmware can help.

If you post code use the preformatet text input image (Ctrl+e) please.

in your ups_power.py the line

from typing import List

is also missing. Here you find the original file for cmk 2.2.x

Appreciate it thank you for all the help. Ill update the firmware and see.

I have the SNMP mibs/parameters for the device would that help getting the power value?
In checkmk it shows the load of 0% I know this is not correct. It must not be getting values correctly.

The cmk checks do not use MIBs. The OIDs used are coded in the “register.snmp_section” part.

If your UPS uses different OIDs than the plugin expects, then the check must be changed for your device.

Just curious, what OIDs does your UPS use for the power value and what is the value of the OID .1.3.6.1.2.1.1.2.0?

You should open another thread for this topic to better follow the content of this thread

For output power I have

System Output Pct Power,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5861
System Output Power,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4208

I cant find .1.3.6.1.2.1.1.2.0

Below is SNMP Parameters

lgpAgentIdentManufacturer,1.3.6.1.4.1.476.1.42.2.1.1.0
lgpAgentIdentModel,1.3.6.1.4.1.476.1.42.2.1.2.0
lgpAgentIdentFirmwareVersion,1.3.6.1.4.1.476.1.42.2.1.3.0
lgpAgentIdentSerialNumber,1.3.6.1.4.1.476.1.42.2.1.4.0
lgpAgentIdentPartNumber,1.3.6.1.4.1.476.1.42.2.1.5.0
lgpAgentReboot,1.3.6.1.4.1.476.1.42.2.5.1.0
lgpAgentDeviceManufacturer,1.3.6.1.4.1.476.1.42.2.4.2.1.3.1
lgpAgentDeviceModel,1.3.6.1.4.1.476.1.42.2.4.2.1.4.1
lgpAgentDeviceFirmwareVersion,1.3.6.1.4.1.476.1.42.2.4.2.1.5.1
lgpAgentDeviceSerialNumber,1.3.6.1.4.1.476.1.42.2.4.2.1.7.1
System Input RMS L1-N,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4096
System Input Nominal Voltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4102
System Input Nominal Frequency,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4103
System Input Nominal Current,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4104
System Input Frequency,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4105
System Input RMS Current L1,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4113
System Status,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4123
 Possible states for the OID above:
  1: "Normal Operation"
  2: "StartUp"
  8: "Normal with Warning"
  16: "Normal with Alarm"
  32: "Abnormal Operation"
DC Bus Voltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4148
Battery Time Remaining,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4150
Battery Discharge Time,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4151
Battery Percentage Charge,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4153
System Output RMS Current L1,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4204
System Output Frequency,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4207
System Output Power,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4208
System Output Apparent Power,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4209
System Model Number,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4240
System Serial Number,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4244
Site Identifier,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4247
Site Equipment Tag Number,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4248
System Output Nominal Voltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4260
System Output Nominal Frequency,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4261
Output Apparent Power Rating,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4264
Inlet Air Temperature,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4291
System Name,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4329
Manufacturer,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4333
Firmware Version,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4335
Outlet Group User Assigned Label,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4359.1
System Output Voltage RMS L1-N,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4385
Outlet Group Identifier,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4510.1
Server Class,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4553
 Possible states for the OID above:
  1: "UPS"
  2: "AIR"
  3: "PMP"
  4: "PDU"
  5: "MONITOR"
Auto Restart Delay,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4710
UPS Battery Status,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4871
 Possible states for the OID above:
  1: "Unknown"
  2: "Normal"
  3: "Low"
  4: "Depleted"
UPS Output Source,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4872
 Possible states for the OID above:
  1: "Other"
  2: "Off"
  3: "Normal"
  4: "Bypass"
  5: "Battery"
  6: "Booster"
  7: "Reducer"
Battery Charge Status,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5799
 Possible states for the OID above:
  0: "fully charged"
  1: "charging"
  2: "discharging"
  3: "not charging (charger off)"
Number of EBC Installed,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5800
Low Battery Warning Time,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5802
Automatic Battery Test,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5803
 Possible states for the OID above:
  0: "disabled"
  1: "enabled"
Nominal Power Factor,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5812
Shutdown After Delay,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5814
Reboot With Delay,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5815
Output On Delay,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5816
Auto Restart,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5831
 Possible states for the OID above:
  0: "disabled"
  1: "enabled"
System Output Pct Power,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5861
DC Converter Status,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6003
 Possible states for the OID above:
  0: "off"
  1: "on"
Battery Test Result,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6181
 Possible states for the OID above:
  0: "Unknown"
  1: "Passed"
  2: "Failed"
  3: "In Progress"
  4: "System Failure"
  5: "Inhibited"
Audible Alarm Control,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6188
 Possible states for the OID above:
  0: "off"
  1: "on"
DC Bus Nominal Voltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6189
UPS Topology,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6199
 Possible states for the OID above:
  0: "unknown"
  1: "Offline"
  2: "Line Interactive"
  3: "Online"
Enable/Disable programmable outlets,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6720
 Possible states for the OID above:
  1: "enabled"
  2: "disabled"
Programmable outlet time limit,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6721
Enable/Disable non-programmable outlets,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6722
 Possible states for the OID above:
  1: "enabled"
  2: "disabled"
Non-Programmable outlet time limit,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6723
Enable/Disable site fault detection,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6724
 Possible states for the OID above:
  1: "enabled"
  2: "disabled"
Enable/Disable neutral grounding in battery mode,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6725
 Possible states for the OID above:
  1: "enabled"
  2: "disabled"
Emergency Power Off (EPO) Logic,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6726
 Possible states for the OID above:
  1: "Active Open"
  2: "Active Close"
Input Waveform Sensitivity,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6727
 Possible states for the OID above:
  1: "High Sensitivity"
  2: "Middle Sensitivity"
  3: "Low Sensitivity"
Outlet Group Power Control,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.6730.1
 Possible states for the OID above:
  0: "off"
  1: "on"
  2: "cycle power"
Inlet Air Temperature,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.2.4291
System Input Power Problem,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4122
Battery Low,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4162
Battery Discharging,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4168
System Output Off,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4215
Emergency Power Off - Latched,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4229
Inverter Failure,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4233
Rectifier Failure,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4295
Equipment Over Temperature,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4310
System Fan Failure,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4311
Battery Test Failed,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4323
Battery Self Test,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4741
Parallel Comm Warning,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.4823
Output Overvoltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.5178
Output Undervoltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.5179
Input Undervoltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.5568
Input Overvoltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.5569
Unspecified General Event,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.5588
Output Overload,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.5806
Battery Over Voltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.5874
Battery Under Voltage,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.6180
Replace Battery,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.6182
Input Frequency Deviation,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.6186
Shutdown Pending,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.6187
Charger Failure,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.6254
Input Wiring Fault,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.6453
DC to DC Converter Fault,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.100.6454
System Status,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.4123
 Possible states for the OID above:
  1: "Normal Operation"
  2: "StartUp"
  8: "Normal with Warning"
  16: "Normal with Alarm"
  32: "Abnormal Operation"
System Model Number,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.4240
Server Class,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.4553
 Possible states for the OID above:
  1: "UPS"
  2: "AIR"
  3: "PMP"
  4: "PDU"
  5: "MONITOR"
Sensor Order Identifier - Slot 01,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6109
Sensor Order Identifier - Slot 02,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6110
Sensor Order Identifier - Slot 03,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6111
Sensor Order Identifier - Slot 04,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6112
Sensor Order Identifier - Slot 05,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6113
Sensor Order Identifier - Slot 06,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6114
Sensor Order Identifier - Slot 07,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6115
Sensor Order Identifier - Slot 08,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6116
Sensor Order Identifier - Slot 09,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6117
Sensor Order Identifier - Slot 10,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.1.6118
Too Many Sensors,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.100.5423
Slots not available,1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.3.20.100.6119