Monitor DHCP status using powershell

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Elefanten
Posts: 1
Joined: Mon Apr 30, 2018 5:06 am

Monitor DHCP status using powershell

Post by Elefanten »

Hi

Nagios newbie here.

I have received a task to setup DHCP status monitoring to specifically monitor alert if DHCP scope is getting full on several servers located externally that is connected to our main site using VPN.

We have a script server where we are allowed to run powershell scripts from and where we also use Nagios++ client to execute different scripts as vbs, batch, powershell.

I am trying to use this script to solve this : https://exchange.nagios.org/directory/P ... es/details

Checking the nsclient.ini file on the script server I can see there is already an entry for Powershell Wrapping for Nagios scripts called :
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode | powershell.exe -command -

Probably entered by another colleague I can not get in touch with atm.

Question 1:
For my script (check_dhcp_scopes.ps1) , can I simply enter another wrapping as well under the current one in nsclient.ini file?
What wrapping should I then enter for my script ?

Question 2:
What command must be used from the Nagios server itself to execute this script ?

I have tried to understand how our Nagios is setup and I have a config file called services.cfg I presume I must add the check_nrpe20! and something command for the powershell script.


BR
Elefanten
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Monitor DHCP status using powershell

Post by tgriep »

An example of a command you would put in the nsclient.ini file would be like this.

Under this section

Code: Select all

[/settings/external scripts/scripts]
You would create a command like this. Save it and restart NSClient++

Code: Select all

check_dhcp_scopes = cmd /c echo scripts\check_dhcp_scopes.ps1 $ARG1$; exit $LastExitCode | powershell.exe -command –

Then to test it from the Nagios server, you would use the check_nrpe command and pass the command and the arguments like this. Replace xxx.xxx.xxx.xxx with the IP address of the Windows system

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xxx.xxx -c check_dhcp_scopes  -a '-all -w 50 -c 80'
This will test all of the Scopes on the system.

Try that out and let us know if you have any questions.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked