Commit graph

127 commits

Author SHA1 Message Date
Pēteris Caune
28fdfd1362
Change Channel.notify() signature to take Flip object as an argument
... and pass it to Transport.notify_flip().

This allows us to pass flip-specific information (the flip timestamp,
the new status) to transport classes.
2024-04-12 13:54:16 +03:00
Pēteris Caune
b29ba7c11b
Make prunepingsslow more resilient to concurrent check deletes 2024-04-02 12:11:26 +03:00
Pēteris Caune
274a59956a
Make statsd metrics collection optional
To enable, set STATSD_HOST env var (or set STATSD_HOST in
local_settings.py):

STATSD_HOST=localhost:1234

cc: #974
2024-03-18 12:55:36 +02:00
Pēteris Caune
ae94648efd
Fix minio-related mypy warnings
A few warnings remain, I think these should be fixed in minio-py:

https://github.com/minio/minio-py/pull/1389
2024-01-04 16:01:34 +02:00
Pēteris Caune
7c5e3130fb
Hardcode a higher S3 operation timeout, add sorting by Check.code 2023-12-21 16:12:22 +02:00
Pēteris Caune
767c3ae702
Add a management command for pruning all checks 2023-12-21 14:55:05 +02:00
Pēteris Caune
52ab8c4703
Improve type hints in hc.lib.curl and hc.api.transports
This results in changes in other places too:

* curl.post() does not accept `data` as positional arg,
  it must now be a keyword argument
* we need asserts and if clauses in a few places to make sure
  we are not passing `None` in the arguments to hc.lib.curl.request
2023-10-20 19:11:08 +03:00
Pēteris Caune
fdfe03158d
Fix mypy warnings 2023-10-18 16:33:15 +03:00
Pēteris Caune
1aec03dfc6
Improve type hints in management commands 2023-10-18 16:15:01 +03:00
Pēteris Caune
e8be347d1a
Improve type hints in management commands 2023-10-18 13:47:02 +03:00
Pēteris Caune
ce622da6bd
Improve type hints and remove threading support which was unused
sendalerts had support for sending notifications
synchronously (with the --no-threads flag) and asynchronously using
threads (the default).

It turns out there was a bug in argument handling and sendalerts
was always using the synchronous mode regardless of the
presence/absence of the "--no-threads" flag. Since noone seems to
have noticed, I removed the unused async code.
2023-10-18 13:45:23 +03:00
Pēteris Caune
1ccd96a045
Fix type warnings 2023-09-05 11:53:57 +03:00
Pēteris Caune
ef3837e7e7
Clean up and improve code comments 2023-09-03 09:29:31 +03:00
Pēteris Caune
2b73ddde17
Improve type hints 2023-08-29 19:10:27 +03:00
Pēteris Caune
7ecbe8fc4e
Make log output more compact 2023-07-08 10:39:47 +03:00
Pēteris Caune
89c26b46a4
Refactor sendalerts and Flip.send_alerts() for cleaner logs 2023-07-08 10:28:40 +03:00
Pēteris Caune
fc41af50f4
Fix sorting of NULLs when fetching a Flip in sendalerts 2023-07-07 18:21:26 +03:00
Pēteris Caune
68bcc5389f
Fix sendalerts to allow "handle_going_down()" to run more often 2023-07-07 17:58:55 +03:00
Pēteris Caune
368e76016d
Add Channel.last_notify_duration, use in sendalerts for prioritization 2023-07-07 16:40:23 +03:00
Pēteris Caune
e342f057df
Hopefully fix DB connection timeouts in manage.py smtpd
The smtpd management command runs a SMTP listener for receiving
ping signals as emails. If emails arrive infrequently, the
database connections can time out. A brute-force workaround for
this was to call `connections.close_all()` before making new
DB queries.

