Page 1 of 1

Number of CPU cores with CPULOAD (nsclient)

Posted: Thu Jan 07, 2016 11:16 am
by dlukinski
Hello Nagios Team

How to report number of CPU cores with check_xi_service_nsclient ?

Thank you

Re: Number of CPU cores with CPULOAD (nsclient)

Posted: Thu Jan 07, 2016 1:01 pm
by rkennedy
You should be able to do this with a powershell script. You'll need to create it, and then modify your nsclient configuration to include that external script as a command.

Here's the one liner powershell script. Create a file called check_cpu_cores.ps1 and place it in the C:\Program Files\NSClient++\scripts\powershell\ directory.

Code: Select all

Get-WmiObject -class Win32_processor | findstr NumberOfCores
Once you've created the file, open up your nsclient configuration and look for -

Code: Select all

[/settings/external scripts/scripts]
below that, add -

Code: Select all

;check_cpu_cores external script
check_cpu_cores = cmd /c echo scripts\powershell\check_cpu_cores.ps1; exit(0) | powershell.exe -command -
At this point you should be able to use the check_cpu_cores script. See an example output below -

Code: Select all

[root@suse11 libexec]# ./check_nrpe -H 192.168.5.47 -c check_cpu_cores
NumberOfCores               : 4

Re: Number of CPU cores with CPULOAD (nsclient)

Posted: Thu Jan 07, 2016 3:03 pm
by dlukinski
rkennedy wrote:You should be able to do this with a powershell script. You'll need to create it, and then modify your nsclient configuration to include that external script as a command.

Here's the one liner powershell script. Create a file called check_cpu_cores.ps1 and place it in the C:\Program Files\NSClient++\scripts\powershell\ directory.

Code: Select all

Get-WmiObject -class Win32_processor | findstr NumberOfCores
Once you've created the file, open up your nsclient configuration and look for -

Code: Select all

[/settings/external scripts/scripts]
below that, add -

Code: Select all

;check_cpu_cores external script
check_cpu_cores = cmd /c echo scripts\powershell\check_cpu_cores.ps1; exit(0) | powershell.exe -command -
At this point you should be able to use the check_cpu_cores script. See an example output below -

Code: Select all

[root@suse11 libexec]# ./check_nrpe -H 192.168.5.47 -c check_cpu_cores
NumberOfCores               : 4
Thank you, so either that or SNMP (which provides Cores information)
- we could now close this one.

Re: Number of CPU cores with CPULOAD (nsclient)

Posted: Thu Jan 07, 2016 3:15 pm
by bwallace
Glad we were able to help. We'll lock this thread now and feel free to open another should you require assistance with anything else.