cleanup & mrtg article

This commit is contained in:
Arne Baeumler 2022-01-15 21:41:04 +01:00
parent ec02097300
commit 88c4ff8877
13 changed files with 105 additions and 3 deletions

0
.hugo_build.lock Normal file
View File

View File

@ -6,11 +6,17 @@ publishdir = "/var/www/localhost/htdocs"
[menu]
[[menu.main]]
identifier = "knowledge"
name = "Knowledge"
url = "/knowledge/"
identifier = "posts"
name = "Posts"
url = "/post/"
title = ""
weight = 1
[[menu.main]]
identifier = "tags"
name = "Tags"
url = "/tags/"
title = ""
weight = 2
[params]
version = "0.2.X"

96
content/post/mrtg/mrtg.md Normal file
View File

@ -0,0 +1,96 @@
---
title: "MRTG - fun with 20th century monitoring solution"
date: 2022-01-15T14:43:04+01:00
draft: false
tags:
- monitoring
- mrtg
---
> 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.
```
<img alt="br0tkasten.eth0 Traffic Graph" src="/cgi-bin/graph.pl?width=680&height=200&graph=br0tkasten.eth0">
```
##### 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).
```
<div>
<b>[br0tkasten.de] eth0</b><br/>
<a href="/cgi-bin/details.pl?graph=br0tkasten.eth0">
<img alt="br0tkasten.eth0 Traffic Graph" src="/cgi-bin/graph.pl?width=680&height=200&graph=br0tkasten.eth0">
</a>
</div>
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

BIN
static/image/mrtg/graph.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
static/image/mrtg/mrtg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB