How to run Multi Router Traffic Grapher (MRTG) as a Windows Service.


MRTG logo



What is Multi Router Traffic Grapher (MRTG)?

Multi Router Traffic Grapher (MRTG) is an excellent tool to monitor the traffic load on network-links (amongst other things). It achieves this by examining the various OID's of SNMP enabled devices that you specify to produce a range of graphs. It is written in Perl.


MRTG screenshotMulti Router Traffic Grapher (MRTG) as a Windows Service.

Can I run Multi Router Traffic Grapher (MRTG) as a Windows Service?

MRTG can be run as a Windows service using FireDaemon Pro. This allows you to start and run the monitor automatically when Windows boots and before login. FireDaemon Pro also allows you to start multiple instances of the application, monitoring them and automatically restarting those instances in the event they crash. FireDaemon Fusion can also be used to manage your MRTG service, plus other Windows services via your web browser.


How to set up MRTG Monitor under FireDaemon Pro

Please follow the steps below to set up a MRTG monitor as a Windows service with FireDaemon Pro


Step 1: Download and Install MRTG

  1. Download the latest MRTG zip. A single ZIP file mrtg-X.Y.Z.zip is downloaded (X.Y.Z corresponds to current version number).
  2. Extract the contents of the zip to "C:\", the path to the monitor files should now be "C:\mrtg-X.Y.Z". For ease of use, rename "C:\mrtg-X.Y.Z" to "C:\MRTG".


Step 2: Download and Install Strawberry Perl

ActivePerl is the most popular windows distribution of Perl but it has problems with several packages. So for this reason we suggest to use Strawberry Perl.

  1. Download the latest Strawberry Perl x64 msi.
  2. Double click "strawberry-perl-W.X.Y.Z-64bit.msi"
    W.X.Y.Z corresponds to current version number. By default it installs to "C:\Strawberry".


Step 3: SNMP Setup

Your SNMP configuration will be dependent on the device or software you are setting up. For example, on a Sonicwall router you might configure SNMP as follows:


Sonicwall SNMP Settings


Step 4: MRTG Configuration File

The next step is to create an MRTG configuration file. Your community strings and IPs are specific to your installation. Do this as follows at a command prompt (Start->Run->cmd):

cd C:\MRTG
perl cfgmaker public@192.168.168.168 --output mysettings.cfg
Then open "C:\MRTG\bin\mysettings.cfg" add to the top:
RunAsDaemon: yes
Interval: 5
WorkDir: C:\Nginx\html

Replace 192.168.168.168 with the IP of the device sending SNMP packets (eg. router, switch, etc.). Check your WorkDir and confirm that the various HTML and PNG files have been generated and that there are no errors in the log file (mrtg.log). Alternately, you can log to the Windows EventLog by substituting "eventlog" for "mrtg.log" above.


Step 5: Download, Install and Configure Nginx

Nginx's naming convention for versions is confusing. Mainline is updated once per month and includes bug fixes and new features. Stable does not get any new features but does get major bug fixes. The Nginx devs suggest you use the mainline version for most cases but if you use a third-party module, it could be broken by a mainline update so in that case, you should use the stable version.

  1. Download the latest Windows mainline or stable version from here
  2. Extract the contents of the zip to your hard disk. For the purposes of this guide, we will use "C:\nginx-1.19.6" (the version number might be different for you).

Step 6: Download and Install FireDaemon Pro

  1. Download FireDaemon Pro installer
  2. Double-click installer and follow the installation wizard to complete the installation.
  3. For more information about installing FireDaemon, see the FireDaemon Pro Users Guide.


Step 7: Set Up Nginx as a FireDaemon Pro Service

Double click the FireDaemon Pro icon on your desktop, then click on the New (i.e. +) button in the toolbar (or type Ctrl + N) to create a new service. Enter the information into the fields as you see below. Adjust the path names to suit your installation. Note the required parameters.


FireDaemon Pro Nginx Service Program Tab


Step 8: Next, click on the FireDaemon Pro Settings tab:

FireDaemon Pro Nginx service settings


Enter appropriate values in the fields on the Settings tab as follows:


  • (Required) Interact with Desktop: Uncheck this because Nginx does not create any window.
  • (Optional) Logon Account: Enter the Windows account under which the application is to be run, e.g. the current user account.
  • Password / Confirm Password:  Enter the logon account's password twice.
  • (Optional) Interact with Desktop: Keep this unchecked because Nginx does not create any window.
  • (Optional) Priority: To allocate more CPU time to the application, select a higher scheduling priority in this field.
  • (Optional) CPU Bindings: To run the application on a specific CPU, specify the appropriate CPU in this field.


Step 9: Now click on the Events tab. 

Append a new Termination Event. This is where we set up Nginx to stop gracefully when we shut down the service.


Apache Solr shutdown


Lastly, click the Save and Close (ie. the tick) button on the toolbar. If the service's Startup Type is set to Automatic or Automatic (Delayed-Start), it will start immediately.


Step 10: Set Up MRTG as a FireDaemon Pro Service

Double click the FireDaemon Pro icon on your desktop, then click on the New (i.e. +) button in the toolbar (or type Ctrl + N) to create a new service. Enter the information into the fields as you see below. Adjust the path names to suit your installation. Note the required parameters.


FireDaemon Pro MRTG Service Program Tab


The most important field on the tab is the Parameters. The Parameters define the initial setup of your server. The full parameter list should be as follows:

mrtg --logging=mrtg.log mysettings.cfg
  • "mrtg" Loads MRTG perl script.
  • "-logging=mrtg.log" Logs to "C:\MRTG\b in\mrtg.log".
  • "mysettings.cfg" Loads the settings file you created previously.

Step 11:  Next, click on the FireDaemon Pro Settings tab:


FireDaemon Pro MRTG service settings


Enter appropriate values in the fields on the Settings tab as follows:

  • (Required) Job Type: Set to "Global Job".
  • (Optional) Logon Account: Enter the Windows account under which the application is to be run, e.g. the current user account.
  • Password / Confirm Password:  Enter the logon account's password twice.
  • (Optional) Interact with Desktop: If this setting is enabled (default), the application's output messages can be seen in the console window on Windows Session 0. To switch to Session 0, it may be necessary to install FireDaemon Zero and ZeroInput. Alternatively, this setting may be disabled, in which case the application's messages will be hidden.
  • (Optional) Priority: To allocate more CPU time to the application, select a higher scheduling priority in this field.
  • (Optional) CPU Bindings: To run the application on a specific CPU, specify the appropriate CPU in this field.


Step 11: Next, click on the Lifecycle tab. 

Set Shutdown By to Forceful Termination and check "Console Program".


FireDaemon Pro MRTG lifecycle settings


Lastly, click the Save and Close (ie. the tick) button on the toolbar. If the service's Startup Type is set to Automatic or Automatic (Delayed-Start), it will start immediately.


Step 12: Verify that MRTG and Nginx are Running Correctly

MRTG and Nginx's statuses can easily be checked on the main FireDaemon Pro Services List - look for a Running Status value and a numeric Process ID (PID) value.


FireDaemon Pro Services list

If the service's Interact with Desktop setting is enabled, the MRTG status can also be verified by switching to Windows Session 0 to view MRTG's messages.


MRTG messages window