Sending an HTTP Request

You’ve shifted the problem from hogging a rules thread to hogging a timer thread.
That can mean that other timers becoming due cannot start executing.

I think you can use HTTP binding for fire-and-forget, because it uses a different timeout mechanism.

I suppose you could use HTTP action with a very short timeout, inside a try-catch that suppresses the error message.

What is the limit on the number of timers?

I don’t mind the error appearing in the log.

Do you see a problem reducing the HTTP timeout to 1 sec, thus making the HTTP call and receiving the error after 1 second, but still the PHP would run my batch file?

createTimer(now.plusMillis(1),  [ |
        logInfo("EntranceDoorOpened", "BEGINNING: Running email batch file - Home Empty")
      sendHttpGetRequest("http://192.168.1.111/SendMailOpenHAB.php", 1000)
        logInfo("EntranceDoorOpened", "END: Running email batch file - Home Empty")   
])

Well, using the 1mS createTimer here is pointless really.

You’re only firing off an HTTP request, whether that triggers a script or makes a bank payment makes no difference to openHAB. It’s only going to wait as long as the timeout to see if anything comes back.
Have you tried 0 out of interest? Not clear from docs if it might work.

Re Timers; you can have as many as you wish awaiting their moment, but I think only two executing their code. Hence the advice not to hog there.

I’d be inclined to do the small work to suppress an expected error message - wood/trees for the next issue.

As rossko57 indicates, this only moves the problem. There are two thread pools, one for Rules that has 5 by default and another for Timers that has 2 by default. You are likely to have fewer Timer actually executing at the same time than Rules so this might be better. Or it could be worse if you have lots of timers. NOTE that some bindings use threads out of the Timer thread pool too like Astro. cron triggered Rules use these threads too.

Yes, 2. Note that they are only using a thread when they are actively running. When they are awaiting their trigger time they do not consume and threads.

The best solution would be if you can modify the php script to not block until the batch file finishes. If the php script can kick off the script and immediately return and do all that extra work in the background it would be far better over all.

Using the HTTP binding like rossko57 recommends indeed would probably be a better approach, though there would be no way to ever suppress the error from the logs short of configuring the logger to not log any errors from the HTTP binding I think.

Thank you @rossko57 and @rlkoshak for spending your time, assisting me and sharing all the information.

That is a great idea, and I made this change in the PHP script.
I have also modified the HTTP call to wait only 1000ms:

sendHttpGetRequest("http://192.168.1.111/SendMailOpenHAB.php", 1000)

This will still allow me to see if there is an error whenever the called server is not responding.

Would you two still recommend the HTTP binding approach also now, when the PHP automatically provides a response?

Please note that even with the HTTP binding I will still have to use the timers, since the same rule makes several HTTP calls, which should be in a specific order along 15 seconds.

This is the full picture:

rule EntranceDoor Opened
when
   Item iEntranceDoorSensor changed to OPEN
then
        createTimer(now.plusMillis(1),  [ |
                sendHttpGetRequest(". . . . .", 1000)  // Move camera to face door
        ])
        createTimer(now.plusSeconds(1),  [ |
                sendHttpGetRequest(". . . . .", 1000)  // Start Video recording
        ])
        createTimer(now.plusSeconds(1),  [ |
                sendHttpGetRequest(". . . . .", 1000)  // Run PHP file that checks what is the latest file NOW but sends it in 30 seconds
        ])
        createTimer(now.plusSeconds(15),  [ |
                sendHttpGetRequest(". . . . .", 1000)  // Stop Video recording
        ])
end

Thanks again for your assistance and tips.

My personal Rule of thumb is if I can have fewer lines of code in Rules it’s better. I’m not sure it saves you much in this case. I wouldn’t change the working Rule.

However I have some observations.

I’d get rid of the first timer (now.plusMillis(1)) and just call the HTTP command.

The next two timers go off at basically the same time, so why not combine them and just use one Timer that calls both?

For me to understand & learn:
Wouldn’t this mean that if it takes the camera 1000ms to respond to the move request, it will make the rule wait for a whole second?
If my understanding is correct, why would you prefer the rule to wait for 1 second over using a timer thread? Because there are only 2 timer threads and 5 rule threads?

You are correct.
The reason for this is that the “Start Video recording” and “Stop video recording” are at the same part of the code, while the “Run PHP file” is in a later part of the code, which calls the PHP file with a parameter, based on an “if” clause.

Based on reading your Design Pattern: How to Structure a Rule, I assume I should build the HTTP string in the “if” clause, and only then create a single timer with the 2 HTTP calls:
One “static” to Start Video recording
Second “dynamic” (which was built in the “if” clause) to run the PHP file.

Am I correct?

EDIT:

While waiting for your answer, I tried modifying the rule, but I receive an error in VS.

The error is:

Cannot refer to the non-final variable httpPHPStr inside a lambda expression

The modified rule:

rule EntranceDoor Opened
when
   Item iEntranceDoorSensor changed to OPEN
then
        createTimer(now.plusMillis(1),  [ |
                sendHttpGetRequest(". . . . .", 1000)  // Move camera to face door
        ])

        var httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php?id=3"   // Parents at home

        if (ParentsNotAtHome) {
             if (KidsAtHome) {
                  httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php?id=1"  // Kids Home Alone
             } else {
                  httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php?id=2"  // Home is Empty
            }
       }

        createTimer(now.plusSeconds(1),  [ |
                sendHttpGetRequest(". . . . .", 1000)  // Start Video recording
                sendHttpGetRequest(httpPHPStr, 1000)  // Run PHP file that checks what is the latest file NOW but sends it in 30 seconds
        ])
        createTimer(now.plusSeconds(15),  [ |
                sendHttpGetRequest(". . . . .", 1000)  // Stop Video recording
        ])
end

I assume this is because the httpPHPStr variable is not defined within the createTimer.
How should I tackle this?
Or does it mean I cannot use your DP in this case?

Rick can give you the “why” about lambdas and context, but the overall effect is that you cannot pass vars into timer lambdas - the code between [ ]. This is the “non-final” thing it’s whinging about.

You can pass vals - but have to observe the limitation that you cannot modify a val after creation, it’s like a constant.

Unrelated consideration; do you want to evaluate conditions at the time you create the timer, or at the moment it executes? Doesn’t matter a lot when it’s just a few seconds, but it can do, and then you’d need to structure as required.

This should work, note use of val and var

             // only one place to set URL, easier to maintain
        val httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php"

        createTimer(now.plusSeconds(1),  [ |
                sendHttpGetRequest(". . . . .", 1000)  // Start Video recording
                var httpPHPStrParam = httpPHPStr + "?id=3"   // Parents at home
                if (ParentsNotAtHome) {
                    if (KidsAtHome) {
                       httpPHPStrParam = httpPHPStr + "?id=1"  // Kids Home Alone
                    } else {
                       httpPHPStrParam = httpPHPStr + "?id=2"  // Home is Empty
                    }
                }
                sendHttpGetRequest(httpPHPStrParam, 1000)  // Run PHP file that checks what is the latest file NOW but sends it in 30 seconds
        ])

I’m a bit confused with the overall task - if you have control of Start and Stop recording, why not do the grab-and-post part after recording has stopped?

1 Like

Thank you for the thorough explanation - I understand the difference between var and val, and now also know that from outside a lambda you can also pass vals, and you can only use vars that are defined within the lambda.

