Install:
pip install critbot
Add to “config.py” file:
import critbot.plugins.syslog
import critbot.plugins.slack
import critbot.plugins.email
from critbot import crit_defaults
import logging
crit_defaults.subject = 'MyService host:port CRIT'
crit_defaults.plugins = [
critbot.plugins.syslog.plugin(),
critbot.plugins.slack.plugin(
token='Get it from https://my.slack.com/services/new/bot',
channel='#general', # '@private' or '#channel'
users='', # '@user1 @user2 @userN'
),
critbot.plugins.email.plugin(
to='Name1 <user1@example.com>, Name2 <user2@example.com>',
user='critbot@example.com', # Add more config if not GMail.
password='pa$$word',
),
]
crit_defaults.crit_in_crit = logging.getLogger('critbot').critical
Check other config options and their defaults, e.g. “seconds_per_notification=60” and “spam=False”:
https://github.com/denis-ryzhkov/critbot/blob/master/critbot/core.py#L23 - “crit_defaults”
https://github.com/denis-ryzhkov/critbot/blob/master/critbot/core.py#L38 - “crit”
https://github.com/denis-ryzhkov/critbot/blob/master/critbot/plugins/syslog.py#L17
https://github.com/denis-ryzhkov/critbot/blob/master/critbot/plugins/slack.py#L14
https://github.com/denis-ryzhkov/critbot/blob/master/critbot/plugins/email.py#L14
Use “crit” in other files of your project:
from my_project import config
from critbot import crit
try:
1/0
except Exception:
crit()
# More processing if needed.
try:
1/0
except Exception:
crit(also='test2')
if True:
crit('test3')
If you are using http://supervisord.org/ then you can monitor stderr, EXITED and FATAL states with:
[eventlistener:critvisor] command=critvisor /path/to/config.py events=PROCESS_LOG_STDERR,PROCESS_STATE_EXITED,PROCESS_STATE_FATAL [program:my_program] stderr_events_enabled=true Optional "crit_defaults.skip_stderrs" list allows to avoid some "safe" crits. Optional "crit_defaults.max_stderr_crit_length" allows to save e.g. Slack from being broken.
If you want to convert stderr of your small scripts to crits:
stdcrit /path/to/config.py /path/to/script.py arg...
To stop spam from multiple processes on the same host:
crit_defaults.stop_spam_file.enabled = True # "crit_defaults.stop_spam_file.path" defaults to "/run/lock/critbot" - RAM, no disk IO.
To stop spam from multiple hosts:
apt-get install libmemcached-dev zlib1g-dev pip install pylibmc crit_defaults.mc.enabled = True And either "apt-get install memcached" or update "crit_defaults.mc.servers" list.
Please fork https://github.com/denis-ryzhkov/critbot and create pull requests with new plugins inside.
Metadata
Release files for critbot 0.1.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| critbot-0.1.19.tar.gz | 6.1 kB | Without provenance | Details for critbot-0.1.19.tar.gz |
Release files / critbot-0.1.19.tar.gz
| Download URL | critbot-0.1.19.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6704b96be70909af167c383e33e4bea2e9c481bcb1bc33786dbddb582c8f824d
|
|
BLAKE2b-256 checksum How to use checksums |
1cc7822fe481995fe3c503c27160c6c8cf3e31fa504d6fe40031a08ad2e9dd1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for critbot 0.1.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.