Show part of the logfiles on your sitemap

Every log-nerd would want to display some contents of their logs in the sitemap right? :wink:
This will require the exec-binding to be installed…

In this example I will show a part of the events.log.
Start by making a shell-script that you store somewhere containing:

#!/bin/bash

echo '<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=utf-8">' > /etc/openhab2/html/events.html

echo "<html>" >> /etc/openhab2/html/events.html
echo "<Body bgcolor="#303030">" >> /etc/openhab2/html/events.html
echo "<pre style='color:white; width:100%'>" >> /etc/openhab2/html/events.html
cat /var/log/openhab2/events.log | tail -n30 >> /etc/openhab2/html/events.html
echo "</pre>" >> /etc/openhab2/html/events.html
echo "</Body>" >> /etc/openhab2/html/events.html
echo "</html>" >> /etc/openhab2/html/events.html

I call my shell script ev.sh and its stored in /etc/openhab2/kommandon/ (this is a folder I made myself just to store shell scripts in…)

Next I make a thing-file containing:

Thing exec:command:ev [command="/etc/openhab2/kommandon/ev.sh", interval=60, timeout=5, autorun=false]

This will update the html-file once a minute…

Next add this to your sitemap:

 Webview url="/static/events.html" height=16

This will show the part of the logfile on your sitemap…

Very cool, that was something on my list as well. I quick and dirty tried to imlement the logtail from @illnesse from this thread (Hacking BasicUI: My current Theme / OH2 Setup *Update with Repo*) and copied & modified his script and html, but unfortunately had some issues with the html accessing the data from the log. As I just had a few minutes time, I left it then.

I will copy your one and if I have the time try to make a structured html page. Well hopefully some time…:smiley: