Using RRDtool and PowerShell to plot performance graphs


I've been working on a quite cool project. When troubleshooting performance problems (or other kind of problems) I always gather important information first. One of the most important pieces is a detailed resource usage report. This report should always look the same and to visualize the graphs, I always made a screenshot of my VMware vSphere Client performance tab (you know - a picture is worth a thousand words), paste it into a Word document and then moved on to the next counter. Quite time consuming - especially when you need to gather info from multiple VMs. Then when I get home I've always found I missed one graph, the quality is bad, you know - it's just not right... So this report needed improvement. I've done some work and the results can be found here. And here are some screenschots:

Open the index.html from your report folder gives you a nice overview:


Example of how the graph looks like. You can adjust the width and height of the graphs and also the comments beneath the graphs:


Gathering the data is quite easy using PowerShell once you know how (LucD has written some excellent articles about that). But plotting the graphs in Excel was a bit too much. I wanted a 'free' solution.

I know there are some ways to create graphs... Using Excel, Microsoft Chart Controls and perhaps a couple of more - however, I was looking into RRDtool. RRDtool is quite awesome. RRD stands for round robin database and with a single executable you can create databases (round robin, meaning the size doesn't change and has a 'fixed' number of records where with a full table, the old values are overwritten) and graphs (and a lot more).

This graphing is around for quite some time and the description says it all: "RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data. Use it to write your custom monitoring shell scripts or create whole applications using its Perl, Python, Ruby, TCL or PHP bindings.". And NOW with PowerShell too ;-)

What do you need?

Well you need to download the Native Windows RRDtool from here: link. I'm using version 1.2.30 from that site since they build all the nice fonts in it. I've found that it's a whole lot faster, but I've heard you could get troubles with fonts... Mr. A. Fokkema linked me to version 1.3 which can also be used. The nice thing is you can create dashed lines with it. But like I've just said: 1.2 is faster and I like the 'crisp' font a bit better.

Once you downloaded RRDtool, just extract it and here comes an important part: "make sure the location of the rrdtool.exe is in your %PATH% variable on your server!!!". So in a way: if you open your dosbox (or better yet: the PowerShell window) - you should be able to start: 'rrdtool' and it should respond. Also make sure you install the fonts which are available in the package.

Then you need to download this script:

graph-vm.zip Version:1

Create RRDtool graphs using PowerShell.

License GNU/GPL Author This email address is being protected from spambots. You need JavaScript enabled to view it. Website Homepage Date 2012-01-03 Language  English System  Windows Filesize 10.56 KB Download 2638

and extract it. Open up the README.txt since I've documented a lot in there. However, here is the content:

## Graph-VM: version 1.00          

## Build by: Bouke Groenescheij    

## Hi, welcome to the VM-Graph script.This script grabs an 'x' amount of statistics from 'y' amount of vCenter servers for 'z' amount of VMs.Three files are used for this, all .csv:x - MetricsVM.csv and MetricsHOST.csvEnter "MetricId","Pct","Description"
1. Do not remove the first line!!!
2. Available MetricId for your VM/Host can be found by using:
connect-viserver <vCenter Server>
Get-StatType -Entity (Get-VM "<one of your VMs>") -Interval "Past Day"
Get-StatType -Entity (Get-VMHost "<one of your Hosts>") -Interval "Past Day"
3 Pct is either empty (so it won't calculate the % of the Metric stats), a value (the max possible for that stat) or an formula to calculate the PCT where needed. Example: [Math]::round((Get-vmhost $Entity.HostFQDN | Get-View).Hardware.CpuInfo.Hz / 100000000 / $Entity.NumCPU , 2) - this calculates the MHz, nice for the MHz stat.
4 Description: HTML formatted text to add after each graph.

y - vCenterServers.csv
Enter "name","user","password"
1. Do not remove the first line!!!
2. "name" = vCenter name
3. "user" = user used to log onto that server - a readonly is recommended, password is in clear text
4. "password" = password to log onto that server with that user

z - ToBeReported.csv
Enter "name"
1. Do not remove the first line!!!
2. list each VM to be reported on it's own line - the script does all the work for you.
Did I say not to remove the first line from the '.csv' files? It will screw up the script ;-)The script uses RRDTOOL.EXE to create an table and plot the graph. It's easy and free, and doesn't need any installing.
Download from here: http://oss.oetiker.ch/rrdtool/download.en.html and grab version 1.3 from the contrib folder
However I've found version 1.2.30 much faster and this link also has the correct fonts in the zip: http://www.gknw.de/mirror/rrdtool/rrdtool-1.2.30-bin-w32.zip
You'll need the Native Windows package. It's recommended to extract to an directory, and add that directory to the %PATH% environment variable.
To test if it works from Powershell, just execute '& rrdtool'.
Also install the fonts into your Windows fonts folder (the DejaVuSansMono-Roman.ttf)
All output just goes to the 'report folder' (change the variable if needed). It's removed if it is still there, else a new folder is created. Check the scripts, it's not rocket science.

Special credits goes to LucD who runs an *excellent* blog on powershell. More info about performance stats in PowerShell can be found here:
And also to Tobi Oetiker for hosting and maintaining the rrdtool scripts.
Cheers and have fun!!!
Bouke Groenescheij
This email address is being protected from spambots. You need JavaScript enabled to view it.


So as you can see, this all is a quite modular approach. If you have a kick ass 'style.css' or perhaps a better 'MetricsVM.csv' - share it!!! I know the script isn't perfect, still needs work - but please share your experiences. I would like to see your results. And... I'll write an article about certain parts of the script - tell you about the decisions I made and why I made it that way.


( 1 Vote ) 
Comments (5)
  • adidas nmd  - Using RRDtool and PowerShell to plot performance g

    Character problem. empty comment

  • Lili Huberty  - Using RRDtool and PowerShell to plot performance g

    Sometimes people don't believe me when I tell them about how much you can make taking paid surveys online...

    So I took a video of myself actually getting paid $500 for paid surveys to finally set the record straight.


    I'm not going to leave this video up for long, so check it out now before I take it down!

  • An Coulter  - Using RRDtool and PowerShell to plot performance g

    I just could not go away your website before suggesting that I really loved the usual info an individual supply in your visitors? Is going to be back ceaselessly to check up on new posts

  • Jackelyn Veitinger  - Using RRDtool and PowerShell to plot performance g

    Thanks for sharing excellent informations. Your website is very cool. I am impressed by the details that you have on this web site. It reveals how nicely you understand this subject. Bookmarked this web page, will come back for extra articles. You, my pal, ROCK! I found simply the information I already searched everywhere and just could not come across. What an ideal site.

  • borvestinkral  - Using RRDtool and PowerShell to plot performance g

    I’ve been exploring for a little bit for any high-quality articles or blog posts in this sort of house . Exploring in Yahoo I ultimately stumbled upon this site. Reading this info So i am glad to express that I've a very good uncanny feeling I came upon exactly what I needed. I such a lot unquestionably will make sure to do not overlook this website and give it a look on a constant basis.

Write comment
Your Contact Details:
Gravatar enabled
[b] [i] [u] [s] [url] [quote] [code] [img]