Search code examples
requestconditional-statementssnmp

Add condition to SNMP request via php


I am trying to integrated two systems using SNMP protocol, here is my question: as you know to get queries from for example MySQL database i have ability to add conditions in query string and get required result, some thing like below:

SELECT * FROM table WHERE a='foo' AND b='bar'

is there any possibility to request queries using SNMP with conditions


Solution

  • It depends if you need to select data based on the mib instance or the mib data.

    You can select data based on the instance, like:

    snmpwalk -v2c -cpublic 1.2.3.4  ifOperStatus
    

    This will give you all interface statuses in a device.

    SNMP do not support getting only ifOperStatus = "up", in this case you need to retrieve all instance and make your selection

    snmpwalk -v2c -cpublic 1.2.3.4  ifOperStatus | grep up
    

    Another more over the top solution is to collect the data and store it in a database, then you can use the SQL syntax you mentioned in your question