MRTG Statistic Updater
version 1.10

return to

NEW! Web page updated with new FAQs on 11/26/1999!

You need to have Windows NT 4.0 with at least Service Pack 3, a TCP connection, and MRTG up and running before attempting to install the MRTG Statistic Updater.

Installing the Service
(NOTE: You must have MRTG up and running before using this! If you don't have it running, this won't help you, nor can I. The MRTG distribution site is here, and a great list of FAQs is here.)

Installing the MRTG Statistic Updater service is easy, provided that you've grabbed the installation files. (1841 Kb, includes VB support files)
Once you've done that, extract the files from the ZIP; extract them to a temporary directory, since the setup program will then take care of installing the application and support files into the proper locations.

Next, run the setup.exe application. The default is to install into a directory named MrtgSvc in your current system drive's Program Files directory; you can change this if you'd like, and then finish the installation. Once you're done with this, you can delete the temporary setup files (although you probably want to hang onto the original archive).

The next step is to install the service itself into NT; to do this, double-click on the install.bat batch file in the MrtgSvc directory. (All that this batch file does is run the application with a -i command-line parameter.)

Now, you need to set your preferences. (They should be self-explanatory, but if not, then see below for explanations of each one.) You do this by running the application with the -p command-line parameter, such as:

O.K., now that the Registry's set up, you may want to go into the Services control panel and set how you want the service to start (Automatic or Manual). It is installed in Manual mode; you may want to change this.

Last, you can start the service from the Services control panel. If your Registry settings are set to show successful updates, then you can check your Application Event Log to see if it's working.

That's it!

The updatePath Setting

If MRTG Statistic Updater is not updating your stats like it should, then the most likely reason (and the first thing to check) is that you entered the path to the update application incorrectly. (A bit of voodoo that I practice is using the 8.3 pathnames, like using C:\PROGRA~1\ rather than C:\Program Files\.) The proper format for this entry is:

[path to perl.exe] [path to "mrtg" app] [path to mrtg.cfg file]

The Application Event Log is now giving as much feedback as I get for failures and successes (assuming that you have the logging turned on in the preferences), so you should be able to figure out what the problem is. Please remember that if you can't figure it out, feel free to email me and we'll see what we can do.

Removing the Service
Removing the service is simple. First, you want to stop the service from the Services control panel.

Once done, run the uninstall.bat batch file in the MrtgSvc directory. (This just runs the application with the -u command-line option.) This will uninstall the service from the NT services database.

Lastly, remove the application and Registry entries with the Add/Remove Applications control panel. It will clean everything up (although you may want to keep the VB support files around, since tons of shareware use them).

That's it for removal! (Although I don't see why you'd want to... :)

