leases = open(dhcp_leases_filename, 'r').read() for lease in leases.split('}'): if lease.find('{') > -1: dhcp_ipv4_address = lease.split('{')[0].split('lease')[1].strip() if lease.find('client-hostname') > -1: dhcp_leases[dhcp_ipv4_address] = {'hostname': lease.split('client-hostname')[1].strip()[1:-2]}
lease 192.168.99.242 { starts 2 2016/12/13 18:05:23; tstp 2 2016/12/13 18:05:23; tsfp 2 2016/12/13 18:05:23; atsfp 2 2016/12/13 18:05:23; binding state backup;}failover peer "dhcp_lan" state { my state normal at 2 2016/12/13 16:30:14; partner state normal at 2 2016/12/13 17:05:23;}
root@fwa:/usr/local/opnsense/scripts/interfaces # ./list_arp.pyTraceback (most recent call last): File "./list_arp.py", line 51, in <module> dhcp_ipv4_address = lease.split('{')[0].split('lease')[1].strip()IndexError: list index out of rangeroot@fwa:/usr/local/opnsense/scripts/interfaces #
# The format of this file is documented in the dhcpd.leases(5) manual page.# This lease file was written by isc-dhcp-4.3.5# authoring-byte-order entry is generated, DO NOT DELETEauthoring-byte-order little-endian;failover peer "dhcp_lan" state { my state normal at 2 2016/12/13 16:30:14; partner state normal at 2 2016/12/13 17:05:23;}
if (lease.find('{') > -1) && (lease.find(something that matches regex "^lease") > -1):
configd.py: [bdfbd41d-060f-46de-969c-c67b1adc0dc0] Script action failed with Command '/usr/local/opnsense/scripts/interfaces/list_arp.py "json"' returned non-zero exit status 1 at Traceback (most recent call last): File "/usr/local/opnsense/service/modules/processhandler.py", line 477, in execute stdout=output_stream, stderr=error_stream) File "/usr/local/lib/python2.7/subprocess.py", line 541, in check_call raise CalledProcessError(retcode, cmd) CalledProcessError: Command '/usr/local/opnsense/scripts/interfaces/list_arp.py "json"' returned non-zero exit status 1
root@fwa:/var/dhcpd/var/db # grep -n peer dhcpd.leases*dhcpd.leases:8:failover peer "dhcp_lan" state {dhcpd.leases:323:failover peer "dhcp_lan" state {dhcpd.leases:328:failover peer "dhcp_lan" state {dhcpd.leases:333:failover peer "dhcp_lan" state {dhcpd.leases~:8:failover peer "dhcp_lan" state {dhcpd.leases~:323:failover peer "dhcp_lan" state {dhcpd.leases~:328:failover peer "dhcp_lan" state {dhcpd.leases~:333:failover peer "dhcp_lan" state {root@fwa:/var/dhcpd/var/db #