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:


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 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/", 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:

hi =)
i tried your scrip but got this error

2019-10-18 20:07:58.492 [ERROR] [hab.binding.exec.handler.ExecHandler] - An exception occurred while executing '/etc/openhab2/kommandon/' : 'Cannot run program "/etc/openhab2/kommandon/": error=2, No such file or directory'

running by console results same
sudo: unable to execute /etc/openhab2/kommandon/ No such file or directory

but file exist
[20:12:04] openhabian@openHABianPi:~$ dir /etc/openhab2/kommandon/

any ideas ?

Do on terminal:
cd /etc/openhab2/kommandon/

sudo chmod 774
Sudo ./

still the same :frowning:

[20:53:04] openhabian@openHABianPi:~$ cd /etc/openhab2/kommandon
[20:53:30] openhabian@openHABianPi:/etc/openhab2/kommandon$ sudo chmod 774
[20:53:46] openhabian@openHABianPi:/etc/openhab2/kommandon$ sudo ./
: No such file or directory

I would think its a problem with ownership/rights…openhab run by default as user/group openhab…

So the files you want to run needs to be owned by openhab (

chown openhab.openhab

why does it not refresh every minute ?
If I call the script from the console the events.html gets updatet but not automatically by refresh time defined in the thing.
Br Peter

Ok… there was a ownership rights problem with my events.html
i fixed it here: