Need to capture cpu utilization with top process
-
lanxessinfy
- Posts: 68
- Joined: Tue Nov 24, 2020 5:55 am
Need to capture cpu utilization with top process
Hi Team,
Need to capture cpu utilization with top process consuming load for windows server
Currently the we are monitoring the load average using nsclient agent , please let us know if plugins any to capture above metrics for windows system.
Need to capture cpu utilization with top process consuming load for windows server
Currently the we are monitoring the load average using nsclient agent , please let us know if plugins any to capture above metrics for windows system.
Re: Need to capture cpu utilization with top process
Hi,
How are you doing?
Please check Nagios Exchange page below, I'm sure you will find one that will fit your needs.
https://exchange.nagios.org/
Another solution you could try is to write a PowerShell script (below), then call its using "check_nrpe", since you already have NSClient++ installed on those remote machines.
I'm not a PS programmer, so this is what I found on the web which will list top 5 CPU
Get-Process gives the amount of processor time that the process has used on all processors
Best Regards,
Vinh
How are you doing?
Please check Nagios Exchange page below, I'm sure you will find one that will fit your needs.
https://exchange.nagios.org/
Another solution you could try is to write a PowerShell script (below), then call its using "check_nrpe", since you already have NSClient++ installed on those remote machines.
I'm not a PS programmer, so this is what I found on the web which will list top 5 CPU
Code: Select all
Get-Process | Sort -Descending CPU | Select -First 5Best Regards,
Vinh
-
lanxessinfy
- Posts: 68
- Joined: Tue Nov 24, 2020 5:55 am
Re: Need to capture cpu utilization with top process
Hi Team,
Is there any possible to call this command(Get-Process | Sort -Descending CPU | Select -First 5) when CPU load is more than 80%..
Thanks in advance.
Is there any possible to call this command(Get-Process | Sort -Descending CPU | Select -First 5) when CPU load is more than 80%..
Thanks in advance.
Re: Need to capture cpu utilization with top process
Hi,
How are you doing?
You might have to write a PowerShell script to do that.
Here's an example, please NOTE you will have to modify this as I am NOT a PowerShell programmer:
Best Regards,
Vinh
How are you doing?
You might have to write a PowerShell script to do that.
Here's an example, please NOTE you will have to modify this as I am NOT a PowerShell programmer:
Code: Select all
Try {
$Threshold = 79
$CpuLoad = (Get-WmiObject win32_processor | Measure-Object -property LoadPercentage -Average | Select Average ).Average
IF($CpuLoad -gt $Threshold) {
Write-Output (Get-Process | Sort -Descending CPU | Select -First 5 | Format-Table -HideTableHeaders)
} Else {
Write-Host "CPU load is" $CpuLoad "%"
}
}
Catch {
Write-Host "Script Check Failed"
}
Best Regards,
Vinh
-
lanxessinfy
- Posts: 68
- Joined: Tue Nov 24, 2020 5:55 am
Re: Need to capture cpu utilization with top process
Hi,
could you please let us know how to call above script.
thanks in advance.
could you please let us know how to call above script.
thanks in advance.
Re: Need to capture cpu utilization with top process
Hi,
How are you doing?
Since I am assuming you will be calling this using the "check_nrpe" with your NSClient already installed.
Please follow the KB below I found on the web:
https://docs.nsclient.org/howto/external_scripts/
Best Regards,
Vinh
How are you doing?
Since I am assuming you will be calling this using the "check_nrpe" with your NSClient already installed.
Please follow the KB below I found on the web:
https://docs.nsclient.org/howto/external_scripts/
Best Regards,
Vinh
-
lanxessinfy
- Posts: 68
- Joined: Tue Nov 24, 2020 5:55 am
Re: Need to capture cpu utilization with top process
Hi I have Created the file with above command as ProcessMonitoring.ps1 in Scripts folder and have Called in
Nsclient.ini as ProcessMonitoring=cscript.exe //T:30 //NoLogo scripts\\ProcessMonitoring.ps1 $ARG1
But when I test this I'm getting this.
[root@xxxxxxxxx libexec]# ./check_nrpe -H xx.xx.xx.xx -2 -t 30 -c ProcessMonitoring
Input Error: There is no script engine for file extension ".ps1".
Nsclient.ini as ProcessMonitoring=cscript.exe //T:30 //NoLogo scripts\\ProcessMonitoring.ps1 $ARG1
But when I test this I'm getting this.
[root@xxxxxxxxx libexec]# ./check_nrpe -H xx.xx.xx.xx -2 -t 30 -c ProcessMonitoring
Input Error: There is no script engine for file extension ".ps1".
Re: Need to capture cpu utilization with top process
Hi,
How are you doing?
Please make sure you have PowerShell installed.
Also, please add your script under the section called below inside the "nsclient.ini" file:
Once done edit the "nsclient.ini" file, please restart NSClient++ services agent.
Example:
Best Regards,
Vinh
How are you doing?
Please make sure you have PowerShell installed.
Also, please add your script under the section called below inside the "nsclient.ini" file:
Code: Select all
[/settings/external scripts/scripts]
Code: Select all
net stop nscp
net start nscp
Code: Select all
[/settings/external scripts/scripts]
restart_service = scripts\restart_service.bat "$ARG1$"
check_windows_time = scripts\check_windows_time.bat $ARG1$
Vinh
-
lanxessinfy
- Posts: 68
- Joined: Tue Nov 24, 2020 5:55 am
Re: Need to capture cpu utilization with top process
HI Vinh
Thanks much.
we are now able to get the output. The mistake was the last line in nsclient.ini
ProcessMonitoring = cmd /c echo scripts\\ProcessMonitoring.ps1 $ARG1$ "$ARG2$"; exit($lastexitcode) | powershell.exe -command -
Could you please let me know what is the average time here? and can we set average time?
Thanks much.
we are now able to get the output. The mistake was the last line in nsclient.ini
ProcessMonitoring = cmd /c echo scripts\\ProcessMonitoring.ps1 $ARG1$ "$ARG2$"; exit($lastexitcode) | powershell.exe -command -
Could you please let me know what is the average time here? and can we set average time?
Re: Need to capture cpu utilization with top process
Hi,
How are you doing?
I'm sorry, but I am not sure I understand what you meant by "average time".
I thought this ticket was to get CPU utilization with top processes.
Best Regards,
Vinh
How are you doing?
I'm sorry, but I am not sure I understand what you meant by "average time".
I thought this ticket was to get CPU utilization with top processes.
Best Regards,
Vinh