Check dhcp-scope-usage

Overview

Checks the IPv4 scope usage for a Windows DHCP server service using the PowerShell command Get-DhcpServerv4ScopeStatistics -ComputerName "dhcpServer.contoso.com". Have a look at https://docs.microsoft.com/en-us/powershell/module/dhcpserver/get-dhcpserverv4scopestatistics for details.

If you provide --winrm-hostname, the check plugin will execute all Powershell commands via WinRM, otherwise it will run locally. This allows the plugin to run on Linux servers as well.

Hints:

  • Set the plugin timeout to 30 seconds.

Fact Sheet

Fact

Value

Check Plugin Download

https://github.com/Linuxfabrik/monitoring-plugins/tree/main/check-plugins/dhcp-scope-usage

Check Interval Recommendation

Every 15 minutes

Can be called without parameters

Yes

Compiled for Windows

Yes

Requirements

PowerShell

3rd Party Python modules

optionally Python module winrm if you want to execute it via WinRM

Help

usage: dhcp-scope-usage [-h] [-V] [--always-ok] [-c CRIT] [-H HOSTNAME]
                        [--test TEST] [-w WARN] [--winrm-domain WINRM_DOMAIN]
                        --winrm-hostname WINRM_HOSTNAME
                        --winrm-password WINRM_PASSWORD
                        [--winrm-transport {basic,ntlm,kerberos,credssp,plaintext}]
                        [--winrm-username WINRM_USERNAME]

Checks the IPv4 scope usage for a Windows DHCP server service.

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  --always-ok           Always returns OK.
  -c, --critical CRIT   Set the CRIT threshold as a percentage. Default: >= 90
  -H, --hostname HOSTNAME
                        Specifies the DNS name, or IPv4 or IPv6 address, of
                        the target computer that runs the DHCP server service.
                        Default: localhost
  --test TEST           For unit tests. Needs "path-to-stdout-file,path-to-
                        stderr-file,expected-retc".
  -w, --warning WARN    Set the WARN threshold as a percentage. Default: >= 80
  --winrm-domain WINRM_DOMAIN
                        WinRM Domain Name. Default: None
  --winrm-hostname WINRM_HOSTNAME
                        Target Windows computer on which the command will be
                        executed.
  --winrm-password WINRM_PASSWORD
                        WinRM Account Password.
  --winrm-transport {basic,ntlm,kerberos,credssp,plaintext}
                        WinRM transport type. Default: ntlm
  --winrm-username WINRM_USERNAME
                        WinRM Account Name. Default: Administrator

Usage Examples

Local usage:

./dhcp-scope-usage

Remote usage, for example on a Linux server:

./dhcp-scope-usage3 \
    --hostname=dhcp01.example.com \
    --winrm-hostname=10.80.32.246 \
    --winrm-username=Administrator \
    --winrm-password=linuxfabrik \
    --winrm-domain=EXAMPLE.COM \
    --winrm-transport=ntlm

Output:

There are one or more criticals.

* 192.168.120.0: 0% used
* 192.168.121.0: 83% used [WARNING]
* 192.168.122.0: 91% used [CRITICAL]

States

  • WARN if PowerShell cmdlet’s return code is not equal to 0.

  • WARN or CRIT if any DHCP scopy usage in percent is above a given threshold.

Perfdata / Metrics

Name

Type

Description

scope_SCOPEID

Percentage

The IP address range usage for the DHCP scope.

Credits, License