Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RRDTool feedback

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,61981
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> RRDTool feedback
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 RRDTool feedback - 6/29/2008 10:46:51 PM   
  gurner78

 

Posts: 7
Score: 0
Joined: 10/16/2006
Status: offline
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

_____________________________

Cheers
 
 
Post #: 1
 
 RE: RRDTool feedback - 6/30/2008 9:48:44 PM   
  4scriptmoni


Posts: 192
Score: 0
Joined: 5/3/2007
Status: offline
I like the Idea about using rrdtool, I have used it under linux.
I download it and ran the script but I get this error:

D:\temp\graph\graph.vbs(33, 8) Error de Microsoft VBScript en tiempo de ejecución: No coinciden los tipos: 'objTextFile.Write'

in the status.bat file I see many lines all the way to this
rrdtool update website1.rrd 1215002097:38
rrdtool update website1.rrd 1215002101:391
rrdtool update website1.rrd 1215002107:

Could it be because I lost connection?

Would be nice if we could throw that output into an .hta do you think it is posible?
How many pings does it do now? 100 ?

Ah.. I pinged another host and it completed all but then... I guess I am missing a font.

D:\temp\graph>rrdtool graph speed.png --start 1215003209 --end 1215013309 DEF:m
speed=website1.rrd:WEBSITE1:AVERAGE LINE2:myspeed#FF0000
439x154
ERROR: failed to load C:\WINDOWS\fonts\DejaVuSansMono-Roman.ttf

cheers,

< Message edited by 4scriptmoni -- 6/30/2008 9:58:23 PM >


_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to gurner78)
 
 
Revisions: 1 | Post #: 2
 
 RE: RRDTool feedback - 6/30/2008 10:54:12 PM   
  4scriptmoni


Posts: 192
Score: 0
Joined: 5/3/2007
Status: offline
ok I was able to make it work!

I tried to attach the required files:
DejaVuSansMono-Roman.ttf
rrdtool.exe

I noticed the graph is quite smaller because the time frame is of about 4 hours and the pings happens in less then 5 minutes. Is there a way to make it shorter?

I change line 33 to avoid the error if the ping does not respond like these:

if PingResult.ResponseTime <> "" then
       objTextFile.Write(PingResult.ResponseTime)
       objTextFile.WriteLine("")
end if

cheers,

Attachment (1)

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to gurner78)
 
 
Post #: 3
 
 RE: RRDTool feedback - 7/1/2008 6:27:48 AM   
  gurner78

 

Posts: 7
Score: 0
Joined: 10/16/2006
Status: offline
Cheers for your feedback

my thinking behind the script was a roundabout carbon copy of how i did it in Excel, ping a host, get the response time, pipe it into Excel along a dated column and build a graph out of it.

i think my research on RRDTool pointed me to having to use the Unix date stamp (http://www.unixtimestamp.com/) and pipe the following information into the .rrd file

this line i gathered defines the graph type and opening time,

'rrdtool create website1.rrd --start 1215029204 --step 1 DS:WEBSITE1:COUNTER:600:U:U RRA:AVERAGE:0.5:1:300'

the start time next to '--start' is found from the exact system time on your machine and coverting it to unix format by this line

DateDiff("s", "12/31/1969 00:00:00", DateSerial(Year(Now), Month(Now), Day(Now)) + TimeSerial(Hour(Now), Minute(Now), Second(Now)))

it pings a host in looped ping 100 times here, define start number

r = 1

Do While z<100

Next
r=r+1   (add 1 on each loop)
z=z+1   (do the same)
If z>100 Then Exit Do   (once Z higher than a hundred, exit)
loop


everytime it loops i planned to add 1 to the unix time too, hence these

rrdtool update website1.rrd 1215029206:47
rrdtool update website1.rrd 1215029210:47
rrdtool update website1.rrd 1215029215:44
rrdtool update website1.rrd 1215029219:49


and then add it all to a batch file and then run it, to pipe it in the rrd file and run the graph generation line last

but as you can see, this is adding a datestamp to the website1.rrd file, with the response time from the ping last after the colons, but the date stamp goes up in increments of 4, 5, 4, 4, 5 etc, which im wondering if it has thrown it off a bit.

i also wondered if anyone has interpreted the RRDtool commands better?  i have seen some great graphs, but havent come close yet

Ta

_____________________________

Cheers

(in reply to 4scriptmoni)
 
 
Post #: 4
 
 RE: RRDTool feedback - 7/2/2008 12:28:55 AM   
  4scriptmoni


Posts: 192
Score: 0
Joined: 5/3/2007
Status: offline
Should it no be there a threshold configuration? for 4, 5 seconds difference, also about the time frame, now 4 hours witch causes the graphic very small.
The idea is great, I can event think of writing an HTA for monitoring internet speed with graphics etc...
Can you pass me the link of the documentations you read?

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to gurner78)
 
 
Post #: 5
 
 RE: RRDTool feedback - 7/2/2008 2:41:12 AM   
  gurner78

 

Posts: 7
Score: 0
Joined: 10/16/2006
Status: offline
i wasnt looking for any particular system or documentation to be made really, just hoped to be able to produce something that could be tailored to any device i could ping at that time, hence the popups asking for a hostname or IP.

I think i have mis-interpreted the Unixtime stamp as it climbs up

I think the large window on the graph (or there abouts comes from the start date and time '1215100574' and the end date and time '1215110785'  (for example, when i ran it just now) as it increments 4 or 5, as it always has, to the unxtime, on the + r, but i hoped it to start at 1 and add 1 each loop, but it is doing 4-5 instead

here

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)

i wanted it to add

1215100574 + 1
1215100575 + 1
and so on 100 times by this

Do While z<100
Next
z=z+1  
If z>100 Then Exit Do   (once Z higher than a hundred, exit)
loop


Again, I was hoping to progress the Unixtimestamp by 1 second each time, and pause the script 1 second, or increment the timestamp 5 seconds and pause the script 5 seconds (5000ms)

But the start time 1215100574 = 07 / 03 / 08 @ 11:56am, and the finish time 1215110785 = 07 / 03 / 08 @ 2:46pm, this end time is generated by the last line of the Batch file, created by

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)

even though the script has looped 100 times in intervals of 1 second

the *100 was to add the 1 of 'r' and times it by the loops '100' and add it to the last Datestamp, but, i since have discovered the Timestamp reflects 1 second by adding 60 to each time as it progresses, so i think i may need to rethink that part ;)

Believe it or not, i mainly butcher scripts to automate Windows tasks etc, i got this far from logic mainly, pulling bit from here and there, but have never been taught, or read any books or pdf's on it, i've got this far, but even though i know the upwards count of the unixtime is wrong ii cant figure why it is incrementing 4-5 'supposid' seconds to each single loop of 1000ms, 2000ms, 3000ms, which ever i assign here

wscript.sleep 3000

event though i have told it to do only +1 on each loop

If you could produce an HTA out the code we've done so far, that'll be awesome, i toyed with the idea, using a butchered version of RRDTool i found on a french website called 'SnmpGraph.exe', that pulls SNMP information from interfaces using pre-defined information and OIDs in a .cfg file, that continually loops adding to an .rrd file.  i created a looping batch file that continually ran into the .rrd file producing an updated graph every few seconds, and adding a refresh to an html file pointing at the PNG files, like so

dim WSH
Set WSH = CreateObject("Wscript.Shell")
Do
wscript.sleep 5000
WSH.Run "rrdtool graph speedDL.png DEF:myspeed=Database1.rrd:adsldl:AVERAGE LINE2:myspeed#FF0000", 0
wscript.sleep 5000
WSH.Run "rrdtool graph speedUP.png DEF:myspeed=Database1.rrd:adslup:AVERAGE LINE2:myspeed#FF0000", 0
wscript.sleep 5000
loop

I added the sleeps, because it got in to a right tangle sometimes, trying to run everything so quickly, and i think i havent got the .cfg file right

Mmm...

(i cant upload anything yet, but can stick it on a site elsewhere later)

_____________________________

Cheers

(in reply to 4scriptmoni)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> RRDTool feedback Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts