Skip to content
Toni Moreno edited this page Jan 9, 2017 · 40 revisions

Intro to SnmpCollector

What is SnmpCollector

SnmpCollector is an Open Source tool an is full featured Generic SNMP data collector with Web Administration Interface witch has as main goal simplify the configuration for getting data from any device witch snmp protocol support and send resulting data to a influxdb.

Features

These are the features for the snmp agent and the webui embedded tool

SNMP Agent Features

  • SNMP versions 1, 2/2c, 3
  • Support for gather any SNMP (ASN.1) data type.
  • Support for pre-process incremental counters to difference or/and rate conversion
  • Support for pre-process gathered STRINGS to get any sub-string as integer
  • Support for Online Post Process data from previously gathered data
  • Gather of SNMP Scalar an Tabular values.
  • Support for filtering table rows, based on snmp data conditions (OIDConditions)
  • Support for table row filtering,based on fixed rules (fileConditions) --compatibility with influxsnmp tool--
  • Support for Override column aliases with custom labels
  • Send self monitoring stats to any influxdb
  • Support for Influxdb > 1.0
  • SQLite/MySQL SQL based configuration
  • influxdb complete customized measurements,field and tag names

WebUI Features

  • Complete configuration Interface for all objects
  • Snmp web console as snmpget/snmpwalk replacement
  • Automatic snmp conectivity check
  • Online Runtime data viewer for all gathered metrics.
  • Online Configuration reload
  • Online device activation/deactivation , and log
  • REST API support

Installation and Setup

Head to and download the latest release and Install the suitable package for your distribution

Debian RedHat
deb - signature rpm - signature

You can see a list of features and changes in the ChangeLog

Check an feel free to change any of the predefined parameters in the main configuration placed in /etc/snmpcollector/config.toml

############################
# General Config
############################

[general]
 # InstanceID will be a string identifying the collector , It will be useful when
 # more than one running on the same server, this ID will be shown in the WebUI.
 instanceID = "WAN Communicactions"
 # datadir set the directory where the data will be placed , also sqlite db if set as db engine
 # if not set the default datadir will be placed in the configuration directory
 # datadir = "/var/lib/snmpcollector"

 # there are as many logs as devices configured
 # logdir set the Directory path for each device individual log, default is /var/log/snmpcollector
 # logdir = "/var/log/somelogpath"
 # NOTE: main process log is now sent to standard output 
 # logLevel set the main process log level
 # valid values: panic,fatal,error,warn,info,debug
 logLevel = "warn"

 ############################
 # DataBase Config
 ############################

[database]
 #type sets the sql backend , valid values sqlite3,mysql
 type = "sqlite3"
 # these parameters are only for mysql
 # host = 127.0.0.1:3306
 # user = "root"
 # password = ""
 # name sets the database name
 name = "snmpcollector"
 # sqllogfile sets the name for a file in the log/ directory where sql backend will write all SQL transactions
 # sqllogfile = "sql.log"
 # debug adds extra verbosity to the SQL log
 debug = false

############################
# Self Monitorig Config
############################
#config for sending self monitoring metrics to our default influx db
# Sent Measurements will be <prefix>selfmon_gvm with the following fields
# runtime_goroutines
# *mem.alloc
# *mem.mallocs
# *mem.frees
# *gc.total_pause_ns
# *memory.heap
# *gc.pause_per_second
# *gc.pause_per_interval
# *gc.gc_per_second
# *gc.gc_per_interval

[selfmon]
 #enable true/false enable/disable self monitoring
 enabled = true
 #send data Frequency
 freq = 60
 #prefix for measurement naming
 prefix = ""
 #adds extra tags to the measurement config should be set as a csv - tag=value1,tag2=value2,...,tagN=valN
 extratags = [ "instance=snmpcollector01" ]

############################
# Embedded WebServer Config
############################

[http]
 #port where webserver will listen waiting for connections
 port   = 8090
 #Admin credentials to access to the SnmpCollector agent
 adminuser = "adm1"
 adminpassword = "adm1pass"
 #When more than one instance you will need customize the cookie_id allowing navigate to all instances
 cookieid ="my_instance_cookie"

After that you will be able to start an snmpcollector agent instance with a zero configuration (without devices or metric definitions).

If you have any problems please open issue to the snmpcollector team

SNMP/Devices Configuration

1. WebUI access.

Open the url http://your_snmpcollector_agent_host:8090/

login

You will be prompted to insert valid credentials.

Once logged you will see the main Runtime view with a list of devices and it's state.

after_login

snmpcollector has not yet support for different users with customized Access control , right now It has only one administrative user that can be customized into the [database] config.toml section with full access to all devices, configurations, runtime , console

1- Adding Influxdb output databases

Fist you need is create a new Influxdb output database.

influx servers list

In the Influx servers list click on new.

Influx servers edit

These are the following parameters, that let you create an HTTP based Influxdb Connection

