#433, 435 work - handle empty in DHCPLSS, email templates fixes

This commit is contained in:
Jokob-sk
2023-09-12 20:32:09 +10:00
parent 78a87c4ed0
commit 0f56f06937
4 changed files with 28 additions and 21 deletions

View File

@@ -29,7 +29,7 @@
<tr>
<td>
<table width=100% border=0 bgcolor=#4b99d3 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#ffffff"> <tr>
<td width=100%> Report Date: <b><REPORT_DATE></b> </td>
<td width=100% bgcolor="#3c8dbc"> Report Date: <b><REPORT_DATE></b> </td>
</tr>
</table>
</td>
@@ -51,7 +51,7 @@
<td>
<table width=100% bgcolor=#3c8dbc cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
<tr>
<td width=50% style="text-align:center;color: white;">
<td width=50% style="text-align:center;color: white;" bgcolor="#3c8dbc">
<a href="https://github.com/jokob-sk/Pi.Alert" target="_blank" style="color: white">Pi.Alert</a>
<a href=".." target="_blank" style="color: white"> (<SERVER_NAME>)</a>
<br><span style="display:inline-block;color: white; transform: rotate(180deg)">&copy;</span>2020 Puche (2022+

View File

@@ -29,7 +29,7 @@
<tr>
<td>
<table width=100% border=0 bgcolor=#4b99d3 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#ffffff"> <tr>
<td width=100%> Report Date: <b><REPORT_DATE></b> </td>
<td width=100% bgcolor="#3c8dbc"> Report Date: <b><REPORT_DATE></b> </td>
</tr>
</table>
</td>
@@ -51,7 +51,7 @@
<td>
<table width=100% bgcolor=#3c8dbc cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
<tr>
<td width=50% style="text-align:center;color: white;">
<td width=50% style="text-align:center;color: white;" bgcolor="#3c8dbc">
<a href="https://github.com/jokob-sk/Pi.Alert" target="_blank" style="color: white">Pi.Alert</a>
<a href=".." target="_blank" style="color: white"> (<SERVER_NAME>)</a>
<br><span style="display:inline-block;color: white; transform: rotate(180deg)">&copy;</span>2020 Puche (2022+

View File

@@ -10,7 +10,7 @@ import sys
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/pialert')
from plugin_helper import Plugin_Object, Plugin_Objects
from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty
from logger import mylog
from dhcp_leases import DhcpLeases
@@ -45,28 +45,28 @@ def get_entries(path, plugin_objects):
row = line.rstrip().split()
if len(row) == 5:
plugin_objects.add_object(
primaryId=row[1],
secondaryId=row[2],
watched1='True',
watched2=row[3],
watched3=row[4],
watched4='True',
extra=path,
foreignKey=row[1]
primaryId = handleEmpty(row[1]),
secondaryId = handleEmpty(row[2]),
watched1 = handleEmpty('True'),
watched2 = handleEmpty(row[3]),
watched3 = handleEmpty(row[4]),
watched4 = handleEmpty('True'),
extra = handleEmpty(path),
foreignKey = handleEmpty(row[1])
)
else:
leases = DhcpLeases(path)
leasesList = leases.get()
for lease in leasesList:
plugin_objects.add_object(
primaryId=lease.ethernet,
secondaryId=lease.ip,
watched1=lease.active,
watched2=lease.hostname,
watched3=lease.hardware,
watched4=lease.binding_state,
extra=path,
foreignKey=lease.ethernet
primaryId = handleEmpty(lease.ethernet),
secondaryId = handleEmpty(lease.ip),
watched1 = handleEmpty(lease.active),
watched2 = handleEmpty(lease.hostname),
watched3 = handleEmpty(lease.hardware),
watched4 = handleEmpty(lease.binding_state),
extra = handleEmpty(path),
foreignKey = handleEmpty(lease.ethernet)
)
return plugin_objects

View File

@@ -33,6 +33,13 @@ pialertConfigFile = read_config_file()
timeZoneSetting = pialertConfigFile['TIMEZONE']
timeZone = pytz.timezone(timeZoneSetting)
# -------------------------------------------------------------------
def handleEmpty(input):
if input == '' or None:
return 'null'
else:
return input
# -------------------------------------------------------------------
def decodeBase64(inputParamBase64):