Link to home
Start Free TrialLog in
Avatar of VelocityNet
VelocityNet

asked on

Monitor Process, CPU Usage and UserName

I'm looking to write a script that will query all processes, CPU usage and the username of the process.  I have found scripts that will give me the process and CPU usage, but not the username.  I am trying to automate a script that will look for processes that are using too much CPU and terminate them.  For example:

On a terminal server 10 users are running the same application:  'Office.exe'

All users instances of 'Office.exe' were running fine except for user 5.  User 5 has opened 4 instances of 'Office.exe' and each instance is using 25% CPU on a quad core system (all 4 cores are maxxed out).  This bogs down the server.  I would need the script to recognize the process and username that is associated with the process so it could terminate the process only for that user.  
Please help
Avatar of RobSampson
RobSampson
Flag of Australia image

Hi, I'm not sure that WMI can give you the username info, but I would have a look at combining / filtering the outputs from the command
tasklist /v
and from the PSList (http://technet.microsoft.com/en-us/sysinternals/bb896682.aspx) command:
pslist -m <processname>

where <processname> could probably be piped from each process name in the tasklist /v output.

Would that give you enough info?

Regards,

Rob.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial