Skip to content
Toni Moreno edited this page Nov 2, 2021 · 40 revisions

Intro to SnmpCollector

What is SnmpCollector

SnmpCollector is an Open Source tool and is full featured Generic SNMP data collector with Web Administration Interface which has as main goal simplify the configuration for getting data from any device which 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
  • SNMPv3 Supported Protocols
    • Authentication protocols: MD5,SHA and from (release >0.10) SHA224SHA256,SHA384,SHA512
    • Privacy Protocols: DES,AES and from (release >0.10) AES192,AES192C,AES256,AES256C
  • Support for gather any SNMP (SMI) data type.
  • Online SNMP maxrepetions changes.
  • Support for cooked counters (online derivative computed on the fly), and/or rate conversion
  • Support for cooked STRINGS to get any sub-string as integer
  • Support for Strings PARSER to get multiple tags and fields from one result.
  • Support for query data not only from result also from OID (IP's/MAC's/STRINGS) on snmp tables.
  • Support for cooked Process data (Online Math expressions computed on the fly) from previously gathered data (these are the supported expressions )
  • Gather of SNMP Scalar an Table values.
  • Support for multi-table merging (capable to query Cisco QoS)
  • Support for filtering table rows, based on snmp data conditions (OIDConditions)
  • Support for multiple conditions (combined in evaluated expressions)
  • Support for table row filtering,based on fixed rules (fileConditions)
  • Support for custom filters from any table (online selectable via webUI)
  • Support for Override column aliases with custom labels
  • Send self monitoring stats to any influxdb
  • Support for Influxdb 1.X
  • Support for SQLite/MySQL/PostgreSQL as config backends.
  • Metric OID Condition Counter (to send only counted results of OID conditions)
  • Self Detection for connection problems and reconnect.
  • Enables multiple gathering periods for diferent metrics in the same device ( > 0.12.0 release)

WebUI Features

  • Complete configuration Interface for all objects
  • Snmp web console as snmpget/snmpwalk replacement
  • Automatic snmp connectivity check
  • Online Runtime data viewer for all gathered metrics.
  • Online Configuration reload
  • Online device activation/deactivation , and log level changing
  • REST API support
  • Support for Import and Export configurations.
  • Online internal statistics (GVM, device stats, output metrics and outgoing buffer stats)
  • Supports for adding, modifying and deleting new devices online based on existing configurations ( avoids restart the gathering process on the other devices) (> 0.8)

Installation and Setup

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

Debian RedHat Docker
deb - signature rpm - signature docker run -d --name=snmpcol_instance00 -p 80:8090 -v /mylocal/conf:/opt/snmpcollector/conf -v /mylocal/log:/opt/snmpcollector/log tonimoreno/snmpcollector

Also downloadable rpm/deb/binary packages on the releases site

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

Note: Environment variables SNMPCOL_XXXX for configuration parameters mapping are only available in 0.8.1+

Note: upgrading docker from version < 0.8.1 to 0.8.1+ needs for UID/GID=472 ownership change for all persistent files/volumes otherwise you will see this message error "attempt to write a readonly database". refer to this issue #447

############################
# 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.
 # could be set also with SNMPCOL_GENERAL_INSTANCE_ID env var
 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
 # could be set also with SNMPCOL_GENERAL_DATA_DIR env var, default $CWD
 # datadir = "/var/lib/snmpcollector"

 # homedir set the directory where the public web dir will be placed
 # if not set the default homedir will be placed in the current directory
 # could be set also with SNMPCOL_GENERAL_HOME_DIR env var, default $CWD
 # homedir = "/var/lib/snmpcollector"

 # there are as many logs as devices configured
 # logdir set the Directory path for each device individual log
 # could be set also with SNMPCOL_GENERAL_LOG_DIR env var, default $CWD
 # logdir = "/var/log/somelogpath"

 # logLevel set the main process log level
 # valid values: panic,fatal,error,warn,info,debug
 # could also be set with SNMPCOL_GENERAL_LOG_LEVEL env var, default info if not set
 loglevel = "info"

 # Log mode  could be "file/console" if console have been selected
 # the content for the main snmpcollector.log and http_access.log will 
 # be writen in stdout 
 # could be set also with  SNMPCOL_GENERAL_LOG_MODE env var
 log_mode = "file"

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

[database]
# type sets the sql backend
# valid values sqlite3,mysql,postgres
# could be set also with SNMPCOL_DATABASE_DRIVER_TYPE default sqlite3
 type = "sqlite3"

# host the host:port where doing DB connection (apply only to mysql/postgresql)
# could be set also with SNMPCOL_DATABASE_SERVER_HOST env var default localhost
# host = 127.0.0.1:3306

# user  Username to connect into DB (apply only to mysql/postgresql)
# could be set also with SNMPCOL_DATABASE_USERNAME env var
# user = "snmpcoluser"

# password Password to connect into DB (apply only to mysql/postgresql)
# could also be set with SNMPCOL_DATABASE_PASSWORD env var
# password = "snmpcolpass"

# name sets the database name
# could also be set with SNMPCOL_DATABASE_NAME  env var
 name = "snmpcollector"

# ssl_mode set ssl in database connection
# For "postgres", use either "disable", "require" or "verify-full"
# For "mysql", use either "true", "false", or "skip-verify".
# could also be set with SNMPCOL_DATABASE_SSL_MODE env var
# ssl_mode = disable

# client_cert_path path for client cert 
# could also be set with  SNMPCOL_DATABASE_CLIENT_CERT_PATH env var
# client_cert_path = /my/path/cert.pem

