<div dir="ltr">Hi Rachael,<div><br></div><div>You an use the API from the lease_cmds hook to explore leases: <a href="https://kea.readthedocs.io/en/kea-2.2.0/arm/hooks.html#lease-cmds-lease-commands-for-easier-lease-management">https://kea.readthedocs.io/en/kea-2.2.0/arm/hooks.html#lease-cmds-lease-commands-for-easier-lease-management</a></div><div><br></div><div>What I usually do is put the API command in a file, cat the file and pipe it to socat (search for socat in the Kea ARM for example usage) then pipe that output to jq which nicely formats the returned JSON.</div><div><br></div><div>Thank you,</div><div><br></div><div>Darren Ankney</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 18, 2023 at 5:47 PM Rachael Wilson <<a href="mailto:RachaelW@okpud.org">RachaelW@okpud.org</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"><div class="msg1846981844539521609">





<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="m_1846981844539521609WordSection1">
<p class="MsoNormal">Thank you for the links, Wlodek!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Here are some sample rows I am loading into the file:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context<u></u><u></u></p>
<p class="MsoNormal">172.16.16.12,6c:33:a9:3b:2e:04,,3600,1682423972,1,0,0,2e-04,0,<u></u><u></u></p>
<p class="MsoNormal">172.16.16.25,da:32:2d:70:57:37,,3600,1682423972,1,0,0,57-37,0,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">If I’m understanding this properly, the lease should last until the expire time of 1682423972 which is equivalent to Tue Apr 25 2023 17:49:47 GMT+0000.  However, if I set the file and wait for the lfc, it empties the data rows of the lease
 file, leaving only the header row.  Currently the lfc-interval is set to 3600.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Is there a way to query kea via the cli for the leases it sees other than opening the lease file?  Looked for a log file to see if there is any information on server startup but even with logging enabled by default, seems it did not create
 a log at /var/log/kea-dhcp4.log as per the conf settings.  <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:8pt;line-height:106%"><u></u><u></u></p>
<p class="MsoNormal" style="margin-bottom:8pt;line-height:106%"><u></u> <u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<br>
<p>--<br>Rachael Wilson<br>(509) 422-8374</p><div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> Wlodek Wencel <<a href="mailto:wlodek@isc.org" target="_blank">wlodek@isc.org</a>> <br>
<b>Sent:</b> Friday, April 14, 2023 2:22 AM<br>
<b>To:</b> Rachael Wilson <<a href="mailto:RachaelW@okpud.org" target="_blank">RachaelW@okpud.org</a>>; <a href="mailto:kea-users@lists.isc.org" target="_blank">kea-users@lists.isc.org</a><br>
<b>Subject:</b> Re: [Kea-users] Migrate to Kea from non-ISC DHCP server ***EXTERNAL EMAIL***<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<table border="0" cellpadding="0" width="347" style="width:260.25pt">
<tbody>
<tr style="height:9.75pt">
<td width="660" style="width:495pt;background:blue;padding:0.75pt;height:9.75pt">
<p><strong><span style="font-size:9pt;font-family:"Arial Black",sans-serif;color:yellow">EXTERNAL EMAIL: Please Think Before You Click!!</span></strong><span style="font-size:9pt;font-family:Arial,sans-serif"><u></u><u></u></span></p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:10pt;font-family:Arial,sans-serif"> <u></u><u></u></span></p>
<p>Kea has two features that deals with expired leases. Please take a look into lease file clean up:<br>
<a href="https://kea.readthedocs.io/en/latest/arm/dhcp4-srv.html#memfile-basic-storage-for-leases" target="_blank">https://kea.readthedocs.io/en/latest/arm/dhcp4-srv.html#memfile-basic-storage-for-leases</a> (you can easily disable this by setting lfc-interval to 0) and lease
 expiration <a href="https://kea.readthedocs.io/en/latest/arm/lease-expiration.html" target="_blank">
