PIHOLE to plugin rewrite
This commit is contained in:
@@ -264,7 +264,7 @@
|
||||
}],
|
||||
"description": [{
|
||||
"language_code":"en_us",
|
||||
"string" : "Add all dhcp.leases mapped paths to watch. Enter full path within the container, e.g. <code>/mnt/dhcp2.leases</code>. You must map these files accordingly in your <code>docker-compose.yml</code> file."
|
||||
"string" : "Add all dhcp.leases mapped paths to watch. Enter full path within the container, e.g. <code>/mnt/dhcp2.leases</code>. You must map these files accordingly in your <code>docker-compose.yml</code> file. (If you are mapping a PiHole dhcp.leases file the path in the container must contain <code>pihole</code>, e.g.: <code>:/etc/pihole/dhcp.leases</code>)"
|
||||
}]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -39,8 +39,7 @@ def main():
|
||||
newEntries = []
|
||||
|
||||
if values.paths:
|
||||
for path in values.paths.split('=')[1].split(','):
|
||||
|
||||
for path in values.paths.split('=')[1].split(','):
|
||||
|
||||
newEntries = get_entries(newEntries, path)
|
||||
|
||||
@@ -79,15 +78,28 @@ def service_monitoring_log(primaryId, secondaryId, created, watched1, watched2 =
|
||||
# -----------------------------------------------------------------------------
|
||||
def get_entries(newEntries, path):
|
||||
|
||||
# PiHole dhcp.leases format
|
||||
if 'pihole' in path:
|
||||
data = []
|
||||
reporting = False
|
||||
with open(piholeDhcpleases, 'r') as f:
|
||||
for line in f:
|
||||
|
||||
row = line.rstrip().split()
|
||||
# rows: DHCP_DateTime, DHCP_MAC, DHCP_IP, DHCP_Name, DHCP_MAC2
|
||||
if len(row) == 5 :
|
||||
tmpPlugObj = plugin_object_class(row[1], row[2], 'True', row[3], row[4], 'True', path)
|
||||
newEntries.append(tmpPlugObj)
|
||||
|
||||
leases = DhcpLeases(path)
|
||||
leasesList = leases.get()
|
||||
# Generic dhcp.leases format
|
||||
else:
|
||||
leases = DhcpLeases(path)
|
||||
leasesList = leases.get()
|
||||
|
||||
for lease in leasesList:
|
||||
for lease in leasesList:
|
||||
|
||||
tmpPlugObj = plugin_object_class(lease.ethernet, lease.ip, lease.active, lease.hostname, lease.hardware, lease.binding_state, path)
|
||||
|
||||
newEntries.append(tmpPlugObj)
|
||||
tmpPlugObj = plugin_object_class(lease.ethernet, lease.ip, lease.active, lease.hostname, lease.hardware, lease.binding_state, path)
|
||||
newEntries.append(tmpPlugObj)
|
||||
|
||||
return newEntries
|
||||
|
||||
|
||||
Reference in New Issue
Block a user