Check Windows Process memory
Check Windows Process memory
I am in need for checking the memory usage for a specific memory process, w3wp.exe (as an example)
I havent found anything for doing that for windows. ANybody know of one?
I havent found anything for doing that for windows. ANybody know of one?
Everybody is somebody else’s weirdo
Re: Check Windows Process memory
You should be able to use powershell, with the Get-Process command. From there, execute the check with NSClient and pull the information. Here's an example of the powershell Get-Process command. -
From there, filter for the type of memory you're looking for.
I was looking for a way to return the Memory (as task manager would), but this was the closest I could find.
Code: Select all
PS C:\Users\rkennedy> get-process firefox
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
984 166 551664 584716 1284 1,014.38 8172 firefox
I was looking for a way to return the Memory (as task manager would), but this was the closest I could find.
Former Nagios Employee
Re: Check Windows Process memory
Great, thank you. That almost is what I am looking for.
with the w3wp process, there can be multiple instances of it running.
I found how to get the Total memory used....but any idea on how to return only the one that is using the most memory?
Basicly, there is a need to check to see if any one process (in a single instance) is using more than 1 gig of memory.
with the w3wp process, there can be multiple instances of it running.
I found how to get the Total memory used....but any idea on how to return only the one that is using the most memory?
Basicly, there is a need to check to see if any one process (in a single instance) is using more than 1 gig of memory.
Everybody is somebody else’s weirdo
Re: Check Windows Process memory
You should be able to with this -
The sort-object will filter based on the highest WS, and then only show the first result.
An example -
Code: Select all
get-process vmware-vmx|sort-object -property ws -descending|select -first 1
An example -
Code: Select all
PS C:\Users\rkennedy> get-process vmware-vmx|sort-object -property ws -descending|select -first 1
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
407 27 33692 2036532 -1832 654.69 5896 vmware-vmx
Former Nagios Employee
Re: Check Windows Process memory
Great, and thank you again.
Which one of those columns is what I see when looking in task manager?
Which one of those columns is what I see when looking in task manager?
Code: Select all
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
1884 97 287676 314068 620 33.13 13072 SomeLameProcessNametheOurDevsMade
Everybody is somebody else’s weirdo
Re: Check Windows Process memory
Think I may have found it.....
but it is still a little bit off
Code: Select all
get-process Name of process|sort-object -property ws -descending|select Name,PrivateMemorySize -first 1Everybody is somebody else’s weirdo
Re: Check Windows Process memory
Did you mean it is a little bit off compared to what you see in the Windows Task Manager? It is normal to be a little bit off as you cannot check it at the exact same time.but it is still a little bit off
If this is a working solution for you, let us know if it is all right to lock this topic. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Check Windows Process memory
yeah, that's what I figured........
now i'm trying to figure out how to get that value back to Nagios.
when I send what it puts out, it gives.
other than figuring that out, you can close this.
now i'm trying to figure out how to get that value back to Nagios.
when I send what it puts out, it gives.
Code: Select all
WorkingSet
----------
469422080
Everybody is somebody else’s weirdo
Re: Check Windows Process memory
What command are you running to have it narrow down to that result? I looked around for ways to format things down to one line (which is what needs to be done) with powershell, but I haven't been able to find too much.
Former Nagios Employee
Re: Check Windows Process memory
oy.......this is killing me.... I am slowly getting closer. Let me show what I have going on so far.
The powershell script:
when the memory for the top user of w3wp (in task manager) reads 396,572 k the script reports 0.42 (close enough)
The powershell script:
Code: Select all
param([int] $warn, [int] $crit)
$Output1 = ""
$LastExitCode = 0
$output = ""
$myW3WP = Get-Process w3wp | Sort -Descending WS| select -first 1 | Measure-Object WS -Sum
$myW3WP = ("{0:N2} " -f ($myW3WP.sum / 1gb))
if ($myW3WP -gt $crit)
{
$LastExitCode = 2
}
elseif ($myW3WP -gt $warn)
{
$LastExitCode = 1
}
else
{
$LastExitCode = 0
}
$output = $LastExitCodeEverybody is somebody else’s weirdo