Statistics.vbs

This example demonstrates how to use PacketX to collect statistics from VBScript.
See also:
PacketX , Statistics , Adapter
00001 '
00002 '// File:         Statistics.vbs
00003 '//
00004 '// Description:  This script demonstrates how to collect statistics
00005 '//
00006 '// Notes:        Run the script from command line using the cscript.exe program
00007 '//
00008 '// Created:      May 10, 2004
00009 '//
00010 '// Copyright (c) 2000-2004 BeeSync Technologies.
00011 '
00012 
00013 '// Constants
00014 const PktXModeStatistics = 2
00015 
00016 '// Create PacketX object
00017 Set oPktX = WScript.CreateObject("PktX.PacketX","PacketX_")
00018 
00019 '// Display network adapters
00020 For i = 1 To oPktX.Adapters.Count
00021   If oPktX.Adapters(i).IsGood Then
00022     WScript.Echo "(" & i & ") " & RTrim(LTrim(oPktX.Adapters(i).Description))
00023   End If
00024 Next
00025 
00026 '// Select network adapter
00027 oPktX.Adapter = Nothing
00028 While oPktX.Adapter Is Nothing
00029   WScript.StdOut.Write "Choose adapter#"
00030   On Error Resume Next
00031     oPktX.Adapter = oPktX.Adapters(RTrim(LTrim(WScript.StdIn.ReadLine)))
00032   On Error Goto 0
00033 Wend
00034 
00035 '// Set statistics mode 
00036 oPktX.Adapter.Mode=PktXModeStatistics
00037 oPktX.Adapter.ReadTimeout=2000 '// 2 sec
00038 
00039 '// Start capture
00040 oPktX.Start
00041   WScript.Sleep(60000)
00042 oPktX.Stop
00043 
00044 '// Statistics event handler
00045 Public Sub PacketX_OnStatistics(ByRef oStats)
00046   WScript.Echo oStats.Date & " Pkts " & oStats.Packets & " Bytes " & oStats.Bytes
00047 End Sub

Copyright © 2000-2007 beeSync. All rights reserved.