Config Parameter Description
id Text String that uniquely identify the influxdb connection
Host the hostname/IP to connect
Port the port to connect
DB the influxdb Database
User the user which you need to login to the influx db
Password a valid password
Retention Policy the database retention policy
Timeout
User Agent HTTP user agent sent to the database backend ( useful to debug input data from de backend view), if not set the agent will send as user agent snmpCollector-<InstanceID> (from the [general] config.toml section)
Description some useful description to administrators

Dummy Server

On first execution , there is not any database configured, and anyway you could add devices and restart agent. In this scenario a internal "dummy Server" is created to send data from all gathered devices, and finally this dummy server will discard them.

The "default" Server

SnmpCollector is able to send its own stats to a InfluxDB , It will look for a influx-server named "default" to use as output backend, if doesn't exist It will send over the Dummy Server.

(Pending define default and dummy influxservers)

2- Defining Metrics

At the metric config view

Metric Config Viewer

click on new and will appear the following form:

create metric

Config Parameter Description
id Text String that uniquely identify the metric recommended use the MIB Name, should be unique in the database
fieldName set the "field" name inside a Influx measurement, could be the same of id or not, should be unique inside the measurement where the metric will be sent.
isTag If true data will be sent as a Influxdb "TAG". (default is false)
baseOID Snmp OID for this metric ( could be the base OID when it belongs to a snmp indexed table), could not be set only if datasrctype is of type "String Eval".
DataSrcType Origin data type could be one of these:
  • (SNMP SMI Type) INTEGER
  • (SNMP SMI Type) Integer32
  • (SNMP SMI Type) Gauge32
  • (SNMP SMI Type) UInteger32
  • (SNMP SMI Type) Unsigned32
  • (SNMP SMI Type) Counter32
  • (SNMP SMI Type) Counter64
  • (SNMP SMI Type) TimeTicks
  • (SNMP SMI Type) OCTETSTRING
  • (SNMP SMI Type) IpAddress
  • (Cooked type) TIMETICKS [Compute TimeTicks to seconds]
  • (Cooked type) COUNTER32 [Compute increments]
  • (Cooked type) COUNTER64 [Compute increments]
  • (Cooked type) HWADDR [ Translate Hardware Address (MAC) from STRING]
  • (Cooked type) STRINGPARSER [ Compute values from Regex ]
  • (Cooked type) STRINGEVAL [evaluate data from other metrics]
ExtraData data needed to special data types as String Eval(evaluated expression needed) or String Parser(regex needed)
GetRate Only useful on counter types , if true value sent will be the computed difference and after divided by the number of elapsed seconds between snmp calls
Scale if set (as a floating point value) computed data will be scaled before sent.
Shift if set (as a floating point value) computed data will be shifted before sent.
Description any useful discretion to understand data gathered for this metric ( recommended place here units of the measurement).

The SnmpCollector Metric engine computes all its data and sent them as floating point values to the database, except for tags that will be sent as text strings

3- Defining Measurements

Measurements are the basic Influxdb structure let us group series of the same type/origin.

When data are gathered from SNMP devices we can group them together as we wish when snmp data are scalar objects but is mandatory group snmp tabular objects in the same measurement.

On the measurement view click new and you will see a form that you will use to create measurements.

Measurement edit

These are the main configuration parameters

Config Parameter Description
id Text String that uniquely identify the measurement recommended use the MIB Name prefixed/suffixed with some other string data we can easily identify (as manufacturer or model) that will help us to look in the Measurement config section, should be unique in the database
Name This will be the Measurement name created in the Database when sending data, will let us to query data with "SELECT * from ..."
GetMode
  • value: in this mode you will be able to group arbitrary scalar metrics.
  • (snmp Table) Direct Indexed Tag: in this mode you will be able to group tabular based data and the specified BaseIndex will give us the TAG name to identify any table row.
  • (snmp Table) Indirect Indexed Tag : in this mode you will be able to group tabular based data but we need get TAG name from other table so will need 2 different OID's de IndexOID and de TagOID ( from other table)
