Not able to Run Powershell Script using NRPE

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Not able to Run Powershell Script using NRPE

Post by lmiltchev »

CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
Can you post the "nsclient.log" file?
Be sure to check out our Knowledgebase for helpful articles and solutions!
CloudOps
Posts: 88
Joined: Mon Feb 08, 2016 12:52 am

Re: Not able to Run Powershell Script using NRPE

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Not able to Run Powershell Script using NRPE

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
CloudOps
Posts: 88
Joined: Mon Feb 08, 2016 12:52 am

Re: Not able to Run Powershell Script using NRPE

Post 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??
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Not able to Run Powershell Script using NRPE

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
CloudOps
Posts: 88
Joined: Mon Feb 08, 2016 12:52 am

Re: Not able to Run Powershell Script using NRPE

Post 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?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Not able to Run Powershell Script using NRPE

Post 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?
Former Nagios employee
CloudOps
Posts: 88
Joined: Mon Feb 08, 2016 12:52 am

Re: Not able to Run Powershell Script using NRPE

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Not able to Run Powershell Script using NRPE

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
CloudOps
Posts: 88
Joined: Mon Feb 08, 2016 12:52 am

Re: Not able to Run Powershell Script using NRPE

Post 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
You do not have the required permissions to view the files attached to this post.
Locked