spread the knowledge
Installation MRTG & vnStat
Analog zur FreeBSD Installation, hier die Anleitung unter Ubuntu.
Installation MRTG
sudo apt-get install mrtg
┌───────────────────────────┤ Configuring mrtg ├────────────────────────────┐
│ If your MRTG configuration file is readable by users other than the user │
│ MRTG runs as ('root' by default) it can present a security risk, as this │
│ file contains SNMP community names. │
│ │
│ It is recommended that you make the file owned by and readable only by │
│ 'root', unless you have specific reasons not to (for example, because │
│ third-party tools need to read that file, like 'mrtg-rrd'). │
│ │
│ Make /etc/mrtg.cfg owned by and readable only by root? │
│ │
│ <Yes> <No> │
└───────────────────────────────────────────────────────────────────────────┘
Hier mit JA bestätigen und weiter
Konfiguration
Nachdem die Installation abgeschlossen ist, das Configfile finden. Je nach Serverumgebung kann es sich an unterschiedlichen Orten befinden.
sudo updatedb && locate mrtg
Bei meiner Installation befindet sich das Sample Configfile hier:
/etc/mrtg.cfg
Man kann das mrtg.cfg File nun nach seinen Wünschen anpassen. Bei mir gibt’s hier eine kleine Abweichung – da ich mein Configfile auf eine Globale Disk schreibe, nutze ich nicht die default Location.
Die Config ist analog zur FreeBSD Installation.
Installation vnStat
sudo apt-get install vnstat
sudo apt-get install vnstati
Anmerkung: vnstati generiert Grafiken
Konfigurieren
Mit ifconfig das gewünschte Interface finden
ifconfig
ens3 Link encap:Ethernet HWaddr 22:3b:a1:1c:56:1a
inet addr:111.11.1.199 Bcast:111.11.1.255 Mask:255.255.255.0
inet6 addr: fe80::203b:a1ff:fe1c:561a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:56861181 errors:0 dropped:1 overruns:0 frame:0
TX packets:371381 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4984547730 (4.9 GB) TX bytes:66279900 (66.2 MB)
ens4 Link encap:Ethernet HWaddr 22:37:1b:08:cd:f3
inet addr:10.0.0.5 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::2037:1bff:fe08:cdf3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:60301 errors:0 dropped:17372 overruns:0 frame:0
TX packets:90976 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7864070 (7.8 MB) TX bytes:14651881 (14.6 MB)
Ich möchte ens3 monitoren. Das Interface jetzt im Configfile eintragen.
sudo vi /etc/vnstat.conf
# default interface
Interface "ens3"
Nun kann vnstat aufgerufen werden:
vnstat -u -i ens3
Diesen Befehl in den Cronjob rein, damit regelmässig Daten gesammelt werden.
vnstati
Nun kann man die gesammelten Daten ganz einfach als Grafiken ausgeben mit vnstati.
Ein Aufruf könnte z.B. so aussehen:
vnstati -s -i ens3 -o /global/monitoring/mrtg/patsy/traffic/summary.png
Eine Liste diverser Optionen (nicht vollständig – nutze man vnstati für die komplette Liste)
-d, --days
Output traffic statistics on a daily basis for the last 30 days.
-h, --hours
Output traffic statistics on a hourly basis for the last 24
hours.
-hs, --hsummary
Output traffic summary including hourly data using a horizontal
layout.
-m, --months
Output traffic statistics on a monthly basis for the last 12
months.
-s, --summary
Output traffic statistics summary.
-t, --top10
Output all time top 10 traffic days.
-vs, --vsummary
Output traffic summary including hourly data using a vertical
layout.
Weitere Infos und Details zu vnstat gibts im FreeBSD Tutorial
.