Monitoring databases - VB .NET
I would like to develop a Windows Service in开发者_运维知识库 VB.NET to monitor different SQL databases running in different servers.
The user will enter/define connection string for each database. Also he/she will define connection interval.
For example, database A needs to be checked in every 5 mins and database B needs to be checked every 24 hours.
What is the best approach for this project?
Thanks.
A Windows Service that has a while loop should suffice:
While (m_serviceIsStopping = False)
For Each _server In _serverList
If ServerNeedsToBeChecked(_server) Then
CheckServer(_server)
End If
Next
Thread.Sleep(100)
End While
The thread sleep is important to make sure the CPU doesn't get used up.
While some here may recommend to do so, DO NOT USE THE TIMER CLASS IN A SERVICE. They fail silently.
Also, I have written this kind of thing before and that's a very long interval if you are checking "up" or blocking status. Something like every minute or so would probably be a better indicator.
精彩评论