Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Search the Community

Showing results for tags 'memory leak'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • FIBARO Community
    • FIBARO Portal and Forum policy
    • FIBARO
    • Say hello!
    • Off-topics
  • FIBARO Update
    • FIBARO System Update
    • FIBARO Mobile Update
  • FIBARO Community Support
    • Scenes and Interface
    • FIBARO Products
    • FIBARO Mobile
    • FIBARO HomeKit
    • FIBARO Assistant Integrations
    • Other Devices / Third-party devices
    • Tutorials and Guides
    • Home Automation
    • Suggestions
  • FIBARO Społeczność
    • FIBARO
    • Przywitaj się!
    • Off-topic
  • FIBARO Aktualizacja
    • FIBARO System Aktualizacja
    • FIBARO Mobile Aktualizacja
  • FIBARO Wsparcie Społeczności
    • Sceny i Interfejs
    • FIBARO Urządzenia
    • FIBARO Mobilnie
    • FIBARO HomeKit
    • Integracja z Amazon Alexa i Google Home
    • Urządzenia Firm Trzecich
    • Poradniki
    • Automatyka Domowa
    • Sugestie

Categories

  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Google+


Skype


Website URL


WhatsApp


Country


Gateway/s


Interests

Found 1 result

  1. Like many others here, I'm frequently plagued by periodic crashes and 503 errors. In my case, I noticed that the memory usage would increase dramatically, to the point where scenes would no longer run, and the web interface wouldn't respond. Only a restart would fix it. I traced it to what I can only think is a memory leak, and I have a suspicion that it's related to the Heating/Cooling Panels. It might be fine for a while, and then for a week or so, I'll get the memory leak problem occur again. I can't be 100% sure, but I'm coming to conclusion that this happens after I've updated the Heating Panel. So I wrote this scene to monitor the memory usage and to automatically reboot the HC2 if the usage exceeds a specified value. I also have it writing the memory usage values off to AllThingsTalk, so that I can see the history, like this: For more details of AllThingsTalk, then see this post: Topic 21656 (Recording Data to AllThingsTalk.IO) Disclaimer: Only use this scene if your system is generally stable but occasionally has a memory problem, otherwise you might send your system into a continuous reboot loop. Please use this scene at your own risk. Only use it if you know what you are doing. Memory Monitor.lua --[[ %% properties %% events %% globals fiveMinuteTimer --]] -- Scene : Memory Monitor -- Version : 1.6 -- Date Created : 16 May 2016 -- Last Changed : 16 May 2017 -- HC Version : Home Center 2 v4.080 -- Created By : Dave Harrison -- Purpose : To keep an eye on the memory usage. -- : When it increases beyond a certain limit, then send a message and reboot the machine. -- : Record data to allthingstalk.io -- Trigger : Triggered by the fiveMinuteTimer global variable --================================================= -------- Declaration: Local Variables --================================================= local debug = true local sourceTrigger = fibaro:getSourceTrigger() local currentDateISO = os.date("!%Y-%m-%dT%XZ") local memoryUsedLimit = 70 local notificationDevice = 266 -- Change this to the mobile device number to send the notification to local allThingsTalkClientID = "xxxxxxxx" -- Change this to your AllThingsTalk ClientID local allThingsTalkClientKey = "yyyyyyyyy" -- Change this to your AllThingsTalk ClientKey local allThingsTalkAssetId = "789b2783e3dfe27040c84833" -- Change this to the Id of the AllThingsTalk Asset that is being used to record the usage --================================================= -------- Functions --================================================= local function log(str) if debug then fibaro:debug(str); end; end local function errorlog(str) fibaro:debug("<font color='red'>"..str.."</font>"); end local function processResponse(response) local memory = response.memory if (memory ~= nil) then local memoryFree = memory.free local memoryCache = memory.cache local memoryBuffers = memory.buffers local memoryUsed = memory.used local memoryTotalUsed = 100 - memoryFree -- Send the memory utilisation to AllThingsTalk local requestData = {value = memoryTotalUsed, at = currentDateISO} local requestBody = json.encode(requestData) sendData(allThingsTalkAssetId, requestBody) if (memoryTotalUsed > memoryUsedLimit) then fibaro:call(notificationDevice, "sendPush", "HC2 memory utilisation is " .. memoryTotalUsed .. "%") errorlog("Memory utilisation is too high: " .. memoryTotalUsed .. "%") -- Reboot the HC2 HomeCenter.SystemService.reboot() else log("Free memory is: " .. memoryFree .. "% Cache: " .. memoryCache .. "% Buffers: " .. memoryBuffers .. "% Used: " .. memoryUsed .. "% Total Used: " .. memoryTotalUsed .. "%") end else errorlog("Memory usage not found in diagnostics API") end end local function processError() errorlog("Error calling diagnostics API") end function sendData (assetId, requestBody) local url = "https://api.allthingstalk.io/asset/" .. assetId .. "/state" local httpClient = net.HTTPClient({timeout=5000}) local httpHeaders = { ["Auth-ClientId"] = allThingsTalkClientID, ["Auth-ClientKey"] = allThingsTalkClientKey, ["Content-Type"] = "application/json", } httpClient:request(url, { options={ headers = httpHeaders, data = requestBody, method = 'PUT', timeout = 5000 }, success = function(response) if (response.status >= 200 and response.status < 300) then log(assetId .. ": " .. response.status .. " - successful") else errorlog(assetId .. ": " .. response.status .. " - ERROR") end end, error = function(error) errorlog(assetId .. ": " .. "ERROR") log(error) end }) end --================================================= -------- Main --================================================= -- Get the memory and CPU usage information response, returnCode = api.get("/diagnostics") if (response ~= nil and returnCode == 200) then processResponse(response) else processError() end If you don't want to mess around with setting up AllThingsTalk, then here is a second version without this functionality: --[[ %% properties %% events %% globals fiveMinuteTimer --]] -- Scene : Memory Monitor -- Version : 1.6 -- Date Created : 16 May 2016 -- Last Changed : 16 May 2017 -- HC Version : Home Center 2 v4.080 -- Created By : Dave Harrison -- Purpose : To keep an eye on the memory usage. -- : When it increases beyond a certain limit, then send a message and reboot the machine. -- Trigger : Triggered by the fiveMinuteTimer global variable --================================================= -------- Declaration: Local Variables --================================================= local debug = true local sourceTrigger = fibaro:getSourceTrigger() local currentDateISO = os.date("!%Y-%m-%dT%XZ") local memoryUsedLimit = 70 local notificationDevice = 266 -- Change this to the mobile device number to send the notification to --================================================= -------- Functions --================================================= local function log(str) if debug then fibaro:debug(str); end; end local function errorlog(str) fibaro:debug("<font color='red'>"..str.."</font>"); end local function processResponse(response) local memory = response.memory if (memory ~= nil) then local memoryFree = memory.free local memoryCache = memory.cache local memoryBuffers = memory.buffers local memoryUsed = memory.used local memoryTotalUsed = 100 - memoryFree -- Send the memory utilisation to AllThingsTalk local requestData = {value = memoryTotalUsed, at = currentDateISO} local requestBody = json.encode(requestData) if (memoryTotalUsed > memoryUsedLimit) then fibaro:call(notificationDevice, "sendPush", "HC2 memory utilisation is " .. memoryTotalUsed .. "%") errorlog("Memory utilisation is too high: " .. memoryTotalUsed .. "%") -- Reboot the HC2 HomeCenter.SystemService.reboot() else log("Free memory is: " .. memoryFree .. "% Cache: " .. memoryCache .. "% Buffers: " .. memoryBuffers .. "% Used: " .. memoryUsed .. "% Total Used: " .. memoryTotalUsed .. "%") end else errorlog("Memory usage not found in diagnostics API") end end local function processError() errorlog("Error calling diagnostics API") end --================================================= -------- Main --================================================= -- Get the memory and CPU usage information response, returnCode = api.get("/diagnostics") if (response ~= nil and returnCode == 200) then processResponse(response) else processError() end The scene is triggered every 5 minutes by a global variable. See Topic 24789 (Simple Timer/Scheduling Scene) or Topic 23510 (Main Scene for Time Based Events Control) for examples of how use a timer global variable. The scene is currently set to reboot when the memory usage exceeds 70%. There is still the possibility that if the memory usage is increasing at a very high rate, then the HC2 will crash before the scene next runs. So setting it to 70% seems to be low enough to catch most instances. Do not set this to a low value otherwise your HC2 might go into a continuous reboot loop. Take a look at your normal RAM usage in the Diagnostics Panel and use a value higher than this. You will need to change the line of code that specifies the Mobile Device Id which should receive the notification message when the memory limit is exceeded. You can find the device id from the API. Enter the following URL into a browser: http://<HC2 IP Address>/api/iosDevices This will return a list of the mobile devices and you can select the appropriate one. You'll also need to assign the correct values to the AllThingsTalk ClientID, ClientKey and AssetId if you're using the first version of the scene. You can get all these values from the Maker pages of AllThingsTalk.com.
×
×
  • Create New...