Configuring the Service
Just run MRTGSVC -P to configure the preferences for the service. Everything's stored in the Registry, at the following key:
Here are the Registry parameters, and what they do.
updatePath     The actual path that the service runs (includes your perl.exe binary, the mrtg perl script, and the MRTG configuration file). See above regarding the exact makeup of, and my voodoo for, this setting.
interval     Sets the interval, in minutes, between MRTG updates.
showFails     If set to 1, logs any inability to run the MRTG update application to the Application Event Log. (If 0, doesn't.)
showSucceeds     If set to 1, logs all successful MRTG updates to the Application Event Log. Be warned; this can get big! (If 0, doesn't.)
Frequently Asked Questions
Here, I've (finally) put together a list of the questions that I've repeatedly received (hence the frequently part of FAQ), and the answers that have worked out.

I want to write my MRTG statistics web pages to a shared directory on a networked computer. Does MRTG Statistic Updater support this setup?

Yes, but with a change to the default setup. First, though, an explanation. Most services in Windows NT run under the "LocalSystem" security account. This account, by design, has near-unlimited access to the resources of the local computer (hard disks, network cards, etc.), but has no access to any other computer. Thus, if you want MRTG Statistic Updater to run an MRTG setup which writes to a networked computer, you need to change the account that MRTG Statistic Updater uses to log into the local computer.

Doing this is easy. Go to the Services... control panel, and select the MRTG Statistic Updater service. Click on the "Startup" button, and under the section where you can choose the account that the service uses to log in, choose an actual account on the local machine.

Note that if you do this, then you must set up and configure the same account on the networked computer. This means creating the account, and setting the permissions on the shared directory so that this account has the appropriate rights (read, write, and execute).

Also note that I recommend creating a brand new account on both machines for this. For a while, Windows NT had (or has) a bug whereby if a service uses an account to log in, then that account had some major problems if someone tried to use it to log in interactively.

I've installed the service, and it is running, but my statistics aren't updating. I can run the UpdatePath from a command line and it works just fine. The Event Log says "MSU update succeded," but this clearly isn't the case. What gives?

There are two potential causes for this -- either the permissions on a directory aren't set correctly, or you are trying to use a shared directory on a networked computer for the output of MRTG. Both are solvable.

Permissions are incorrect

By default, MRTG Statistic Updater runs under then "LocalSystem" security context in Windows NT. (This means that, whereas you log in as "JohnDoe" or "Administrator" or whatever, MRTG Statistic Updater logs in as "LocalSystem".) Thus, everything that MRTG Statistic Updater uses needs to have permissions set such that the LocalSystem account (named "System" in most installations of Windows NT) can use it. There are three important directories in MRTG -- the perl directory, the MRTG directory, and the directory to which MRTG writes its HTML output. All three of these directories need permissions set so that the LocalSystem account can read, write, and execute.

Networked setup fails

See the section above (the first FAQ), where a properly-configured networked setup is described. If the setup is incorrect, then the Event Log will show that the statistics were properly updated, but in fact, the remote machine denied access to MRTG Statistic Updater.

I have a bunch of MRTG configuration (.CFG) files, and would like to set MRTG Statistic Updater to update all of them. Is this possible?
This is possible, and pretty easy to set up. The easiest way is to create a .CMD file (an NT batch file) that has the commands for each MRTG configuration file, and then point MRTG Statistic Updater's updatePath setting to this file. Here's an example:

Create a file named C:\MRTG\MRTGUP.CMD in any text editor (like NotePad). This file should contain the update statements for each MRTG configuration file:

Now, set the updatePath setting to point to the .CMD file that you created above. In my example, the updatePath would be set to:
At this point, your setup is complete; when MRTG Statistic Updater fires each interval, the .CMD file will run, and all of the configuration files will be processed. Note that you probably should run the .CMD file from a Command Prompt window, and see how long it takes to run; then, make sure that your interval is longer than this amount of time. (Otherwise, MRTG Statistic Updater will fire an update before the prior update is complete.)

I am using a .CMD file (as described above), and am getting an error ("MSU received a message back from NT when running the update. Note that this is not necessarily an error. The returned message was: ") on every run of MSU. What's up?

This is because you didn't put the @ECHO OFF line at the top of the .CMD file. When NT runs a .CMD file, there is an inherent null character echoed back to the standard output; MSU gets this, and reports it back to you as an error because it doesn't know any better. Put the @ECHO OFF line at the top of your .CMD file; you'll be much happier.

I want to use MSU to update a few different sets of MRTG statistics, but each set needs to run at different intervals. How do I do this?

This is a tough one, but doable. To start off, you can't install multiple copies of MSU; I just didn't write it that way. (Someday, maybe, but not now.) So, the best way to do it is to use a Windows Scripting Host (WSH) script... you have MSU run the WSH script every minute, and the WSH script is the thing that checks to see if it's time to run one of your sets of statistics, and if so, it does it.

I jotted off a quick version of this WSH script; out of the box, it's set up to run one set of stats every five minutes, and another set every 20 minutes. It's really easy to change these numbers to whatever you want; the instructions are at the top of the script itself.

First, download the test script which makes sure that you have the Windows Scripting Host installed. If the script doesn't work, then download and install the Windows Scripting Host from Microsoft.

Download the script here, and open it up in any text editor (like Notepad, or my favorite, TextPad). Read the top of the file, which explains how to edit it to run your tasks and set the interval times that you want. Edit away.

Test the file by waiting for one of the interval minutes (i.e., if you've set it to run a task every five minutes, wait until a minute multiple of five) and double-clicking the script. It should update your stats; if it doesn't, then check out the section above regarding troubleshooting this.

Once you have it working, set MSU's preferences (as explained above) so that your updatePath points to the full pathname to the multipleTasks.vbs file and your interval is one (1) minute. At this point, you should be all set.

I like MRTG Statistic Updater, and how it installs as a Windows NT service. How can I write a program that installs as a service?

I used to not be able to answer this question, as the Visual Basic component that I use is written by Microsoft and distributed as part of my Microsoft Developer Network (MSDN) membership (which carries with it a non-disclosure agreement). Now, however, Microsoft has opened up a bit, and the actual component that I use, NTSVC.OCX, is available on the MSDN Library website. You do have to be a member of the Online Library (which is free to join). Once you have joined, go to the following URL:
At that point, everything's self-explanatory.

Does MRTG Statistic Updater work with Windows NT Service Pack 4? 5? 6? 6a?

Yes, on all of my machines, and on the people's machines who I've thought to ask. (This question probably stems from the fact that this web page, for a long time, said that you had to be running NT with Service Pack 3.)

If you have found any bugs, have any suggestions, or just want to say hello, feel free to drop me a line -- I'll try to get back to you as soon as I can (given that I'm a full-time physician!).

Copyright (C) 1999 by Queso Technologies. All Rights Reserved. terms of use