The Secret Diary of Han, Aged 0x29

Existing SNMP poller structure

I will write up the redesign of the poller on the worklog, for future reference. To understand it, it is important to have an idea of how the SNMP poller version 1 works. Here is a short description.

Main structures

The existing SNMP Poller keeps 3 main collections:

1. @Polls.
Each poll describes a separate timed request to an agent (Ip address + optional port), that comprises 1 or more measurements (SNMP gets) that are combined. SNMP gets are only combined if they have the same frequency (poll modus). Each poll record contains a list of indexes into tables 2 and 3 (below), plus various parameters it needs to do make the SNMP request, such as ip, community, version, poll modus (freq) and poll constant (to spread the polls), etc). A separate hash index is kept from IP + poll modus to the poll record, to easily find the poll record from the address + modus

2. @SampleCollections
Stores address, address space, class, instance and measurementtype, plus all collected samples for each individual measurement

3. @SNMPParams
Stores things needed for each individual SNMP get: OID, SNMP Instance (iid), eval expression.

Collections 2 and 3 are in sync. The index of each is stored in the each record in the @Polls collection as well.

Configuration maps

In addition to these collections, a couple of hashes exist to give access to configuration data:

  1. %oidMap. Contains the oid for each class, measurement type, mib combination.
  2. %evalMap. Contains the evaluation expression using the same key as %oidMap.
  3. %snmpVersionMap. Contains SNMP version and the maximum number of combined polls by IP address.
  4. %communityMap. Contains the SNMP Community string by IP address

Instance mapping

Instance mapping has two levels. First, maps exist that find the configuration parameters based on the OID. These maps are called ConfigurationMaps. Second, maps exist that map from the Smart24, human readable, instance value to the dotted numerical SNMP instance value. These maps are called InstanceMaps. The InstanceMaps are read directly from the servers (”dynamic”, “index” and “ipaddress” instance mapping) or from a static file (”static”) instance mapping. The configuration is kept around, because instance maps are refreshed every once in a while.

The poll cycle

Net-SNMP calls back to the SNMP Poller’s poll method every 2 seconds. The poll method then checks whether it has do certain actions based on whether signals were received and based on a poll counter it maintains. It checks for the following

  • Was a KILL signal received? If yes write the collected data to disk and quit
  • Was a HUP signal received? If yes write the collected data to disk, and reread configuration
  • Is it time to do the regular write to disk? if yes, write out the data
  • Is it time to create a polling report? if yes, write the stats to the log file
  • Is it time to do an instance refresh for certain IPs? if yes do so
  • Check which polls are up, and carry out those.

Written by Han

January 27, 2006 at 12:53

Posted in Tools

%d bloggers like this: