From 1bdd4c82a7a2a0d114d43cd3ded65ab51efa9eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20M=C3=A4der?= <maeder@phys.ethz.ch> Date: Wed, 19 Jun 2019 07:31:23 +0200 Subject: [PATCH] Add icons --- bin/xymon-vulnerabilities.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/bin/xymon-vulnerabilities.py b/bin/xymon-vulnerabilities.py index 518eb11..63c422c 100755 --- a/bin/xymon-vulnerabilities.py +++ b/bin/xymon-vulnerabilities.py @@ -28,22 +28,28 @@ def red(xymon): def run_check(xymon): + title = 'CPU' + content = [] + for vuln in cpu_vulnerabilities: - title = ''.join([vuln, ': ']) + icon = '&green' vuln_file = Path(''.join([cpu_vulnerabilities_base, vuln])) + if vuln_file.is_file(): with open(str(vuln_file)) as f: - content = '<br/>'.join(f.readlines()) - if content.startswith('Vulnerable'): - title += 'Vulnerable' + lines = '<br>'.join(f.readlines()).rstrip() + + if lines.startswith('Vulnerable'): + icon = '&red' red(xymon) - else: - title += content.split(':')[0] else: - title += 'Potentially Vulnerable' - content = 'Kernel needs update and host reboot' + lines = 'Kernel needs update and host reboot' + icon = '&yellow' yellow(xymon) - xymon.section(title, content) + + content.append(''.join([icon, ' ', vuln, ': ', lines])) + + xymon.section(title, '<br>'.join(content)) def main(): -- GitLab