A process monitoring and alerting tool that keeps an up-to-date status of processes in Redis
Project description
arb_watchdog
arb_watchdog
is a Python package designed to monitor and manage the status of specified processes. It uses Redis as a backend for storing process data and provides a simple API for interacting with this data. The package is highly configurable and can be used to monitor and manage a wide range of processes.
Features
- Monitor the status of specified processes
- Store process data in Redis
- Configurable process monitoring interval
- Automatically reloads configuration when the config file is updated
- Supports multiple processes
- Provides a simple API for interacting with process data
Installation
To install the arb_watchdog
package, you can use pip
:
pip install arb_watchdog
Config File
First, create a configuration file in JSON format with the following keys:
redis_host
: The hostname of your Redis server (e.g., "localhost")redis_port
: The port number of your Redis server (e.g., 6379)interval
: The interval (in seconds) at which the processes will be monitored (e.g., 60)processes
: A list of process names to monitor (e.g., ["fake_process", "another_fake_process"])
Example configuration file (config.json):
{
"redis_host": "localhost",
"redis_port": 6379,
"interval": 60,
"processes": ["fake_process", "another_fake_process"]
}
By default,
arb_watchdog
will look for a configuration file under the$ARB_CONFIGS_PATH
directory. ($ARB_CONFIGS_PATH/arb_watchdog_config.json
). If this variable is not set, it will use./arb_watchdog_config.json
.
Usage
To use arb_watchdog
, import the package and create a ProcessWatcher
instance with the path to your configuration file:
from arb_watchdog.process_watcher import ProcessWatcher
config_file = "config.json"
process_watcher = ProcessWatcher(config_file=config_file)
You can then use the ProcessWatcher
instance to perform various operations, such as getting the process list, updating process data, and getting process data for specified processes:
# Get the list of processes to monitor
process_list = process_watcher.get_process_list()
# Update process data
process_data = ProcessData(name="fake_process", pid=12345, status="UP")
process_watcher.update_process_data(process_data)
# Get process data for a specified process
process_data = process_watcher.get_process_data("fake_process")
Console Scripts
arb_watchdog
provides two console scripts for easy interaction with the package: arb_watchdog
and arb_watchdog_cli
.
arb_watchdog
arb_watchdog
is a console script that runs the arb_watchdog
process in the background, continuously monitoring the specified processes and updating their data in Redis. To run the script, simply execute the following command in your terminal, replacing <config_file> with the path to your configuration file:
arb_watchdog -f <config_file>
arb_watchdog_cli
arb_watchdog_cli
is a console script that shows data stored in the Redis database based on the config.json
file
To run the script, execute the following command in your terminal, replacing <config_file> with the path to your configuration file:
arb_watchdog_cli -f <config_file>
Example output:
Running Tests
To run the tests for the arb_watchdog
package, use the following command:
python -m unittest discover -s tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file arb_watchdog-1.0.1.tar.gz
.
File metadata
- Download URL: arb_watchdog-1.0.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6b4ad207c22d347dbc667b5941cf706bf8f2e5f6a7965b7c4c52b3f4950980c |
|
MD5 | 4613c7013457c829d716af1c10bbe735 |
|
BLAKE2b-256 | 1547a8682a4dba04214e71abd7333d0a265f0c0a6936903b19c98af280dd03fe |
File details
Details for the file arb_watchdog-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: arb_watchdog-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c66d11166080c554e4add2a24b791166b0c41485c55626b908a49acaaff932da |
|
MD5 | f2e68120ea14a0ac1ab4958201327f43 |
|
BLAKE2b-256 | 44eecad7b0b2e264a7e9b66dbb10525c785a35a1e6915900e38bf48afaba6db8 |