https://kea.readthedocs.io/en/latest/arm/lease-expiration.html</a><u></u><u></u></p>
<p>But none of those processes touch unexpired leases, my guess is that you are putting incorrect state of a lease.<u></u><u></u></p>
<p>There is also lease sanity check feature, but this by default wouldn't remove your leases
<a href="https://kea.readthedocs.io/en/latest/arm/dhcp4-srv.html#sanity-checks-in-dhcpv4" target="_blank">
https://kea.readthedocs.io/en/latest/arm/dhcp4-srv.html#sanity-checks-in-dhcpv4</a><u></u><u></u></p>
<p>I hope that our documentation will help you find solution.<u></u><u></u></p>
<p>Włodek Wencel<u></u><u></u></p>
<p>QA, ISC<u></u><u></u></p>
<div>
<p class="MsoNormal">On 13/04/2023 21:21, Rachael Wilson wrote:<u></u><u></u></p>
</div>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<p class="MsoNormal">Thank you very much Wlodek!  With that info I was able to create a lease file for dhcp4.  The only thing is it seems a collector runs at a certain interval that cleans up the memfile?  Looks like it blows out any loaded leases before they
 could expire from the old DHCP server.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:8pt;line-height:105%"> <u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p>--<br>
Rachael Wilson<br>
(509) 422-8374<u></u><u></u></p>
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> Kea-users <a href="mailto:kea-users-bounces@lists.isc.org" target="_blank">
<kea-users-bounces@lists.isc.org></a> <b>On Behalf Of </b>Wlodek Wencel<br>
<b>Sent:</b> Thursday, April 13, 2023 8:48 AM<br>
<b>To:</b> <a href="mailto:kea-users@lists.isc.org" target="_blank">kea-users@lists.isc.org</a><br>
<b>Subject:</b> Re: [Kea-users] Migrate to Kea from non-ISC DHCP server ***EXTERNAL EMAIL***<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<table border="0" cellpadding="0" width="347" style="width:260.25pt">
<tbody>
<tr style="height:9.75pt">
<td width="660" style="width:495pt;background:blue;padding:0.75pt;height:9.75pt">
<p><strong><span style="font-size:9pt;font-family:Calibri,sans-serif">EXTERNAL EMAIL: Please Think Before You Click!<span style="color:white">!</span></span></strong><u></u><u></u></p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:10pt;font-family:Arial,sans-serif"> </span><u></u><u></u></p>
<p>Couple simple leases files I took out from our automated testing are attached. Please be aware that in user context Kea can store quite extensive info in json structure (also attached).
<u></u><u></u></p>
<p>Hope that will help<u></u><u></u></p>
<p>Wlodek Wencel<u></u><u></u></p>
<p> <u></u><u></u></p>
<div>
<p class="MsoNormal">On 13/04/2023 16:42, Rachael Wilson wrote:<u></u><u></u></p>
</div>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<p class="MsoNormal">Thank you, Darren!  I will give perfdhcp a try.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal" style="margin-bottom:8pt;line-height:105%"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p>--<br>
Rachael Wilson<br>
(509) 422-8374<u></u><u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> Kea-users <a href="mailto:kea-users-bounces@lists.isc.org" target="_blank">
<kea-users-bounces@lists.isc.org></a> <b>On Behalf Of </b>Darren Ankney<br>
<b>Sent:</b> Thursday, April 13, 2023 3:27 AM<br>
<b>To:</b> <a href="mailto:kea-users@lists.isc.org" target="_blank">kea-users@lists.isc.org</a><br>
<b>Subject:</b> Re: [Kea-users] Migrate to Kea from non-ISC DHCP server ***EXTERNAL EMAIL***<u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<table border="0" cellpadding="0" width="347" style="width:260.25pt">
<tbody>
<tr style="height:9.75pt">
<td width="660" style="width:495pt;background:blue;padding:0.75pt;height:9.75pt">
<p><strong><span style="font-size:9pt;font-family:Calibri,sans-serif">EXTERNAL EMAIL: Please Think Before You Click!<span style="color:white">!</span></span></strong><u></u><u></u></p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:10pt;font-family:Arial,sans-serif"> </span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Hello Rachael,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">There probably isn't an example file anywhere in the documentation (I looked also) or if there is, I just didn't find it.  I would suggest setting up a test kea server with the memfile lease database persisting to a file.  Then use perfdhcp
 to generate traffic thus populating the file.  If you need specific options to appear in the lease file, it is possible to use perfdhcp to generate most of them (even if you have to create the hex yourself).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thank you,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Darren Ankney<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, Apr 12, 2023 at 5:19 PM Rachael Wilson <<a href="mailto:RachaelW@okpud.org" target="_blank">RachaelW@okpud.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<div>
