Forum Discussion

Johanvdv's avatar
Johanvdv
Level 4
14 years ago

How to Detect slow network connection

We have a working BESR 8.5 with management solution installation on our site. Our Windows 7 or Windows XP clients are backed up on a daily basis to a central backup server.   Problem is that wh...
  • Johanvdv's avatar
    14 years ago

    I have created a solution myself that works for our environment (BESR 8.5.x clients with management component).

    To this end, I have created a backup job that has the following batch file executed in the before data capture event :

     

     

    I had to add a helper .vbs script so the Add file filter was to be put to *.* in order to upload the this file.

    The check-speed.bat file currently contains the following code :

     @ECHO OFF
    echo START >>"%~dp0check-speed.log"
    echo Executing ["%~dp0script-short.vbs"] >>"%~dp0check-speed.log"
    
    cscript //nologo "%~dp0script-short.vbs" 1>>"%~dp0check-speed.log" 2>>&1
    rem cscript //nologo script.vbs 1>>c:\Log.txt 2>>&1
    IF ERRORLEVEL 1 GOTO LOW-SPEED
    IF ERRORLEVEL 0 GOTO LOCAL
    
    :LOW-SPEED
    ECHO Connected to a low-speed network (VPN) so cancel the backup >>"%~dp0check-speed.log"
    EXIT /B 1
    GOTO END
    
    :LOCAL
    ECHO Connected to the local network so proceed with backup >>"%~dp0check-speed.log"
    EXIT /B 0
    GOTO END
    
    :END
    ECHO ending the check-speed in an undesired place >>"%~dp0check-speed.log"
    EXIT /B 0 

    The salient part is that this .bat file will call the .vbs script and depending on its outcome it will return an exit code to Backup Exec System Recovery.

    If the exit code is not zero, then the before capture event failed and the backup job will also fail (no backup).

    The .vbs script is something I found via Google (I have to give credit) that will enumerate all 'Network Adapters' and if a MAC address is assigned and the name of the Adapter contains 'JUNIPER' do a check wether this adapter is connected.

    If it is connected, a return code of 1 is set.

    I am using this test (there is definitely a better one around) as my VPN connection is of the SSL Juniper type and this adapter becomes active when a LAPTOP connects to our internal network using the Network connect option.

    I could not do a reliable test on network speed as the 'fake' JUNIPER network connector reports the theoretical speed that is possible (1 Gbit) and not the actual internet speed. To get around this, I would have to run an internet connection speed test on every connection and this is beyond what I want to do here. 

     '  Set NIC.vbs
    '  VBScript to check your network connection.
    '  Author Guy Thomas http:// computerperformance.co.uk/
    '  Version 4.9 - October 3th 2004
    '  --------------------------------------------------------------'
    Option Explicit
    Dim objWMIService, ObjItem
    Dim GuyMessage, strComputer, colItems
    'On Error Resume Next
    strComputer = "."
    
    '   These Set commands are important.
    '    See Learning Points after / below the script
    
    Set objWMIService = GetObject("winmgmts:\\" & strComputer _
    & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapter",,48)
    
    For Each objItem in colItems
    
    If objItem.MACAddress <> "" and Instr(Ucase(objItem.Name),"JUNIPER") > 0 Then
    ' Remove objItem's that you do not want.
    WScript.Echo "Name: " & objItem.Name & vbCRLf & _
    "Net Connection ID: " & objItem.NetConnectionID & vbCRLf & _
    "Net Connection Status: " & objItem.NetConnectionStatus & vbCRLf & _
    "Computer Name: " & objItem.SystemName & vbCRLf & _
    "Speed: " & objItem.Speed & vbCRLf & _
    ""
      if objItem.Netconnectionstatus = "2" then
         WScript.Echo "Connected via VPN using NC : OK." 
         WScript.Quit 1       
         If CDBl(objItem.speed) > 80000000 then
            WScript.Echo "Connection SPEED ? : OK."
            WScript.Quit 0
         else
            WScript.Echo "Connection SPEED ? : SLOW."
            WScript.Quit 1
         end if   
      else
         WScript.Echo "Connected via VPN using NC : NOT."    
         WScript.Quit 0
      end if 
       
    End IF
    Next
    
    WScript.Quit 0