Commit c0b78bdb authored by Matthew Smith's avatar Matthew Smith
Browse files

Tidy up code

parent f08b3dd7
......@@ -60,7 +60,7 @@ COLUMN = '144'
DIFFERENCE = str(int(WIDTH) - int(COLUMN))
DEBUG = os.getenv('DEBUG')
DEBUG = True
DEBUG = False
#################
# External Vars #
......@@ -257,9 +257,9 @@ class Grafana:
pattern = None
if display_name:
pattern = re.compile(display_name)
if name and pattern == None:
if name and pattern is None:
pattern = re.compile(name)
if command and pattern == None:
if command and pattern is None:
pattern = re.compile(command)
if DEBUG:
......@@ -351,7 +351,7 @@ if service_state:
HTML += '\n<tr><th>Service Data:</th><td><a style="color: #0095bf; text-decoration: none;" href="' + ICINGA2BASE + '/monitoring/service/show?host=' + host_alias + '&service=' + service_name + '">' + service_output + '</a></td></tr>'
HTML += '\n<tr><th>Event Time:</th><td>' + long_date_time + '</td></tr>'
if (notification_author and notification_comment):
if notification_author and notification_comment:
HTML += '\n<tr><th>Comment:</th><td>' + notification_comment + ' (' + notification_author + ')</td></tr>'
if netbox.host:
......@@ -381,19 +381,19 @@ if netbox.ip:
HTML += netbox.addNetboxVal('Host', netbox.ip, 'device', 'name')
if (performance_data or grafana.panelID):
if performance_data or grafana.panelID:
HTML += '\n</table><br>'
HTML += '\n<table width=' + WIDTH + '>'
HTML += '\n<tr><th colspan=6 class=perfdata>Performance Data</th></tr>'
if (performance_data):
if performance_data:
HTML += '\n<tr><th>Label</th><th>Last Value</th><th>Warning</th><th>Critical</th><th>Min</th><th>Max</th></tr>'
PERFDATALIST = performance_data.split(" ")
for PERFDATA in PERFDATALIST:
if '=' not in PERFDATA:
perf_data_list = performance_data.split(" ")
for data in perf_data_list:
if '=' not in data:
continue
(LABEL,DATA) = PERFDATA.split("=")
if (len(DATA.split(";")) is 5):
(LABEL,DATA) = data.split("=")
if len(DATA.split(";")) is 5:
(VALUE,WARNING,CRITICAL,MIN,MAX) = DATA.split(";")
else:
(VALUE,WARNING,CRITICAL,MIN) = DATA.split(";")
......@@ -461,7 +461,7 @@ except socket.error as e:
os.sys.exit(e.errno)
if (EMAILUSERNAME and EMAILPASSWORD):
if EMAILUSERNAME and EMAILPASSWORD:
smtp.login(EMAILUSERNAME, EMAILPASSWORD)
try:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment