Page 4 of 6

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 3:10 pm
by lmiltchev
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
Can you post the "nsclient.log" file?

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 3:47 pm
by CloudOps
lmiltchev wrote:
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
Can you post the "nsclient.log" file?
I have attached the log file.

Re: Not able to Run Powershell Script using NRPE

Posted: Thu Mar 24, 2016 4:35 pm
by lmiltchev
Did you load the default settings in nsclient.ini file by running:

Code: Select all

nscp settings --generate --add-defaults --load-all
from the CMD prompt?

I suspect that running PS scripts fails because you are missing the "[/settings/external scripts/wrappings]" section.

Add the "defaults" AND restart the NSClient++ service.

Next, upload the "updated" nsclient.ini file, so that we can review it. We may need to modify some of the "timeout" settings in case this is what is causing the problem.

Re: Not able to Run Powershell Script using NRPE

Posted: Fri Mar 25, 2016 11:20 am
by CloudOps
lmiltchev wrote:Did you load the default settings in nsclient.ini file by running:

Code: Select all

nscp settings --generate --add-defaults --load-all
from the CMD prompt?

I suspect that running PS scripts fails because you are missing the "[/settings/external scripts/wrappings]" section.

Add the "defaults" AND restart the NSClient++ service.

Next, upload the "updated" nsclient.ini file, so that we can review it. We may need to modify some of the "timeout" settings in case this is what is causing the problem.
Hi lmiltchev,

Thanks for your help i am getting the output now. can we only check CPU usage of ? we are giving memwarn and memcrit, can we do similar for CPU usage??

Re: Not able to Run Powershell Script using NRPE

Posted: Fri Mar 25, 2016 12:26 pm
by lmiltchev
Great! I am glad we are moving to the right direction. :)

The CPU usage would be shown if some conditions were met. You have the following condition in the script:

Code: Select all

if (($CPUQueue -gt $CPUq) -and ($CPUpercent -gt $CPUp)) {
...
}
In my case, the "$CPUQueue" was 0 (zero), so I changed this condition to:

Code: Select all

if (($CPUQueue -lt $CPUq) -and ($CPUpercent -gt $CPUp)) {
...
}
for testing purposes (used "less than" instead of "greater than"), and tested it from the CLI to see if the CPU usage will be displayed.

Code: Select all

[root@localhost nagiosxi]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c myscript -a 'myPC -memwarn 85 -memcrit 95 -CPUq 1 -CPUp 0'

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
   1329     175   538800     669784  1597 ...71.21   1304 firefox
CRITICAL: CPU Queue = 0 CPU% = 13. firefox is using the most resources, its PID is 1304 |'CPU'=13%;;;0 'CPU'=0 'Queue'=0;;;0
Hope this helps.

Re: Not able to Run Powershell Script using NRPE

Posted: Fri Mar 25, 2016 12:50 pm
by CloudOps
lmiltchev wrote:Great! I am glad we are moving to the right direction. :)

The CPU usage would be shown if some conditions were met. You have the following condition in the script:

Code: Select all

if (($CPUQueue -gt $CPUq) -and ($CPUpercent -gt $CPUp)) {
...
}
In my case, the "$CPUQueue" was 0 (zero), so I changed this condition to:

Code: Select all

if (($CPUQueue -lt $CPUq) -and ($CPUpercent -gt $CPUp)) {
...
}
for testing purposes (used "less than" instead of "greater than"), and tested it from the CLI to see if the CPU usage will be displayed.

Code: Select all

[root@localhost nagiosxi]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c myscript -a 'myPC -memwarn 85 -memcrit 95 -CPUq 1 -CPUp 0'

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
   1329     175   538800     669784  1597 ...71.21   1304 firefox
CRITICAL: CPU Queue = 0 CPU% = 13. firefox is using the most resources, its PID is 1304 |'CPU'=13%;;;0 'CPU'=0 'Queue'=0;;;0
Hope this helps.
Hi lmiltchev,

Our requirement is : if any process usage memory more then 85 % then it should return the warning output with process name and memory usage.
For critical : if process memory usage is more than 90% then output with process name and memory usage.

and if any process CPU usage , For warning, if any process CPU usage with more than 85% then it should return the warning output with process name and cpu usage.

for critical, if any process cpu usage is more than 90% then output with process name and cpu usage of that process.

can you modify the script accordingly? is it possible?

Re: Not able to Run Powershell Script using NRPE

Posted: Fri Mar 25, 2016 2:06 pm
by tmcdonald
CloudOps wrote:[can you modify the script accordingly? is it possible?
A few lines here and there we can take care of, but anything more than that needs to be quoted as custom development. I can certainly start the conversation with sales and our developers if that is something you are interested in doing.

Before we do that though, I would need clarification on the examples you provided. You mention warning and critical behavior twice, but each mention seems to be the same scenario. Is there supposed to be any difference between the two?

Re: Not able to Run Powershell Script using NRPE

Posted: Fri Mar 25, 2016 2:17 pm
by CloudOps
tmcdonald wrote:
CloudOps wrote:[can you modify the script accordingly? is it possible?
A few lines here and there we can take care of, but anything more than that needs to be quoted as custom development. I can certainly start the conversation with sales and our developers if that is something you are interested in doing.

Before we do that though, I would need clarification on the examples you provided. You mention warning and critical behavior twice, but each mention seems to be the same scenario. Is there supposed to be any difference between the two?
can you confirm if any cost is involved in this??

in this script its showing the process name in output, but its not showing whether the process is related to CPU or Memory usage.

Re: Not able to Run Powershell Script using NRPE

Posted: Mon Mar 28, 2016 8:58 am
by lmiltchev
can you confirm if any cost is involved in this??
Definitely - it is a custom development. It could be a very reasonable cost though, depending on how much time our developers will have to spend modifying the script. You can contacts our sales team at [email protected], and request a quote for a custom development.

Re: Not able to Run Powershell Script using NRPE

Posted: Mon Mar 28, 2016 10:02 am
by CloudOps
lmiltchev wrote:
can you confirm if any cost is involved in this??
Definitely - it is a custom development. It could be a very reasonable cost though, depending on how much time our developers will have to spend modifying the script. You can contacts our sales team at [email protected], and request a quote for a custom development.

i will check with my team members for this.

Meanwhile this script is giving wrong output. i am attaching the output. Can you help here