Results 1 to 7 of 7
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    controll if Server is Down (2000)

    How to controll via VBA for Excel if a server is Down...???
    Similar when i use the dos command ping.
    My server is myserver

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: controll if Server is Down (2000)

    Do you know the IP address of the server or just its name?
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: controll if Server is Down (2000)

    yes, i know the complete IP

    and complete name is:

    sdd02s0900

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: controll if Server is Down (2000)

    With the IP address, you can use something like this:
    <pre>Option Explicit

    Private Declare Function IcmpCreateFile Lib "icmp.dll" () As Long
    Private Declare Function inet_addr Lib "WSOCK32.DLL" _
    (ByVal cp As String) As Long
    Private Declare Function IcmpCloseHandle Lib "icmp.dll" _
    (ByVal IcmpHandle As Long) As Long
    Private Declare Function IcmpSendEcho Lib "icmp.dll" _
    (ByVal IcmpHandle As Long, _
    ByVal DestinationAddress As Long, _
    ByVal RequestData As String, _
    ByVal RequestSize As Long, _
    ByVal RequestOptions As Long, _
    ReplyBuffer As ICMP_ECHO_REPLY, _
    ByVal ReplySize As Long, _
    ByVal Timeout As Long) As Long
    Private Type IP_OPTION_INFORMATION
    Ttl As Byte
    Tos As Byte
    Flags As Byte
    OptionsSize As Byte
    OptionsData As Long
    End Type
    Public Type ICMP_ECHO_REPLY
    address As Long
    Status As Long
    RoundTripTime As Long
    DataSize As Long
    Reserved As Integer
    ptrData As Long
    Options As IP_OPTION_INFORMATION
    data As String * 250
    End Type
    Public Function ping(sAddress As String) As Boolean
    Dim hIcmp As Long
    Dim lAddress As Long
    Dim lTimeOut As Long
    Dim strEcho As String
    Dim Reply As ICMP_ECHO_REPLY
    strEcho = "blah"
    'ICMP (ping) timeout
    lTimeOut = 1000 'ms
    'Convert string address to a long representation.
    lAddress = inet_addr(sAddress)
    If (lAddress <> -1) And (lAddress <> 0) Then

    'Create the handle for ICMP requests.
    hIcmp = IcmpCreateFile()

    If hIcmp Then
    'Ping the destination IP address.
    Call IcmpSendEcho(hIcmp, lAddress, strEcho, Len(strEcho), _
    0, Reply, Len(Reply), lTimeOut)
    'Reply status
    ping = (Reply.Status = 0)

    'Close the Icmp handle.
    IcmpCloseHandle hIcmp
    Else
    ping = False
    End If
    Else
    ping = False
    End If
    End Function

    Sub test_ping()
    If ping("10.111.21.38") Then
    MsgBox "server is available"
    Else
    MsgBox "server is unavailable"
    End If
    End Sub
    </pre>


    There is a test sub at the bottom showing how to use the code.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: controll if Server is Down (2000)

    Work fine!
    Tks.

    But is possible to know the effective stsus of server?!
    For example:
    -Disk full
    -Other Error (description)
    -ecc...

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: controll if Server is Down (2000)

    No idea. You can check the disk space on a computer but the method for doing that is completely different form checking its error log and so on. What exactly are you trying to accomplish?
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: controll if Server is Down (2000)

    tks Rory and sorry for delay...
    In effect, is usual the disk of one server in my farm is full, and not permit to store a files.
    In thi case i want to controll or chek if disk is full... tath is all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •