- Notifications
You must be signed in to change notification settings - Fork17
🐳 Docker MRTG Instance that will configure monitoring from the environment variable.
License
fboaventura/dckr-mrtg
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Docker instance to runMRTG - The Multi Router Traffic Grapher.
This image is built for all the architectures supported by Alpine image. Although not all of them were tested and validated to be working.
Architecture | Validated? |
---|---|
amd64 | Yes |
arm64v8 | Yes |
arm32v6 | No |
arm32v7 | No |
i386 | No |
ppc64le | No |
s390x | No |
riscv64 | No |
- fboaventura/dckr-mrtg
Until version2.2.0
, I usedNGINX, and all the HTML files were statically built byMRTG.
From2.3.0
onwards, I've implemented the support forrrdtool andreplaced NGINX withLIGHTTPD, since I needed the support to run CGI scripts.
From version2.3.0
theWEBDIR
went from/usr/share/nginx/html
to/mrtg/html
.So please, check all your configuration files if you are getting some path-related error on the graphics.
It's also possible to pass the environment variableWEBDIR
on thedocker-compose.yml
or command line (-e
).
Starting on version2.5.5
the development will be made using branches. Themaster
will be the stable version, and the development will be made on the versioned branches. The auto-build will create images with-dev
suffix and puredev
, instead oflatest
, for the development branches and these images will be deleted as soon as new stable release is made.
MRTG uses SNMP to monitor the devices. The SNMP protocol look up for an OID (Object Identifier) in the device and return the value of that OID.
OID is the Object Identifier. It is a unique identifier for a piece of data in the MIB. The OID is a sequence of numbers separated by periods. For example, the OID for the device's name is.1.3.6.1.2.1.1.5
.
To make life easier, SNMP can use a MIB (Management Information Base) file. The MIB file is a text file that describes the data that can be retrieved from a device. For example, usingSNMPv2-MIB
file we can reach the device's name usingsysName.0
instead of the OID.
Some vendors provide the MIB files for their devices. If you have the MIB file, you can use it to translate the OID to a human-readable name.
This container adds thenet-snmp-libs
packages that containsthese MIB files. You can add your custom MIB files to the/mrtg/mibs
folder. And you may find some useful MIB files atOIDView, in theobservium repository or, in some cases, at the vendor' support site.
This instance is published atDocker Hub, and allyou need to run is:
$ docker run -d -p 8880:80 -e"HOSTS='public:localhost:2,community:ipaddress'" fboaventura/dckr-mrtg:latest
You can, of course, pass some custom values to make it more prone to your usage. The variables andtheir defaults are:
ENV CFGMAKEROPTIONS=""ENV ENABLE_V6="no"ENV GRAPHOPTIONS="growright, bits"ENV GROUPID="101"ENV HOSTS"community:host[:version[:port]]"ENV INDEXMAKEROPTIONS=""ENV MIBSDIR="/mrtg/mibs"ENV MRTG_COLUMNS=2ENV PATHPREFIX=""ENV REGENERATEHTML="yes"ENV TZ="UTC"ENV USERID="100"ENV WEBDIR="/mrtg/html"
The variableCFGMAKEROPTIONS
(default: empty string) allows you to add any extra options passed tocfgmaker
, e.g.--zero-speed=1000000000 --show-op-down
. The options can be found in themanpage forcfgmaker
.
The variableENABLE_V6
(default: "no") will enable IPv6 support in the container. If you need to monitor IPv6 devices, set this to "yes".
The variableGRAPHOPTIONS
(default: "growright, bits") will configure the graphs generated by MRTG. The default is to grow the graph from left to right and show the values in bits. You can change this to your needs and the available options can be foundhere.
The variableGROUPID
(default: 101) defines the groupid for the lighttpd user.Normally this value should be set to the same value asUSERID
, but other values can be used depending on your needs.
The variableHOSTS
is where you may set the hosts that MRTG will monitor. The format to be usediscommunity:host[:version[:port]],community:host[:version:[port]],...
Where:
- community: is the SNMP community with read access
- host: is the IP address or hostname (if Docker can resolve it)
- version: can be
1
or2
for SNMP1 or2c. If left empty it will assume2c. - port: can be any custom port. There is one point of attention, if the port is needed, then the version must be set.
The variableINDEXMAKEROPTIONS
(default: empty string) allows you to add any extra options passed toindexmaker
, e.g.--nolegend
. The options can be found in themanpage forindexmaker
.
The variableMIBSDIR
(default: "/mrtg/mibs") is the path where the custom MIB files can be stored. If you have custom MIB files, you can mount a volume to this path to make them available to MRTG. Take into consideration that all files in this directory will be loaded by MRTG.
The variableMRTG_COLUMNS
(default: 2) defines the number of columns in the index.html file. This is useful if you have a large number of hosts and want to display them in multiple columns.
The variablePATHPREFIX
(default: empty string) is the path passed toindexmaker
to prefix URLs torrdviewer
orany images.The format mustNOT include a trailing slash. For example, "/mrtg"Used with a reverse proxy, this allows mrtg to exist at a subpath rather than the root.
The variableWEBDIR
(default: "/mrtg/html") is the path where the HTML files are stored. This is the path where the index.html file is generated and where the RRD files are stored. If you need to change this path, you can set this variable to the desired path.
The variableTZ
will configure the timezone used by the OS and MRTG to show dates and times.
The variableUSERID
(default: 100) defines the userid for the lighttpd user. The files in the html directory will be owned by this user.Normally this value should be set to 1000 (or above), depending on your needs for mapped volumes.
The variableREGENERATEHTML
(default: "yes") determines if the index.html file will be regenerated at container restart. The original index.html will be renamed index.old (overwriting any earlier file with that name).You should set this value to anything other than "yes" if you have any custom changes to index.html that you do not want overwritten at container restart.
The container will create and use the following directories to store the data and configuration:
/etc/mrtg/conf.d
: where the generated and custom configuration files are stored/mrtg/html
: where the HTML and RRD files are stored/mrtg/mibs
: where the custom MIB files can be stored/mrtg/fonts
: where custom fonts can be stored
If you plan on keeping this instance running as your MRTG service, you may pass volumesto be used to save the information produced by MRTG. To achieve this:
$ mkdir html conf.d$ docker run -d -p 8880:80 -e"HOSTS='public:localhost,community:ipaddress'" -v`pwd`/html:/mrtg/html -v`pwd`/conf.d:/etc/mrtg/conf.d fboaventura/dckr-mrtg:latest
---services:mrtg:image:fboaventura/dckr-mrtg:latesthostname:mrtgrestart:alwaysports: -"8880:80"volumes: -"./conf.d:/etc/mrtg/conf.d" -"./html:/mrtg/html" -"/etc/localtime:/etc/localtime:ro" -"/etc/timezone:/etc/timezone:ro"environment:TZ:"Brazil/East"HOSTS:"public:192.168.0.123"WEBDIR:"/mrtg/html"USERID:1000GROUPID:1000REGENERATEHTML:"yes"INDEXMAKEROPTIONS:""CFGMAKEROPTIONS:"--zero-speed=1000000000"MRTG_COLUMNS:2tmpfs: -"/run"
Once the instance is running, all you have to do is open a web browser and point it tohttp://localhost:8880
orhttp://<server_ip>:8880
and you will see the MRTG index page.
- Updated packages versions
- Fixed
indexmaker
andcfgmaker
options (Fixes #25) - Added support fordevcontainers
- Added
provenance
andSBOM
attestations to the builds
- Added versioned
dev
branches for development - Added the
net-snmp-libs
package to include the MIB files - Added the
MIBSDIR
environment variable to set the path to the MIB files - Added a Table of Contents to the
README.md
file - Added more platforms to the build matrix
- Updated the
14all.cgi
script to match latest Perl coding standards - Updated the
README.md
file to include information about MIBs and fix typos (Thanks @mlazarov) - Fixed some of the warnings in the
14all.cgi
script (#21 and #23) - Fixed the
lighttpd
configuration to remove deprecated options
- Updated packages versions
- Updated the
14all.cgi
script, added option to export the data in CSV format - Added the
MRTG_COLUMNS
environment variable to set the number of columns in the index.html file
- Force font cache clean-up to avoid fontconfig errors
- Fix security concerts in Dockerfile
- Fixed errors with lighttpd configuration
- Added fixed versions to packages
- Added command to update alpine packages
- Updated Alpine version to reduce vulnerabilities
- Fix missing icon images when using PathPrefix (@michaelkrieger)
- Fixed the auto-build to publish multi-arch versions and documentation
- Added volume information to README.md
- Added the ability to set
USERID
andGROUPID
for volume mapping scenarios (@TweakM) - Added the option to not regenerate the index.html file, applicable when custom/manual changes to this file have been made (@TweakM)
- Added the ability to specify additional options for
indexmaker
(allowing more customizations) (@TweakM) - Updated documentation
- Fixed typo's
- Enabled multi-arch building and images atDocker Hub
- Released the Docker
latest
tag to follow the releases - Bumped Alpine version
- Added
/etc/localtime
to docker example (@michaelkrieger) - Added the option to allow use ofPath Prefix (@michaelkrieger)
- Updated Alpine version
- Fixed README.md example settings for HTML folder (#4)
- Fixed the lighttpd daemon flag
- Added support for a custom port
- Updated Alpine version
- Added support for SNMP version
- Added support for
rrdtool
- ReplacedNGINX byLIGHTTPD
- Changed the HTML folder from
/usr/share/nginx/html
to/mrtg/html
- Fixed
latest
tag tov2.2.0
to prevent compatibility breaking - Changed the versioning schema to support only tagged versions
- Updated Alpine version
- Updated
docker-compose.yml
to version3.5
- Fixed the fallback for the empty
HOST
- Updated Alpine and MRTG Versions
- Updated Alpine version
- Updated Alpine version
- 2018.10 - Updated MRTG and Alpine versions
- First version
About
🐳 Docker MRTG Instance that will configure monitoring from the environment variable.