'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" "From Date" "To Date" 'Example: cscript show_graph2.vbs "ATDBQA" "2005-04-27 10:00 am" "2005-04-27 3:00 pm" Dim Mycolor(16) dim count Mycolor(0) = "#FF0000" 'Red Mycolor(1) = "#0000A0" 'Dark Blue Mycolor(2) = "#FF00FF" 'Pink Mycolor(3) = "#000000" 'Black Mycolor(4) = "#00FFFF" 'Turquoise Mycolor(5) = "#0000FF" 'Light Blue Mycolor(6) = "#FF0080" 'Light Purple Mycolor(7) = "#800080" 'Dark Purple Mycolor(8) = "#FFFF00" 'Yellow Mycolor(9) = "#00FF00" 'Pastel Green Mycolor(10) = "#808080" 'Dark Grey Mycolor(11) = "#FF8040" 'Orange Mycolor(12) = "#804000" 'Brown Mycolor(13) = "#800000" 'Burgundy Mycolor(14) = "#808000" 'Forest Green Mycolor(15) = "#408080" 'Grass Green count=0 Set WshShell = WScript.CreateObject("WScript.Shell") Set objArgs = WScript.Arguments servername=objArgs(0) fromtime=UDATE(getutc(objArgs(1))) totime=UDATE(getutc(objArgs(2))) query ="rrdtool graph "& servername &"_cpu.png --start " & fromtime &" --end "& totime Set procset = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & ServerName & "\root\cimv2").InstancesOf ("Win32_Processor") for each System in ProcSet filename = servername & "_" & system.deviceid varname= "speed" & system.deviceid string1="Average_"& system.deviceid query = query & " DEF:" & varname & "=" & filename & ".rrd:LOAD1:AVERAGE LINE3:" & varname &mycolor(count) &":"& string1& " " count=count+1 next 'Return = WshShell.Run(Query, 1) query =query & " --alt-autoscale-max -a PNG -h400 -w800 -l0 -u100 -v CPU_Load_Percentage_of_CPU -t CPU_Utilization_on_" & Servername wscript.echo Query Return = WshShell.Run(Query, 1) Query ="Start "&servername &"_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