centreon-plugins icon indicating copy to clipboard operation
centreon-plugins copied to clipboard

[apps::protocols::snmp::plugin] snmp collection mode cannot parse oid leef with constant

Open Luth1ng opened this issue 1 year ago • 1 comments

Quick description

I cannot use constant in snmp leef oid with snmp collection mode

How to reproduce

Try to replace an OID with a constant

Expected result

with this json file :

{
        "mapping": {},
        "constants": {
                "ifIndex": "167837696"
        },
        "snmp": {
                "leefs": [
                        {
                                "name": "opticalIfLaserTxPower",
                                "oid": ".1.3.6.1.4.1.4746.2.6.1.2.1.2.167837696"
                        }
                ]
        },
        "selection": [
                {
                        "name": "myLeefs1",
                        "expand": {
                                "leefvalue": "%(snmp.leefs.opticalIfLaserTxPower)"
                        },
                        "formatting": {
                                "printf_msg": "Status is %s.",
                                "printf_var": [
                                        "%(leefvalue)"
                                ],
                                "display_ok": true
                        }
                }
        ],
        "selection_loop": [],
        "formatting": {}
}

result is : OK: Status is -24. .1.3.6.1.4.1.4746.2.6.1.2.1.2.167837696 = -24

Actual result

With this json file :

{
        "mapping": {},
        "constants": {
                "ifIndex": "167837696"
        },
        "snmp": {
                "leefs": [
                        {
                                "name": "opticalIfLaserTxPower",
                                "oid": ".1.3.6.1.4.1.4746.2.6.1.2.1.2.[%(constants.ifIndex)]"
                        }
                ]
        },
        "selection": [
                {
                        "name": "myLeefs1",
                        "expand": {
                                "leefvalue": "%(snmp.leefs.opticalIfLaserTxPower)"
                        },
                        "formatting": {
                                "printf_msg": "Status is %s.",
                                "printf_var": [
                                        "%(leefvalue)"
                                ],
                                "display_ok": true
                        }
                }
        ],
        "selection_loop": [],
        "formatting": {}
}

Result is :

OK: Status is . ======> variables Status is .

Questions

My goal here is to call a json find to check a particular OID with an input parameter. I don't want to request all the table and filter with this OID.

I know I could use the table and filter the oid with a selection_loop, but I would like to minimize the SNMP requests sent to the equipment.

How can I achieve this ?

Luth1ng avatar Feb 14 '24 11:02 Luth1ng

Hi @Luth1ng, I have recently faced the exact same limitation and at the moment I see no reason why we wouldn't support it. We'll try to improve that.

omercier avatar Apr 08 '24 07:04 omercier