Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Testing to see if a server/computer is up and running is a vb.net appication

Posted on 2011-03-09
4
Medium Priority
?
341 Views
Last Modified: 2012-05-11
Sql 2005
Vb .net 2008

I am building an application to put any warning or errors in the event file into a table. I have one table with all the server and users machine name.  I also am putting what areas in the Event log I want. ( application – security – system) I have a table where I will add any non informational errors/warning to.

My questions are
 How can I tell a server/computer is up and running? How can I tell I successfully read a record in the say application area in my event log? I mean right now I can read thought the event logs and get the transactions and log them but I have no status checking to say oh yes my server ‘abc’ is up and running.
I read though and get a table of all machines up and responding now.(old way see code )

‘code
    Public Function GetNetworkComputers() As ArrayList
        Dim networkComputers As New ArrayList()
        Const MAX_PREFERRED_LENGTH As Integer = -1
        Dim SV_TYPE_WORKSTATION As Integer = 1
        Dim SV_TYPE_SERVER As Integer = 2
        Dim buffer As IntPtr = IntPtr.Zero
        Dim tmpBuffer As IntPtr = IntPtr.Zero

        Dim entriesRead As Integer = 0
        Dim totalEntries As Integer = 0
        Dim resHandle As Integer = 0
        Dim sizeofINFO As Integer = Marshal.SizeOf(GetType(_SERVER_INFO_100))

        Try
            Dim ret As Integer = NetServerEnum(Nothing, 100, buffer, MAX_PREFERRED_LENGTH, entriesRead, totalEntries, _
                                               SV_TYPE_WORKSTATION Or SV_TYPE_SERVER, Nothing, resHandle)

            If ret = 0 Then
                For i As Integer = 0 To totalEntries
                    tmpBuffer = New IntPtr(CType(buffer, Integer) + (i * sizeofINFO))
                    Dim svrInfo As _SERVER_INFO_100 = CType(Marshal.PtrToStructure(tmpBuffer, _
                                                            GetType(_SERVER_INFO_100)), _SERVER_INFO_100)
‘code end

 
-      But even now once they are in my array it doesn’t mean by the time I go to read then they are they still up and running? I guess also I  am also asking for the way I am doing it now can I do a check and see if a machine is still up and responding Which probably is the same answer  I need for above.
Thanks
0
Comment
Question by:john M
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35086981
0
 
LVL 3

Author Comment

by:john M
ID: 35087845
Kaufmed
can you give me some code examples?
I am new and yes i see what your talking about- but how do I apply it?

Thanks

John
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 35088673
It's quite simple actually:
Imports System.Net.NetworkInformation

...

Dim pinger As New Ping()
Dim reply As PingReply

reply = pinger.Send("www.example.com")

If reply.Status = IPStatus.Success Then
    Console.WriteLine("Server alive!")
    Console.WriteLine("TTL: {0}", reply.Options.Ttl)
    Console.WriteLine("Time: {0}ms", reply.RoundtripTime)
End If

Open in new window

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35088704
The above WILL NOT tell you if a particular service (port) is available--it will only tell you if the server is responding to pings (there is the potential that you server, or router, could be blocking ICMP messages). If you need to know if a particular port is available, then you will need to look into the Sockets class.
0

Featured Post

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question