DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Thread: Re: CPU Usage

  1. #1
    Chris Fitzsimons Guest

    Re: CPU Usage


    I have a very similar class using the registry to get the CPU usage. I have
    been unsuccessful in getting it to work under Windows NT. Does anyone know
    of an API or a way to hook into the Windows NT performance monitor to get
    usage?



    tjeshGibberish@mindspring.com (Tom Esh) wrote:
    >Hmm... simpler than mine. I just fired up Regmon again - jeez I
    >completely missed the StopStat on close before. Looks like maybe you
    >found the bare minimum.
    >
    >On Thu, 9 Mar 2000 18:21:53 -0500, "David Crowell" <davidc@qtm.net>
    >wrote:
    >
    >>Okay, I managed to find MSKB article Q174631
    >>
    >>It gives an example (in C) of how to do it, I managed to get it working

    in
    >>VB also.
    >>
    >>I re-wrote the class module to do the following:
    >>
    >>in Class_Inititalize:
    >>RegOpenKey -- HKDD\PerfStats\StartStat
    >>RegQueryKeyEx -- KERNEL\CPUUsage
    >>RegCloseKey -- HKDD\PerfStats\StartStat
    >>RegOpenKey -- HKDD\PerfStats\StatData
    >>
    >>in the Usage property get (call as many times as needed):
    >>RegQueryKeyEx -- KERNEL\CPUUsage (from above open HKDD\PerfStats\StatData)
    >>
    >>in Class_Terminate:
    >>RegCloseKey -- HKDD\PerfStats\StatData
    >>RegOpenKey -- HKDD\PerfStats\StopStat
    >>RegQueryKeyEx -- KERNEL\CPUUsage
    >>RegCloseKey -- HKDD\PerfStats\StopStat
    >>
    >>
    >>The StartSrv does not appear to be needed. I'm also not going to worry
    >>about an NT version, as I don't have NT to test with.
    >>
    >>Anyway, thanks for the pointers.
    >>
    >>Dave
    >>
    >>
    >>> For example gathering Win9x CPU usage the sequence is:
    >>> 1) Open StatData, stash the key and leave it open 'till you're done
    >>> monitoring or your app closes.
    >>> 2) Open StartSrv and StopSrv
    >>> 3) Query the value of StartSrv\KERNEL. (It's a throwaway, but
    >>> apparently necessary.)
    >>> 4) Open StartStat
    >>> 5) Query the value of StartStat\KERNEL\CPUUsage. (Another throwaway.)
    >>> 6) Close StartStat
    >>> 7) Query the value of StopSrv\KERNEL. (throwaway).
    >>> 8) Close StartSrv and StopSrv
    >>>
    >>> 9) Query StatData\KERNEL\CPUUsage as needed
    >>> 10) Close StatData

    >>newsgroup)
    >>
    >>

    >
    >
    >-Tom
    >(please post replies to the newsgroup)



  2. #2
    Garth Oatley Guest

    Re: CPU Usage

    Hi,

    If we're talking NT then you can use the Performance Data Helper library.
    An example of this can be found at

    http://www.netfokus.dk/vbadmincode/w...tm#Performance

    You can also connect to remote servers using this library.

    --
    Regards,

    Garth Oatley

    Take a look at http://www.netfokus.dk/vbadmincode
    "Chris Fitzsimons" <fitzsic@byte400.demon.co.uk> wrote in message
    news:38ccd673$1@news.devx.com...
    >
    > I have a very similar class using the registry to get the CPU usage. I

    have
    > been unsuccessful in getting it to work under Windows NT. Does anyone

    know
    > of an API or a way to hook into the Windows NT performance monitor to get
    > usage?
    >
    >
    >
    > tjeshGibberish@mindspring.com (Tom Esh) wrote:
    > >Hmm... simpler than mine. I just fired up Regmon again - jeez I
    > >completely missed the StopStat on close before. Looks like maybe you
    > >found the bare minimum.
    > >
    > >On Thu, 9 Mar 2000 18:21:53 -0500, "David Crowell" <davidc@qtm.net>
    > >wrote:
    > >
    > >>Okay, I managed to find MSKB article Q174631
    > >>
    > >>It gives an example (in C) of how to do it, I managed to get it working

    > in
    > >>VB also.
    > >>
    > >>I re-wrote the class module to do the following:
    > >>
    > >>in Class_Inititalize:
    > >>RegOpenKey -- HKDD\PerfStats\StartStat
    > >>RegQueryKeyEx -- KERNEL\CPUUsage
    > >>RegCloseKey -- HKDD\PerfStats\StartStat
    > >>RegOpenKey -- HKDD\PerfStats\StatData
    > >>
    > >>in the Usage property get (call as many times as needed):
    > >>RegQueryKeyEx -- KERNEL\CPUUsage (from above open

    HKDD\PerfStats\StatData)
    > >>
    > >>in Class_Terminate:
    > >>RegCloseKey -- HKDD\PerfStats\StatData
    > >>RegOpenKey -- HKDD\PerfStats\StopStat
    > >>RegQueryKeyEx -- KERNEL\CPUUsage
    > >>RegCloseKey -- HKDD\PerfStats\StopStat
    > >>
    > >>
    > >>The StartSrv does not appear to be needed. I'm also not going to worry
    > >>about an NT version, as I don't have NT to test with.
    > >>
    > >>Anyway, thanks for the pointers.
    > >>
    > >>Dave
    > >>
    > >>
    > >>> For example gathering Win9x CPU usage the sequence is:
    > >>> 1) Open StatData, stash the key and leave it open 'till you're done
    > >>> monitoring or your app closes.
    > >>> 2) Open StartSrv and StopSrv
    > >>> 3) Query the value of StartSrv\KERNEL. (It's a throwaway, but
    > >>> apparently necessary.)
    > >>> 4) Open StartStat
    > >>> 5) Query the value of StartStat\KERNEL\CPUUsage. (Another throwaway.)
    > >>> 6) Close StartStat
    > >>> 7) Query the value of StopSrv\KERNEL. (throwaway).
    > >>> 8) Close StartSrv and StopSrv
    > >>>
    > >>> 9) Query StatData\KERNEL\CPUUsage as needed
    > >>> 10) Close StatData
    > >>newsgroup)
    > >>
    > >>

    > >
    > >
    > >-Tom
    > >(please post replies to the newsgroup)

    >




  3. #3
    Garth Oatley Guest

    Re: CPU Usage

    Hi,

    If we're talking NT then you can use the Performance Data Helper library.
    An example of this can be found at

    http://www.netfokus.dk/vbadmincode/w...tm#Performance

    You can also connect to remote servers using this library.

    --
    Regards,

    Garth Oatley

    Take a look at http://www.netfokus.dk/vbadmincode
    "Chris Fitzsimons" <fitzsic@byte400.demon.co.uk> wrote in message
    news:38ccd673$1@news.devx.com...
    >
    > I have a very similar class using the registry to get the CPU usage. I

    have
    > been unsuccessful in getting it to work under Windows NT. Does anyone

    know
    > of an API or a way to hook into the Windows NT performance monitor to get
    > usage?
    >
    >
    >
    > tjeshGibberish@mindspring.com (Tom Esh) wrote:
    > >Hmm... simpler than mine. I just fired up Regmon again - jeez I
    > >completely missed the StopStat on close before. Looks like maybe you
    > >found the bare minimum.
    > >
    > >On Thu, 9 Mar 2000 18:21:53 -0500, "David Crowell" <davidc@qtm.net>
    > >wrote:
    > >
    > >>Okay, I managed to find MSKB article Q174631
    > >>
    > >>It gives an example (in C) of how to do it, I managed to get it working

    > in
    > >>VB also.
    > >>
    > >>I re-wrote the class module to do the following:
    > >>
    > >>in Class_Inititalize:
    > >>RegOpenKey -- HKDD\PerfStats\StartStat
    > >>RegQueryKeyEx -- KERNEL\CPUUsage
    > >>RegCloseKey -- HKDD\PerfStats\StartStat
    > >>RegOpenKey -- HKDD\PerfStats\StatData
    > >>
    > >>in the Usage property get (call as many times as needed):
    > >>RegQueryKeyEx -- KERNEL\CPUUsage (from above open

    HKDD\PerfStats\StatData)
    > >>
    > >>in Class_Terminate:
    > >>RegCloseKey -- HKDD\PerfStats\StatData
    > >>RegOpenKey -- HKDD\PerfStats\StopStat
    > >>RegQueryKeyEx -- KERNEL\CPUUsage
    > >>RegCloseKey -- HKDD\PerfStats\StopStat
    > >>
    > >>
    > >>The StartSrv does not appear to be needed. I'm also not going to worry
    > >>about an NT version, as I don't have NT to test with.
    > >>
    > >>Anyway, thanks for the pointers.
    > >>
    > >>Dave
    > >>
    > >>
    > >>> For example gathering Win9x CPU usage the sequence is:
    > >>> 1) Open StatData, stash the key and leave it open 'till you're done
    > >>> monitoring or your app closes.
    > >>> 2) Open StartSrv and StopSrv
    > >>> 3) Query the value of StartSrv\KERNEL. (It's a throwaway, but
    > >>> apparently necessary.)
    > >>> 4) Open StartStat
    > >>> 5) Query the value of StartStat\KERNEL\CPUUsage. (Another throwaway.)
    > >>> 6) Close StartStat
    > >>> 7) Query the value of StopSrv\KERNEL. (throwaway).
    > >>> 8) Close StartSrv and StopSrv
    > >>>
    > >>> 9) Query StatData\KERNEL\CPUUsage as needed
    > >>> 10) Close StatData
    > >>newsgroup)
    > >>
    > >>

    > >
    > >
    > >-Tom
    > >(please post replies to the newsgroup)

    >




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links