Module Contents

class noc.core.script.snmp.base.SNMP(script)

Bases: object

name = snmp
set_timeout_limits(self, n)

Set sequental timeouts l :param n: :return:

_get_snmp_version(self, version=None)
get(self, oids, cached=False, version=None, raw_varbinds=False)

Perform SNMP GET request :param oid: string or list of oids :param cached: True if get results can be cached during session :param raw_varbinds: Return value in BER encoding :returns: eigther result scalar or dict of name -> value

set(self, *args)

Perform SNMP GET request :param oid: string or list of oids :returns: eigther result scalar or dict of name -> value

count(self, oid, filter=None, version=None)

Iterate MIB subtree and count matching instances :param oid: OID :param filter: Callable accepting oid and value and returning boolean

getnext(self, oid, community_suffix=None, filter=None, cached=False, only_first=False, bulk=None, max_repetitions=None, version=None, max_retries=0, timeout=10, raw_varbinds=False)
get_table(self, oid, community_suffix=None, cached=False)

GETNEXT wrapper. Returns a hash of <index> -> <value>

join_tables(self, oid1, oid2, community_suffix=None, cached=False)

Generator returning a rows of two snmp tables joined by index

get_tables(self, oids, community_suffix=None, bulk=False, min_index=None, max_index=None, cached=False, max_retries=0)

Query list of SNMP tables referenced by oids and yields tuples of (key, value1, …, valueN)

  • oids – List of OIDs
  • community_suffix – Optional suffix to be added to community
  • bulk – Use BULKGETNEXT if true
  • min_index
  • max_index
  • cached
  • max_retries

join(self, oids, community_suffix=None, cached=False, join='left')

Query list of tables, merge by oid index Tables are records of: * <oid>.<index> = value

join may be one of: * left * inner * outer

Yield records of (<index>, <value1>, …, <valueN>)

get_chunked(self, oids, chunk_size=20, timeout_limits=3)

Fetch list of oids splitting to several operations when necessary

  • oids – List of oids
  • chunk_size – Maximal GET chunk size
  • timeout_limits – SNMP timeout limits

dict of oid -> value for all retrieved values