Page 2 of 2

Re: Monitor top 10 processes using up the most memory

Posted: Tue Mar 22, 2016 2:27 pm
by rkennedy
CloudOps wrote:
rkennedy wrote:You'll need to create the corresponding script (ps1 or sh), and then create a command for it in NSClient++ / NRPE.

For example, in NSClient++, it would be similar to this -

Code: Select all

topcpu = cmd /c echo scripts\powershell\topcpu.ps1; exit(0) | powershell.exe -command -
Then, you'll need to create an event handler to trigger the newly created commands over check_nrpe / check_nt. Once those have been created, assign the event handler to the service that's checking your MEM or CPU. Any time a state change occurs, it will log the data to the corresponding file on the local client machine.
Hi rkennedy,

i have to save the command into ps1 file?

command " date | Out-File "C:\Program Files\NSClient++\scripts\powershell\topcpu.txt" -append
Get-Process | Sort CPU | Select -last 10 | Out-File "C:\Program Files\NSClient++\scripts\powershell\topcpu.txt" -append "

then add into nsclient file? i have tried that but throwing some error.

Also i have powershell script to get process memory usage , can you guide me to get the output to display in nagios :
"get-wmiobject WIN32_PROCESS | Sort-Object -Property ws -Descending|select -first 5|Select processname, @{Name="Mem Usage(MB)";Expression={[math]::round($_.ws / 1mb)/1024}} "
Yes, please save that as C:\Program Files\NSClient++\scripts\powershell\topcpu.ps1

Then, under your external scripts section of NSClient++, add -

Code: Select all

topcpu = cmd /c echo scripts\powershell\topcpu.ps1; exit(0) | powershell.exe -command -
What error are you seeing?

Can you please open a new post for your second request here? I'd like to keep this thread on topic to what has been discussed.

Re: Monitor top 10 processes using up the most memory

Posted: Tue Mar 22, 2016 3:16 pm
by CloudOps
rkennedy wrote:
CloudOps wrote:
rkennedy wrote:You'll need to create the corresponding script (ps1 or sh), and then create a command for it in NSClient++ / NRPE.

For example, in NSClient++, it would be similar to this -

Code: Select all

topcpu = cmd /c echo scripts\powershell\topcpu.ps1; exit(0) | powershell.exe -command -
Then, you'll need to create an event handler to trigger the newly created commands over check_nrpe / check_nt. Once those have been created, assign the event handler to the service that's checking your MEM or CPU. Any time a state change occurs, it will log the data to the corresponding file on the local client machine.
Hi rkennedy,

i have to save the command into ps1 file?

command " date | Out-File "C:\Program Files\NSClient++\scripts\powershell\topcpu.txt" -append
Get-Process | Sort CPU | Select -last 10 | Out-File "C:\Program Files\NSClient++\scripts\powershell\topcpu.txt" -append "

then add into nsclient file? i have tried that but throwing some error.

Also i have powershell script to get process memory usage , can you guide me to get the output to display in nagios :
"get-wmiobject WIN32_PROCESS | Sort-Object -Property ws -Descending|select -first 5|Select processname, @{Name="Mem Usage(MB)";Expression={[math]::round($_.ws / 1mb)/1024}} "
Yes, please save that as C:\Program Files\NSClient++\scripts\powershell\topcpu.ps1

Then, under your external scripts section of NSClient++, add -

Code: Select all

topcpu = cmd /c echo scripts\powershell\topcpu.ps1; exit(0) | powershell.exe -command -
What error are you seeing?

Can you please open a new post for your second request here? I'd like to keep this thread on topic to what has been discussed.
Hi rkennedy,
i have opened a new post. please reply on that.

thanks

Re: Monitor top 10 processes using up the most memory

Posted: Wed Mar 23, 2016 9:08 am
by rkennedy
Will do, I'll watch for your new post so we can continue there. I'll be closing this one out now.