'Objective: To generate the PNG graph file for the given RRD database 'Created by: MAK 'Date: Apr 23, 2005 'Usage: cscript show_graph.vbs "ServerName" "Processor#" "From Date" "To Date" 'Example: cscript show_graph.vbs "ATDBQA" "0" "2005-04-27 10:00 am" "2005-04-27 3:00 pm" Set WshShell = WScript.CreateObject("WScript.Shell") Set objArgs = WScript.Arguments servername=objArgs(0) CPU=objArgs(1) fromtime=UDATE(getutc(objArgs(2))) totime=UDATE(getutc(objArgs(3))) query ="rrdtool graph "& servername &"_cpu"& CPU &".png --start " & fromtime &" --end "& totime &" DEF:myspeed="& servername &"_cpu"&cpu&".rrd:LOAD1:AVERAGE LINE2:myspeed#FF0000 --alt-autoscale-max -a PNG -h400 -w800 -l0 -u100 -v CPU_Load_Percentage_of_CPU"& CPU&" -t CPU_Utilization_on_" & Servername & " " wscript.echo Query Return = WshShell.Run(Query, 1) Query ="Start "&servername &"_cpu"& CPU &".png" wscript.echo "You can see the graph by typing the following command in command shell " & Query 'Return = WshShell.Run(Query, 1) function UDate(oldDate) UDate = DateDiff("s", "01/01/1970 00:00:00", oldDate) end function function getutc(mydate) od = mydate set oShell = CreateObject("WScript.Shell") atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias" offsetMin = oShell.RegRead(atb) nd = dateadd("n", offsetMin, od) ' wscript.echo nd 'Response.Write("Current = " & od & "
UTC = " & nd) getutc= nd end function