I thought i'd stick this up here, and see if anyone had any better ideas or more efficient ways of doing it?
I thought up a reasonable way of doing tests of latency/connectivity to a device using vbscript, and came up with load of ways with Excel and other apps etc. but wondered about graphing it using vbscript.
i managed this with the chart functions in excel, but wondered if it could be done more separated from an app some people might not have, and came across RRDTool
after quite a bit of reading (ha, if youve tried RRDTool you'll know) i kinda figured out this.
--------------------------------
Const ForAppending = 8
Dim HOST
Dim TARGET
Dim PingResults
Dim PingResult
dim WSH
Set WSH = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("status.bat", ForAppending, True)
HOST = InputBox("Enter the computer that will initiate the ping" & VbCrLf & "The Host needs to be Windows 2003 or Windows XP" & VbCrLf & "" & VbCrLf & "if you are pinging a machine/server/website from this machine" & VbCrLf & "you are running this program from, type" & VbCrLf & "" & VbCrLf & "LOCALHOST or 127.0.0.1", "Gurner ping test")
TARGET = InputBox("Enter the computer name or IP address that you want to ping", "Gurner ping test")
objTextFile.Write("rrdtool create website1.rrd --start ")
objTextFile.Write(DateDiff("s", "12/31/1969 00:00:00", DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(Hour(Now), Minute(Now), Second(Now))))
objTextFile.Write(" --step 1 DS:WEBSITE1:COUNTER:600:U:U RRA:AVERAGE:0.5:1:300")
objTextFile.WriteLine("")
r = 1
Do While z<100
Set PingResults = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
HOST & "/root/cimv2"). ExecQuery("SELECT * FROM Win32_PingStatus " & _
"WHERE Address = '" + TARGET + "'")
For Each PingResult In PingResults
objTextFile.Write("rrdtool update website1.rrd ")
objTextFile.Write(DateDiff("s", "12/31/1969 00:00:00", DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(Hour(Now), Minute(Now), Second(Now))) + r)
objTextFile.Write(":")
objTextFile.Write(PingResult.ResponseTime)
objTextFile.WriteLine("")
wscript.sleep 3000
Next
r=r+1
z=z+1
If z>100 Then Exit Do
loop
objTextFile.Write("rrdtool graph speed.png --start ")
objTextFile.Write(DateDiff("s", "12/31/1969 00:00:00", DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(Hour(Now), Minute(Now), Second(Now))))
objTextFile.Write(" --end ")
objTextFile.Write(DateDiff("s", "12/31/1969 00:00:00", DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(Hour(Now), Minute(Now), Second(Now))) + r*100)
objTextFile.Write(" DEF:myspeed=website1.rrd:WEBSITE1:AVERAGE LINE2:myspeed#FF0000")
objTextFile.Close
WSH.Run "status.bat"
-----------------------------
this works (as long as the loop count is around 100) and produces a little graph based on the (unix timestamped) figures added to an RRD database, but the results dont look right, and certainly dont log enough information
I was wondering if anyone could come up with better graphs, better/clearer results etc? i can increase the range of results a bit more by expanding the pause between each loop, which is ok to an extent, but i want wanted to get it to run over a long period for example.
or if run for a minute, to produce a graph of a minute, rather than a fixed amount of hours, blank, and one little plot from the ping at the beginning
I guess it is more of an understadning of RRDTool im looking for, as ive got this far, but i thought i'd contribute it somewhere to see what other could do, and get help too
Gurner
I thought up a reasonable way of doing tests of latency/connectivity to a device using vbscript, and came up with load of ways with Excel and other apps etc. but wondered about graphing it using vbscript.
i managed this with the chart functions in excel, but wondered if it could be done more separated from an app some people might not have, and came across RRDTool
after quite a bit of reading (ha, if youve tried RRDTool you'll know) i kinda figured out this.
--------------------------------
Const ForAppending = 8
Dim HOST
Dim TARGET
Dim PingResults
Dim PingResult
dim WSH
Set WSH = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("status.bat", ForAppending, True)
HOST = InputBox("Enter the computer that will initiate the ping" & VbCrLf & "The Host needs to be Windows 2003 or Windows XP" & VbCrLf & "" & VbCrLf & "if you are pinging a machine/server/website from this machine" & VbCrLf & "you are running this program from, type" & VbCrLf & "" & VbCrLf & "LOCALHOST or 127.0.0.1", "Gurner ping test")
TARGET = InputBox("Enter the computer name or IP address that you want to ping", "Gurner ping test")
objTextFile.Write("rrdtool create website1.rrd --start ")
objTextFile.Write(DateDiff("s", "12/31/1969 00:00:00", DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(Hour(Now), Minute(Now), Second(Now))))
objTextFile.Write(" --step 1 DS:WEBSITE1:COUNTER:600:U:U RRA:AVERAGE:0.5:1:300")
objTextFile.WriteLine("")
r = 1
Do While z<100
Set PingResults = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
HOST & "/root/cimv2"). ExecQuery("SELECT * FROM Win32_PingStatus " & _
"WHERE Address = '" + TARGET + "'")
For Each PingResult In PingResults
objTextFile.Write("rrdtool update website1.rrd ")
objTextFile.Write(DateDiff("s", "12/31/1969 00:00:00", DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(Hour(Now), Minute(Now), Second(Now))) + r)
objTextFile.Write(":")
objTextFile.Write(PingResult.ResponseTime)
objTextFile.WriteLine("")
wscript.sleep 3000
Next
r=r+1
z=z+1
If z>100 Then Exit Do
loop
objTextFile.Write("rrdtool graph speed.png --start ")
objTextFile.Write(DateDiff("s", "12/31/1969 00:00:00", DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(Hour(Now), Minute(Now), Second(Now))))
objTextFile.Write(" --end ")
objTextFile.Write(DateDiff("s", "12/31/1969 00:00:00", DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(Hour(Now), Minute(Now), Second(Now))) + r*100)
objTextFile.Write(" DEF:myspeed=website1.rrd:WEBSITE1:AVERAGE LINE2:myspeed#FF0000")
objTextFile.Close
WSH.Run "status.bat"
-----------------------------
this works (as long as the loop count is around 100) and produces a little graph based on the (unix timestamped) figures added to an RRD database, but the results dont look right, and certainly dont log enough information
I was wondering if anyone could come up with better graphs, better/clearer results etc? i can increase the range of results a bit more by expanding the pause between each loop, which is ok to an extent, but i want wanted to get it to run over a long period for example.
or if run for a minute, to produce a graph of a minute, rather than a fixed amount of hours, blank, and one little plot from the ping at the beginning
I guess it is more of an understadning of RRDTool im looking for, as ive got this far, but i thought i'd contribute it somewhere to see what other could do, and get help too
Gurner