used/free ips per scope on the DHCP Server

This board serves as an open discussion and support collaboration point for Nagios XI. NOTE: Nagios XI customers should use the Customer Support forum to obtain expedited support.

used/free ips per scope on the DHCP Server

Postby grayloglearn » Tue Dec 10, 2019 1:12 am

Hi Team,

we would like to monitor the used/free ip address per scope on the DHCP server. This will help us to check us how many are free in each scope and how may are used. Do we have such script for this to get the valid data??

We are using the nsclient++ in windows server. Can someone help with the scripts. so that we will check, the script should give output saying as per scope how many are free and how many are used.
grayloglearn
 
Posts: 204
Joined: Thu Jul 06, 2017 8:55 am

Re: used/free ips per scope on the DHCP Server

Postby mbellerue » Tue Dec 10, 2019 4:29 pm

Do you already have a plugin that is supposed to check the DHCP scopes? We can try troubleshooting it, if you have one.

Otherwise, I found a Powershell script on the Nagios Exchange that might suit your needs.
https://exchange.nagios.org/directory/P ... es/details
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
mbellerue
 
Posts: 1165
Joined: Fri Jul 12, 2019 11:10 am

Re: used/free ips per scope on the DHCP Server

Postby grayloglearn » Wed Dec 11, 2019 4:13 am

We have used the attached script and we executed that script in windows and we are able to get the data. but when we call from nagios the below errors we are getting.

[root@nagihpc ~]# /usr/local/nagios/libexec/check_nrpe -H DHCPCORP02 -t 120 -c check_DHCP_perscope
Missing expression after unary operator '-'.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : MissingExpressionAfterOperator


And the below are command we have enabled in nsclient.ini

check_DHCP_perscope=cmd /c echo scripts\fari\check_DHCP_perscope.ps1;exit($lastexitcode) | powershell.exe -command –
Attachments
check_DHCP_perscope.txt
(3.81 KiB) Downloaded 20 times
grayloglearn
 
Posts: 204
Joined: Thu Jul 06, 2017 8:55 am

Re: used/free ips per scope on the DHCP Server

Postby mbellerue » Wed Dec 11, 2019 12:50 pm

Okay, I put that code into Powershell ISE, and gave it a once over. I'm not seeing any syntax errors. If you load that script into Powershell ISE (best to copy/paste the text of the script into ISE) and just run the script, what is the output?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
mbellerue
 
Posts: 1165
Joined: Fri Jul 12, 2019 11:10 am

Re: used/free ips per scope on the DHCP Server

Postby mbellerue » Thu Dec 12, 2019 4:40 pm

That is a lot of output in that script. I'm wondering if there's too much for NRPE to return properly. Let's try narrowing it down to just one scope. Add -a 'one-dhcp-scope-name' to your check_nrpe command. And of course replace "one-dhcp-scope-name" with one of your actual DHCP scope names. See what that gives you, and if you wouldn't mind sending the results of the command back, that would be great. That can be here or in a PM.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
mbellerue
 
Posts: 1165
Joined: Fri Jul 12, 2019 11:10 am

Re: used/free ips per scope on the DHCP Server

Postby grayloglearn » Thu Dec 12, 2019 9:29 pm

Hi Team,

We don't want go individually we want to check all scopes details should come in single. Let us know how to resolve this.
How the output is coming in windows server while we executing the entire should come in nagios console. Please help on this. If we go individual scope if we have 1000 scope we need to enable 1000 services. Hope you understand.

While we executing the script in windows server the same should display in nagios console. Please help on this. how we can resolve that syntax issue.

[root@nagiht ~]# /usr/local/nagios/libexec/check_nrpe -H DHCPCORP02 -t 120 -c check_DHCP_perscope
Missing expression after unary operator '-'.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : MissingExpressionAfterOperator
grayloglearn
 
Posts: 204
Joined: Thu Jul 06, 2017 8:55 am

Re: used/free ips per scope on the DHCP Server

Postby mbellerue » Fri Dec 13, 2019 11:00 am

Oh absolutely I understand. It looked like you had quite a number of DHCP scopes, and that would indeed be a large number of services to create. Another way to go about this would be to make a passive check. If you have an agent like NCPA on your Windows server, it could run the Powershell script, and send the results back via NRDP. You would definitely want this to be a volatile service, and have state stalking enabled.

Does that sound like something you'd like to try?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
mbellerue
 
Posts: 1165
Joined: Fri Jul 12, 2019 11:10 am

Re: used/free ips per scope on the DHCP Server

Postby grayloglearn » Sun Dec 15, 2019 8:27 pm

Could you please help with to resolve the syntax error. Let us resolve the syntax error first. How to resolve this. We want to resolve the issue. I think if we can resolve this we will get the data from windows server. I know there is huge rows are showing after executing the script.

kindly help us why this error is showing.

[root@nagiht ~]# /usr/local/nagios/libexec/check_nrpe -H DHCPCORP02 -t 120 -c check_DHCP_perscope
Missing expression after unary operator '-'.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : MissingExpressionAfterOperator
grayloglearn
 
Posts: 204
Joined: Thu Jul 06, 2017 8:55 am

Re: used/free ips per scope on the DHCP Server

Postby mbellerue » Mon Dec 16, 2019 11:28 am

Well, it could be how ps1 scripts get piped into Powershell, rather than just having Powershell call them. In your nsclient.ini file, try setting up your check like this,

Code: Select all
check_DHCP_perscope = powershell.exe -command C:\Program` Files\NSClient++\scripts\check_DHCP_perscope.ps1
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
mbellerue
 
Posts: 1165
Joined: Fri Jul 12, 2019 11:10 am

Re: used/free ips per scope on the DHCP Server

Postby grayloglearn » Wed Dec 18, 2019 2:03 am

Hi Team,we are getting below error

[root@nagi~]# /usr/local/nagios/libexec/check_nrpe -H dhcpcrp02 -t 120 -c check_DHCP_perscope
C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1

+ C:\Program Files\NSClient++\scripts\far\check_DHCP_perscope.ps1
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Program:String) [], CommandN
otFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

we have added line as below
check_DHCP_perscope = powershell.exe -command C:\Program Files\NSClient++\scripts\far\check_DHCP_perscope.ps1
grayloglearn
 
Posts: 204
Joined: Thu Jul 06, 2017 8:55 am

Next

Return to Nagios XI

Who is online

Users browsing this forum: No registered users and 19 guests