Page 2 of 3
Re: Passive check configuration with ncpa and nsca
Posted: Wed Feb 05, 2020 10:17 pm
by grayloglearn
thanks for the replay.
I have tested as you suggested i have done changes in script and we are getting output as you suggest but still i am not getting out put in nagios console and graphs.
Please find the attachment for the output of the script and nagios console output also in attachments.
After changing the script we are not getting data in advanced tab-->perfdata. Please find the attachment.
As you told if the data is huge i want to break it as we are getting the 100 plus rows in output, we will call only 25 scopes, can you give me that command how to call only 25 scopes. please provide the command to call only 25 scopes we will try that also, and also please provide above details too.
Re: Passive check configuration with ncpa and nsca
Posted: Thu Feb 06, 2020 5:10 pm
by Box293
My recommendation is to create an individual service per scope.
Looking at the plugin you need to use the
-s argument:
Code: Select all
.PARAMETER scopeID (-s)
Optional - define a single scope in the format of the subnet ID, or all scopes by using "all"
Default: all
Example: 192.168.0.0
Example: all
Any other method of reducing the amount of scopes returned by the plugin is going to require you to manually edit the Powershell script to your needs.
Re: Passive check configuration with ncpa and nsca
Posted: Thu Feb 06, 2020 11:26 pm
by grayloglearn
As you suggest i tried to call the script with argument but still i did not get any valid output.
Our requirement is simple we should get the graphs for scope monitoring.
root@ip-172-31-84-117:/usr/local/nagios/libexec# /usr/local/nagios/libexec/check_ncpa.py -H ip-172-31-94-235.ec2.internal -t 'Test@123' -P 5693 -M 'plugins/dhcpncpa.ps1' -a 'scope1,scope2'
Get-DhcpServerv4Scope : Cannot process argument transformation on parameter 'ScopeId'. Cannot convert value
"scope1,scope2" to type "System.Net.IPAddress[]". Error: "Cannot convert value "scope1,scope2" to type
"System.Net.IPAddress". Error: "An invalid IP address was specified.""
At C:\Program Files (x86)\Nagios\NCPA\plugins\dhcpncpa.ps1:75 char:43
+ $activeScopes = Get-DhcpServerv4Scope $scopeID | Where { $_.State ...
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-DhcpServerv4Scope], ParameterBindingArgumentTransformationExceptio
n
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-DhcpServerv4Scope
Get-DhcpServerv4ScopeStatistics : Cannot validate argument on parameter 'ScopeId'. The argument is null or empty.
Provide an argument that is not null or empty, and then try the command again.
At C:\Program Files (x86)\Nagios\NCPA\plugins\dhcpncpa.ps1:82 char:46
+ $stats = Get-DhcpServerv4ScopeStatistics $scope.ScopeId
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-DhcpServerv4ScopeStatistics], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Get-DhcpServerv4ScopeStatistics
OK: in good order. is 0% used, (0 leases, 0 IP's available.) | _freeIPS=0; _AvailableIPS=0;
Please tell me how to define command for this ncpa and how to call from nagios. I know the script is having -S argument but in ncpa.cfg some where we should define where we have define, and how to call from nagios server. If you could help on this we will try to call 25 scope per service. Please help on this.
As you requested we have given output for the perfdata after changing the script but you haven't replay for this can you please help on that also please.
Re: Passive check configuration with ncpa and nsca
Posted: Fri Feb 07, 2020 4:53 pm
by mbellerue
Try the check_ncpa.py command like this,
Code: Select all
root@ip-172-31-84-117:/usr/local/nagios/libexec# /usr/local/nagios/libexec/check_ncpa.py -H ip-172-31-94-235.ec2.internal -t 'Test@123' -P 5693 -M 'plugins/dhcpncpa.ps1' -a '-s scope1,scope2'
Re: Passive check configuration with ncpa and nsca
Posted: Sun Feb 09, 2020 9:35 pm
by grayloglearn
we have tried both ip and name please find the below error from the command.
root@ip-172-31-84-117:~# /usr/local/nagios/libexec/check_ncpa.py -H 172.31.94.235 -t 'Test@123' -P 5693 -M 'plugins/dhcpncpa.ps1' -a '-s scope1,scope2'
Get-DhcpServerv4Scope : Cannot process argument transformation on parameter 'ScopeId'. Cannot convert value
"scope1,scope2" to type "System.Net.IPAddress[]". Error: "Cannot convert value "scope1,scope2" to type
"System.Net.IPAddress". Error: "An invalid IP address was specified.""
At C:\Program Files (x86)\Nagios\NCPA\plugins\dhcpncpa.ps1:75 char:43
+ $activeScopes = Get-DhcpServerv4Scope $scopeID | Where { $_.State ...
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-DhcpServerv4Scope], ParameterBindingArgumentTransformationExceptio
n
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-DhcpServerv4Scope
Get-DhcpServerv4ScopeStatistics : Cannot validate argument on parameter 'ScopeId'. The argument is null or empty.
Provide an argument that is not null or empty, and then try the command again.
At C:\Program Files (x86)\Nagios\NCPA\plugins\dhcpncpa.ps1:82 char:46
+ $stats = Get-DhcpServerv4ScopeStatistics $scope.ScopeId
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-DhcpServerv4ScopeStatistics], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Get-DhcpServerv4ScopeStatistics
OK: in good order. is 0% used, (0 leases, 0 IP's available.) | _freeIPS=0; _AvailableIPS=0;
root@ip-172-31-84-117:~# /usr/local/nagios/libexec/check_ncpa.py -H 172.31.94.235 -t 'Test@123' -P 5693 -M 'plugins/dhcpncpa.ps1' -a '-s 192.168.92.0,192.168.93.0'
Get-DhcpServerv4Scope : Cannot process argument transformation on parameter 'ScopeId'. Cannot convert value
"192.168.92.0,192.168.93.0" to type "System.Net.IPAddress[]". Error: "Cannot convert value "192.168.92.0,192.168.93.0"
to type "System.Net.IPAddress". Error: "An invalid IP address was specified.""
At C:\Program Files (x86)\Nagios\NCPA\plugins\dhcpncpa.ps1:75 char:43
+ $activeScopes = Get-DhcpServerv4Scope $scopeID | Where { $_.State ...
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-DhcpServerv4Scope], ParameterBindingArgumentTransformationExceptio
n
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-DhcpServerv4Scope
Get-DhcpServerv4ScopeStatistics : Cannot validate argument on parameter 'ScopeId'. The argument is null or empty.
Provide an argument that is not null or empty, and then try the command again.
At C:\Program Files (x86)\Nagios\NCPA\plugins\dhcpncpa.ps1:82 char:46
+ $stats = Get-DhcpServerv4ScopeStatistics $scope.ScopeId
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-DhcpServerv4ScopeStatistics], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Get-DhcpServerv4ScopeStatistics
OK: in good order. is 0% used, (0 leases, 0 IP's available.) | _freeIPS=0; _AvailableIPS=0;
Re: Passive check configuration with ncpa and nsca
Posted: Mon Feb 10, 2020 4:35 pm
by Box293
Box293 wrote:My recommendation is to create an individual service per scope.
Looking at the plugin you need to use the
-s argument:
Code: Select all
.PARAMETER scopeID (-s)
Optional - define a single scope in the format of the subnet ID, or all scopes by using "all"
Default: all
Example: 192.168.0.0
Example: all
Any other method of reducing the amount of scopes returned by the plugin is going to require you to manually edit the Powershell script to your needs.
The help says "define a
single scope"
So:
Code: Select all
/usr/local/nagios/libexec/check_ncpa.py -H 172.31.94.235 -t 'Test@123' -P 5693 -M 'plugins/dhcpncpa.ps1' -a '-s 192.168.92.0'
Once you've updated your plugin so it is returning the unique data source names then you will also need to delete the existing RRD and XML files for this service as they will cause issues with the new data coming in. Deleting them starts it from scratch. The files should be in
/usr/local/nagios/share/perfdata/freeipsusedipswitchncpa/
Re: Passive check configuration with ncpa and nsca
Posted: Mon Feb 10, 2020 8:37 pm
by grayloglearn
Let me know how to define command in ncpa.cfg for the script. I mean i will call the "check_DHCP_perscope" so that i will create service with different scopes. In ncpa.cfg where we have to define the command and how to define as below ??
check_DHCP_perscope = powershell.exe -command C:\Program` Files\NSClient++\scripts\check_DHCP_perscope.ps1 -s $ARG1$
Re: Passive check configuration with ncpa and nsca
Posted: Wed Feb 12, 2020 5:37 pm
by Box293
This guide provides a working example of how you can do this and I suggest you follow it and implement the example. Once you understand how it works then it will make it easy to implement your script.
https://support.nagios.com/kb/article/n ... a-722.html
You don't define plugin commands with NCPA, you call the plugins directly, for example:
Code: Select all
/usr/local/nagios/libexec/check_ncpa.py -H your_windows_server_ip_address -t your_windows_server_ncpa_token -P 5693 -M 'plugins/check_DHCP_perscope.ps1' -q "args=-s 192.168.92.0"
Re: Passive check configuration with ncpa and nsca
Posted: Wed Feb 12, 2020 9:20 pm
by grayloglearn
thanks for the command but we don't have any luck we are not able to pass multiple scopes. please find the below error.
root@ip-172-31-84-117:~# /usr/local/nagios/libexec/check_ncpa.py -H 172.31.94.235 -t Test@123 -P 5693 -M 'plugins/dhcpncpa.ps1' -q "args=-s 192.168.92.0"
OK: 92 in good order. 92 is 0% used, (0 leases, 4 IP's available.) | 92_freeIPS=4; 92_AvailableIPS=0;
root@ip-172-31-84-117:~# /usr/local/nagios/libexec/check_ncpa.py -H 172.31.94.235 -t Test@123 -P 5693 -M 'plugins/dhcpncpa.ps1' -q "args=-s 192.168.92.0,192.168.93.0"
UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
Re: Passive check configuration with ncpa and nsca
Posted: Thu Feb 13, 2020 3:02 pm
by lmiltchev
thanks for the command but we don't have any luck we are not able to pass multiple scopes. please find the below error.
You cannot pass two IPs with "-s"... it's for a "single scope. This is not supported by the plugin. See the usage below:
EXAMPLE
If using standalone:
>.check_dhcp_scope.ps1
This will evaluate all DHCP scopes and return a warning or critical if any of the scopes are above 90% or 98% full.
>.check_dhcp_scope.ps1 -all -w 50 -c 80
This will evaluate all DHCP scopes and return a warning or critical if any of the scopes are above 50% or 80% full.
>.check_dhcp_scope.ps1 -s 192.168.0.0
This will evaluate the 192.168.0.0 scope and return a warning or critical if is above 90% or 98% full.
You could use "-all" instead:
Code: Select all
/usr/local/nagios/libexec/check_ncpa.py -H 172.31.94.235 -t Test@123 -P 5693 -M 'plugins/dhcpncpa.ps1' -q "args=-all"
Note: If you wanted to pass specific (individual) IPs, you would need to either find a different plugin that supports this functionality of write your own plugin.