I wold like to evaluate at the time the timer is created. Thanks.

I have 1 more question:
Is it allowed to use createTimer within a createTimer? Is there any risk involved (apart of what you already explained me, that only 2 timer threads can be executed at the same time)?
If, for example, I would like to send a Telegram message with a photo, a few seconds after the door was opened, can I use this (note the sendTelegramPhoto inside:

     // only one place to set URL, easier to maintain
val httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php"

createTimer(now.plusSeconds(1),  [ |
        sendHttpGetRequest(". . . . .", 1000)  // Start Video recording
        var httpPHPStrParam = httpPHPStr + "?id=3"   // Parents at home
        if (ParentsNotAtHome) {
            if (KidsAtHome) {
               httpPHPStrParam = httpPHPStr + "?id=1"  // Kids Home Alone
            } else {
               httpPHPStrParam = httpPHPStr + "?id=2"  // Home is Empty
              createTimer(now.plusSeconds(3),  [ | 
                         sendTelegramPhoto("bot1", "http://192.168.1.222/snapshot.cgi", "Door Opened when Kids home alone")
               ])
            }
        }
        sendHttpGetRequest(httpPHPStrParam, 1000)  // Run PHP file that checks what is the latest file NOW but sends it in 30 seconds
])

Is there a better approach to this?

This is a bit complicated - I hope I’ll manage to explain it with my lousy English.

My camera starts and stops recording based on different events (for example, motion detected, size of video file, etc).

In order for the video file to be played correctly after being sent, it must be sent in full, i.e. after the recording of that file is stopped.

Therefor, whenever the door is opened I want to start recording (and make sure a new video file is created).
Then, I want to check what is the name of that last video file, wait for 15 seconds, finish recording (thus “closing” the file) and only then sending it.

Also look at the expire binding because it can be used for some tasks not unlike what you are doing

I am already using the expire binding for a dozen of “virtual” switch items that operate as timers (for example: change air condition temperature after some time, etc.)

Do you recommend creating a couple of virtual items that will server as timers with the expire binding, and using a couple of rules, execute the relevant activities?

Yes… exactly!
I have just been checking out some forum posts on use of the expire binding and there is info in the forums but I don’t find a clear easy example of how I mostly use it… so

I usually create a switch item as follows

Switch BathDayXpr { expire="3m,command=OFF" }

So, the switch changes to OFF after 3 minutes. If it is sent any command except OFF, it re-triggers the timer. So if it is sent ON from a motion sensor or something, the 3 minutes starts over.

then I use a rule as such

rule "My timer ran out"
when
    BathDayXpr changes to OFF
then
   // do whatever you want here
   MyBathroomLight.sendCommand (OFF)
end

What may be useful for you is not worrying about running out of timer threads or creating new timers or whatever, just set up an unbound expire item as shown then do whatever when it is ready

Yes and you are creating a lot of timers in this a rule which increases the likelihood that you will have two or more that need to run at the same time.

There is also no evidence presented to indicate that you are usually running low on rule threads.

This sounds like a good approach.

I believe this is one of those cases where VSCode complains but the rule will actually run just fine.

The following code works.

var Timer timer = null

rule "Test string"
when
 Item Test received command
then
 logInfo("Test", "Test changed to \""+Test.state.toString+"\"")

 var count = 0
 timer = createTimer(now, [ |
     logInfo("test", "Looping timer with " + count)
     if(count < 10) {
       count = count + 1
       timer.reschedule(now.plusMillis(500))
     }
     else {
       timer = null
     }
 ])
end

I tested it not to long ago. As you can see, count is a var referenced inside the lambda. The trick though is that the changes to count exist only inside the lambda.

Actually you can with create timer. It doesn’t make sense to with a lambda passed to forEach, for example, because the changes made to the var only exist inside the lambda.

This has been reported as an error by the vscode forever but I wonder if it’s always been allowed despite the warning.

All that being said, rossko57’s version is a bit cleaner over all.

1 Like

So taking into consideration the advantages and disadvantages, how would you implement if it was for yourself?

A. Using the rossko57’s version (which does uses timers)
or
B. leaving the sendHttp* calls in the rule, and taking the risk that the rule could hang up to 3 seconds (and another rule with expire binding that will be executed 15 seconds later and could hang for 1 second a well)?

You are right.
When I originally built my rules, I placed all my sendHTTP* calls in a createTimer, because I read somewhere a recommendation to refrain from having it in a rule.
I was not aware that there is also a limit on the number of timer threads running together.

When I check the number of threads using htop, is it normal that this number fluctuates, with an overall growing trend?

On June 13th at 10:45 it was 287
On June 13th at 15:12 it was 301
On June 13th at 16:48 it was 291
On June 13th at 23:33 it was 296
On June 14th at 08:35 it was 298
On June 14th at 23:03 it was 294
On June 15th at 23:48 it was 316
On June 16th at 21:46 (now) it is 310

What should I pay attention to in my rules, to make sure I don’t cause this number to grow?

Also, is it normal to see on the htop list many threads with:

/usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab

Here are the first 50 lines on htop:

  1  [|||||                                                        6.7%]   Tasks: 42, 317 thr; 1 running
  2  [|||||                                                        5.9%]   Load average: 0.58 0.52 0.53
  3  [||||                                                         4.6%]   Uptime: 5 days, 01:29:10
  4  [|||||                                                        7.5%]
  Mem[||||||||||||||||||||||||||||||||||||||||||||||||||||||||608M/976M]
  Swp[|||||||||||                                          16.5M/100.0M]

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
 6197 openhab    20   0  670M  470M 10520 S 14.0 48.2 14h55:46 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
28934 openhabia  20   0  8092  4020  2428 R  4.7  0.4  0:25.41 htop
27081 openhab    20   0  670M  470M 10520 S  2.0 48.2  0:27.47 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
27082 openhab    20   0  670M  470M 10520 S  2.0 48.2  0:37.69 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 7163 openhab    20   0  670M  470M 10520 S  2.0 48.2 49:37.98 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
  525 openhab    20   0  670M  470M 10520 S  1.3 48.2  0:00.17 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6305 openhab    20   0  670M  470M 10520 S  1.3 48.2  2h42:29 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
28071 openhab    20   0  670M  470M 10520 S  1.3 48.2  0:05.69 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
  475 openhab    20   0  670M  470M 10520 S  1.3 48.2  0:00.13 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
  754 openhab    20   0  670M  470M 10520 S  1.3 48.2  0:00.02 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6301 openhab    20   0  670M  470M 10520 S  0.7 48.2  1h16:57 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
28876 openhabia  20   0  6220  2572  2388 S  0.7  0.3  0:03.02 bash -c while [ -d /proc/$PPID ]; do sleep 1;head -v -n 8 /proc/meminfo; head -v -n 2 /
31800 openhab    20   0  670M  470M 10520 S  0.7 48.2  0:00.76 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
28776 openhab    20   0  670M  470M 10520 S  0.7 48.2  0:02.35 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
28486 openhab    20   0  670M  470M 10520 S  0.7 48.2  0:03.32 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
  476 openhab    20   0  670M  470M 10520 S  0.7 48.2  0:00.12 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
32245 openhab    20   0  670M  470M 10520 S  0.7 48.2  0:00.69 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
  516 grafana    20   0  921M 17880  7812 S  0.7  1.8  8:08.91 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/g
  597 influxdb   20   0  868M 57644  7208 S  0.7  5.8  3:37.33 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
28945 influxdb   20   0  868M 57644  7208 S  0.7  5.8 10:34.45 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
28854 openhabia  20   0 11896  4608  3624 S  0.0  0.5  0:02.98 sshd: openhabian@pts/0
 7171 openhab    20   0  670M  470M 10520 S  0.0 48.2  2:53.00 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6801 openhab    20   0  670M  470M 10520 S  0.0 48.2  1h26:00 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6568 openhab    20   0  670M  470M 10520 S  0.0 48.2 31:18.52 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6827 openhab    20   0  670M  470M 10520 S  0.0 48.2 22:03.65 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6820 openhab    20   0  670M  470M 10520 S  0.0 48.2 22:00.24 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
14565 openhab    20   0  670M  470M 10520 S  0.0 48.2  4:01.44 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6458 openhab    20   0  670M  470M 10520 S  0.0 48.2 23:55.31 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 4651 openhab    20   0  670M  470M 10520 S  0.0 48.2  0:04.89 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
  515 influxdb   20   0  868M 57644  7208 S  0.0  5.8  3h52:24 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
 7387 openhab    20   0  670M  470M 10520 S  0.0 48.2  6:00.75 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6482 openhab    20   0  670M  470M 10520 S  0.0 48.2  1:20.90 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6823 openhab    20   0  670M  470M 10520 S  0.0 48.2  2:13.36 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6826 openhab    20   0  670M  470M 10520 S  0.0 48.2 22:16.44 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
32759 openhab    20   0  670M  470M 10520 S  0.0 48.2  0:00.29 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
29298 openhab    20   0  670M  470M 10520 S  0.0 48.2  0:02.12 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
14563 openhab    20   0  670M  470M 10520 S  0.0 48.2  3:41.95 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
30079 openhab    20   0  670M  470M 10520 S  0.0 48.2  0:00.17 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6355 openhab    20   0  670M  470M 10520 S  0.0 48.2  3:15.26 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
31983 openhab    20   0  670M  470M 10520 S  0.0 48.2  0:00.04 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
28743 openhab    20   0  670M  470M 10520 S  0.0 48.2  0:00.11 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
  635 grafana    20   0  921M 17880  7812 S  0.0  1.8  0:42.87 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/g
  704 influxdb   20   0  868M 57644  7208 S  0.0  5.8 15:24.99 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
 6307 openhab    20   0  670M  470M 10520 S  0.0 48.2  4:47.56 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
 6323 openhab    20   0  670M  470M 10520 S  0.0 48.2  2:26.99 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab
  858 influxdb   20   0  868M 57644  7208 S  0.0  5.8 23:19.62 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
  509 openhab    20   0  141M 27012  8816 S  0.0  2.7  2:56.87 node /usr/bin/frontail --ui-highlight --ui-highlight-preset /usr/lib/node_modules/front
 6935 openhab    20   0  670M  470M 10520 S  0.0 48.2  0:11.01 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab

The answer depends on information I don’t have. The better solution depends on what the rest of your rules and timers are doing. If you are unlikely to have lots of other rules running when this rule runs then I’d the up the Rule thread. If you are but you are unlikely to have more than one other Timer, Cron triggered rule, or Astro triggered rule go off at the same time then Timers would be a better choice. If you are likely to have rules and timers going off at the same time, I’d move these long running http calls to an external script that can execute without consuming OH resources.

Also note that as you update and modify your rules the better solution may change.

That shows you all of the OH threads. But in this discussion all that matters is the timer threads and the rules threads. By default you only get two timer threads and five rules threads.

Rules cannot cause this number to increase.

1 Like

Thanks for your detailed answer.

What can cause the number of threads to increase?
Do the statistics I provided above reflect a normal status or not?
Do these threads get “released” after some time?

Since I recently had issues with slow response, I re-installed openhabian and OH, and would like to make sure I don’t get to the same situation again.

The thread gets released when the rule is done executing

I’m sure Rich can explain it better but there are 5 rules threads. Every running rule consumes one thread while it is actually running. Most rules only run for a few fractions of a second so long as they are not overly complex. Example: motion sensor signal ON, rule runs, turns light on… done, maybe a few milliseconds. So 5 should be plenty, in case 2 or 3 things happen all at once. But if you have rules that run for a long period of time, for what ever reason, that is one less thread in the pool of available threads for other rules that want to run

So… what causes threads to run for a long time? Lots of stuff, but most is common sense. Long thread sleeps are the worst offenders. Long running loops, calls to services that don’t reply quickly, whatever

//yoda voice//
much reading to do have you

I am already familiar with everything you wrote (with regards to rules, and thanks to this thread, also with regards to timers).

I don’t use any Thread::sleep, all my sendHTTP* calls were within createTimer to prevent rules hanging, and apart of this my rules don’t use any timers (I do have 16 cron-based rules and 3 astro-based rules, but they are all well spread along the day).

I am not familiar, though, with the OS, how it should behave, and how to analyze the usage of resources, and making sure it works as it should, or I should look into specific areas and analyze them.

As @rlkoshak wrote,

I am looking for what causes the number of threads growing on my system, and whether this is a "temporary"grow (and threads get released over time) or it is a “constant” grow.

If it helps, my setup is using openhabian over a RPi 3B+ with the following bindings:

  • Astro (only 3 very short rules are triggered by the astro binding)
  • Expire (~30 items using it)
  • HarmonyHub
  • Xiaomi Mi (2 nodes connected to it)
  • Network (pinging 4 iPhones)
  • Samsung Tv (polling every 1 second)
  • openHAB Weather (polling every 2 minutes)
  • YamahaReceiver (polling every 10 seconds)
  • ZWave (~22 nodes connected to it)

Also using:

  • openHAB Cloud connector
  • Google Calendar connector
  • Mapdb for RestoreOnStartup
  • Influxdb for some other items (installed grafana as well, but didn’t “play” with it too much, yet)

Here is a the full bundle list:

openhab> bundle:list
START LEVEL 100 , List Threshold: 50
 ID │ State    │ Lvl │ Version                │ Name
 20 │ Active   │  80 │ 5.3.1.201602281253     │ OSGi JAX-RS Connector
 21 │ Active   │  80 │ 2.7.0.v20170129-0911   │ Gson: Google Json Library for Java
 22 │ Active   │  80 │ 18.0.0                 │ Guava: Google Core Libraries for Java
 23 │ Active   │  80 │ 3.0.0.v201312141243    │ Google Guice (No AOP)
 26 │ Active   │  80 │ 3.5.5                  │ JmDNS
 28 │ Active   │  80 │ 1.0.0                  │ Units of Measurement API
 30 │ Active   │  80 │ 1.1.0.Final            │ Bean Validation API
 31 │ Active   │  80 │ 2.0.1                  │ javax.ws.rs-api
 32 │ Active   │  80 │ 3.2.0.v201101311130    │ ANTLR Runtime
 35 │ Active   │  80 │ 3.2.1                  │ Commons Collections
 36 │ Active   │  80 │ 1.1                    │ Commons Exec
 37 │ Active   │  80 │ 2.2.0                  │ Commons IO
 38 │ Active   │  80 │ 2.6                    │ Commons Lang
 47 │ Active   │  80 │ 4.2.1                  │ Apache Karaf :: OSGi Services :: Event
 63 │ Active   │  80 │ 4.6.0                  │ Apache XBean OSGI Bundle Utilities
 64 │ Active   │  80 │ 4.6.0                  │ Apache XBean :: Classpath Resource Finder
 65 │ Active   │  80 │ 2.12.0.v20160420-0247  │ EMF Common
 66 │ Active   │  80 │ 2.12.0.v20160420-0247  │ EMF Ecore
 67 │ Active   │  80 │ 2.11.0.v20160420-0247  │ EMF Change Model
 68 │ Active   │  80 │ 2.12.0.v20160420-0247  │ EMF XML/XMI Persistence
 69 │ Active   │  80 │ 3.8.0.v20160509-1230   │ Common Eclipse Runtime
 70 │ Active   │  80 │ 3.6.100.v20160223-2218 │ Extension Registry Support
 80 │ Active   │  80 │ 9.4.11.v20180605       │ Jetty :: Proxy
 94 │ Active   │  80 │ 0.4.1.v20180515-1321   │ org.eclipse.lsp4j
 95 │ Active   │  80 │ 0.4.1.v20180515-1321   │ org.eclipse.lsp4j.jsonrpc
 96 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome OAuth2Client
 97 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Config Core
 98 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Configuration Discovery
 99 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Configuration mDNS Discovery
100 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Config Dispatcher
101 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome Config XML
102 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Core
103 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Core Audio
104 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Core Binding XML
105 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Core ID
106 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Core Persistence
107 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Scheduler Service
108 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Core Semantics
109 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Core Thing
110 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome Core Thing XML
111 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Transformation Service
112 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Core Voice
113 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Console
114 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Console for OSGi runtime Karaf
115 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome HTTP Interface Bundle
116 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome JavaSound I/O, Fragments: 183
117 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Monitor
118 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Net I/O Bundle
119 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome REST Interface Bundle
120 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Core REST API
121 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome REST mDNS Announcer
122 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome REST Interface JAX-RS optimization Bundle
123 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Sitemap REST API
124 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome SSE REST API
125 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Voice REST API
126 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Bonjour/MDS Service Discovery Bundle
127 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Web Audio Support
128 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Model Core
129 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Item Model
130 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Item Model IDE
131 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Item Model Runtime
132 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Language Server
133 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Persistence Model
134 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Persistence Model IDE
135 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Persistence Runtime
136 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Rule Model
137 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Rule Model IDE
138 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Rule Runtime
139 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Script
140 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Script Model IDE
141 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Script Runtime
142 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Sitemap Model
143 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Sitemap Model IDE
144 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Sitemap Runtime
145 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Thing Model
146 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Thing Model IDE
147 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Thing Model Runtime
148 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Json Storage Service
149 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome UI
150 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome UI Icons
151 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Classic IconSet
152 │ Active   │  80 │ 2.14.0.v20180522-1629  │ Xtend Runtime Library
153 │ Active   │  80 │ 2.14.0.v20180522-1629  │ Xtend Macro Interfaces
154 │ Active   │  80 │ 2.14.0.v20180522-1821  │ Xtext
155 │ Active   │  80 │ 2.14.0.v20180522-1833  │ Xtext Common Types
156 │ Active   │  80 │ 2.14.0.v20180522-1821  │ Xtext IDE Core
157 │ Active   │  80 │ 2.14.0.v20180522-1821  │ Xtext Utility
158 │ Active   │  80 │ 2.14.0.v20180522-1833  │ Xbase Model
159 │ Active   │  80 │ 2.14.0.v20180522-1833  │ Xbase Generic IDE Services
160 │ Active   │  80 │ 2.14.0.v20180522-1629  │ Xbase Runtime Library
175 │ Active   │  80 │ 1.9.6                  │ MIME streaming extension
177 │ Active   │  80 │ 6.2.0                  │ org.objectweb.asm
178 │ Active   │  80 │ 6.2.0                  │ org.objectweb.asm.commons
179 │ Active   │  80 │ 6.2.0                  │ org.objectweb.asm.tree
180 │ Active   │  90 │ 2.4.0                  │ openHAB Core
181 │ Active   │  80 │ 2.4.0                  │ openHAB Karaf Integration
183 │ Resolved │  80 │ 2.4.0                  │ openHAB Sound Support, Hosts: 116
184 │ Active   │  80 │ 2.4.0                  │ openHAB Dashboard UI
189 │ Active   │  80 │ 1.0.2                  │ Units of Measurement Common Library
190 │ Active   │  80 │ 1.0.8                  │ Units of Measurement Implementation for Java SE
191 │ Active   │  80 │ 1.6.0                  │ Commons Codec
192 │ Active   │  80 │ 3.3.0                  │ Commons Net
193 │ Active   │  80 │ 4.2.3                  │ Apache HttpClient OSGi bundle
194 │ Active   │  80 │ 4.2.3                  │ Apache HttpCore OSGi bundle
195 │ Active   │  80 │ 3.1.0.7                │ Apache ServiceMix :: Bundles :: commons-httpclient
196 │ Active   │  80 │ 2.4.0                  │ openHAB 1.x Compatibility Layer
197 │ Active   │  80 │ 1.1.1.201605111122     │ Swagger Provider
198 │ Active   │  80 │ 2.4.5                  │ Jackson-annotations
199 │ Active   │  80 │ 2.4.5                  │ Jackson-core
200 │ Active   │  80 │ 2.4.5                  │ jackson-databind
201 │ Active   │  80 │ 2.4.5                  │ Jackson-dataformat-XML
202 │ Active   │  80 │ 2.4.5                  │ Jackson-dataformat-YAML
203 │ Active   │  80 │ 2.4.5                  │ Jackson-module-JAXB-annotations
204 │ Active   │  80 │ 2.1.0                  │ json-path
205 │ Active   │  80 │ 3.14.0                 │ nrjavaserial
206 │ Active   │  80 │ 3.15.0.OH2             │ nrjavaserial
207 │ Active   │  80 │ 1.5.8                  │ swagger-annotations
208 │ Active   │  80 │ 1.5.8                  │ swagger-core
209 │ Active   │  80 │ 1.5.8                  │ swagger-jaxrs
210 │ Active   │  80 │ 1.5.8                  │ swagger-models
211 │ Active   │  80 │ 3.19.0.GA              │ Javassist
212 │ Active   │  80 │ 2.2                    │ json-smart
213 │ Active   │  80 │ 3.2.1                  │ Apache Commons Lang
214 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Astro Binding
215 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Configuration UPnP Discovery
216 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Configuration USB-Serial Discovery
217 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Configuration USB-Serial Discovery Linux sysf Scanning
218 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Config Serial
219 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Serial Transport
220 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Serial Transport for RXTX
221 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Serial Transport extension for RXTX RFC2217
222 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome UPnP Transport Bundle
223 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome Exec Transformation Service
224 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome JavaScript Transformation Service
225 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome JSonPath Transformation Service
226 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome Map Transformation Service
227 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome RegEx Transformation Service
228 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome Scale Transformation Service
229 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome XPath Transformation Service
230 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome Xslt Transformation Service
231 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Basic UI, Fragments: 249
232 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome WebApp UI, Fragments: 250
233 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome Paper UI, Fragments: 253
234 │ Active   │  80 │ 2.5.1                  │ JUPnP Library
235 │ Active   │  80 │ 1.13.0                 │ openHAB Telegram Action
236 │ Active   │  80 │ 2.4.0                  │ Amazon Echo Control Binding
237 │ Active   │  80 │ 1.13.0                 │ openHAB Expire Binding
238 │ Active   │  80 │ 2.4.0                  │ HarmonyHub Binding
239 │ Active   │  80 │ 2.4.0                  │ Xiaomi Mi Smart Home Binding
240 │ Active   │  80 │ 2.4.0                  │ Network Binding
241 │ Active   │  80 │ 2.4.0                  │ Samsung Tv Binding
242 │ Active   │  80 │ 1.13.0                 │ openHAB Weather Binding
243 │ Active   │  80 │ 2.4.0                  │ YamahaReceiver Binding
244 │ Active   │  80 │ 2.4.0                  │ ZWave Binding
245 │ Active   │  80 │ 1.13.0                 │ openHAB Google Calendar
246 │ Active   │  80 │ 2.4.0                  │ openHAB Cloud Connector Bundle
247 │ Active   │  80 │ 2.4.0                  │ openHAB REST Documentation
248 │ Active   │  80 │ 1.13.0                 │ openHAB InfluxDB Persistence bundle
249 │ Resolved │  75 │ 2.4.0                  │ openHAB Basic UI Fragment, Hosts: 231
250 │ Resolved │  75 │ 2.4.0                  │ openHAB Classic UI Fragment, Hosts: 232
251 │ Active   │  80 │ 2.4.0                  │ HABmin User Interface
252 │ Active   │  80 │ 2.4.0                  │ HABPanel User Interface
253 │ Resolved │  75 │ 2.4.0                  │ openHAB Paper UI Theme Fragment, Hosts: 233
254 │ Active   │  80 │ 0.9.10.v20160429-1435  │ reflections (wrap)
255 │ Active   │  80 │ 3.1.4                  │ Stax2 API
256 │ Active   │  80 │ 1.5.8.v20160511-1038   │ swagger-jersey2-jaxrs (wrap)
257 │ Active   │  80 │ 1.13.0                 │ openHAB MapDB Persistence Bundle

Also, when I check the list of shell threads, it seems that there are many HttpClient threads - is this normal?

openhab> shell:threads --list
Id     │ Name                                                                                          │ State         │ CPU time │ Usr time
───────┼───────────────────────────────────────────────────────────────────────────────────────────────┼───────────────┼──────────┼─────────
1      │ main                                                                                          │ WAITING       │ 2575     │ 2470
2      │ Reference Handler                                                                             │ WAITING       │ 26863    │ 25880
3      │ Finalizer                                                                                     │ WAITING       │ 26459    │ 24960
4      │ Signal Dispatcher                                                                             │ RUNNABLE      │ 0        │ 0
8      │ Active Thread: Equinox Container: 06135c0a-8aaf-4d50-a8c5-f0b33656f5c8                        │ TIMED_WAITING │ 82598    │ 73330
10     │ Framework Event Dispatcher: org.eclipse.osgi.internal.framework.EquinoxEventPublisher@16d6c1e │ WAITING       │ 139      │ 100
11     │ Start Level: Equinox Container: 06135c0a-8aaf-4d50-a8c5-f0b33656f5c8                          │ WAITING       │ 56948    │ 55870
12     │ Karaf Lock Monitor Thread                                                                     │ TIMED_WAITING │ 160805   │ 126410
13     │ Karaf Shutdown Socket Thread                                                                  │ RUNNABLE      │ 1        │ 0
24     │ Coordination Timer                                                                            │ WAITING       │ 0        │ 0
25     │ CM Configuration Updater                                                                      │ WAITING       │ 1972     │ 1920
26     │ CM Event Dispatcher                                                                           │ WAITING       │ 47       │ 40
27     │ fileinstall-/var/lib/openhab2/etc                                                             │ TIMED_WAITING │ 185857   │ 176160
28     │ Thread-12                                                                                     │ RUNNABLE      │ 2        │ 0
31     │ EventAdminAsyncThread #11                                                                     │ WAITING       │ 208411   │ 187470
32     │ EventAdminAsyncThread #12                                                                     │ WAITING       │ 208582   │ 187030
35     │ Bundle File Closer                                                                            │ WAITING       │ 249      │ 140
37     │ fileinstall-/usr/share/openhab2/addons                                                        │ TIMED_WAITING │ 80329    │ 69900
38     │ Thread-16                                                                                     │ RUNNABLE      │ 0        │ 0
39     │ SCR Component Actor                                                                           │ WAITING       │ 0        │ 0
41     │ pool-1-thread-1                                                                               │ TIMED_WAITING │ 28587    │ 20810
42     │ Thread-17                                                                                     │ RUNNABLE      │ 1        │ 0
45     │ pool-3-thread-1                                                                               │ TIMED_WAITING │ 28698    │ 21070
46     │ Thread-19                                                                                     │ RUNNABLE      │ 0        │ 0
55     │ Thread-21                                                                                     │ RUNNABLE      │ 73       │ 60
56     │ sshd-SshServer[1021c4c]-timer-thread-1                                                        │ TIMED_WAITING │ 46469    │ 35370
64     │ ServletEventDispatcher: 1                                                                     │ WAITING       │ 8        │ 0
65     │ ServletEventDispatcher: 2                                                                     │ WAITING       │ 25       │ 20
66     │ qtp11319873-66                                                                                │ RUNNABLE      │ 6        │ 0
67     │ qtp11319873-67                                                                                │ RUNNABLE      │ 0        │ 0
68     │ Scheduler-15005426                                                                            │ TIMED_WAITING │ 919      │ 900
69     │ qtp11319873-69-acceptor-0@1bbc586-0.0.0.0:8443@430ba8{SSL,[ssl, http/1.1]}{0.0.0.0:8443}      │ RUNNABLE      │ 2        │ 0
72     │ qtp11319873-72-acceptor-0@1e9e2ad-default@bbaeb2{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}           │ RUNNABLE      │ 4573     │ 3410
74     │ ServletEventDispatcher: 3                                                                     │ WAITING       │ 27       │ 20
75     │ ResourcePublisher                                                                             │ WAITING       │ 12855    │ 12680
76     │ Thread-30                                                                                     │ RUNNABLE      │ 29       │ 20
77     │ Dir Watcher                                                                                   │ WAITING       │ 148      │ 100
81     │ Scheduler-28557918                                                                            │ TIMED_WAITING │ 22300    │ 19740
83     │ pool-8-thread-1                                                                               │ TIMED_WAITING │ 19416    │ 18240
87     │ ESH-OSGiEventManager                                                                          │ TIMED_WAITING │ 1537770  │ 1444690
96     │ openHAB-job-scheduler_Worker-1                                                                │ TIMED_WAITING │ 478086   │ 453590
97     │ openHAB-job-scheduler_Worker-2                                                                │ TIMED_WAITING │ 485735   │ 461030
98     │ openHAB-job-scheduler_QuartzSchedulerThread                                                   │ TIMED_WAITING │ 95613    │ 92960
99     │ EMF Reference Cleaner                                                                         │ WAITING       │ 149735   │ 89090
100    │ pool-12-thread-1                                                                              │ WAITING       │ 35       │ 30
108    │ com.google.inject.internal.util.$Finalizer                                                    │ WAITING       │ 0        │ 0
127    │ SocketListener(JmDNS-/192.168.1.7)                                                            │ RUNNABLE      │ 394522   │ 376510
128    │ JmDNS(JmDNS-/192.168.1.7).Timer                                                               │ TIMED_WAITING │ 131836   │ 125430
129    │ JmDNS(JmDNS-/192.168.1.7).State.Timer                                                         │ TIMED_WAITING │ 1607     │ 1430
135    │ pool-9-thread-1                                                                               │ TIMED_WAITING │ 149100   │ 111670
136    │ pool-13-thread-1                                                                              │ WAITING       │ 2019166  │ 1866580
140    │ pool-21-thread-1                                                                              │ WAITING       │ 14438    │ 14140
141    │ pool-22-thread-1                                                                              │ WAITING       │ 11606    │ 11240
146    │ lsp-1                                                                                         │ RUNNABLE      │ 50       │ 40
147    │ Timer-3                                                                                       │ WAITING       │ 0        │ 0
148    │ Timer-4                                                                                       │ WAITING       │ 0        │ 0
149    │ Timer-5                                                                                       │ WAITING       │ 63       │ 30
150    │ Timer-6                                                                                       │ WAITING       │ 211      │ 110
152    │ Timer-7                                                                                       │ WAITING       │ 5626853  │ 5019810
165    │ ESH-thingHandler-1                                                                            │ TIMED_WAITING │ 1416985  │ 1345640
168    │ Thread-68                                                                                     │ RUNNABLE      │ 146380   │ 132380
169    │ ESH-thingHandler-2                                                                            │ RUNNABLE      │ 1250077  │ 1184630
170    │ ESH-thingHandler-3                                                                            │ TIMED_WAITING │ 1427966  │ 1355070
171    │ ESH-thingHandler-4                                                                            │ TIMED_WAITING │ 1433097  │ 1361320
172    │ ESH-thingHandler-5                                                                            │ TIMED_WAITING │ 1419435  │ 1347850
185    │ Thread-72                                                                                     │ RUNNABLE      │ 3        │ 0
198    │ Thread-76                                                                                     │ TIMED_WAITING │ 5        │ 0
200    │ Timer-9                                                                                       │ WAITING       │ 158      │ 140
201    │ ZWaveReceiveProcessorThread                                                                   │ WAITING       │ 16422    │ 15830
216    │ ESH-astro-Monitor-1                                                                           │ TIMED_WAITING │ 745      │ 720
236    │ Timer-18                                                                                      │ WAITING       │ 0        │ 0
238    │ Smack Packet Writer (1)                                                                       │ WAITING       │ 31023    │ 27580
239    │ Smack Packet Reader (1)                                                                       │ RUNNABLE      │ 44373    │ 40310
240    │ Smack-Cached Executor 0 (1)                                                                   │ TIMED_WAITING │ 18151    │ 16830
241    │ Smack-Incoming Processor 0 (1)                                                                │ WAITING       │ 12010    │ 10440
242    │ Smack-Single Threaded Executor 0 (1)                                                          │ WAITING       │ 28406    │ 26840
243    │ pool-28-thread-1                                                                              │ TIMED_WAITING │ 8404     │ 6680
305    │ ZWaveNode14Init2019-06-11 20:39:15.914                                                        │ WAITING       │ 1        │ 0
306    │ ZWaveNode31Init2019-06-11 20:39:15.952                                                        │ WAITING       │ 1        │ 0
308    │ ZWaveNode28Init2019-06-11 20:39:15.952                                                        │ WAITING       │ 1        │ 0
332    │ pool-27-thread-14                                                                             │ WAITING       │ 1        │ 0
333    │ pool-27-thread-13                                                                             │ WAITING       │ 0        │ 0
342    │ pool-27-thread-19                                                                             │ WAITING       │ 0        │ 0
363    │ Timer-20                                                                                      │ WAITING       │ 13       │ 10
365    │ Timer-22                                                                                      │ WAITING       │ 417      │ 280
375    │ ServletModel-20-375                                                                           │ RUNNABLE      │ 0        │ 0
376    │ ServletModel-20-376                                                                           │ RUNNABLE      │ 0        │ 0
377    │ ServletModel-20-377                                                                           │ TIMED_WAITING │ 487      │ 380
378    │ ServletModel-20-378                                                                           │ TIMED_WAITING │ 466      │ 290
379    │ ServletModel-20-379                                                                           │ TIMED_WAITING │ 440      │ 330
380    │ ServletModel-20-380                                                                           │ TIMED_WAITING │ 440      │ 270
381    │ ServletModel-20-381                                                                           │ TIMED_WAITING │ 459      │ 330
382    │ ServletModel-20-382                                                                           │ TIMED_WAITING │ 477      │ 350
390    │ ESH-usb-serial-discovery-linux-sysfs-1                                                        │ TIMED_WAITING │ 3248288  │ 2198450
391    │ upnp-main-1                                                                                   │ TIMED_WAITING │ 133012   │ 123140
392    │ upnp-main-2                                                                                   │ RUNNABLE      │ 186758   │ 174790
394    │ upnp-main-4                                                                                   │ RUNNABLE      │ 247      │ 220
431    │ Expire Refresh Service                                                                        │ TIMED_WAITING │ 91141    │ 81130
442    │ HttpClient@a44b6a-scheduler                                                                   │ WAITING       │ 12838    │ 6430
458    │ HttpClient@13466d5-458                                                                        │ RUNNABLE      │ 0        │ 0
459    │ HttpClient@13466d5-459                                                                        │ TIMED_WAITING │ 544      │ 450
460    │ HttpClient@13466d5-460                                                                        │ TIMED_WAITING │ 615      │ 490
461    │ HttpClient@13466d5-461                                                                        │ TIMED_WAITING │ 826      │ 680
462    │ HttpClient@13466d5-462                                                                        │ TIMED_WAITING │ 767      │ 670
463    │ HttpClient@13466d5-463                                                                        │ RUNNABLE      │ 273      │ 240
464    │ HttpClient@13466d5-464                                                                        │ TIMED_WAITING │ 677      │ 540
465    │ HttpClient@13466d5-465                                                                        │ TIMED_WAITING │ 719      │ 530
467    │ HttpClient@13466d5-scheduler                                                                  │ WAITING       │ 44       │ 40
498    │ Google Calendar Event Downloader                                                              │ TIMED_WAITING │ 85218    │ 82510
499    │ pool-36-thread-1                                                                              │ TIMED_WAITING │ 393868   │ 287190
504    │ ESH-persist-Monitor-1                                                                         │ TIMED_WAITING │ 1048381  │ 1041260
514    │ pool-37-thread-1                                                                              │ WAITING       │ 192623   │ 189280
515    │ pool-38-thread-1                                                                              │ WAITING       │ 287278   │ 282350
659    │ Thread-399                                                                                    │ RUNNABLE      │ 0        │ 0
1013   │ Timer-86                                                                                      │ WAITING       │ 16       │ 10
1126   │ ESH-httpClient-common-1126                                                                    │ TIMED_WAITING │ 605      │ 490
1127   │ ESH-httpClient-common-1127                                                                    │ RUNNABLE      │ 594      │ 490
1128   │ ESH-httpClient-common-1128                                                                    │ RUNNABLE      │ 0        │ 0
1129   │ ESH-httpClient-common-1129                                                                    │ TIMED_WAITING │ 587      │ 480
1130   │ ESH-httpClient-common-1130                                                                    │ RUNNABLE      │ 0        │ 0
1131   │ ESH-httpClient-common-1131                                                                    │ TIMED_WAITING │ 585      │ 500
1132   │ ESH-httpClient-common-1132                                                                    │ TIMED_WAITING │ 589      │ 360
1133   │ ESH-httpClient-common-1133                                                                    │ TIMED_WAITING │ 628      │ 540
1134   │ ESH-httpClient-common-1134                                                                    │ TIMED_WAITING │ 621      │ 490
1135   │ ESH-httpClient-common-1135                                                                    │ RUNNABLE      │ 593      │ 520
1142   │ HttpClient@14488e3-scheduler                                                                  │ WAITING       │ 150      │ 100
1275   │ Timer-122                                                                                     │ WAITING       │ 4        │ 0
2100   │ Timer-260                                                                                     │ WAITING       │ 41       │ 40
2581   │ sshd-SshServer[1021c4c]-nio2-thread-1                                                         │ WAITING       │ 5105     │ 4960
2582   │ Thread-1144                                                                                   │ TIMED_WAITING │ 8        │ 0
2585   │ sshd-SshServer[1021c4c]-nio2-thread-2                                                         │ WAITING       │ 1171     │ 1010
4948   │ Timer-720                                                                                     │ WAITING       │ 16       │ 10
7939   │ Timer-1162                                                                                    │ WAITING       │ 1        │ 0
16087  │ ZWaveNode12Init2019-06-12 02:39:04.162                                                        │ WAITING       │ 1        │ 0
16092  │ ZWaveNode20Init2019-06-12 02:39:04.167                                                        │ WAITING       │ 2        │ 0
16095  │ pool-27-thread-52                                                                             │ WAITING       │ 0        │ 0
16098  │ pool-27-thread-54                                                                             │ WAITING       │ 1        │ 0
16103  │ ZWaveNode24Init2019-06-12 02:39:04.194                                                        │ WAITING       │ 1        │ 0
16109  │ pool-27-thread-57                                                                             │ WAITING       │ 0        │ 0
32979  │ HttpClient@1f71f16-32979                                                                      │ RUNNABLE      │ 0        │ 0
32980  │ HttpClient@1f71f16-32980                                                                      │ TIMED_WAITING │ 459      │ 350
32981  │ HttpClient@1f71f16-32981                                                                      │ TIMED_WAITING │ 445      │ 320
32982  │ HttpClient@1f71f16-32982                                                                      │ TIMED_WAITING │ 468      │ 290
32983  │ HttpClient@1f71f16-32983                                                                      │ RUNNABLE      │ 70       │ 50
32984  │ HttpClient@1f71f16-32984                                                                      │ TIMED_WAITING │ 505      │ 380
32985  │ HttpClient@1f71f16-32985                                                                      │ TIMED_WAITING │ 432      │ 300
32986  │ HttpClient@1f71f16-32986                                                                      │ TIMED_WAITING │ 427      │ 280
32988  │ HttpClient@1f71f16-scheduler                                                                  │ WAITING       │ 11       │ 10
39897  │ HttpClient@1a4a3a7-39897                                                                      │ RUNNABLE      │ 0        │ 0
39898  │ HttpClient@1a4a3a7-39898                                                                      │ TIMED_WAITING │ 1675     │ 1460
39899  │ HttpClient@1a4a3a7-39899                                                                      │ TIMED_WAITING │ 1637     │ 1510
39900  │ HttpClient@1a4a3a7-39900                                                                      │ TIMED_WAITING │ 1975     │ 1810
39901  │ HttpClient@1a4a3a7-39901                                                                      │ TIMED_WAITING │ 1667     │ 1460
39902  │ HttpClient@1a4a3a7-39902                                                                      │ TIMED_WAITING │ 1972     │ 1730
39903  │ HttpClient@1a4a3a7-39903                                                                      │ TIMED_WAITING │ 1597     │ 1390
39904  │ HttpClient@1a4a3a7-39904                                                                      │ RUNNABLE      │ 1719     │ 1500
39906  │ HttpClient@1a4a3a7-scheduler                                                                  │ TIMED_WAITING │ 362      │ 330
39911  │ Timer-7067                                                                                    │ TIMED_WAITING │ 18462    │ 17530
57804  │ Thread-19998                                                                                  │ RUNNABLE      │ 248530   │ 65510
57806  │ ZWaveReceiveInputThread                                                                       │ RUNNABLE      │ 270706   │ 209870
57808  │ Timer-10556                                                                                   │ WAITING       │ 1244     │ 1110
57809  │ ZWaveReceiveProcessorThread                                                                   │ WAITING       │ 56674    │ 54900
57869  │ ZWaveNode31Init2019-06-12 21:59:06.256                                                        │ WAITING       │ 1        │ 0
57870  │ pool-7362-thread-7                                                                            │ WAITING       │ 2        │ 0
57873  │ ZWaveNode28Init2019-06-12 21:59:06.277                                                        │ WAITING       │ 2        │ 0
57874  │ ZWaveNode14Init2019-06-12 21:59:06.277                                                        │ WAITING       │ 1        │ 0
57887  │ pool-7362-thread-16                                                                           │ WAITING       │ 1        │ 0
57889  │ pool-7362-thread-12                                                                           │ WAITING       │ 0        │ 0
58430  │ Timer-10629                                                                                   │ WAITING       │ 68       │ 50
58578  │ Timer-10650                                                                                   │ WAITING       │ 73       │ 50
59866  │ Timer-10874                                                                                   │ WAITING       │ 69       │ 60
68919  │ ZWaveNode7Init2019-06-13 02:59:01.609                                                         │ WAITING       │ 36       │ 30
68936  │ ZWaveNode20Init2019-06-13 02:59:01.661                                                        │ WAITING       │ 4        │ 0
68943  │ pool-7362-thread-42                                                                           │ WAITING       │ 1        │ 0
76167  │ Timer-13991                                                                                   │ WAITING       │ 8        │ 0
94634  │ Timer-17928                                                                                   │ WAITING       │ 1        │ 0
111481 │ Timer-20759                                                                                   │ WAITING       │ 2        │ 0
112235 │ pool-14374-thread-1                                                                           │ WAITING       │ 89634    │ 87950
112236 │ pool-14375-thread-1                                                                           │ WAITING       │ 133463   │ 130910
121511 │ ZWaveNode15Init2019-06-14 02:59:01.637                                                        │ TIMED_WAITING │ 150      │ 110
145425 │ OkHttp https://myopenhab.org/...                                                              │ RUNNABLE      │ 13996    │ 11940
145426 │ pool-18774-thread-1                                                                           │ TIMED_WAITING │ 7848     │ 6430
145427 │ OkHttp ConnectionPool                                                                         │ TIMED_WAITING │ 82       │ 40
145431 │ HttpClient@522096-145431                                                                      │ TIMED_WAITING │ 280      │ 190
145432 │ HttpClient@522096-145432                                                                      │ RUNNABLE      │ 392      │ 300
145433 │ HttpClient@522096-145433                                                                      │ TIMED_WAITING │ 577      │ 500
145434 │ HttpClient@522096-145434                                                                      │ TIMED_WAITING │ 469      │ 350
145435 │ HttpClient@522096-145435                                                                      │ TIMED_WAITING │ 368      │ 310
145436 │ HttpClient@522096-145436                                                                      │ RUNNABLE      │ 404      │ 320
145437 │ HttpClient@522096-145437                                                                      │ TIMED_WAITING │ 550      │ 340
145438 │ HttpClient@522096-145438                                                                      │ TIMED_WAITING │ 427      │ 370
145666 │ features-3-thread-1                                                                           │ WAITING       │ 8616     │ 8460
145688 │ Refresh Thread: Equinox Container: 06135c0a-8aaf-4d50-a8c5-f0b33656f5c8                       │ WAITING       │ 847      │ 740
147792 │ Java2D Disposer                                                                               │ WAITING       │ 16       │ 10
150396 │ HttpClient@522096-scheduler                                                                   │ WAITING       │ 7        │ 0
170839 │ pool-21993-thread-1                                                                           │ WAITING       │ 749      │ 740
170840 │ pool-21994-thread-1                                                                           │ WAITING       │ 987      │ 970
170911 │ pool-22004-thread-1                                                                           │ WAITING       │ 321      │ 320
170914 │ pool-22005-thread-1                                                                           │ WAITING       │ 500      │ 470
171037 │ pool-22022-thread-1                                                                           │ WAITING       │ 36937    │ 36380
171044 │ pool-22023-thread-1                                                                           │ WAITING       │ 51159    │ 50070
172372 │ MarlinRenderer Disposer                                                                       │ WAITING       │ 0        │ 0
212296 │ items-16981                                                                                   │ TIMED_WAITING │ 13038    │ 11220
213722 │ pool-27872-thread-1                                                                           │ WAITING       │ 140545   │ 137820
213723 │ pool-27873-thread-1                                                                           │ WAITING       │ 192521   │ 189250
225665 │ ZWaveNode24Init2019-06-16 02:59:01.646                                                        │ WAITING       │ 2        │ 0
225667 │ pool-7362-thread-330                                                                          │ WAITING       │ 0        │ 0
230942 │ items-18502                                                                                   │ TIMED_WAITING │ 9703     │ 8370
236720 │ items-18960                                                                                   │ TIMED_WAITING │ 8761     │ 7480
251942 │ items-20102                                                                                   │ TIMED_WAITING │ 6764     │ 5950
266453 │ pool-34757-thread-1                                                                           │ WAITING       │ 188613   │ 185710
266454 │ pool-34758-thread-1                                                                           │ WAITING       │ 259494   │ 255050
268333 │ Keep-Alive-SocketCleaner                                                                      │ WAITING       │ 4        │ 0
269425 │ Timer-49377                                                                                   │ WAITING       │ 5        │ 0
271227 │ RequestManager-Queue-0                                                                        │ WAITING       │ 49384    │ 48650
273634 │ ESH-astro-27                                                                                  │ TIMED_WAITING │ 146      │ 140
276763 │ jupnp-jetty-client-276763                                                                     │ TIMED_WAITING │ 5846     │ 4970
276912 │ jupnp-jetty-client-276912                                                                     │ RUNNABLE      │ 4949     │ 4160
277450 │ jupnp-jetty-client-277450                                                                     │ RUNNABLE      │ 2801     │ 2430
277634 │ items-22170                                                                                   │ TIMED_WAITING │ 2517     │ 2070
277832 │ jupnp-jetty-client-277832                                                                     │ TIMED_WAITING │ 616      │ 530
277955 │ jupnp-jetty-client-277955                                                                     │ TIMED_WAITING │ 52       │ 40
280651 │ ZWaveNode12Init2019-06-17 02:59:01.637                                                        │ WAITING       │ 2        │ 0
280656 │ pool-7362-thread-443                                                                          │ WAITING       │ 0        │ 0
287611 │ qtp11319873-287611                                                                            │ TIMED_WAITING │ 14294    │ 13540
290312 │ Timer-52826                                                                                   │ WAITING       │ 2        │ 0
290636 │ qtp11319873-290636                                                                            │ TIMED_WAITING │ 6182     │ 5850
291294 │ qtp11319873-291294                                                                            │ TIMED_WAITING │ 7287     │ 6880
291839 │ qtp11319873-291839                                                                            │ TIMED_WAITING │ 4488     │ 4210
292458 │ qtp11319873-292458                                                                            │ TIMED_WAITING │ 6143     │ 5810
293283 │ pool-7362-thread-476                                                                          │ WAITING       │ 0        │ 0
293318 │ RequestManager-Queue-0                                                                        │ WAITING       │ 21558    │ 21280
293502 │ safeCall-6395                                                                                 │ TIMED_WAITING │ 996      │ 880
293520 │ safeCall-6396                                                                                 │ TIMED_WAITING │ 1216     │ 1080
293558 │ qtp11319873-293558                                                                            │ TIMED_WAITING │ 2590     │ 2370
293949 │ qtp11319873-293949                                                                            │ TIMED_WAITING │ 1415     │ 1260
294156 │ safeCall-6411                                                                                 │ TIMED_WAITING │ 663      │ 620
294250 │ safeCall-6412                                                                                 │ TIMED_WAITING │ 439      │ 390
294322 │ ESH-common-9521                                                                               │ TIMED_WAITING │ 8        │ 0
294350 │ safeCall-6413                                                                                 │ TIMED_WAITING │ 268      │ 250
294415 │ safeCall-6416                                                                                 │ TIMED_WAITING │ 188      │ 160
294452 │ qtp11319873-294452                                                                            │ RUNNABLE      │ 359      │ 350
294481 │ org.apache.karaf.shell.ssh.SshTerminal@87637a input pump thread                               │ WAITING       │ 17       │ 10
294482 │ Karaf ssh console user openhab                                                                │ WAITING       │ 1476     │ 1410
294483 │ pool-38105-thread-1                                                                           │ TIMED_WAITING │ 2006     │ 1750
294486 │ pipe-shell:threads --list                                                                     │ RUNNABLE      │ 697      │ 650
294498 │ ESH-persist-10274                                                                             │ TIMED_WAITING │ 1        │ 0
294510 │ process reaper                                                                                │ TIMED_WAITING │ 15       │ 10
294514 │ ESH-discovery-14566                                                                           │ TIMED_WAITING │ 16       │ 10
294519 │ qtp11319873-294519                                                                            │ RUNNABLE      │ 133      │ 120
294523 │ ESH-common-9527                                                                               │ TIMED_WAITING │ 1        │ 0
294534 │ job controller 1                                                                              │ WAITING       │ 347      │ 310
294545 │ process reaper                                                                                │ TIMED_WAITING │ 5        │ 0
294548 │ ESH-common-9528                                                                               │ TIMED_WAITING │ 0        │ 0
294554 │ ESH-common-9529                                                                               │ TIMED_WAITING │ 0        │ 0
294572 │ ESH-discovery-14568                                                                           │ TIMED_WAITING │ 0        │ 0
294573 │ ESH-persist-10278                                                                             │ TIMED_WAITING │ 0        │ 0
294578 │ Timer-53644                                                                                   │ TIMED_WAITING │ 0        │ 0
294579 │ Keep-Alive-Timer                                                                              │ TIMED_WAITING │ 0        │ 0

There is another way to achieve a similar result, that is by using the ipcamera binding and the create gif feature. I have been considering adding the ability to output an mp4 file instead of a gif.

The way it works is simple.

Use a rule to turn on the create gif switch when your door is opened.
When the file is created the binding turns the switch off and this can trigger a rule to send the email.
No timers or sleep needed as the binding handles this for you.

1 Like