IndexOID (only required for SNMP Table based data) The OID will be queried to get row Tag Values of the table.
TagOID (only required for SNMP indirect Tag based data) the OID will be queried to get TAG value names from other table.
IndexTAG (only required for SNMP Table based data) the tag name will be sent to distinguish among different rows.
IndexAsValue (only required for SNMP Table based data) if true we will send TagValue direct from the numeric Index (useful with tables without string names -- Some IBM disk arrays has this kind of tables--)
Fields A list of metricID which will be part of this measurement and what to do with the value.

  • always send:in this mode the vale gathered for this Metric by the agent will be sent to the output db
  • never send:in this mode the value gathered for this metric will not be sent, it has sense when we need this value as a input parameter for computed metrics (metrics of type String-Eval)

    4- Defining Measurement Groups

    A Measurement Group is a collection of measurements, and its main goal is to act as a "Product" or "Device Model" Template. Once defined should be easy creating new devices and only adding this measurement group. You can add as many measurements as you wish.

    Config parameters are

    Config Parameter Description
    id Text String that uniquely identify the measurement group recommended use the Product/Device Name/model as , should be unique in the database
    Measurements A list of measurement id's
    Description A description text for the measurement group.

    5- Defining Measurement Filters

    Filters has only sense over indexed measurements (snmp tables), the goal of these filters are limit the amount of data sent to the backend, and it will be related to the data contained in the measurement, so it will be applied only to the selected measurement

    measurement filters list

    In the above list you could see a filter_port_if_status_up defined as a condition over and OID. Only indexes which will match the condition will be selected to send data to the database backend.

    Filter and Re-Indexing measurements are performed periodically and controlled by the "Update Filter" device parameter

    There is two filter types.

    Type OID Condition

    It will apply a logical condition over the result of a snmp query over an OID.

    OidCondition

    Type File

    It will apply filtering over the indexes of the measurement taken as values an input file

    FileCondigion

    File must a TXT file placed at the config directory with the following scheme.

    #this is a comment
    eth0
    #following interface has a name defined as an alias	
    eth2  backup_net
    sit0	

    _This filter mode is mainly maintained for compatibility with the influxsnmp tool, it is planned for 1.0 version to create a similar custom filtering from the webUI and stored over the database _

    These are all parameters.

    Config Parameter Description
    id Text String for each
    MeasurementID The measurement on which filter could be applied if selected in the device.
    Filter Type
    • OID Condition
    • File Condition
    File Name (Only apply on the File Filter type) the file name by example ("my_filer_file_for_device_xxxxx.txt")
    Enable Alias (Only apply on the File Filter type) after filtering it takes 2on column if defined as a TAG for the measurement better than the original name ( in the first column)
    OID condition (Only apply on the OID Condition Filter type) the OID will be used to get and evaluate data.
    Condition Type These are all possible conditions

    • neq: returns true if value is equal (number evaluation)
    • nlt:returns true if value is less than (number evaluation)
    • ngt:returns true if value is greather than (number evaluation)
    • nge:returns true if value is greater or equal than (number evaluation)
    • nle:returns true if value is less or equal (number evaluation)
    • match:returns true if value match (regex string evaluation)
    • nomatch:returns true if value not match (regex string evaluation)
    Condition Value the number or regex will apply to filter result from queried snmp OID's

    6- Defining Snmp Devices

    Over the list view click on New button

    snmp device list

    And a big form with a lot of option will appear.

    snmp device edit1 snmp device edit2

    These are the parameters

    Config Parameter Description
    id Text String that uniquely identify the device , should be unique in the config db, it can be hostname, serial number or any other text id
    host the network direction the agent will use to do snmp connection , could be IP or fqdn name
    port the network port where the agent will use to do snmp connections
    snmpversion could be any of these [1,2c,3]
    disable snmpbulk if true the bulk feature won't be used ( these feature is needed to query IBM XIV disk arrays, which has a snmpv2/v3 agent with a buggy bulk support)
    community the snmp version 2 community
    v3seclevel (only for snmpv3) define the level of security needed for the connection valid values are.

    • NoAuthNoPriv
    • AuthNoPriv
    • AuthPriv
    v3authuser (snmpv3 only) the username that will establish the snmp query
    v3authpass (snmpv3 only) the authentication password
    v3authprot (snmpv3 only) the Authentication Protocol values should be any of "MD5", "SHA"
    v3privpass (snmpv3 only) Privacy password
    v3privprot (snmpv3 only) Privacy Protocol values should be any of [ "DES", "AES"]
    freq Frequency of polling in seconds ( default 30 sec if not set)
    FilterUpdate Number pof complete polls that agent will wait before perform snmp table index/filter updates , the final update time will be Freq*FilterUpdate ( in seconds) Default 1h
    DeviceTagName Tag name the agent will send to the output db (default : "device"), could be any of the other more explicit tagname depending on the device type, context , by example (router,switch,firewall,dns..etc)
    DeviceTagValue could be one of these:
    • id: will send as device tag the configured ID for this measurement
    • Hostwill send as device tag data configured in the Host configuration (name or IP).
    ExtraTags an array of tags for this device that will be sent on all its measurements.
    Measurement Groups an array of Measurement Group ID.
    Filters an array for configured filters

    Runtime Options

    Snmpcollector has an embedded online device state and data measurement viewer, which help us to monitor how data has been gathered for each device. On the device list you will see if device is active devactive or have been stoped devnotactive by the administrator. You can also see if there is any connectivity problems notconnected

    Device List

    On the eye icon you will see both state and number of measurements/metrics configured on that device

    Device Basic Stats

    system description

    Host Info

    measurement online data

    Meas Online data

    Meas Detailed Info