<p class="MsoNormal">Hi, I would like to migrate a few thousand DHCP leases from a non-ISC DHCP server to a memfile backed Kea instance.  Looking through the docs, it seems it would be easier to populate
 the lease file in /var/lib/kea/kea-leases4.csv rather than using hooks.  However, in a fresh install the file only contains the header row.  Is there an example file populated with rows I could look at to properly format the data for import?  Didn’t see anything
 in the docs, but might have missed it.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal" style="margin-bottom:8pt;line-height:105%">
 <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<table border="0" cellspacing="0" cellpadding="0" width="660" style="width:495pt" id="m_1846981844539521609m_-55651584395806363520.d7lo0ephf9g">
<tbody>
<tr>
<td width="79" style="width:59.25pt;padding:0in">
<p class="MsoNormal" style="line-height:12.75pt"><span style="font-size:10pt;font-family:Arial,sans-serif"><img border="0" width="87" height="87" style="width: 0.9062in; height: 0.9062in;" id="m_1846981844539521609m_-55651584395806363520.84vrp5kjk1v" src="cid:18798cf2ee24cff311" alt="logo__250px.png"></span><u></u><u></u></p>
</td>
<td width="581" valign="top" style="width:435.75pt;padding:4.5pt">
<p class="MsoNormal" style="line-height:12.75pt"><strong><span style="font-size:12pt;font-family:Calibri,sans-serif">Rachael Wilson
</span></strong><span style="font-size:12pt;color:rgb(127,127,127)">| </span><span style="font-size:12pt;color:rgb(31,73,125)">Network Analyst</span><span style="font-size:10pt"><br>
<span style="color:rgb(127,127,127)">Public Utility District No. 1 Of Okanogan County <br>
Office: (509) 422-8374 | <a href="mailto:RachaelW@okpud.org" target="_blank">RachaelW@okpud.org</a> <br>
</span><span style="color:black">1331 2nd Ave N., Okanogan, WA 98840 | P.O. Box 912, Okanogan, WA 98840 </span></span><u></u><u></u></p>
</td>
</tr>
<tr>
<td width="660" colspan="2" valign="top" style="width:495pt;padding:0in">
<p class="MsoNormal" style="line-height:12.75pt"><span style="font-size:6pt;font-family:Arial,sans-serif">P.U.D. No. 1 of Okanogan County is an equal opportunity provider and employer.  If you think that you have received this message in error, please e-mail
 the sender at the above e-mail address.</span><u></u><u></u></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">-- <br>
ISC funds the development of this software with paid support subscriptions. Contact us at
<a href="https://www.isc.org/contact/" target="_blank">https://www.isc.org/contact/</a> for more information.<br>
<br>
To unsubscribe visit <a href="https://lists.isc.org/mailman/listinfo/kea-users" target="_blank">
https://lists.isc.org/mailman/listinfo/kea-users</a>.<br>
<br>
Kea-users mailing list<br>
<a href="mailto:Kea-users@lists.isc.org" target="_blank">Kea-users@lists.isc.org</a><br>
<a href="https://lists.isc.org/mailman/listinfo/kea-users" target="_blank">https://lists.isc.org/mailman/listinfo/kea-users</a><u></u><u></u></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br>
<br>
<u></u><u></u></p>
</blockquote>
</blockquote>
</div>
</div>

-- <br>
ISC funds the development of this software with paid support subscriptions. Contact us at <a href="https://www.isc.org/contact/" rel="noreferrer" target="_blank">https://www.isc.org/contact/</a> for more information.<br>
<br>
To unsubscribe visit <a href="https://lists.isc.org/mailman/listinfo/kea-users" rel="noreferrer" target="_blank">https://lists.isc.org/mailman/listinfo/kea-users</a>.<br>
<br>
Kea-users mailing list<br>
<a href="mailto:Kea-users@lists.isc.org" target="_blank">Kea-users@lists.isc.org</a><br>
<a href="https://lists.isc.org/mailman/listinfo/kea-users" rel="noreferrer" target="_blank">https://lists.isc.org/mailman/listinfo/kea-users</a><br>
</div></blockquote></div>