mickem / nscp

NSClient++
http://nsclient.org
GNU General Public License v2.0
239 stars 94 forks source link

How graphs are coming for the default services like memory disk cpu why not coming for custom scripts #661

Open grayloglearn opened 4 years ago

grayloglearn commented 4 years ago

Issue and Steps to Reproduce

Describe your issue and tell us how to reproduce it. How graphs are coming for the default services like memory disk cpu why not coming for custom scripts. What is the process for how default services are getting graphs?

PLEASE PROVIDE COMMAND HERE

Expected Behavior

Tell us what you think should happen. For custom scripts we are not getting graphs. Does script have capability to send performance graphs to nagios server ??, The below is the script which we are using to get the details from windows server. script.txt

Why when we call script from nagios server its showing only 9 rows, where as when we run the same script in windows server we could seen more than 300 rows. Do we have limitations on this to capture all rows??

Actual Behavior

when we call script from nagios server, In nagios console it showing only 9 rows instead of 300 rows.

Details

Additional Details

NSClient++ log:

PLEASE PASTE LOG HERE
mintsoft commented 4 years ago

There's a maximum payload size for nrpe (as part of the protocol) that is probably the reason that you're not seeing all the output. If you use the REST api (via check_nsc_web for example: https://github.com/m-kraus/check_nsc_web) You'll probably get the full output

nsissues12 commented 4 years ago

As i discussed with nagios support they told its limitations of nsclient. shall we increase this from nsclient configurations side. Could you please help on this.

Could you please help with at least how to call single scope monitoring with performance graph. We have followed below steps to call the single scope 1) In nsclient.cfg we have added the below line. check_DHCP_perscope = powershell.exe -command C:\Program` Files\NSClient++\scripts\check_DHCP_perscope.ps1 $ARG1$ And we are calling from server as below

nagios@nagi ~]$ /usr/local/nagios/libexec/check_nrpe -H DHCP t 120 -c check_DHCP_perscope -s 192.9.3.0 ** #Get-DhcpServerv4Scope : Cannot process argument transformation on parameter 'ScopeId'. Cannot convert value "$" to type "System.Net.IPAddress[]". Error: "Cannot convert value "$" to type "System.Net.IPAddress". Error: "An invalid IP address was specified."" At C:\Program Files\NSClient++\scripts\own\check_DHCP_perscope.ps1:75 char:43

We are getting the Error which is in Bold format.Could you please help to resolve this We need performance graph also could you please help with script if possible

mintsoft commented 4 years ago

@nsissues12 are you referencing the same problem as @grayloglearn or are the same person? If not it'd be better if you opened a new issue.

It looks like the argument 192.9.3.0 isn't getting through to the script, I'd guess you probably don't have:

[/settings/external scripts]
allow arguments = true

In your nsclient.cfg

nsissues12 commented 4 years ago

yes i am the same person. grayloglearn is my ID only,but that is in nagios support forum. Yes we have allow argument=1 in nsclient.cfg. But still we are getting the same error. Let me know if you need any info. Please tell me that we have chances to enabled the dhcp scope monitoring with snmp for windows server. Can you give the steps to enable please. Mean while pls help for the below issue. ; *** [/settings/external scripts] ; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed. allow arguments = 1

mintsoft commented 4 years ago

@nsissues12 I've not used nrpe for an absolute age, however I think the problem is that you've confused arguments to check_nrpe and arguments to the script itself. Based on: https://docs.nsclient.org/howto/nrpe/ it looks like -a is how you pass an argument to an nrpe check:

$ usr/local/nagios/libexec/check_nrpe -H DHCP t 120 -c check_DHCP_perscope -a 192.9.3.0

I'd assume then that $ARG1$ will end up being 192.9.3.0. If that's true, then we need to redefine the check in nsclient.cfg to include the -s that the script needs like:

check_DHCP_perscope = powershell.exe -command C:\Program` Files\NSClient++\scripts\check_DHCP_perscope.ps1 -s $ARG1$

I think that's probably going to work? I don't have an nrpe-configured setup I can test it with however, but that might get you moving in the right direction.

grayloglearn commented 4 years ago

This works it works for me. we are getting output after changing --s $ARG1$ and calling like usr/local/nagios/libexec/check_nrpe -H DHCP t 120 -c check_DHCP_perscope -a 192.9.3.0.

Can you help on that by changing the script as we should get the performance graphs over time (historical data). Can you tell how the default services cpu, memory are getting performance graph?. could you please explain.

mintsoft commented 4 years ago

This works it works for me. we are getting output after changing --s $ARG1$ and calling like usr/local/nagios/libexec/check_nrpe -H DHCP t 120 -c check_DHCP_perscope -a 192.9.3.0.

Glad to hear it!

Can you help on that by changing the script as we should get the performance graphs over time (historical data). Can you tell how the default services cpu, memory are getting performance graph?. could you please explain.

For both of these the scripts need to be updated to output the performance data in a format that the graphing solution you have (i.e. pnp4nagios or cacti I'd guess). Basically the output (i.e. write-host or write-out should be something like:

OK: All Scopes Are Good | free_ips=25; used_ips=100;

or whatever you want and then you should get free_ips and used_ips graphed. I'm not going to walk you through changing the script as it depends on which you're using and what you want to graph but some useful docs are here:

There's also loads of examples for this output format from basically any nagios/naemon check

mickem commented 4 years ago

If you run any of the built-in commands you can see the syntax of performance data (it is also documented over in the nagios docs). But the gist of it is anything after | is performance data and it has the syntax is: 'label'=value[UOM];[warn];[crit];[min];[max]

Does this mean the commnds is working so we can close the issue or do you need futher help?

mintsoft commented 4 years ago

@mickem the command is working fine; there's no NSClient problem here so I think close it :)

nsissues12 commented 4 years ago

@mickem and mintsoft, if you can change the script that will be good to me as well as the same will help in future so many peoples. As i don't have knowledge on this scripting.

And we are trying the same some other server it is giving error. In windows server itself the output is showing good how many or free and used but when i am calling the from nagios i am getting below error.

root@ip/usr/local/nagios/etc/services# /usr/local/nagios/libexec/check_nrpe -H 172.31.41.228 -t 120 -c check_DHCP_perscope -a 192.168.1.0 At C:\Program Files\NSClient++\scripts\check_DHCP_perscope.ps1.ps1:97 char:2

we have changed as you suggested but still getting error. This is in some other server. check_DHCP_perscope = powershell.exe -command C:\Program` Files\NSClient++\scripts\check_DHCP_perscope.ps1 -s $ARG1$

/usr/local/nagios/libexec/check_nrpe -H 172.31.41.228 -t 120 -c check_DHCP_perscope -a 192.168.1.0

the below output its showing when i run in safe mode nscp.exe test

D nrpe Accepting connection from: 172.31.40.170, count=1 D nrpe Accepting connection from: 172.31.40.170, count=1 D ext-script Command line: powershell.exe -command C:\Program` Files\NSClient++\scripts\check_DHCP_perscope.ps1 -s 192.168.1.0

mickem commented 4 years ago

check_DHCP_perscope.ps1.ps is not a part of NSClient++, so we cannot change it from here... Given that I cannot find the script anywhere my guess is that it is something written on your end?

nsissues12 commented 4 years ago

No we have not created it. We just get this from below link.

https://exchange.nagios.org/directory/Plugins/Network-Protocols/DHCP-and-BOOTP/check_dhcp_scopes/details

Could you please help with that error which we are getting.

**root@ip/usr/local/nagios/etc/services# /usr/local/nagios/libexec/check_nrpe -H 172.31.41.228 -t 120 -c check_DHCP_perscope -a 192.168.1.0 At C:\Program Files\NSClient++\scripts\check_DHCP_perscope.ps1.ps1:97 char:2

|'break ~ An'=0 'empty'=0 'pipe'=0 'element'=0 'is'=0 'not'=0 'allowed. '=0 '+'=0 'CategoryInfo'=0 ':'=0 'ParserError:'=0 '(:)'=0 '[],'=0 'ParseException '=0 '+'=0 'FullyQualifiedErrorId'=0 ':'=0 'EmptyPipeElement'=0 we have changed as you suggested but still getting error. This is in some other server. check_DHCP_perscope = powershell.exe -command C:\Program` Files\NSClient++\scripts\check_DHCP_perscope.ps1 -s $ARG1$

/usr/local/nagios/libexec/check_nrpe -H 172.31.41.228 -t 120 -c check_DHCP_perscope -a 192.168.1.0

the below output its showing when i run in safe mode nscp.exe test

D nrpe Accepting connection from: 172.31.40.170, count=1 D nrpe Accepting connection from: 172.31.40.170, count=1 D ext-script Command line: powershell.exe -command C:\Program` Files\NSClient++\scripts\check_DHCP_perscope.ps1 -s 192.168.1.0**

nsissues12 commented 4 years ago

can someone help on this please

mintsoft commented 4 years ago

@nsissues12 It's not really a problem we can help with as it's not an NSClient thing; you're probably better off finding a powershell forum (powershell.org maybe) to help you with the script