Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DHCP include scope statistics #1836

Open
englm opened this issue Jan 16, 2025 · 5 comments · May be fixed by #1837
Open

DHCP include scope statistics #1836

englm opened this issue Jan 16, 2025 · 5 comments · May be fixed by #1837

Comments

@englm
Copy link

englm commented Jan 16, 2025

Problem Statement

At the moment the DHCP collector lacks information about the scopes, especially how many IPs are in use and available (see also Issue #880 )

Proposed Solution

There is a Powershell command to receive this metrics: Get-DhcpServerv4ScopeStatistics
In background this is leveraging the Get method of the PS_DhcpServerv4ScopeStatistics class
The response is like that

{
    "cmdletOutput": [
        {
            "ScopeId": {
                "Address": 6727872,
                "AddressFamily": 2,
                "ScopeId": null,
                "IsIPv6Multicast": false,
                "IsIPv6LinkLocal": false,
                "IsIPv6SiteLocal": false,
                "IsIPv6Teredo": false,
                "IsIPv4MappedToIPv6": false,
                "IPAddressToString": "192.168.102.0"
            },
            "Free": 11,
            "InUse": 0,
            "Reserved": 0,
            "Pending": 0,
            "AddressesFree": 11,
            "AddressesFreeOnPartnerServer": null,
            "AddressesFreeOnThisServer": null,
            "AddressesInUse": 0,
            "AddressesInUseOnPartnerServer": null,
            "AddressesInUseOnThisServer": null,
            "PendingOffers": 0,
            "PercentageInUse": 0,
            "ReservedAddress": 0,
            "SuperscopeName": "",
            "PSComputerName": null
        }
    ],
    "ReturnValue": 0
}

I played around to make use this cim method englm@bb43a37
At the moment I'm struggling to unmarshal the InstanceA response type.
It would be nice if somebody more familar with the Microsoft MI api in Go could help here. Then I would also be happy to contribute a pull request.

Additional information

No response

Acceptance Criteria

No response

@jkroepke
Copy link
Member

It would be nice if somebody more familar with the Microsoft MI api in Go could help here.

The MI API was written by myself for this project, since it seems there is no public project availible. It might be possible, that the API isn't feature complete.

If you could publish your draft as draft Pull Request, I can take a look into it.

The goal is that the data from https://wutils.com/wmi/root/microsoft/windows/dhcp/dhcpserverv4scopestatistics/ is availible in windows_exporter. is that correct?

@englm
Copy link
Author

englm commented Jan 16, 2025

Exactly. My idea is to have:

  • AddressesFree
  • AddressesFreeOnPartnerServer
  • AddressesFreeOnThisServer
  • AddressesInUse
  • AddressesInUseOnPartnerServer
  • AddressesInUseOnThisServer
  • PendingOffers
  • ReservedAddress

available per scope with the scopeId as label.

@jkroepke you want me to create a draft pull request that you can play with it, right?

@jkroepke
Copy link
Member

@jkroepke you want me to create a draft pull request that you can play with it, right?

yes

@englm englm linked a pull request Jan 16, 2025 that will close this issue
@englm
Copy link
Author

englm commented Jan 16, 2025

PR #1837
I hope everything is fine, it's my first PR

@jkroepke
Copy link
Member

@englm A update from my site: Currently looking into the Win32 API for the DHCP server and I'm going to investigate how I can observe the metric from there:

https://learn.microsoft.com/de-de/previous-versions/windows/desktop/dhcp/dhcp-server-management-api

Based on my experience, I avoid WMI/MI much as I result into a better performance and less memory leaking issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants