--- title: "MRTG - fun with 20th century monitoring solution" menu: main: parent: Monitoring --- > I'm totaly aware there are more modern monitoring solutions (prometheus, icinga2, prtg and other hipster stuff) out there. Despite this, I still like MRTG's minimalist approach. ![MRTG](/image/mrtg/mrtg.png#center) ## (my) setup In my configuration MRTG is solely used for *collecting metrics* from various sources. MRTG is very flexible where these metrics come from (snmp, curl, scripts ...). My current configuration can be found at https://git.br0tkasten.de/br0tkasten/mrtg ### backend #### installation In [Alpine](https://www.alpinelinux.org), mrtg can be installed with `apk add mrtg`. #### configuration Details on mrtg's config can be found in the [projects online documentation](https://oss.oetiker.ch/mrtg). You will find my configs in [my git project](https://git.br0tkasten.de/br0tkasten/mrtg/src/branch/master/config). **Example:** ``` LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt WorkDir: /var/www/mrtg/rrd LogFormat: rrdtool Target[br0tkasten.eth0]: #eth0:oom6faayaTosh0nizoepoonahCohhahy@10.3.0.1: Title[br0tkasten.eth0]: [br0tkasten] eth0 MaxBytes[br0tkasten.eth0]: 4294967295 ``` ### frontend #### cgi-bin/graph.pl A perl script is generating graphs from rrd using templates for each metric. ``` br0tkasten.eth0 Traffic Graph ``` ##### Parameter - graph: name of the metric, the script will look for a template with the same name in tmpl/*.tmpl - width & height: dimensions of the returned image in pixel ![cgi-bin/graph.pl](/image/mrtg/graph.png) ##### Templates For each metric to be displayed you will have to create a template in tmpl/*metric*.tmpl. Templates use rrdgraph syntax. More details can be found at [the projects online documentation](https://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html) **Example: tmpl/br0tkasten.eth0.tmpl** ``` -v in/up bps -t [br0tkasten] eth0 --full-size-mode --color=BACK#343637 --color=CANVAS#F0F0F0 --color=FONT#F0F0F0 --font=TITLE:12:DejaVu Bold DEF:d=/var/www/mrtg/rrd/br0tkasten.eth0.rrd:ds0:AVERAGE DEF:u=/var/www/mrtg/rrd/br0tkasten.eth0.rrd:ds1:AVERAGE CDEF:down=d,8,* CDEF:up=u,-8,* AREA:down#CC9A5780:Down AREA:up#2EA34960:Up LINE1:down#CC9A57 LINE1:up#2EA349 LINE1:0#000000 ``` #### cgi-bin/details.pl Renders tmpl/details.tmpl to display a html page with a bigger version of the graph. Using [rrdGraphJs](https://github.com/oetiker/RrdGraphJS) you can interactively zoom and scroll in your graph. ![cgi-bin/details.pl](/image/mrtg/details.png) #### html Graphs are embedded in static (and some dynamically generated) html pages. I like to keep things simple - so most content is static. Examples can be found in [htdocs](https://git.br0tkasten.de/br0tkasten/mrtg/src/branch/master/htdocs/index.html). ```
[br0tkasten.de] eth0
br0tkasten.eth0 Traffic Graph
```