I have a few use-cases for this but I will use just one simple scenario as an example. I want to monitor my raspberry pi and make sure some tasks are completing properly. I want to add a line in a script to post to the cloud a confirmation when the script is run. This part I think I can do.

The question I have is how to know if the task was not completed within the expected time-frame. Something similar to what wdt.io does for cron jobs. Basically some type of

if time/date is <past expected completion> then check <thingspeak API> for value returned by script
else send email <it seems script1234> failed

Is there a service that can check for a value somewhere? for example an http get to thingspeak api and act depending on the value.

  • You need to find out how to implement a watchdog in your cloud service of choice. If you can't find one, perhaps you can schedule an event in the future, and cancel it if you get a success. And then either way reschedule another one further into the future. – Chris Stratton Mar 14 '18 at 16:20
  • I am looking for a cloud service that does this or better I am looking for a cloud service that can check for a value somewhere and act depending on the value. If you or someone else knows of such a service please tell us. – FoxSam12 Mar 19 '18 at 3:22
  • Have you looked at IFTTT ? – Chris Stratton Mar 19 '18 at 3:47
  • I have looked at ifttt and I just can't figure out how to set up what I need. I tried using webhooks and react from thingspeak but I dont know how to set it up based on time/date and !value. – FoxSam12 Mar 19 '18 at 13:22
  • Using Thingspeak, could you set up a proxy data channel that collects a state flag and a time elapsed value from your Raspberry Pi? When not running set both to 0, when the task starts set to 1 and the time elapsed. When finished change flag and time back to 0. Your react could then look for flag = 1 and time elapsed > X seconds/minutes and act accordingly. – Geoff Mar 21 '18 at 1:49

Firstly, a simple way to monitor these types of conditions is to monitor how long ago the last task was complete.

Instead of knowing when the next script is supposed to be completed, if we know if should be executed every 6 hours, we now just need to compare the last execution time with 'now', if the number of hours between the two (now - lastExecution) is greater than 6, then trigger your alert.

simply post the timestamp when the task/script was last completed to thingspeak, now your simply monitor that timestamp on a regular frequency, usually smaller than the period that your are trying to detect, if it is ever greater than 'x' minutes ago, send the alert.

if <thingspeak API - Last Execution> more than x hours ago
send email <it seems script1234> failed

If your monitoring tool does not have simple date time functions or logical operations that you can configure in the above way,. change your script to report the timestamp with the 'x' time period added to it, so if it is a 6 hourly script, add 6 hours to the timestamp that you send, now the monitoring logic is very simple:

if <thingspeak API - Last Execution Expiry> greater than now
send email <it seems script1234> failed

If that isn't appropriate for you, or perhaps you can combine that with modifying your script to post at the start to clear a status flag, effectively report that "script 1 is starting" and optionally record the time that it started.

Now that there is a start time, and an end time, you can monitor if (End-Start) greater than x hours to determine if the script took to long to execute, or if Start > End then the script is still executing or has failed to complete.

This is not really how I would like to answer these types of questions as we should not really be endorsing specific products, but I want to make an exception in this case. There are many free and paid services that you could use for this task. Use Bing or Google to find them :)

I use the Bizeo platform for this type of monitoring. I am not affiliated with this product, but very happy with it

There are many templates in there, one will periodically ping a REST endpoint and operate on the response, so you could target the thingspeak api directly. There are some other simple templates intended to be actioned by users even using emails as the trigger, or the lack of an email in a certain timeframe. The SMS alerts or emails when the deadline is missed are easy to setup.

So you could send your notification to that service directly, either as an email from your device, or you can use their REST API to send a notification that the script completed.

  • Is there a way within thingspeak (or another cloud-based) to do the checking. I am looking for a way that all the monitoring is done in the cloud. – FoxSam12 Apr 5 '18 at 3:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.