thp / urlwatch

Watch (parts of) webpages and get notified when something changes via e-mail, on your phone or via other means. Highly configurable.
https://thp.io/2008/urlwatch/
Other
2.81k stars 352 forks source link

Send individual mail for each changed URL #695

Closed bokkabonga closed 7 months ago

bokkabonga commented 2 years ago

Hey everyone,

we have been using urlwatch for a really long time now nad are monitoring around 30 websites. Recently we changed our Ticketsystem to Zammad. Before this we had a self written reporter for our old redmine system which created an individual ticket for each changed website.

For Zammad we moved from this old, self developed reporter to simply using the email report. However this reporter creates one email for all changes he detects at the same time. I could not find a way so far to make him send one email for each changed website.

Is there a way to influence this behaviour?

neutric commented 2 years ago

I couldn't find anything that would allow you to do that in the docs.

Iterating over the list of jobs one by one with something like for i in {1..30}; do urlwatch $i; done would achieve what you want at the loss of parallelism. The subset feature is documented here. The current list of jobs including indexes can be printed with --list.

thp commented 2 years ago

One way to do this by modifying the code (the "duration" in every report will be the same, which is the overall duration of ALL URLs, so it might be a bit misleading, but probably works for your use case):

diff --git a/lib/urlwatch/handler.py b/lib/urlwatch/handler.py
index bcb23fe..57cde61 100644
--- a/lib/urlwatch/handler.py
+++ b/lib/urlwatch/handler.py
@@ -214,7 +214,8 @@ class Report(object):
         end = datetime.datetime.now()
         duration = (end - self.start)

-        ReporterBase.submit_all(self, self.job_states, duration)
+        for job_state in self.job_states:
+            ReporterBase.submit_all(self, [job_state], duration)

     def finish_one(self, name):
         end = datetime.datetime.now()

If you confirm this works for your use case, it probably can be made a configuration option.

thp commented 7 months ago

This has been implemented in 2.26 with the "separate" configuration:

New separate configuration option for reporters to split reports into one-per-job (contributed by Ryne Everett)