Class OfflineSnmpClient

java.lang.Object
org.metricshub.snmp.client.OfflineSnmpClient
All Implemented Interfaces:
ISnmpClient

public final class OfflineSnmpClient extends Object implements ISnmpClient
An offline SNMP client that reads OID values from a snmp WALK dump file and executes SNMP operations (GET, GET_NEXT, TABLE, WALK) against those OIDs.
  • Constructor Details

    • OfflineSnmpClient

      public OfflineSnmpClient(Path directory) throws IOException
      Reads oid values from all .walk files in the specified directory.
      Parameters:
      directory - A given directory containing .walk files
      Throws:
      IOException - If an I/O error occurs reading from the directory or a file
  • Method Details

    • get

      public String get(String oid) throws Exception
      Description copied from interface: ISnmpClient
      Performs SNMP get action for a single OID.
      Specified by:
      get in interface ISnmpClient
      Parameters:
      oid - A given OID.
      Returns:
      The corresponding object as a string.
      Throws:
      Exception - on error (e.g. no such OID).
    • getNext

      public String getNext(String oid)
      Description copied from interface: ISnmpClient
      Performs SNMP getNext action for a single OID.
      Specified by:
      getNext in interface ISnmpClient
      Parameters:
      oid - A given OID.
      Returns:
      The corresponding object as a string.
    • table

      public List<List<String>> table(String rootOID, String[] selectColumns)
      Description copied from interface: ISnmpClient
      Reads an SNMP table.
      Specified by:
      table in interface ISnmpClient
      Parameters:
      rootOID - Root OID of the table (e.g. …7.1)
      selectColumns - Numeric column indexes or "ID" for the row index
      Returns:
      Rows serialized with semicolons (one row per line)
    • walk

      public String walk(String oid)
      Description copied from interface: ISnmpClient
      Performs SNMP walk action starting from a given OID.
      Specified by:
      walk in interface ISnmpClient
      Parameters:
      oid - A given OID.
      Returns:
      The corresponding object as a string.
    • freeResources

      public void freeResources()
      Description copied from interface: ISnmpClient
      Frees any resources held by the client, such as network connections or file handles or memory space.
      Specified by:
      freeResources in interface ISnmpClient