From a7dcb35bdca36d8681fedbf160d1155b5d1e68b4 Mon Sep 17 00:00:00 2001
From: Robin Sonnabend <robin@fsmpi.rwth-aachen.de>
Date: Tue, 5 Jun 2018 12:29:51 +0200
Subject: [PATCH] Add weathermap html page with auto refresh

---
 mrtg/files/weathermap.html | 11 +++++++++++
 mrtg/tasks/main.yml        |  2 +-
 mrtg/tasks/weathermap.yml  |  9 +++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 mrtg/files/weathermap.html

diff --git a/mrtg/files/weathermap.html b/mrtg/files/weathermap.html
new file mode 100644
index 0000000..abab69c
--- /dev/null
+++ b/mrtg/files/weathermap.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<html>
+<head>
+<title>Weathermap</title>
+<meta http-equiv="refresh" content="300" />
+<meta charset="utf-8" />
+</head>
+<body>
+<img src="weathermap.png">
+</body>
+</html>
diff --git a/mrtg/tasks/main.yml b/mrtg/tasks/main.yml
index 5b05e2e..8f88e6e 100644
--- a/mrtg/tasks/main.yml
+++ b/mrtg/tasks/main.yml
@@ -46,7 +46,7 @@
   tags: mrtg
 
 - name: create an index HTML page
-  command: "indexmaker --output /var/www/mrtg/index.html --title='Traffic of {{domain}}' --columns=3 --pagetop='{% for switch in mrtg_switches %}<a href=\"index-{{switch['router']}}.html\"><b>{{switch['router']}}</b>.{{domain}}</a> {% endfor %} {% if use_weathermap %}<a href=\"weathermap.png\">Weathermap</a>{%endif %}' /etc/mrtg.cfg"
+  command: "indexmaker --output /var/www/mrtg/index.html --title='Traffic of {{domain}}' --columns=3 --pagetop='{% for switch in mrtg_switches %}<a href=\"index-{{switch['router']}}.html\"><b>{{switch['router']}}</b>.{{domain}}</a> {% endfor %} {% if use_weathermap %}<a href=\"weathermap.html\">Weathermap</a>{%endif %}' /etc/mrtg.cfg"
   become: yes
   become_user: mrtg
   tags: mrtg
diff --git a/mrtg/tasks/weathermap.yml b/mrtg/tasks/weathermap.yml
index de0162d..c86d8a6 100644
--- a/mrtg/tasks/weathermap.yml
+++ b/mrtg/tasks/weathermap.yml
@@ -61,6 +61,15 @@
   script: "makeweather.py {{weathermap_placement_strategy}} --colorscale /root/colorscale.pal"
   tags: weathermap
 
+- name: upload the weathermap html file
+  copy:
+    src: weathermap.html
+    dest: /var/www/mrtg/
+    owner: mrtg
+    group: www-data
+    mode: 0644
+  tags: weathermap
+
 - name: create the weathermap regularly
   cron:
     name: "create weathermap"
-- 
GitLab