<div dir="ltr"><div><div><div>Simon, thank you very much for your explanation, it is really helpful.<br><br></div>I may have to slightly re-design my script. Best way I see is using arguments as Bob also suggested.<br><br></div>Thanks again.<br><br></div>Klemen<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 13, 2018 at 10:57 AM, Simon Hobson <span dir="ltr"><<a href="mailto:dhcp1@thehobsons.co.uk" target="_blank">dhcp1@thehobsons.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Klemen Sladic <<a href="mailto:gosturnca@gmail.com">gosturnca@gmail.com</a>> wrote:<br>
<br>
> 1. What is the difference between dhcpd.leases and dhcpd.leases~ files?<br>
<br>
</span>The latter is the previous file. Periodically (compiled in 1 hour by default) the server will write out a fresh leases file, move the old one (that's the one with ~ appended to it's name), and the new file moved into place. It's done that way so that if an error occurs, you haven't just over-written the only copy of the file !<br>
<span class=""><br>
> 2. My dhcpd.leases parsing script is executed on commit, like:<br>
><br>
> subnet 192.168.0.0 netmask 255.255.255.0<br>
> {<br>
>    interface "eth0";<br>
>    range 192.168.0.1 192.168.0.100;<br>
>    option routers 192.168.0.254;<br>
>    on commit {<br>
>       execute("/home/user/leases_<wbr>parse.sh");<br>
>    }<br>
> }<br>
><br>
> Can I assume that dhcpd.leases has already been updated with latest lease when my script is executed?<br>
<br>
</span>Don't know. It's required that the leases file is updated before sending teh packet to the client, but I don't know if it's defined at what point the on commit is executed.<br>
<span class=""><br>
> 3. Is a new lease always appended at the end of dhcpd.leases file?<br>
<br>
</span>Yes<br>
<span class=""><br>
> 4. On renew is a new lease block always added at the end or is existing block updated?<br>
<br>
</span>Yes. A lease is never updated in-place - a new record is appended to the leases file which is why you will see several entries for some clients. Obviously this append only method needs a cleanup from time to time - see 1 above.<br>
<br>
BTW, there are some things you need to be aware of.<br>
<br>
AIUI "on xxxx" scripts are not executed asynchronously - hence running your script has the ability to severely compromise the performance of your DHCP service.<br>
If you are running the script to parse the lease that's just been written, can you obtain the information from within the server ? Eg build a log statement and then just tail the log file ?<br>
Can values be passed in the on xxxx call ? I don't know, but if they can then that might save you have to parse the file.<br>
<br>
______________________________<wbr>_________________<br>
dhcp-users mailing list<br>
<a href="mailto:dhcp-users@lists.isc.org">dhcp-users@lists.isc.org</a><br>
<a href="https://lists.isc.org/mailman/listinfo/dhcp-users" rel="noreferrer" target="_blank">https://lists.isc.org/mailman/<wbr>listinfo/dhcp-users</a><br>
</blockquote></div><br></div>