Question

Does anyone know of a way to programatically find the uptime of a server running Windows 2000? We have a service running on the machine written in VB.NET, that reports back to our server via a webservice.

Was it helpful?

Solution

Another way is to use the performance counters from .NET e.g.

Dim pc As PerformanceCounter = New PerformanceCounter("System", "System Up Time")

pc.NextValue() ' This returns zero for a reason I don't know

' This call to NextValue gets the correct value
Dim ts As TimeSpan = TimeSpan.FromSeconds(pc.NextValue())

So basically, the PerformanceCounter class will return the number of seconds the system has been up and from there you can do what you want.

OTHER TIPS

If you have SNMP enabled, you can query the following OID: 1.3.6.1.2.1.1.3.0. This will give you the system uptime. It is defined as "The time (in hundredths of a second) since the network management portion of the system was last re-initialized."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top