-
NT Server System Uptime
Hi, I am trying to get an NT Server's uptime (Since the time of its last reboot)
and I have been unable to find anywhere this is possible. I would like to
do this within VB (by calling a dll if possible).
I have tried the following:
1. Reading the eventlog and searching through it to locate EventID 6005 and
obtain the time and subtract it from current date/time. The problem is, if
the event log has been cleared, it is no longet useful and the statistice
would not be correct.
2. Using it through SNMP (there is a Sys Uptime MIB within it), but I am
unable to formulate the correct syntax to obtain this information, also I
believe it runs asynchronously, meaning if I try and run it, my machine will
hang until it receives a response from the target machine.
3. I have tried using the STAT_SERVER_0 type and the Function NetStatisticsGet
Lib "Netapi32.dll" (lpSvrName As Any, lpService As Any, ByVal Level As Long,
ByVal Options As Long, lpBuffer As Any) As Long function, when I get the
sts0_start variable (nbr of seconds since 1970 - Pres date in seconds, it
seems to be off by a day and a half, and I am not even sure if this correct.
4. I have tried obtaining it from HKEY_PERFORMANCE_DATA\System Uptime key,
this is stored as an 8 byte binary value, but I can't seem to retrieve it
correctly.
Is there any way of obtaining this information, I have been unable to find
it and there must be an easier way than the ones I have tried.
Any help would be appreciated.
Thank you.
-
Re: NT Server System Uptime
RJ Krawchuk wrote:
> Hi, I am trying to get an NT Server's uptime (Since the time of its last
reboot)
> and I have been unable to find anywhere this is possible. I would like to
> do this within VB (by calling a dll if possible).
Have you tried the timeGetTime and/or timeGetSystemTime found in the
Winmm.dll ?
The documentation says:
"The timeGetSystemTime function retrieves the system time, in milliseconds.
The system time is the time elapsed since Windows was started. This function
works very much like the timeGetTime function. See timeGetTime for details
of these functions' operation."
"The timeGetTime function retrieves the system time, in milliseconds. The
system time is the time elapsed since Windows was started."
-------
Tomas
-
Re: NT Server System Uptime
"Tomas Christiansen" <toc@blikroer.dk.PLEASEREMOVETHIS> wrote:
>RJ Krawchuk wrote:
>> Hi, I am trying to get an NT Server's uptime (Since the time of its last
>reboot)
>> and I have been unable to find anywhere this is possible. I would like
to
>> do this within VB (by calling a dll if possible).
>
>Have you tried the timeGetTime and/or timeGetSystemTime found in the
>Winmm.dll ?
>
>The documentation says:
>
>"The timeGetSystemTime function retrieves the system time, in milliseconds.
>The system time is the time elapsed since Windows was started. This function
>works very much like the timeGetTime function. See timeGetTime for details
>of these functions' operation."
>
>"The timeGetTime function retrieves the system time, in milliseconds. The
>system time is the time elapsed since Windows was started."
>
>-------
>Tomas
>
HI,
Yes I have, unfortunately, it starts back at 0 again after 49 days.
-
Re: NT Server System Uptime
On 21 Mar 2000 04:01:05 -0800, "RJ Krawchuk" <Robert.Krawchuk@gs.com> wrote:
»
»"Tomas Christiansen" <toc@blikroer.dk.PLEASEREMOVETHIS> wrote:
»>RJ Krawchuk wrote:
»>> Hi, I am trying to get an NT Server's uptime (Since the time of its last
»>reboot)
(snip)
»>Have you tried the timeGetTime and/or timeGetSystemTime found in the
»>Winmm.dll ?
(snip)
»
»Yes I have, unfortunately, it starts back at 0 again after 49 days.
How about QueryPerformanceCounter and QueryPerformanceFrequency?
-
Re: NT Server System Uptime
Hi RJ --
>Hi, I am trying to get an NT Server's uptime (Since the time of its last reboot)
>and I have been unable to find anywhere this is possible. I would like to
>do this within VB (by calling a dll if possible).
MS has a tool that provides this info:
http://www.microsoft.com/ntserver/nt...me/default.asp
http://support.microsoft.com/support.../q232/2/43.asp
But it appears it's using (one of) the same strategies you are -- hitting the event
log.
>sts0_start variable (nbr of seconds since 1970 - Pres date in seconds, it
>seems to be off by a day and a half, and I am not even sure if this correct.
Did you account for that number being in GMT? That might explain part of the
discrepancy you see?
Good luck... Karl
-
Re: NT Server System Uptime
Paul Marshall <pmarshal@vulcraft-al.com> wrote:
>On 21 Mar 2000 04:01:05 -0800, "RJ Krawchuk" <Robert.Krawchuk@gs.com> wrote:
>
>»
>»"Tomas Christiansen" <toc@blikroer.dk.PLEASEREMOVETHIS> wrote:
>»>RJ Krawchuk wrote:
>»>> Hi, I am trying to get an NT Server's uptime (Since the time of its
last
>»>reboot)
>
>(snip)
>
>»>Have you tried the timeGetTime and/or timeGetSystemTime found in the
>»>Winmm.dll ?
>
>(snip)
>
>»
>»Yes I have, unfortunately, it starts back at 0 again after 49 days.
>
>How about QueryPerformanceCounter and QueryPerformanceFrequency?
>
Hi,
I have tried accessing the System Uptime Value from HKEY_PERFORMANCE_DATA
in the registry. It is binary data whose value is stored as an 8 byte value,
unformtunately, I do not know the layout of structure.
-
Re: NT Server System Uptime
On 27 Mar 2000 05:37:12 -0800, "RJ Krawchuk" <Robert.Krawchuk@gs.com> wrote:
»>How about QueryPerformanceCounter and QueryPerformanceFrequency?
»>
»I have tried accessing the System Uptime Value from HKEY_PERFORMANCE_DATA
»in the registry. It is binary data whose value is stored as an 8 byte value,
»unformtunately, I do not know the layout of structure.
Can't help you there. How about this instead:
==========
Private Declare Function QueryPerformanceCounter Lib "kernel32" _
(lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" _
(lpFrequency As Currency) As Long
Public Function SystemUpTimeInSeconds() As Double
Dim curCount As Currency
Dim curFreq As Currency
Call QueryPerformanceCounter(curCount)
Call QueryPerformanceFrequency(curFreq)
SystemUpTimeInSeconds = curCount / curFreq
End Function
==========
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks