The Vera Community forums have moved!

Advanced => Plugins & Plugin Development => Programming => Google Calendar Switch => Topic started by: Stuart on March 07, 2016, 06:40:08 pm

Title: GetLog Plugin for UI5 and UI7 R1.2
Post by: Stuart on March 07, 2016, 06:40:08 pm
In order to assist with getting log files remotely from vera, I put together this simple plugin.  It takes a copy of the logfile (and optionally applies a grep pattern) and places it in the /etc/cmh-ludl folder.  You can then directly download the logfile. Hopefully it will be useful -- feedback welcome.

You can install the latest version of the plugin from the marketplace or directly from the link below.

http://<your vera ip>:3480/data_request?id=update_plugin&Plugin=7626


When you press the "Get Log" button (either from the front panel or the control tab) a copy of the log file will be created.  It will be modified by any grep pattern you set (from the control tab).  The log file will be named 00-GetLog.log.  This may take up to a minute or so depending on the size of the log file.

Once the log file is created -- go to  Apps --> Develop Apps --> Luup files and you will see the log file listed near the top.  "Download" it ("View" does not work) and view it with a good text editor.  I use Notepad++.

Release 1.2
Fixed a bug that caused grep errors and made V1.1 unusable in certain situations.

Release 1.1 (Withdrawn)
Added  a "Clear Logs" button - this will remove logs for GCal3 as well as the log file for GetLogs.






Title: Re: GetLog Plugin
Post by: korttoma on March 08, 2016, 12:20:35 am
Thanks Stuart. I will give this a try.
Title: Re: GetLog Plugin
Post by: aste on March 09, 2016, 06:31:05 am
Thanks! Great to have it saved to a file directly.

Previously I used this to get the logs:

http://<vera IP>/cgi-bin/cmh/log.sh?Device=LuaUPnP (http://<vera IP>/cgi-bin/cmh/log.sh?Device=LuaUPnP)

\\ Andreas
Title: Re: GetLog Plugin
Post by: korttoma on March 09, 2016, 06:32:55 am
@aste

your previous solution only works localy
Title: Re: GetLog Plugin
Post by: amg0 on March 13, 2016, 05:18:32 am
for information, it is one of the feature ALTUI plugin offers this out of the box
ALTUI plugin discussions: http://forum.micasaverde.com/index.php/board,78.0.html (http://forum.micasaverde.com/index.php/board,78.0.html)
Title: Re: GetLog Plugin for UI5 and UI7
Post by: Stuart on March 13, 2016, 05:44:18 pm
@amg0 -- good to know -- looks classy.  I'm finishing up some upgrades to GCal3 and likely that will remain stable for a while.   I'll then give ALTUI a look.
Title: Re: GetLog Plugin for UI5 and UI7
Post by: korttoma on March 14, 2016, 08:45:11 am
@Stuart GetLog plugin works fine for me on my VeraPlus

@amg0 stil have not found time to look in to AltUI, sorry about that  :-\
Title: Re: GetLog Plugin for UI5 and UI7
Post by: Stuart on March 24, 2016, 11:49:32 pm
Production version posted -- see first post for details.
Title: Re: GetLog Plugin for UI5 and UI7
Post by: adma on May 27, 2016, 09:41:38 am
It would be nice to have some grep examples on the plugin device page to help users (like myself) that aren't familiar with grep and aren't familiar with the logging syntax in general. For example, how to filter by device ID, or command name, or view the last X lines of the log, etc.

Thanks.
Title: Re: GetLog Plugin for UI5 and UI7
Post by: Stuart on May 27, 2016, 11:52:42 am
The easiest way is to get a log file without any filter and take a look.
grep is well explained on the web - so play around with it and see what suits you.

As an example - if you put "device: 50" (with the quotes) into the filter you will get all lines with that string  as the output.

The actual command being executed is this:

grep "device: 50" /var/log/cmh/LuaUPnP.log > /etc/cmh-ludl/00-GetLog.log

Whatever you put in the filter end up going in here grep [filter] /var/log .......

Here is an example of how to use grep:

http://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples/
Title: Re: GetLog Plugin for UI5 and UI7
Post by: amg0 on May 27, 2016, 12:01:12 pm
@Stuart GetLog plugin works fine for me on my VeraPlus

@amg0 stil have not found time to look in to AltUI, sorry about that  :-\

:-),  you should... ( selling my own soup here ). more seriously, it makes this easy because you see the logs, can enter a string and it will construct the grep string for you, and you can even save your favorite commands under a button , so next time , it is one click only ( even if you have a parameter that you want to change for that command )
Title: Re: GetLog Plugin for UI5 and UI7
Post by: Stuart on May 27, 2016, 01:23:08 pm
@ amigO.   I will - promise  -- just need to fit it all in with my day job .....
Title: Re: GetLog Plugin
Post by: kevink619 on August 26, 2016, 06:02:50 pm
Thanks! Great to have it saved to a file directly.

Previously I used this to get the logs:

http://<vera IP>/cgi-bin/cmh/log.sh?Device=LuaUPnP (http://<vera IP>/cgi-bin/cmh/log.sh?Device=LuaUPnP)

\\ Andreas

