Swatch...eshold(3pm)

πŸ’– Swatchdog::Threshold πŸ’–

okay bestie, so this is Swatchdog::Threshold β€” it's the Perl extension that does the thresholding thing inside swatchdog(1). It lives in the User Contributed Perl Documentation, which is giving "community-made, hand-crafted, artisanal" energy and honestly? we love that for it. πŸŽ€


✨ SYNOPSIS ✨

here's the vibe when you call it from Perl, copy it exactly bestie:

use Swatchdog::Threshold;

&Swatchdog::threshold(        SWID => <int>,
                      TYPE => <limit|threshold|both>,
                      TRACK_BY => <key>, # like an IP addr
                      COUNT => <int>,
                      SECONDS => <int>
                      );

🌸 SWATCH SYNTAX 🌸

and here's how you write it inside a swatch config file, no code required:

threshold track_by=<key>,
   type=<limit|threshold|both>,
   count=<int>,
   seconds=<int>

πŸ’… DESCRIPTION πŸ’…

okay so let's break it down, no cap:

  • SWID β€” this is swatchdog's own internal ID number for the watchfor block. it's the little name tag swatchdog puts on each block so it knows who's who. 🏷️
  • TYPE β€” can be limit, threshold, or both. three flavors, all iconic, here's the tea:
    • Limit β€” alerts you on the 1st COUNT events during the time interval, and then? it just ignores events for the rest of that time interval. it said "I've said my piece" and went to go lie down. 😌
    • Threshold β€” alerts every COUNT times we see this event during the time interval. consistent queen. every single time. πŸ”₯
    • Both β€” alerts once per time interval after seeing COUNT occurrences of the event, and then ignores any additional events during that time interval. so it's like β€” one alert, then silence, then reset. main character energy, minimal drama. ✨
  • SECONDS β€” this is the time interval. the clock. the window. the timeframe in which all this counting happens. ⏳
fr fr, that's the whole mechanic β€” you're just telling swatchdog how many times and how long before it should start yelling at you. πŸ’–

πŸ‘‘ AUTHOR πŸ‘‘

E. Todd Atkins, todd.atkins@stanfordalumni.org β€” we stan a legend. 🫢


πŸ¦‹ SEE ALSO πŸ¦‹

perl(1), swatchdog(1) β€” go read those too bestie, they're right there.


k that's the whole page!! this was documented in perl v5.36.0 and dated 2023-01-20, so like β€” vintage but make it relevant πŸ’œ thanks for reading, mwah πŸ’…πŸ’–

πŸ“¦ where this page comes from