mrtg for Debian --------------- 1. IMPORTANT CHANGES 2. DIRECTORY OF PAGES 3. HOW TO DISABLE SYSTEMD/INIT.D AUTOSTART 4. OVERRIDING THE SYSTEMD 5. TROUBLESHOOTING MRTG 6. TROUBLESHOOTING: 403 Forbidden 1. IMPORTANT CHANGES -------------------- The most relevant recent change is the MRTG is running via init/systemd (since revision 2.17.8+git20211022.f52e91e-1). Please, read the file /usr/share/doc/mrtg/NEWS.Debian.gz to know about these changes. The most relevant change is that currently (since revision 2.17.8+git20211022.f52e91e-1) MRTG is running via init/systemd. The current start command called by init/systemd can be viewed below: LANG=C /usr/bin/mrtg --daemon --fhs --user=mrtg The default configuration file is /etc/mrtg/mrtg.cfg 2. DIRECTORY OF PAGES --------------------- The default directory for pages generated from MRTG is /var/www/html/mrtg/. This directory needs to be owned by 'mrtg' user and 'www-data' group. This configuration will allow MRTG to write the pages and a web server (Apache, lighttpd, etc.) reads the content. A good permission for this directory is 0750. 3. HOW TO DISABLE SYSTEMD/INIT.D AUTOSTART ------------------------------------------ Maybe you want to disable the autostart to use a cronjob. In Debian, the init.d script will call a systemd config file, if available. The MRTG on Debian has a systemd config file. To disable the autostart, run the following command: # systemctl disable mrtg To re-enable, run: # systemctl enable mrtg 4. OVERRIDING THE SYSTEMD ------------------------- To change any option in systemd config file, run the following command: # systemctl edit mrtg To see details about how to change a specific option, read this post[1]. [1] https://askubuntu.com/questions/659267/how-do-i-override-or-configure-systemd-services 5. TROUBLESHOOTING MRTG ----------------------- If MRTG not work after your changes: - Check the log at /var/log/mrtg/mrtg.log - Run '# systemctl status mrtg' - Run '# journalctl -xeu mrtg' - Verify the permissions for each file and directory. The recommended permissions are: FILE OWNER:GROUP PERM ---------------------------------------- /etc/mrtg/: mrtg:mrtg 2750 /etc/mrtg/*: mrtg:mrtg 0640 /var/lib/mrtg/: mrtg:mrtg 0750 /var/log/mrtg/: mrtg:mrtg 0750 /var/www/html/mrtg/: mrtg:www-data 0750 /var/www/html/mrtg/*: mrtg:www-data 0640 - Stop the service (# systemctl stop mrtg or /etc/init.d/mrtg stop) and run MRTG via command line. Example: # LANG=C mrtg The command above will use the default config file, /etc/mrtg/mrtg.cfg. To call other config file, use something like this: # LANG=C mrtg ~/test/test.cfg Check the on screen messages and the main log at /var/log/mrtg/mrtg.log. - When MRTG is not running, a /run/mrtg/mrtg.pid file must not exist. Remove it if needed. However, is a bit odd there is a pid file without a service running. Please, double check it. 6. TROUBLESHOOTING: 403 Forbidden --------------------------------- This is not a MRTG issue. Some web servers block directory listing. In other words, if you don't have an index file, like index.html or index.php, you won't be able to see the content of the /var/www/html/mrtg/ directly. The basic solutions are: - Creating an index.html to list each .html generated by MRTG. - Calling a .html file created by MRTG. An example: http://myserver.example/203.0.113.10_eth0.html - Enabling the directory listing only for /var/www/html/mrtg/ in your webserver. -- Joao Eriberto Mota Filho Sun, 31 Oct 2021 20:55:08 -0300