Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP, need a way to get memory useage trends per user 1

Status
Not open for further replies.

sparkbyte

Technical User
Sep 20, 2002
879
US
I am needing a way to get memory consumption stats on a per user level that can be leveraged to provide numbers to why I need to upgrade the RAM in roughly 30 servers.

Windows task manager is able to display process data with most of this data but not totaled on a per user, just per process.

Thanks everyone!!!!!!



Thanks

John Fuhrman
Titan Global Services
 
I would search this forum for examples of WMI scripts. The Win32_Process class has a property (I think it is called Owner) that indicates the owner of each process.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I am already playing with that, but not having much luck tying the owner to the correct process.


Code:
' List Process Owners

' Windows Server 2003 : Yes
' Windows XP : Yes
' Windows 2000 : YesX
' Windows NT 4.0 : Yes
' Windows 98 : Yes

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

Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")

For Each objProcess in colProcessList
    colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
If strNameOfUser = "jfuhrman" Then 
    Wscript.Echo "Process " & objProcess.Name & " is owned by " _ 
        & strUserDomain & "\" & strNameOfUser & "."

'On Error Resume Next
'Set colItems = objWMIService.ExecQuery("Select * from Win32_Process",,48)
'For Each objItem in colItems
'	WScript.Echo "Caption: " & objItem.Caption
'	WScript.Echo "Description: " & objItem.Description
'Next 
'On Error Goto 0 
End If 

Next
    WScript.Echo ""

'Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
'	WScript.Echo "CommandLine: " & objItem.CommandLine
'	WScript.Echo "CreationClassName: " & objItem.CreationClassName
'	WScript.Echo "CreationDate: " & objItem.CreationDate
'	WScript.Echo "CSCreationClassName: " & objItem.CSCreationClassName
'	WScript.Echo "CSName: " & objItem.CSName
'	WScript.Echo "ExecutablePath: " & objItem.ExecutablePath
'	WScript.Echo "ExecutionState: " & objItem.ExecutionState
'	WScript.Echo "Handle: " & objItem.Handle
'	WScript.Echo "HandleCount: " & objItem.HandleCount
'	WScript.Echo "InstallDate: " & objItem.InstallDate
'	WScript.Echo "KernelModeTime: " & objItem.KernelModeTime
'	WScript.Echo "MaximumWorkingSetSize: " & objItem.MaximumWorkingSetSize
'	WScript.Echo "MinimumWorkingSetSize: " & objItem.MinimumWorkingSetSize
'	WScript.Echo "Name: " & objItem.Name
'	WScript.Echo "OSCreationClassName: " & objItem.OSCreationClassName
'	WScript.Echo "OSName: " & objItem.OSName
'	WScript.Echo "OtherOperationCount: " & objItem.OtherOperationCount
'	WScript.Echo "OtherTransferCount: " & objItem.OtherTransferCount
'	WScript.Echo "PageFaults: " & objItem.PageFaults
'	WScript.Echo "PageFileUsage: " & objItem.PageFileUsage
'	WScript.Echo "ParentProcessId: " & objItem.ParentProcessId
'	WScript.Echo "PeakPageFileUsage: " & objItem.PeakPageFileUsage
'	WScript.Echo "PeakVirtualSize: " & objItem.PeakVirtualSize
'	WScript.Echo "PeakWorkingSetSize: " & objItem.PeakWorkingSetSize
'	WScript.Echo "Priority: " & objItem.Priority
'	WScript.Echo "PrivatePageCount: " & objItem.PrivatePageCount
'	WScript.Echo "ProcessId: " & objItem.ProcessId
'	WScript.Echo "QuotaNonPagedPoolUsage: " & objItem.QuotaNonPagedPoolUsage
'	WScript.Echo "QuotaPagedPoolUsage: " & objItem.QuotaPagedPoolUsage
'	WScript.Echo "QuotaPeakNonPagedPoolUsage: " & objItem.QuotaPeakNonPagedPoolUsage
'	WScript.Echo "QuotaPeakPagedPoolUsage: " & objItem.QuotaPeakPagedPoolUsage
'	WScript.Echo "ReadOperationCount: " & objItem.ReadOperationCount
'	WScript.Echo "ReadTransferCount: " & objItem.ReadTransferCount
'	WScript.Echo "SessionId: " & objItem.SessionId
'	WScript.Echo "Status: " & objItem.Status
'	WScript.Echo "TerminationDate: " & objItem.TerminationDate
'	WScript.Echo "ThreadCount: " & objItem.ThreadCount
'	WScript.Echo "UserModeTime: " & objItem.UserModeTime
'	WScript.Echo "VirtualSize: " & objItem.VirtualSize
'	WScript.Echo "WindowsVersion: " & objItem.WindowsVersion
'	WScript.Echo "WorkingSetSize: " & objItem.WorkingSetSize
'	WScript.Echo "WriteOperationCount: " & objItem.WriteOperationCount
'	WScript.Echo "WriteTransferCount: " & objItem.WriteTransferCount
'	WScript.Echo ""
'Next



Thanks

John Fuhrman
Titan Global Services
 
Does this work for you?

Code:
Option Explicit 
'On Error Resume Next

Dim strComputer, wmiQuery, objWMIService
Dim colItems, objItem, strUser, errRtn

strComputer = "."
wmiQuery = "Select * From Win32_Process"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery(wmiQuery)

For Each objItem in colItems
    WScript.Echo "Name: " & objItem.Name
    errRtn = objItem.GetOwner(strUser)
    WScript.Echo "Owner: " & strUser
Next

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
If the above works, then maybe you can add each user to a dictionary and add the memory for each.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thanks!! That does seem to identify processes by user, I just don't fully understatnd what you did.

For Each objItem in colItems
WScript.Echo "Name: " & objItem.Name
[highlight]errRtn = objItem.GetOwner(strUser)[/highlight]
WScript.Echo "Owner: " & strUser
WScript.Echo ""
Next

I see you use the GetOwner method but not sure why strUser has the value and not errRtn. Could you take just a sec and enlighten me?? This looks to be very useful for retrieving "narrowed" information using WMI.

Thanks very much for you seemingly never ending patience, your advise has been very helpful!! I hope to be able to return the favor(s)!!!

Oh, and a star [medal] for your code post and effort to help me....



Thanks

John Fuhrman
Titan Global Services
 
The reference:
As you can see, GetOwner will return the user and the domain. You simply need to provide it with a variable where it can put that information into.

errRtn simply shows if there was an error retrieving the information and is not really required. You could get the username like this too:

objItem.GetOwner strUser

Notice how you don't use the parenthesis when doing it this way.

I'm glad to have been of some help.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top