Show openHAB events log on UI

1,823 views
Skip to first unread message

cau...@gmail.com

unread,
Sep 9, 2014, 12:53:43 PM9/9/14
to ope...@googlegroups.com
Hi all,

Is there any way to show the events log on the UI in order for the users to see what's going on? Some kind of widget or the like...

Thanks!

karsten.k...@gmail.com

unread,
Sep 9, 2014, 12:57:33 PM9/9/14
to ope...@googlegroups.com, cau...@gmail.com
Yes,

easy one :)

use attached perl scripts and install them on the webserver.

then you can use the following entries on the sitemap:

Text label="openHAB Eventlog" icon="office" {
         Webview url="http://192.168.1.10:8082/cgi-bin/openhab_events.pl" height=20
}
Text label="openHAB OH Log" icon="office" {
         Webview url="http://192.168.1.10:8082/cgi-bin/openhab_oh.pl" height=20

Cheers
Karsten

openhab_events.pl
openhab_oh.pl

Ben Jones

unread,
Sep 9, 2014, 4:16:20 PM9/9/14
to ope...@googlegroups.com, cau...@gmail.com
That looks great Karsten - apologies but I am pretty useless when it comes to web servers etc, could you explain how to install these perl scripts on a webserver? 

Do you mean in the openHAB /webapps folder somewhere? Or does it need to be in a standalone web server? I have apache2 running but I am not sure where these scripts should go to be accessed via /cgi-bin/.

Apologies for the stupid questions!

Cheers,
Ben

Ben Jones

unread,
Sep 9, 2014, 5:13:33 PM9/9/14
to ope...@googlegroups.com, cau...@gmail.com
Hi Karsten,

I got it working by dropping those scripts in /usr/lib/cgi-bin and adding the webview widgets to my sitemap - awesome stuff!

One question, I can only see the log output when I connect locally on my LAN. If I try connecting via SSL (i.e. on port 8443) or from the outside world (via my static IP) I don't see anything.

Is this an apache config problem you think? Do I need to allow access to those perl scripts somehow? 

As mentioned I have very little clue when it comes to webservers/apache and how to configure them...

Cheers,
Ben

cau...@gmail.com

unread,
Sep 10, 2014, 4:17:58 AM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
Hi all,

Thanks a lot for the fast replies.

I've been able to integrate the script and see the logs. However I have 2 pitfalls:
  1. How can I integrate this webview to ALL pages on the UI? Can I modify any kind of page template and add it there?
  2. How can I make this webview autorefresh on every event, without having to reload the whole page?
@Ben:
It can be an Apache config issue, try accessing the same way as you do when you're at your LAN (http instead of https maybe).

Greetings!

Jeroen Idserda

unread,
Sep 10, 2014, 5:08:41 AM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
On Wednesday, September 10, 2014 10:17:58 AM UTC+2, cau...@gmail.com wrote:
  1. How can I make this webview autorefresh on every event, without having to reload the whole page?

You could also use something like this in a webview: https://github.com/ukhas/js-logtail . No server side runtime required and it automatically shows new lines from the logfile. 

Jeroen.

karsten.k...@gmail.com

unread,
Sep 10, 2014, 5:27:05 AM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
@Ben

the apache webserver runs from my script call on port 8082 - and externally you are using the openhab https 8443 port. so you need to free up this port as well. Anyhow not recommended as this is then an unsecure connection.

Cheers
Karsten

Ben Jones

unread,
Sep 10, 2014, 6:40:38 AM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
Hi Jeroen,

Are you using this script? I downloaded and tried to run on my server but nothing was displayed aside from the 'Reverse'/'Pause' links.

Would be interested to hear if you are actually using this script as it sounds very useful.

Cheers,
Ben

Jeroen Idserda

unread,
Sep 10, 2014, 7:15:51 AM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
Yes, I am using this script right now. All you have to do is symlink the openhab logfile to a file called 'log' in the same directory as the js-logtail files. Like this for example:

ln -s /opt/openhab/logs/openhab.log log

You can also edit logtail.js and set url to the name of your logfile. The logfile still has to be in the same directory as the js-logtail files, because it has to be reachable through the webserver. 

Jeroen.

Ben Jones

unread,
Sep 10, 2014, 7:16:49 AM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
I am a complete noob when it comes to Apache and web servers/authentication/ssl. I have just spent the last hour trying to decipher the apache docs but my head is spinning. Basically your perl scripts working when I access the openHAB UI from within my own network (as long as I don't use SSL). Ideally I would like to access it remotely as well. External access to my openHAB server is permitted (over a non-standard port) via SSL with authentication but I can't work out how to allow your perl script to run in this scenario.

I will keep reading...

Ben Jones

unread,
Sep 10, 2014, 7:21:02 AM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
Where did you put the logtail files on your server? Under /opt/openhab/webapps/ or in /usr/lib/cgi-bin?

Sorry for the probably stupid questions!

Ben Jones

unread,
Sep 10, 2014, 7:33:14 AM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
Ok - got it working by putting the logtail folder under /var/www and symlinking to my openhab log (as you suggested).

If I point my browser at index.html though I just get a page with 'logtail.html' printed at the top. If I browse directly to logtail.html I see the log, but the reverse/chrono options don't work and take me back to the blank page with 'logtail.html' printed at the top.

Is this something to do with my apache config? Not allowing redirects or something?

Appreciate your help with this.

Jeroen Idserda

unread,
Sep 10, 2014, 8:00:19 AM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
In the js-logtail repo, index.html is a symlink to logtail.html. Your Apache should be set to allow symlinks (by using the FollowSymLinks option), see this for an example: http://superuser.com/questions/244245/how-do-i-get-apache-to-follow-symlinks

An easier option would be to just remove the index.html symlink and rename logtail.html to index.html

Jeroen.

Ben Jones

unread,
Sep 10, 2014, 3:51:38 PM9/10/14
to ope...@googlegroups.com, cau...@gmail.com
Cheers Jeroen - got it working now. I renamed logtail.html -> index.html and added an individual /apache2/conf.d/ file. Still can't access remotely or via SSL but I can live with that. Thanks for you help.

infono...@googlemail.com

unread,
Sep 24, 2014, 6:50:32 AM9/24/14
to ope...@googlegroups.com, cau...@gmail.com
Hi,

cool discussion as I was about to create a system information section in my sitemap. In fact I already did but it consists of placeholders only so far.
I planned on pulling many information by the system binding but I also wanted to be able to see logfiles through the ios app when being away from home. (Would be nice if the messages could be even filtered for errors/warnings  only ...)

I am not a developer but I wonder if it would't be a lot simpler to enhance the webview widget to not only display difficult stuff like pictures, videos and special formatted stuff but simple (local!) textfiles?

Digging deeper into the issue, I discovered its possible already.
https://192.168.x.xxx:8443/static/log.log directly shows the logfile since its a simple, plain text file. (copied there manually)
Testing the webview widget: not working since it seems that jetty is not handling symlinks by default. A copied file works though.  (well, webview items still cannot part of items but sitemaps only but thats something different. - I dont want logfiles on my start page)
Jetty Alias serving: http://wiki.eclipse.org/Jetty/Howto/How_to_serve_symbolically_linked_files

I really would prefer to be able to use a standard function than to add code snippets here and there (and even in different languages) for additional comfort.

-> is there a reason not being able to display sym links ? Or is it just a standard setting whick lacked of a  reason for changing it ?
-> How could a filter display warn / error messages only ?

Maximilian

unread,
Sep 24, 2014, 7:02:05 AM9/24/14
to
Hi,

it seems my last entry was not saved....
Again:

I would prefer to use build in functions only.
Displaying a log file with the webview widget works well.

There is just a few limitations so far . Maybe even these can be handled using build in functions:
- jetty does not display symlinked filed. (look here for alias serving: http://wiki.eclipse.org/Jetty/Howto/How_to_serve_symbolically_linked_files)
- it would be nice to filter the output for warnings / errors only

Does anyone know how to ? Or why (symlinks are disabled? default or needed ?)

Kind regards,
Maximilian

Thomas E.-E.

unread,
Sep 26, 2014, 2:19:15 PM9/26/14
to ope...@googlegroups.com
Hi,

wouldn't be HABmin more suitable to make log files available rather than the small smartphone or tablet displays. I agree it would be great to see notifications of certain severity in the client in order to learn more about the latest activities being processed in openHAB but i think this would be a more general question to be discussed in ESH.

Best, Thomas E.-E.


On Wednesday, September 24, 2014 1:02:05 PM UTC+2, Maximilian wrote:
Hi,

it seems my last entry was not saved....
Again:

I would prefer to use build in functions only.
Displaying a log file with the webview widget works well.

There is just a few limitations so far . Maybe even these can be handled using build in functions:
- jetty does not display symlinked filed. (look here for alias serving: http://wiki.eclipse.org/Jetty/Howto/How_to_serve_symbolically_linked_files)
- it would be nice to filter the output for warnings / errors only
- webviews cannot be part of items list. (does not really belong here). I do not want logfiles to cover my whole front page. ;)
Reply all
Reply to author
Forward
0 new messages