Let's say you want to install MRTG to Archlinux...
First things first, you need Apache, PHP, PHP-GD, GD library on itself.
sudo pacman -S gd autoconf apache php-gd perl
Install development version of GD:
pikaur -S gd-git
(instead of pikaur you can use yay or any other AUR helper)
Then enable mod_fcgi in Apache: https://wiki.archlinux.org/title/Apache_HTTP_Server/mod_fcgid
I will not include this in the manual as this is covered by ArchWiki and a lot of articles
After that, you can either follow steps here: https://wiki.archlinux.org/title/Multi_Router_Traffic_Grapher or here:
Add mrtg user:
sudo useradd -d /srv/http/mrtg mrtg
Create directories with proper permissions:
sudo mkdir /srv/http/mrtg/ && sudo chown mrtg:mrtg /srv/http/mrtg
Edit httpd apache conf:
sudo nano /etc/httpd/conf/httpd.conf
Paste the following in the end:
Alias /mrtg /srv/http/mrtg/html/
<Directory "/srv/http/mrtg/html/">
AllowOverride None
Options None
DirectoryIndex index.html
Order allow,deny
Allow from all
</Directory>
Restart Apache:
apachectl restart
Create HTTP dir:
sudo mkdir /srv/http/mrtg/html
Write SNMP config:
sudo cfgmaker --output=/srv/http/mrtg/mrtg.cfg --ifref=name --ifref=descr --global "WorkDir: /srv/http/mrtg" public@localhost
Edit MRTG config file:
sudo nano /srv/http/mrtg/mrtg.cfg
Insert the following:
# Created by
# /usr/bin/cfgmaker --output=/srv/http/mrtg/mrtg.cfg --ifref=name --ifref=descr --global "WorkDir: /srv/http/mrtg" public@localhost
### Global Config Options
### Global configuration ###
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
EnableIPv6: no
HtmlDir: /srv/http/mrtg/html
ImageDir: /srv/http/mrtg/html
LogDir: /srv/http/mrtg
ThreshDir: /srv/http/mrtg
RunAsDaemon: Yes
Interval: 5
Refresh: 600
# for UNIX
# WorkDir: /home/http/mrtg
# or for NT
# WorkDir: c:\mrtgdata
### Global Defaults
# to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits
EnableIPv6: no
WorkDir: /srv/http/mrtg
######################################################################
# System:
# Description:
# Contact:
# Location:
######################################################################
Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:[email protected] + ssCpuRawSystem.0&ssCpuRawSystem.0:[email protected] + ssCpuRawNice.0&ssCpuRawNice.0:[email protected]
RouterUptime[localhost.cpu]: [email protected]
MaxBytes[localhost.cpu]: 100
Title[localhost.cpu]: <H1>CPU Load</H1>
PageTop[localhost.cpu]: <h1>Active CPU Load %</h1>
Unscaled[localhost.cpu]: ymwd
ShortLegend[localhost.cpu]: %
YLegend[localhost.cpu]: CPU Utilization
Legend1[localhost.cpu]: Active CPU in % (Load)
Legend2[localhost.cpu]:
Legend3[localhost.cpu]:
Legend4[localhost.cpu]:
LegendI[localhost.cpu]: Active
LegendO[localhost.cpu]:
Options[localhost.cpu]: growright,nopercent
# get memory Usage
Target[localhost.memtotal]: ( .1.3.6.1.4.1.2021.4.5.0&.1.3.6.1.4.1.2021.4.5.0:public@localhost ) - ( .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.6.0:public@localhost )
PageTop[localhost.memtotal]: <h1> Memory Usage </h1>
Options[localhost.memtotal]: nopercent,growright,gauge
Title[localhost.memtotal]: Memory Usage
MaxBytes[localhost.memtotal]: 100000000
kMG[localhost.memtotal]: k,M,G,T,P,X
YLegend[localhost.memtotal]: bytes
ShortLegend[localhost.memtotal]: bytes
LegendI[localhost.memtotal]: Memory Usage:
LegendO[localhost.memtotal]:
Legend1[localhost.memtotal]: Memory Usage, not including swap, in bytes
Colours[localhost.memtotal]: Blue#1000ff, Black#000000, Gray#CCCCCC, Yellow#FFFF00
# get swap memory
Target[localhost.swap]:( .1.3.6.1.4.1.2021.4.3.0&.1.3.6.1.4.1.2021.4.3.0:public@localhost ) - ( .1.3.6.1.4.1.2021.4.4.0&.1.3.6.1.4.1.2021.4.4.0:public@localhost)
PageTop[localhost.swap]: <h1> Swap Usage </h1>
Options[localhost.swap]: nopercent,growright,gauge,noinfo
Title[localhost.swap]: Swap Usage
MaxBytes[localhost.swap]: 100000000
kMG[localhost.swap]: k,M,G,T,P,X
YLegend[localhost.swap]: bytes
ShortLegend[localhost.swap]: bytes
LegendI[localhost.swap]: Swap Usage:
LegendO[localhost.swap]:
Legend1[localhost.swap]: Swap memory avail, in bytes
Colours[localhost.swap]: Blue#1000ff,Violet#ff00ff,Black#000000, Gray#CCCCCC
# get number of processes running
Target[localhost.procs]: `/usr/local/mrtg/linux_porc.pl`
Title[localhost.procs]: Process Statistics
PageTop[localhost.procs]: <h1> Process Statistics </h1>
MaxBytes[localhost.procs]: 10000
YLegend[localhost.procs]: Processes
LegendI[localhost.procs]: Blocked Processes:
LegendO[localhost.procs]: Run Queue:
Legend1[localhost.procs]: Number of Blocked Processes
Legend2[localhost.procs]: Number of Processes in Run Queue
Legend3[localhost.procs]: Maximal Blocked Processes
Legend4[localhost.procs]: Maximal Processes in Run Queue
Options[localhost.procs]: growright, integer, nopercent, gauge
# get number of established connections
Target[localhost.estconn]: `/usr/local/mrtg/linux_estconn.pl`
Title[localhost.estconn]: Established connections
PageTop[localhost.estconn]: <h1> Established connections </h1>
MaxBytes[localhost.estconn]: 100000
YLegend[localhost.estconn]: Established connections
LegendI[localhost.estconn]: Established connections:
LegendO[localhost.estconn]: Number of Established connections:
Options[localhost.estconn]: growright, integer, nopercent, gauge
Colours[localhost.estconn]: Red#FF0000,Blue#0066CC,Black#000000, White#FFFFFF
# get number of current users
Target[localhost.users]: `/usr/local/mrtg/linux_users.pl`
Title[localhost.users]: logged in users
PageTop[localhost.users]: <h1> number of users </h1>
MaxBytes[localhost.users]: 100000
YLegend[localhost.users]: users count
#Legend0[localhost.users]: logged in users count
Options[localhost.users]: growright, integer, nopercent, gauge
Colours[localhost.users]: Red#FF0000,White#FFFFFF,Blue#0066CC,Black#000000
Become root:
sudo su -
Become MRTG user:
su mrtg
Run indexmaker:
indexmaker ./mrtg.cfg > index.html
Exit MRTG user by pressing Ctrl+D.
Move the index file to html folder:
mv index.html html
Create dir for scripts:
mkdir /usr/local/mrtg
Save script 1:
nano /usr/local/mrtg/linux_porc.pl
Paste the script:
#!/usr/bin/perl
open(COMD,"ps -ef | wc -l|");
$num = <COMD>;
close(COMD);
print int($num);
Save script 2:
nano /usr/local/mrtg/linux_estconn.pl
Paste inside:
#!/usr/bin/perl
open(COMD,"ss -an | grep ESTABLISHED | wc -l|");
$num = <COMD>;
close(COMD);
print int($num);
Save script 3:
nano /usr/local/mrtg/linux_users.pl
Paste following:
#!/usr/bin/perl
open(COMD,"w | grep -v load | grep -v USER | wc -l|");
$num = <COMD>;
close(COMD);
print int($num);
Open your web-browser with this address: http://localhost/mrtg/html/
Version 0.1 beta -> probably this will not work for you perfectly -> please use only as reference