Add support for Gude 8311 PDUs

This minor patch adds support for the Gude 8311, which are basically just the successor of the 8310 and have a slightly different OID number (62 instead of 27). Checkmk supports the 8310 out-of-the-box, but the 8311 is unsupported as of today.

--- old/lib/check_mk/base/plugins/agent_based/pdu_gude.py	2024-02-24 00:59:06.000000000 +0100
+++ new/lib/check_mk/base/plugins/agent_based/pdu_gude.py	2024-06-19 11:15:22.722195234 +0200
@@ -109,6 +109,27 @@
     ),
 )

+register.snmp_section(
+    name="pdu_gude_8311",
+    parsed_section_name="pdu_gude",
+    parse_function=parse_pdu_gude,
+    detect=equals(
+        ".1.3.6.1.2.1.1.2.0",
+        ".1.3.6.1.4.1.28507.62",
+    ),
+    fetch=SNMPTree(
+        ".1.3.6.1.4.1.28507.62.1.5.1.2.1",
+        [
+            "3",  # Consumption
+            "4",  # Power
+            "5",  # Current
+            "6",  # Voltage
+            "10",  # Track power
+        ],
+    ),
+)

 register.snmp_section(
     name="pdu_gude_8801",
--- old/lib/check_mk/base/api/agent_based/register/section_plugins_legacy/detect_specs.py	2024-02-24 00:59:06.000000000 +0100
+++ new/lib/check_mk/base/api/agent_based/register/section_plugins_legacy/detect_specs.py	2024-06-19 11:17:26.099753000 +0200
@@ -242,6 +242,7 @@
     (b'd\x01|\x00d\x02\x83\x01\xa0\x00\xa1\x00k\x06o\x1c|\x00d\x03\x83\x01\xa0\x01d\x04\xa1\x01S\x00', (None, 'th2e', '.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.2.0', '.0.10.43.6.1.4.1'), ('lower', 'startswith')): [[('.1.3.6.1.2.1.1.1.0', '.*th2e.*', True), ('.1.3.6.1.2.1.1.2.0', '\\.0\\.10\\.43\\.6\\.1\\.4\\.1.*', True)]],  # papouch_th2e_sensors: <lambda>
     (b'|\x00d\x01\x83\x01d\x02k\x02S\x00', (None, '.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.28507.26'), ()): [[('.1.3.6.1.2.1.1.2.0', '\\.1\\.3\\.6\\.1\\.4\\.1\\.28507\\.26', True)]],  # pdu_gude_8301: <lambda>
     (b'|\x00d\x01\x83\x01d\x02k\x02S\x00', (None, '.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.28507.27'), ()): [[('.1.3.6.1.2.1.1.2.0', '\\.1\\.3\\.6\\.1\\.4\\.1\\.28507\\.27', True)]],  # pdu_gude_8310: <lambda>
+    (b'|\x00d\x01\x83\x01d\x02k\x02S\x00', (None, '.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.28507.62'), ()): [[('.1.3.6.1.2.1.1.2.0', '\\.1\\.3\\.6\\.1\\.4\\.1\\.28507\\.62', True)]],  # pdu_gude_8311: <lambda>
     (b'|\x00d\x01\x83\x01\xa0\x00d\x02\xa1\x01S\x00', (None, '.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.1966.20'), ('startswith',)): [[('.1.3.6.1.2.1.1.2.0', '\\.1\\.3\\.6\\.1\\.4\\.1\\.1966\\.20.*', True)]],  # perle_chassis: perle_scan_function
     (b'd\x01|\x00d\x02\x83\x01\xa0\x00\xa1\x00k\x06S\x00', (None, 'pfsense', '.1.3.6.1.2.1.1.1.0'), ('lower',)): [[('.1.3.6.1.2.1.1.1.0', '.*pfsense.*', True)]],  # pfsense_counter: <lambda>
     (b'|\x00d\x01\x83\x01\xa0\x00d\x02\xa1\x01S\x00', (None, '.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.21796.3'), ('startswith',)): [[('.1.3.6.1.2.1.1.2.0', '\\.1\\.3\\.6\\.1\\.4\\.1\\.21796\\.3.*', True)]],  # poseidon_inputs: <lambda>

Hi @Jay2k1. Posting patches in the forum is probably not the best idea.
Maybe you want to open a pull request on GitHub?

2 Likes

I had sent it to the feedback email address, hoping that it would be added, but they suggested I post it in this how-to section, so that’s what I did. I could however PR it, that’s true :slight_smile:

1 Like

I think, that would be the most sensible way. :+1:

After upgrade to 2.4.x unfortunately it’s not working anymore. I already realized “pdu_gude.py” moved from “/lib/check_mk/base/plugins/agent_based/” to “/lib/check_mk/plugins/collection/agent_based” , but I can’t find the file “detect_specs.py” and can’t make it work again. Any ideas how to make it work again?

Restart of OMD did the job.

I should mention I did make a PR recently, but apparently the automated checks are broken at the moment. Add support for Gude 8311 PDUs by Jay2k1 · Pull Request #865 · Checkmk/checkmk · GitHub

It perfectly works when you just add the following code to /lib/check_mk/plugins/collection/agent_based.pdu_gude.py

snmp_section_pdu_gude_8311 = SimpleSNMPSection(
    name="pdu_gude_8311",
    parsed_section_name="pdu_gude",
    parse_function=parse_pdu_gude,
    detect=equals(
        ".1.3.6.1.2.1.1.2.0",
        ".1.3.6.1.4.1.28507.62",
    ),
    fetch=SNMPTree(
        ".1.3.6.1.4.1.28507.62.1.5.1.2.1",
        [
            "3",  # Consumption
            "4",  # Power
            "5",  # Current
            "6",  # Voltage
            "10",  # Track power
        ],
    ),
)

Just restart omd and everything is fine again. The small differnece is the part in the code “register.snmp_section” what has to be now “snmp_section_pdu_gude_8311 = SimpleSNMPSection”

I’ve seen it’s exactly what you did as well, but since your PR is not merged, i shared the solution for people who are looking for a solution.