Frequent Luup engine restarts - help debugging

I had a long period of stability with my Vera. A few weeks ago, I started noticing issues and started keeping an eye on the System Monitor plugin. It was showing that I’m having frequent Luup restarts. I haven’t changed anything before the issues began: I was happy to let a stable Vera do its thing.

I checked in with MCV and they suspected that it’s a PLEG issue and said (after one check):

Something about this PLEG condition is crashing the unit. You can try to delete it or edit it to stop it from flooding with requests as it?s generating memory leaks and eventually crash the engine.

I know to take this with a grain of salt, so I’m trying to figure out the best way to debug things.

I guess that the first issue is figuring out how to view the log without leaving the “Log for LuaUPnP” window open to the log all the time, then hunt for the error. I know how to SSH to my Vera, but I’m not familiar with tail/less/more to know the best way to view the pertinent section of my log to see what was happening.

Can someone get me started on the road back to stability? I suppose the first thing I need to be able to do is browse the LuaUPnP log for whatever happened just before a restart.

Is there a way to download the LuaUPnP log rather than view it on the Vera?

I would suggest using winscp and notepad++ but since you are not a fan of Bill, these free tools might not be at your disposal. The file is located in the /var/log/cmh/LuaUPnP.log.

I use emacs as my editor for most things … With it I can access files remotely on Vera (or any other unix box) via scp access.

Tha main issue is not to access to the log file by Winscp or other SSH app but how to analyse the log file ( Luup Exit code etc…) as tutorial on this subjet is not really availble in order to start.

I went ahead and left the log URL (http://xxx/cgi-bin/cmh/log.sh?Device=LuaUPnP) open and captured a few crashes. I got 1

Terminated with Exit Code: 138

and 2

2015-09-25 13:45:23 - LuaUPnP Terminated with Exit Code: 245

which suggests (to me anyway) that the reasons for crash were different.

But I’m getting a restart every 60-90 minutes. Which makes things flaky.

But it’s weird to me that everything was fine for quite a while, then all of a sudden, I’ve got problems.

Is it possible for me to introduce memory leaks via PLEGs? I do have a bit of startup Lua:

[code]function to_hex(spec_char)
return string.format(“%%%2X”, spec_char:byte(1))
end

function escape(in_string)
return string.gsub(in_string, “%W”, to_hex)
end

function trim(s)
return (s:gsub(“^%s*(.-)%s*$”, “%1”))
end

function deedeeSay(text,unmute)
unmute = unmute or 0

local s_awake = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 47)
local h_awake = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 48)


s_awake = tonumber(s_awake)
h_awake = tonumber(h_awake)
luup.log("Scott:" .. s_awake .. " Holly:" .. h_awake)
if ( ( (h_awake == 1)  and (s_awake == 1) ) or unmute == 1) then
	t = escape(text)
	durl = "http://192.168.1.110/gir/speak.lhtml?t=" .. t
	http = require("socket.http")
	http.TIMEOUT = 1
	local  body, code, headers, status = http.request(durl)
end
luup.log(body)
luup.log(code)

end

function ievent(cmd)
cmd = escape(cmd)
durl = ‘http://192.168.1.110/gir/triggerEvent.lhtml?es=’ … cmd

http = require("socket.http")
http.TIMEOUT = 1
local  body, code, headers, status = http.request(durl)

end

function setLightState(device, value)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, { newTargetValue = value }, device)
end

function setDimmerState(device, value)
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, { newLoadlevelTarget = value }, device)
end[/code]

After watching “top” for a while, it does indeed appear that there’s a leak that’s making LuaUPnP eat up more and more memory.

What’s the best method to figure out what’s causing trouble? I have a little bit of Lua (posted above) and everything else is plugin-based. And I’m not using what I’d consider exotic plugins.

(With the above Lua, I added “local” to several of the variables for which it wasn’t declared, worried that that could be part of the cause. Fixing that had no effect.)

One thing of note. I do use Chixxi’s Variable Container and see that he’s unpublished that plugin. I don’t have auto-update on, but I continue to use the plugin. And I’m occasionally seeing “GetPluginVersionOnline failed to convert” warnings in the log for RexBecket’s MiLightRGBW plugin and for the GCal3 plugin (both were set to auto-update, but I’m disabling that as I post this)