# client_key_path path for client cert key
# could also be set with  SNMPCOL_DATABASE_CLIENT_KEY_PATH env var
# client_key_path = /my/path/cert.key

# ca_cert_path path path for client cert key
# could also be set with  SNMPCOL_DATABASE_CA_CERT_PATH env var
# ca_cert_path= /my/path/ca.pem

# Log mode  could be "none/file/console" 
# if console have been selected all the SQL queries  will be writen into stdout 
# if file queries will be written in the logdir with name "sqllogfile" parameter if set or "sql.log" if not set 
# could be set also with  SNMPCOL_DATABASE_LOG_MODE env var
log_mode = "none"

# sqllogfile sets the name for a file in the log/ directory where sql backend will write all SQL transactions
# could also be set with SNMPCOL_DATABASE_SQL_LOG_FILE env var 
# sqllogfile = "mysql.log"

# debug adds extra verbosity to the SQL log
# could also be set with SNMPCOL_DATABASE_SQL_DEBUG env var
 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
 # could also be set with SNMPCOL_SELFMON_ENABLED env var
 enabled = true

 # send data Frequency
 # could also be set with SNMPCOL_SELFMON_FREQ env var
 freq = 60

 # prefix for measurement naming
 # could also be set with SNMPCOL_SELFMON_PREFIX env var
 prefix = ""
 
 # inherit device tags
 # could also be set with SNMPCOL_SELFMON_INHERIT_DEVICE_TAGS env var
 inheritdevicetags = true

 # adds extra tags to the measurement config should be set as a csv - tag=value1,tag2=value2,...,tagN=valN
 # could also be set with SNMPCOL_SELFMON_EXTRATAGS env va
 extratags = [ "instance=snmpcollector01" ]

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

[http]
 # listen where webserver will listen waiting for connections
 # could also be set with SNMPCOL_HTTP_LISTEN  env var
 listen   = ":8090"
 # NOTE: port = 8090 still usable option but DEPRECATED!!
 
 # Protocol could be set as https or https 
 # could also be set with SNMPCOL_HTTP_PROTOCOL  env var
 protocol = "http"

 # Cert key  Path to the certificate file (if protocol is set to https)
 # could also be set with SNMPCOL_HTTP_CERT_FILE  env var
 cert_file = "/path/to/certificate.pem"
 
 # Cert key  Path to the certificate key file (if protocol is set to https)
 # could also be set with SNMPCOL_HTTP_CERT_KEY  env var
 cert_key = "/path/to/certificate.key"

 # Admin user to log in the UI
 # could also be set with SNMPCOL_HTTP_ADMIN_USER  env var
 adminuser = "adm1"

 # Admin password to log in the UI
 # could also be set with SNMPCOL_HTTP_ADMIN_PASSWORD  env var
 adminpassword = "adm1pass"

 # When more than one instance you will need customize the cookie_id allowing navigate to all instances
 # could also be set with SNMPCOL_HTTP_COOKIE_ID  env var
 cookieid ="my_instance_cookie"

After that and if you are using sqlite3 config backend you will be able to start an snmpcollector agent instance with a zero configuration (without devices or metric definitions). It you prefer MySQL you must setup the database first

MySQL Initial Setup

After mysql install you will have to create the database and configure user credentials over it you could use the following sql.

create database snmpcollector;
GRANT USAGE ON `snmpcollector`.* to 'snmpcoluser'@'localhost' identified by 'snmpcolpass';
GRANT ALL PRIVILEGES ON `snmpcollector`.* to 'snmpcoluser'@'localhost' with grant option;
flush privileges;

PostgreSQL Initial Setup

After postgresql install you will have to create the database and configure user credentials over it you could use the following sql.

sudo -u postgres psql
postgres=# create database snmpcollector;
postgres=# create user snmpcoluser with encrypted password 'snmpcolpass';
postgres=# grant all privileges on database snmpcollector to snmpcoluser;

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

WebUI Navigation Features

WebUI access.

Login

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

Available components

Component Description
Variable Catalog Add/edit/view Variables to use on STRINGEVAL metric type
Influx Servers Add/edit/view InfluxDB servers to store data
OID Conditions Add/edit/view OID queries with some conditions to be applied on Metrics and Filters
SNMP Metrics Add/edit/view Metrics you want to collect
Measurements Add/edit/view Measurements with selected defined Metrics
Measurement Groups Add/edit/view groups of Measurements to create easy configuration templates
Measurement Filters Add/edit/view Filters to be applied on Measurements and attached to the Device
Custom Filters Add/edit/view filters based on a results query
SNMP Devices Add/edit/view desired Devices to collect data from

View

All components are listed with a table. The list view allows the user to add/modify/view/remove items stored on database.

  • Edit Button Edit Item: enters on modify view allowing to modify components parameters
  • Export Button Export Item: Allows the user export selected item.
  • View Button View Item: Allows the user to see all parameters of selected item
  • New Button New Item: Allows the user enter into parameters form to create a new component
  • Filter Input Filter: Allows the user filter all columns. Note: it accepts regex expressions
  • Remove Item Remove Item: Allows the user to remove selected item. When it is clicked it will show to the user elements that would be affected if the item is removed.
  • Enable Edit Enable Edit: Allows the user to select different items and remove or change properties of them.
  • Items per page Items per page: select the maximum items shown at same page

Runtime component

Component Description
Runtime View what the agent is collecting and change options on runtime

Data Management component

Component Description
Import Allows the user import data from file
Export Allows the user export data from different components