<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 4 mai 2023, 14:06, Thomas Haller <<a href="mailto:thaller@redhat.com">thaller@redhat.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
On Thu, 2023-05-04 at 11:47 +0200, Frédéric Martinsons wrote:<br>
> Hello list,<br>
> <br>
> I would like to add some monitoring of the dhcp servers via the<br>
> machines which request ip addresses from it (no access to the server<br>
> itself) <br>
> For the moment, we are only aware of the outage of this server when<br>
> the lease expired.<br>
> <br>
> I first check if NM has a dbus api for that and didn't find one, the<br>
> I use a Nagios plug-in as a standalone program<br>
> (<a href="https://github.com/nagios-plugins/nagios-plugins/blob/master/plugins" rel="noreferrer noreferrer" target="_blank">https://github.com/nagios-plugins/nagios-plugins/blob/master/plugins</a><br>
> -root/check_dhcp.c) but it seems to not work on all cases I have<br>
> (strong firewalling among other).<br>
> <br>
> I don't want to use nmap or other external tools that I didn't<br>
> already have on the machines (I have strong constraint on the size<br>
> available)<br>
> <br>
> Since our machines used NM to manage ethernet , I decided to look at<br>
> the code to know how the things are handled and if a can have the<br>
> possibility to "ping" (just emit a DISCOVER and listen for OFFER<br>
> without accepting the lease). I first came up with a solution that<br>
> involves instantiating a NMDhcpClient to use an internal dhcp<br>
> mechanism. It worked but I had to patch NM code to avoid messing with<br>
> the system (I don't want to read the already accepted lease or modify<br>
> the current lease). Moreover my binary had to link with almost all NM<br>
> code which makes it very big.<br>
> <br>
> I finally came up with a minimal solution by mimicking what is done<br>
> in nm-dhcp-nettools.c and talking directly to the n-dhcp4 library.<br>
> <br>
> Long story short, I'm wondering if this "ping dhcp" capability is a<br>
> feature fitted to enter as a standalone binary (or a dedicated DBus<br>
> endpoint) in NM code ?<br>
<br>
I don't see how such functionality would fit into NetworkManager. But<br>
maybe it does, if you have a specific suggestion please make it.<br>
<br>
Instead, I would use/build a separate tool for that. If it's a specific<br>
tool for that purpose, then the API would be simple. If it's a more<br>
general tool (e.g. integrate it into ISC dhclient) then it is already<br>
more complicated to make the functionality general purpose and fit it<br>
into a more general tool.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">It could be generic since during my search, I found several request for such a case (but people seems happy with the tools that are already available like Nagios plug-in)</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
There are several DHCP client libraries and implementations. For<br>
example there is <a href="https://github.com/nispor/mozim" rel="noreferrer noreferrer" target="_blank">https://github.com/nispor/mozim</a><br>
<br>
I would actually use nettools' n-dhcp4 library (which you already<br>
investigated) and build a specialized one-purpose tool on top of that.<br>
That should be relatively straight forward, and if API is missing for<br>
making it happen, it probably can be accepted upstream.<br>
<br>
<a href="https://github.com/nettools/n-dhcp4" rel="noreferrer noreferrer" target="_blank">https://github.com/nettools/n-dhcp4</a><br>
<br>
<br>
Thomas<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">This is exactly what I have done (thank you very much for the code in NM which help me to achieve that), I just wanted to know if someone here could be interdested to have that ship directly in NM but I heard you, loud and clear.</div><div dir="auto"><br></div><div dir="auto"> Thank you Thomas for the answer. </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div></div>