<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 4 May 2023 at 14:39, Thomas Haller <<a href="mailto:thaller@redhat.com">thaller@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 2023-05-04 at 14:33 +0200, Frédéric Martinsons wrote:<br>
> <br>
> <br>
> Le jeu. 4 mai 2023, 14:06, Thomas Haller <<a href="mailto:thaller@redhat.com" target="_blank">thaller@redhat.com</a>> a<br>
> écrit :<br>
> > 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<br>
> > > server<br>
> > > itself) <br>
> > > For the moment, we are only aware of the outage of this server<br>
> > > when<br>
> > > the lease expired.<br>
> > > <br>
> > > I first check if NM has a dbus api for that and didn't find one,<br>
> > > the<br>
> > > I use a Nagios plug-in as a standalone program<br>
> > > (<br>
> > > <a href="https://github.com/nagios-plugins/nagios-plugins/blob/master/plugi" rel="noreferrer" target="_blank">https://github.com/nagios-plugins/nagios-plugins/blob/master/plugi</a><br>
> > > ns<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<br>
> > > size<br>
> > > available)<br>
> > > <br>
> > > Since our machines used NM to manage ethernet , I decided to look<br>
> > > 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<br>
> > > 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<br>
> > > with<br>
> > > the system (I don't want to read the already accepted lease or<br>
> > > modify<br>
> > > the current lease). Moreover my binary had to link with almost<br>
> > > all NM<br>
> > > code which makes it very big.<br>
> > > <br>
> > > I finally came up with a minimal solution by mimicking what is<br>
> > > done<br>
> > > in  nm-dhcp-nettools.c and talking directly to the n-dhcp4<br>
> > > library.<br>
> > > <br>
> > > Long story short, I'm wondering if this "ping dhcp" capability is<br>
> > > a<br>
> > > feature fitted to enter as a standalone binary (or a<br>
> > > dedicated DBus<br>
> > > endpoint) in NM code ?<br>
> > <br>
> > I don't see how such functionality would fit into NetworkManager.<br>
> > 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<br>
> > 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<br>
> > already<br>
> > more complicated to make the functionality general purpose and fit<br>
> > it<br>
> > into a more general tool.<br>
> <br>
> It could be generic since during my search, I found several request<br>
> for such a case (but people seems happy with the tools that are<br>
> already available like Nagios plug-in)<br>
> <br>
> > There are several DHCP client libraries and implementations. For<br>
> > example there is <a href="https://github.com/nispor/mozim" rel="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<br>
> > that.<br>
> > That should be relatively straight forward, and if API is missing<br>
> > for<br>
> > making it happen, it probably can be accepted upstream.<br>
> > <br>
> > <a href="https://github.com/nettools/n-dhcp4" rel="noreferrer" target="_blank">https://github.com/nettools/n-dhcp4</a><br>
> > <br>
> > <br>
> > Thomas<br>
> <br>
> This is exactly what I have done (thank you very much for the code in<br>
> NM which help me to achieve that), I just wanted to know if someone<br>
> here could be interdested to have that ship directly in NM but I<br>
> heard you, loud and clear.<br>
> <br>
>  Thank you Thomas for the answer. <br>
<br>
<br>
Hi,<br>
<br>
maybe I just lack of imagination for how it could fit. Patch welcome,<br>
if you see a use-case :)<br>
<br>
<br>
Thomas<br>
<br></blockquote><div><br></div><div>Ok I'll submit a merge request soon for  providing such a little tool and </div><div>we will discuss the usage (and if it can remain a standalone binary or</div><div>if it should be more integrated) there.</div><div><br></div></div></div>