Thanks. This actually works. The plug-in seems to be incompatible with the latest firmware on my VeraLite. I keep getting a grep 512 error with the plugin, but your URL method works like a charm.
Title: Re: GetLog Plugin for UI5 and UI7
Post by: Stuart on September 01, 2016, 06:24:10 pm
I'm on V 1.7.2139.

It is possible, depending on how much is installed on your vera, to run out of file space and that can throw an error.  Are you using a usb drive for the log files ?  Do you have verbose logging turned on ?

I had a similar problem a few days ago - so I turned on USB logging and also made some small changes to GetLog so that it will use the log file directory (and hence USB) to generates any temporary file (which can he large).  Previously it created a temp file in the vera upload directory ......

Try this version of GetLog and let me know if it helps.
Title: Re: GetLog Plugin for UI5 and UI7
Post by: kevink619 on September 07, 2016, 02:28:06 pm
Hi,

The version in the app store fails regardless of whether I enable USB logging or not.

The version attached to your message has the same problem:

Grep Pattern: Configured UI7 file
Grep Error Code: 512

Thanks,

Kevin

I'm on V 1.7.2139.

It is possible, depending on how much is installed on your vera, to run out of file space and that can throw an error.  Are you using a usb drive for the log files ?  Do you have verbose logging turned on ?

I had a similar problem a few days ago - so I turned on USB logging and also made some small changes to GetLog so that it will use the log file directory (and hence USB) to generates any temporary file (which can he large).  Previously it created a temp file in the vera upload directory ......

Try this version of GetLog and let me know if it helps.
Title: Re: GetLog Plugin for UI5 and UI7
Post by: Stuart on September 07, 2016, 07:03:59 pm
What are you using as the Grep Pattern ?

The grep call is returning an error (non zero code) that is interpreted by Lua as 512.  Either it cannot handle the pattern or there are no results found..
I have not looked but my guess is that vera is using busybox to implement grep and that may be limiting the results.

If there is no pattern (blank) - what happens ?  The grep code is not called if the pattern is blank.  So it's not possible (unless I have cleverly disguised bug) to get this error in the version I posted.  If you think this is not the case - can you grab and post a copy of the log file where the GetLog plugin is being called.
Title: Re: GetLog Plugin for UI5 and UI7
Post by: kevink619 on September 08, 2016, 12:19:04 am
I finally got it to work. :)

Somehow some random characters were getting added to the grep pattern field. I cleared it out and now it works.

Thanks,

Kevin
Title: Added new release R1.1
Post by: Stuart on October 11, 2016, 01:03:27 pm
This release adds the ability to delete the GetLog log file as well as any GCal3 log files.   When GCal3 is uninstalled / installed vera will create new device numbers.  This can leave old, unneeded log files in the directory.
Title: Re: GetLog Plugin for UI5 and UI7 R1.1
Post by: Andy on October 31, 2016, 06:11:06 am
I can't get getlog to save a log file, have tried no text for the grep, and a couple of words I thought it should find (log and wave).

In the case of no text a file is created that can't be viewed or successfully downloaded. In the case of using thone words I get "Grep Error Code: 256".

A bit of googling suggests this might actually be a count returned by grepfile via grep.
Title: Re: GetLog Plugin for UI5 and UI7 R1.2b
Post by: Stuart on October 31, 2016, 11:14:27 am
Try this file - I definitely had a bug that was producing the 256 error.  As a side note - the codes returned by Lua are not the ones grep returns, so it's unfortunately not that helpful.  There is some translation going on that I have not had time to figure out.

When you try to read the log file you need to use "Download" and open in a text editor.  I've never had vera do anything much (other than some xml  complaint) with "view".  If the log file is large - I have found that it will sometimes appear to be blank if the file is in the process of downloading when you try to open it in an editor.  In which case, try "save" and see if it opens once the download is complete.

Edit:  I released this as V1.2 in the marketplace and revoked V1.1
Title: Re: GetLog Plugin for UI5 and UI7 R1.2
Post by: korttoma on January 09, 2018, 03:45:16 am
Have not used this plugin for a while but today I tried to create a Log and found that it log file is not generated.
Does this plugin still work in 7.0.24 firmware?
Title: Re: GetLog Plugin for UI5 and UI7 R1.2
Post by: Stuart on January 09, 2018, 12:53:29 pm
Hi Thomas --

I just tried and got similar errors.  It seems something has changed (again) at the vera level.  I tried an alternate syntax for formulating the grep search and it seems to work. My guess is that busybox (from memory that's what's used in the OS as a command interpreter) has changed or the way vera pass commands to the OS.

Try this - it's a one-line change - and see if it works on your system.

Title: Re: GetLog Plugin for UI5 and UI7 R1.2
Post by: korttoma on January 11, 2018, 03:40:27 am
I noticed that it showed version 1.1 for GetLog Plugin even if I uploaded the new files you posted so I decided to uninstal the PluGin and reinstall from Marketplace. After reinstall it seems to be working correctly (version 1.2) again even if I did not add any of the files you posted here.
Title: Re: GetLog Plugin for UI5 and UI7 R1.2
Post by: Stuart on January 11, 2018, 11:13:19 am
My bad - I uploaded the wrong file.   Try this one (should log as 1.3) as it's possibly less sensitive to the different OS versions used in Vera.