Announcement

Collapse
No announcement yet.

CPU usage is very high - Solved!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CPU usage is very high - Solved!

    Hi.

    I have an ongoing problem with HS CPU usage. This has been the same on HS3 later upgraded to HS4. HS3 was installed on a Win10 clean install PC, HS4 is now installed on Win10 clean install virtual machine. The very same problem.


    HS starts fine with no log errors, CPU usage is a few percent, after a few hours CPU load rises after a few days it hits 100% and I need to restart HS

    Click image for larger version

Name:	cpu.jpg
Views:	264
Size:	191.1 KB
ID:	1493273

    I installed Jon00 Perfmon and got this

    Click image for larger version

Name:	cpu jon.jpg
Views:	211
Size:	23.5 KB
ID:	1493274

    Clearly, something happens in about 2 hours after the start of HS

    Click image for larger version

Name:	cpustart.jpg
Views:	204
Size:	9.1 KB
ID:	1493275Click image for larger version

Name:	cpulater.jpg
Views:	206
Size:	8.2 KB
ID:	1493276

    At the time of CPU load rise, there is a spike.

    Click image for larger version

Name:	spike.jpg
Views:	210
Size:	63.3 KB
ID:	1493277

    For that time the log will show this error.

    Click image for larger version

Name:	log.jpg
Views:	209
Size:	16.8 KB
ID:	1493278

    There are a lot of forum posts about high CPU usage but couldn't find solutions. So how to troubleshoot it properly and find the cause of the problem?

    Thank you

    Br,
    Dali



    #2
    Can you list all the running plug-ins and scripts?



    From what's listed is your log above, looks like HStouch is trying to execute something which doesn't want to play ball


    Eman.
    TinkerLand : Life's Choices,"No One Size Fits All"

    Comment


      #3
      Thank you for your reply Eman!

      Originally posted by Eman View Post
      Can you list all the running plug-ins and scripts?Eman.
      Not many, but those are not showing high CPU load in task manager.

      Click image for larger version

Name:	plug.jpg
Views:	249
Size:	24.1 KB
ID:	1493286

      Script 1 (4 instances). To grab the battery state of for Android tablet I use;

      HTML Code:
      'HS4 Script 2020-11-02 JG
      'Modified by SER 2020-11-6
      Sub Main(ByVal parm As Object)
      
      Dim BattLevel
      BattLevel = parm(0).ToString ' Get string from HSTouch
      
      hs.SetDeviceValueByRef(2267, BattLevel, True)
      'hs.SetDeviceValueEx(2267, BattLevel, True)
      
      
      ' hs.writelog("HSTouch", Zipcode + " Battery Level changed to: " + BattLevel & "%")
      ' hs.writelog("HSTouch", "Client Name: " & Zipcode)
      ' hs.writelog("HSTouch", "Battery Level changed to: " & BattLevel & "%")
      End Sub
      Script 2 - Countdown
      HTML Code:
      Public Sub Main(param As Object)
      Dim StartVar as integer = 36000 ' Set this to the countdown starting value
      Dim x as Integer
      x = Convert.ToInt32(hs.TimerValue("Heater-1st_BathroomWall").TotalSeconds)
      hs.SetDeviceValueByRef(2097, StartVar - x, True)
      hs.SetDeviceString(2097, StartVar - x & " seconds", True)
      'hs.writelog("Utility Countdown","Updating")
      
      Dim hms as TimeSpan = TimeSpan.FromSeconds(StartVar - x)
      Dim h = hms.Hours.ToString
      Dim m = hms.Minutes.ToString
      Dim s = hms.Seconds.ToString
      'hs.SetDeviceString(2098, h & ":" & m & ":" & s, True)
      hs.SetDeviceString(2098, h & "h " & m & "m " & s & "s", True)
      hs.SetDeviceValueByRef(2098, StartVar - x, True)
      
      If x = StartVar then
      hs.WaitSecs(1)
      hs.SetDeviceValueByRef(2097, StartVar, True)
      hs.SetDeviceString(2097, StartVar & " seconds", True)
      
      Dim hmsSV as TimeSpan = TimeSpan.FromSeconds(StartVar)
      Dim hSV = hmsSV.Hours.ToString
      Dim mSV = hmsSV.Minutes.ToString
      Dim sSV = hmsSV.Seconds.ToString
      hs.SetDeviceValueByRef(2098, StartVar, True)
      hs.SetDeviceString(2098, h & "h " & m & "m " & s & "s", True)
      End If
      End Sub
      Script 3 - Dissarm (In never actually run it, but it's there)

      HTML Code:
      'HS3 Script 2014-08-14 RJS
      Sub Main(ByVal parm As Object)
      ' Get Armed Unarmed Button input code from HSTouch
      Dim inputcode
      inputcode = parm(0).ToString ' get input code
      
      If inputcode = "3254" Then
      hs.TriggerEvent("Passcodes CODE-XXX")
      
      End If
      
      If inputcode = "3600" Then
      hs.TriggerEvent("Passcodes CODE-XXX")
      
      End If
      
      If inputcode = "2468" Then
      hs.TriggerEvent("Passcodes CODE-XXX")
      
      End If
      
      If inputcode = "2345" Then
      hs.TriggerEvent("Passcodes Panic Alarm")
      
      End If
      
      If inputcode = "1111" Then
      hs.TriggerEvent("Passcodes Guest Passcode")
      
      End If
      End Sub
      Originally posted by Eman View Post
      From what's listed in your log above, looks like HStouch is trying to execute something which doesn't want to play ball
      That is what it appears if this is realy the cause of the problem.

      So the next step would be to restart HS without HS touch devices and monitor the CPU load? Or is there another debug log that could point out the problem directly.

      Thank you,

      Br,
      Dali

      Comment


        #4
        Am not really any good at scripts but the easiest to implement this, say if you use it for the purpose of recharging the battery is to use MQTT any plug-in will do...
        • The Android OS has Tasker and MQTT so you are already half way there...
        • The Profile/Event (Battery Changed) from the Tablet sends the Task, Topic ..../battery/state with the message %BATT (... for the device name)
        • Then once in HomeSeer you send it (value) back to be shown in HSTouch
        Android OS can multi Task!


        Eman.
        TinkerLand : Life's Choices,"No One Size Fits All"

        Comment


          #5
          The normal procedure for tracking rogue processes is to disable all plugins and one by one start enabling them until the rogue process shows itself.

          Unfortunately the reason you may not see any solutions to your problem is when some users find a solution to their problem they tend not to report back here.

          Comment


            #6
            Originally posted by concordseer View Post
            The normal procedure for tracking rogue processes is to disable all plugins and one by one start enabling them until the rogue process shows itself..
            Ok, I disabled the battery scripts and restarted HS4. Then I move to other scripts and plugins

            Thank you

            Br,
            Dali

            Comment


              #7
              Originally posted by concordseer View Post
              Unfortunately the reason you may not see any solutions to your problem is when some users find a solution to their problem they tend not to report back here.
              Very True. Some of these threads are like ripping the last few pages out of a good book.

              Too many "I got what I needed so I'm moving on."

              Comment


                #8
                Originally posted by concordseer View Post
                The normal procedure for tracking rogue processes is to disable all plugins and one by one start enabling them until the rogue process shows itself.

                Unfortunately the reason you may not see any solutions to your problem is when some users find a solution to their problem they tend not to report back here.
                Agree 100%.


                Regarding the issue. After disabling the Battery fetch script all seems OK. It's been 2 days and CPU is very still low. Let's hope it stays like this, but so far looks good.


                Click image for larger version

Name:	cpu_ok.jpg
Views:	157
Size:	87.8 KB
ID:	1493619


                Looking back now it makes perfect sense that scrips are the first thing to look at. HS and plugins have been tested and CPU bugs would surely be eliminated by now.

                Just for my understanding. What in this script could cause HS CPU to rise? I was using 4 of these scripts to get the battery level of 4 Android tablets.

                HTML Code:
                'HS4 Script 2020-11-02 JG
                'Modified by SER 2020-11-6
                Sub Main(ByVal parm As Object)
                
                Dim BattLevel
                BattLevel = parm(0).ToString ' Get string from HSTouch
                
                hs.SetDeviceValueByRef(2266, BattLevel, True)
                ' hs.SetDeviceValueEx(2266, BattLevel, True)
                
                
                ' hs.writelog("HSTouch", Zipcode + " Battery Level changed to: " + BattLevel & "%")
                ' hs.writelog("HSTouch", "Client Name: " & Zipcode)
                ' hs.writelog("HSTouch", "Battery Level changed to: " & BattLevel & "%")
                End Sub
                Thank you
                Br,
                Dali

                Comment


                  #9
                  SOLVED: After 7 days I can surely confirm the CPU load was caused by this script in my previous post.

                  I learned that for CPU issues custom scripts are the first thing to look at.

                  Thank you all for helping.

                  Br,
                  Dali

                  Comment

                  Working...
                  X