RRD (a system to store and display data)

RRD is a tool for handle graphing and logging similar to MRTG, see the homepage for details.


I don't think the manual contains very simple example, I was able to make it run on Windows; after downloading the zip archive you only need to use rrdtool.exe, basically you should create the structure, feed it periodically with data and generate the graph.

Create Structure:
rrdtool create datafile.rrd DS:value:ABSOLUTE:900:0:10000000 RRA:AVERAGE:0.5:1:9600 RRA:AVERAGE:0.5:4:9600 RRA:AVERAGE:0.5:24:6000

Update:
rrdtool update datafile.rrd N:20

Graph:
rrdtool graph graph.png DEF:val=datafile.rrd:value:AVERAGE LINE1:value#ff0000:Value


Below a simple vbscript with 3 switch (create, update, graph).

rrdpath = "rrdtool.exe"
dbpath = "test.rrd"
imgpath = "image.png"
set WshShell = CreateObject("WScript.Shell")
Set oArgs = WScript.Arguments
Action = oArgs(0)
Select Case Action
Case "create"
parameters = "DS:cpu:GAUGE:300:1:100 RRA:AVERAGE:0.5:1:100, RRA:AVERAGE:0.5:1:576,RRA:AVERAGE:0.5:6:672, RRA:AVERAGE:0.5:24:732, RRA:AVERAGE:0.5:144:1460"
WshShell.Run(rrdpath & " create " & dbpath & " " & parameters)
Case "update"
Set Processors = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
for each Proc1 in Processors
parameters = "N:" & proc1.LoadPercentage
next
WshShell.Run(rrdpath & " update " & dbpath & " " & parameters)
Case "graph"
parameters = "DEF:cpu=" & dbpath & ":cpu:AVERAGE LINE1:cpu#ff0000:cpu"
WshShell.Run(rrdpath & " graph " & imgpath & " " & parameters)
End Select
Share on Google Plus

About Vittorio Pavesi

    Blogger Comment
    Facebook Comment

0 commenti: