SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Member
    Join Date
    Sep 2009
    Posts
    262
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Get the CPU capacity through QTP

    Is there a way to get the “CPU” usage via QTP? I have a task where I need to get the CPU usage, memory usage for my application. I used “Local System Monitor” , but does not include CPU usage.

  2. #2
    Senior Member
    Join Date
    Dec 2006
    Location
    Germany, Dresden
    Posts
    1,536
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get the CPU capacity through QTP

    you have a perfomrance monitor included in QTP 10, try this ine out, you will get the parameters you need associated to your steps
    http://qcmt.pc-polis.de

    de omnibus dubitandum

    For all Questions: Please be sure to take a look at the QTP Manual before posting any Questions, thanks for doing this

  3. #3
    Senior Member
    Join Date
    Mar 2009
    Posts
    184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get the CPU capacity through QTP

    Try this

    Set objArgs = WScript.Arguments
    strComputer =objArgs(0)
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colProcess = objWMIService.ExecQuery("Select * from Win32_PerfFormattedData_PerfProc_Process",,48)
    wscript.echo "Computer Name, Process Name, CPU Usage"
    For Each objItem in colProcess
    if objItem.Name <> "Idle" and objItem.Name <> "_Total" then
    wscript.echo strcomputer & ", " & objItem.Name & ","& objItem.PercentProcessorTime
    end if
    Next

    You will need to supply the name of the machine. I have only run this at the command prompt. Not in QTP.

  4. #4
    Member
    Join Date
    Aug 2008
    Posts
    150
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get the CPU capacity through QTP

    You can get the memory usage as well (if you don't have QTP 10):

    <font class="small">Code:</font><hr /><pre>
    Public function Get_Mem_Usage (APP_ID)
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2")
    Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process")
    For Each objProcess in colProcessList
    If objProcess.Name = APP_ID Then
    test1 = objProcess.WorkingSetSize
    End If
    Next
    Get_Mem_Usage = test1/1000
    End function
    </pre><hr />

  5. #5
    Member
    Join Date
    Sep 2009
    Posts
    262
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get the CPU capacity through QTP

    what is strComputer? could you give me an example?

  6. #6
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Get the CPU capacity through QTP

    it is the name of computer. If you want to check it on local system then you can use "."

  7. #7
    Member
    Join Date
    Sep 2009
    Posts
    262
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get the CPU capacity through QTP

    Thank you, Tarun

  8. #8
    Member
    Join Date
    Sep 2009
    Posts
    262
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get the CPU capacity through QTP

    I am trying to use the following function:
    Public function Get_Mem_Usage (APP_ID)
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _ &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2")
    Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process")
    For Each objProcess in colProcessList
    If objProcess.Name = APP_ID Then
    test1 = objProcess.WorkingSetSize
    End If
    Next
    Get_Mem_Usage = test1/1000End function

    Now I have 2 computer names: Computer name: SA-TA-987 and Full computer name: SA-Ta-987.sab.sam.com. Which one I need to use for this function? please show me how it is done; I mean how to apply it to the function

    If I used my computer full name for the variable strComputer (i.e., strComputer = "SA-Ta-987.sab.sam.com"), I get this run error: The test run cannot continue due to a syntax error: Invalid character Line (1): Set objWMIService = GetObject("winmgmts:" _ &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2")

    Thank you,

  9. #9
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Get the CPU capacity through QTP

    If the script is running on the same machine for which you want to check the process then just use ".". The issue in your code is that once you put _ then the line should end

    Set objWMIService = GetObject("winmgmts:" _ &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2")

    should be

    Set objWMIService = GetObject("winmgmts:" _
    &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2")

  10. #10
    Junior Member
    Join Date
    Aug 2010
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Get the CPU capacity through QTP

    Hi everybody
    So there isn't a way to get the cpu usage of a process through qtp 9.5??!
    Your solution only gave me memory...
    thank you

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.38%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:09 AM.

Copyright BetaSoft Inc.