Code moved around while migrating to aiosmtpd, and looks like
the workaround did not work any more – #847. This commit
replaces `connections.close_all()` with `connection.close()` and
moves it to the `_process_message()` function, which *hopefully* fixes 
the problem.
2023-06-26 16:24:56 +03:00
Max
19d05498ae
Fix smtpd service without stdin (#840)
Fixes: #839
2023-06-05 23:23:37 +03:00
Pēteris Caune
4b05fc6a8c
Update the smtpd management command to use the aiosmtpd library
smtpd from the standard library is deprecated and will
be removed in Python 3.12. aiosmtpd is the recommended
replacement.
2023-05-09 17:23:18 +03:00
Pēteris Caune
0c45424a92
Change timezone.now import in sendalerts and sendreports 2023-05-04 11:05:52 +03:00
Pēteris Caune
a9b084ec9a
Add "Start Keyword" filtering for inbound emails
Fixes: #716
2023-01-16 13:19:35 +02:00
Pēteris Caune
5e826ec15a
Fix pruneflips 2022-12-02 12:19:52 +02:00
seidnerj
b6027fa126
Added support for a "run id" parameter (#722)
Add support for specifying a run ID via a "rid" query parameter

cc: #461
2022-11-08 11:34:26 +02:00
seidnerj
c82c1a3a4a
Added duration to ping details (#720)
* Added duration to ping details. This is useful on a device with a small screen, since the duration cannot be seen in the main view so now one can see it in the ping's details.
* Changed terms across the board from "delta" to "duration"
* timedelta is now consistently imported as "td" across the entire project (even in Django generated migration files)
2022-11-01 09:18:34 +02:00
Pēteris Caune
161430fb10
Sort imports and add "from __future__ import annotations" 2022-10-17 16:52:15 +03:00
Pēteris Caune
3a50396806
Switch from requests to pycurl in integration onboarding views 2022-08-17 12:02:06 +03:00
Leandro Britez
37ff7b1b05 Add support for multiple RCPT TO in incoming email 2022-07-29 12:56:30 +03:00
Pēteris Caune
003d35d431
Add "Filter by keywords in the message body" feature
cc: #653
2022-07-12 15:46:15 +03:00
Pēteris Caune
a5e5b45983
Reduce logging, add Ctrl+C handler in sendalerts and sendreports
cc: #656
2022-05-27 14:49:44 +03:00
Pēteris Caune
b776762ba9
Fix prunenotifications to handle checks with missing pings
Fixes: #636
2022-04-20 16:25:19 +03:00
Pēteris Caune
90d30c8b62
Add management command to submit Signal CAPTCHAs 2022-04-11 09:29:33 +03:00
Pēteris Caune
664c6018ab
Add pruneobjects management command and update README 2022-03-09 15:30:52 +02:00
Pēteris Caune
5ecd625c0b
Add Ping.body_raw field for storing body as bytes 2022-02-25 16:50:54 +02:00
Pēteris Caune
abb7bc7150
Add support for Telegram channels
To make this work, existing installations must re-run
the "settelegramwebhook" management command.

Fixes: #592
2021-12-28 18:50:06 +02:00
Pēteris Caune
1299738f50
Add SIGTERM handling in sendreports 2021-11-07 11:05:10 +02:00
Pēteris Caune
bc2d127c27
Add SIGTERM handling in sendalerts 2021-11-06 19:54:41 +02:00
Pēteris Caune
e1f51093f1
Implement automatic api_ping and api_notification pruning
cc: #556
2021-10-21 14:35:02 +03:00
Pēteris Caune
6bb0c77934
Replace backfillchannels with a data migration 2021-10-21 12:35:29 +03:00
Pēteris Caune
bcc7009437
Update channels.html to use Channel.last_notify
Channel.last_notify is the datetime of the most recent
notification sent via the channel. Channel.last_error is
the error message (blank if the delivery was successful).

In the integrations list, "Last Notification" column,
use these fields instead of looking up the most recent
Notification object. This saves some db queries,
and also fixes a subtle issue: if prunenotifications
cleans up all notifications for a given channel, the
"Last Notification" column would display "Never", which
would not be correct – not any more.
2021-10-21 11:42:13 +03:00
Pēteris Caune
33fb4a36ca
Add Channel.last_notify and a command to backfill it 2021-10-21 10:56:03 +03:00
swoga
b70e2c9a25 feat: treat failure before success 2021-06-29 14:05:56 +03:00
Pēteris Caune
6094bca241
Improve wording 2021-05-24 14:13:43 +03:00
Pēteris Caune
df44ee58c0
Add an option for weekly reports (in addition to monthly) 2021-05-24 13:44:34 +03:00
Pēteris Caune
7ba5fcbb71
Fix sendalerts to clear Profile.next_nag_date if all checks up
Profile.next_nag_date tracks when the next hourly/daily reminder
should be sent. Normally, sendalerts sets this field when
a check goes down, and sendreports clears it out whenever
it is about to send a reminder but realizes all checks are up.

The problem: sendalerts can set next_nag_date to a non-null
value, but it does not clear it out when all checks are up.
This can result in a hourly/daily reminder being sent out
at the wrong time. Specific example, assuming hourly reminders:

13:00: Check A goes down. next_nag_date gets set to 14:00.
13:05: Check A goes up. next_nag_date remains set to 14:00.
13:55: Check B goes down. next_nag_date remains set to 14:00.
14:00: Healthchecks sends a hourly reminder, just 5 minutes
       after Check B going down. It should have sent the reminder
       at 13:55 + 1 hour = 14:55

The fix: sendalerts can now both set and clear the next_nag_date
field. The main changes are in Project.update_next_nag_dates()
and in Profile.update_next_nag_date(). With the fix:

13:00: Check A goes down. next_nag_date gets set to 14:00.
13:05: Check A goes up. next_nag_date gets set to null.
13:55: Check B goes down. next_nag_date gets set to 14:55.
14:55: Healthchecks sends a hourly reminder.
2021-03-15 12:34:39 +02:00
Pēteris Caune
9a0888aacd
Update sendalerts to log per-notification send times
To send notifications, sendalerts calls Flip.send_alerts().
I updated Flip.send_alerts() to be a generator, and to yield
a (channel, error, send_time_in_seconds) triple per sent
notification.
2021-01-15 15:15:00 +02:00
Pēteris Caune
66a1a108bf
When decoding inbound emails, decode encoded headers. Fixes #420 2020-09-08 12:06:32 +03:00
Pēteris Caune
43e56ce788
Add support for multiple, comma-separated keywords (cc: #396) 2020-07-23 12:06:17 +03:00