IT Consulting Los Angeles Woodland Hills Tech Support Small Business Computer Networking Server Setup Microsoft Certified Partner California Company Network
Click here to Check for Security Risks

OR CALL US AT (818) 789-0088
How to setup MRTG to monitor your windows servers
Software Requirements
  • MRTG - download and install the latest version, according to the Win32 MRTG Installation Guide which is linked on the homepage for MRTG - you also might want to save copies of the documentation for MRTG, and browse some of the MRTG how-to sites on the web
  • Perl - the ActiveState Perl installer is the ONLY working way to install Perl on Win32 systems - and it gives you the flexibility to do other admin tasks as well
Major Steps
  1. Install the MRTG package above, along with ActiveState Perl.
  2. Create a directory on the root of your C: drive called Perflogs
    C:\> mkdir c:\perflogs
  3. For each server you are going to monitor, create a directory in MRTG\logs
    C:\> mkdir c:\mrtg\logs\server1
    C:\> mkdir c:\mrtg\logs\server2
  4. Open performance monitor and go to counter logs - for the name of the log file, enter the server name

  5. Add counters from each category that is important to you - at the minimum, I always record processor, hard drive and memory usage

  6. When you add a counter, you won't see anything, BUT, once you close this window, you will see all of your counters in the Server | General window

  7. Setup the log file to recycle, without changing the file name - otherwise, our perl script (that gets data from the permon file) will fail You MUST setup a comma delimited file - our perl script is specifically looking for this

  8. Schedule the logging to start right away (at the moment you create it), recycle every 30 days, and run for a damn long time

OK, we have now setup a performance monitor log file. It will collect data every 15 seconds for the next 2 years or so.

Creating the MRTG configuration file

Next, we have to tell MRTG what graphs we are going to make from this file. MRTG creates 4 graphs for every performance counter - daily, weekly, monthly and yearly. For most use, the daily and weekly graphs are all you will need.

To create the configuration file for MRTG, run my mkcfg.vbs script. It will generate 2 files for you.
  • First file is a MRTG configuration file. You will have to edit the file, because the last entry will be repeated a bunch of times. Just delete the repeated entry using notepad.
  • Second file is a HTML file that indexes the daily and weekly graphs for each performance monitor counter - copy this file to the directory where the rest of the MRTG files are going to be created. Again, the last entry will be repeated a bunch of times, so just delete the repeated entry.
Simply run the script with 2 command line arguments - first argument is the path to the .csv file that perfmon is creating, and the 2nd argument is the name of the server
C:\mrtg\bin>cscript mkcfg.vbs c:\perflogs\karachi.csv karachi
Now you can copy the server.htm file to your logs directory, c:\mrtg\logs\server1.

The entries in the config file should match the performance counters that you selected. In the config maker script I have set MaxBytes to 100. The config file generated can be edited manually if required to set a more realistic value, but the setting of 100 will work reasonably well. Log the data with Performance Monitor for a few days and open the CSV file with Excel to get an idea of what Maxbytes value you should set.

Example: If you are monitoring available MBytes of memory & you have 1gb of RAM, then you would set MaxBytes to 1024.
Example: If you are monitoring available MBytes of space on your 36GB C: drive, then you would set the MaxBytes to 38654705664.
Example: If you are monitoring Bytes Sent on your 100mbit network card, then you would set MaxBytes to 134217728

Important - If the graphs don't look right then adjust the MaxBytes value in the cfg file. Delete the associated png file in the logs directory and wait for the next update.

Collecting the stats

To use the config file created you must put the following perl script in c:\mrtg\bin - MRTG will run this perl script every time you run MRTG. This perl script will open the perfmon .csv file, gather all the stats, and output the data into a format that MRTG can read.

Enter the following:

c:\mrtg\bin>perl mrtg server.cfg

If you now look in the c:\mrtg\logs\server directory, there should be a bunch of files. Look for the html files. These are the MRTG web pages for each performance counter.

Running MRTG automatically

There are different ways to do this. I prefer to create a batch file containing the command above, and let the Windows Task Scheduler run the batch file every 10 minutes.

Communication via email - Chris Willis, Senior SE, Castellan

2003 Server - Alerts - Business Answers - Anti Virus / Backup - Bigger - Computer Associates - Clients - Contact Us / Free Consultation - Dell - Desktop Support - Enterprise - Exchange Server - How To - HP - Microsoft Gold Certified Partner - Networking Solutions - Linux Firewall - Microsoft - Mission - MRTG - Networking - Tech News - Equipment Leasing - Philosophy - Security - Small Business - Spam Filtering - Symantec - Testimonials - Web Design - Windows Server - SpywareToolkit - Sitemap

Design and Contents Copyright © 2016 Castellan, Inc. All rights reserved.

Website Design by AVETAR Interactive

Microsoft Certified Partner in Los Angeles - San Fernando Valley Microsoft Certified Partner - Microsoft Business Solution Partner