ParseWatchDog is a log monitoring tool specifically designed to detect and alert on significant events in Asterisk systems, such as mass disconnection alerts. Currently, it focuses on monitoring SIP and PJSIP logs, specifically checking for "Unreachable" events, which indicate the disconnection of devices or users in the telephony network.
When ParseWatchDog detects a mass disconnection event, it generates alerts that can be sent through multiple notification channels, including email, Telegram, an API endpoint, RabbitMQ and Slack. This multi-channel alerting capability ensures that responsible teams are immediately notified through the most convenient means.
Although its initial purpose is to monitor disconnection events in Asterisk, ParseWatchDog is designed with flexibility, allowing it to expand its capabilities in the future to monitor other events or services, adapting to the evolving needs of the telecommunications environment and ensuring comprehensive system supervision.
- Monitors specified log file for disconnection patterns
- Supports Email, Telegram, API, RabbitMQ and Slack notifications
- Customizable configuration file
- Adjustable debug levels for granular logging
Install ParseWatchDog quickly using the following command:
curl -fsSL https://raw.githubusercontent.com/lordbasex/parsewatchdog/refs/heads/main/install.sh | bash
-
Clone this repository:
git clone https://github.com/lordbasex/parsewatchdog.git
-
Navigate into the project directory:
cd parsewatchdog
-
Install the necessary dependencies:
go mod tidy
-
Ensure RabbitMQ and other services used for notifications are properly configured.
The configuration file (/etc/parsewatchdog.conf
) controls ParseWatchdog's behavior and notification settings.
[smtp]
enabled=true
host=smtp.gmail.com
port=587
user[email protected]
pass=your_email_password
recipients[email protected],[email protected]
[telegram]
enabled=false
token=your_telegram_bot_token
chat_id=123456789
[api]
enabled=false
endpoint=https://example.com/notify
api_key=your_api_key
[rabbitmq]
enabled=false
type=amqp
user=rabbitmq_user
password=rabbitmq_password
ip=192.168.0.10
port=5672
queue=parsewatchdog_notifications
[slack]
enabled = false
webhook_url = https://hooks.slack.com/services/XXXXXXXXXXX/XXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX
[debug]
debug_level=1 # Levels: 0 = no logs, 1 = only critical logs, 2 = all logs
To run ParseWatchdog:
make build
make run
For production, you may want to compile the binary:
./dist/parsewatchdog-x86_64
cp -fra ./dist/parsewatchdog-x86_64 /usr/local/bin/parsewatchdog-x86_64
chmod 777 /usr/local/bin/parsewatchdog-x86_64
cat > /etc/systemd/system/parsewatchdog.service <<ENDLINE
[Unit]
Description=ParseWatchDog
Requires=network.target
After=network.target network-online.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/usr/local/bin/
ExecStart=/usr/local/bin/parsewatchdog-x86_64
Restart=on-failure
# Redirige logs de salida estándar a un archivo
StandardOutput=append:/var/log/parsewatchdog.log
StandardError=append:/var/log/parsewatchdog.log
[Install]
WantedBy=multi-user.target
ENDLINE
systemctl enable parsewatchdog.service
systemctl start parsewatchdog.service
systemctl status parsewatchdog.service
- 0: No logs displayed
- 1: Only disconnection event logs
- 2: All logs for full debugging information
To generate simulated disconnection events in the Asterisk log file, run the following script:
bash test.sh
ParseWatchdog can send notifications via the following channels:
Sends an HTML email to specified recipients when a mass disconnection event is detected.
Sends a message to a specified Telegram chat. The Telegram bot token and chat ID are configured in the configuration file.
Sends a JSON payload to a specified API endpoint.
Publishes a JSON message to a RabbitMQ queue. The URI for RabbitMQ is configured in the configuration file.
Sends a message to a specified Slack channel via a webhook URL. The Slack webhook URL is configured in the configuration file.
This project is licensed under the MIT License.
Copyright (c) 2024 Federico Pereira
Save this content in README.md
for your project. This includes the license section formatted as requested at the end.