forked from pinks/eris
1
0
Fork 0

webhooks #1

Merged
Akiru merged 12 commits from webhooks into main 2024-01-26 13:20:20 +00:00
1 changed files with 29 additions and 0 deletions
Showing only changes of commit ffff9c87ef - Show all commits

29
monitoring/monitoring.sh Normal file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# This script has to be run as systemd service. It checks journalctl output for errors and restarts the bot automatically when they occur too often.
# Define the regex pattern to search for occurrences of "GrammyError" and "sendMediaGroup"
ERROR_PATTERN="GrammyError.*sendMediaGroup"
# Initialize the counter for consecutive occurrences
error_count=0
# Monitor the journalctl output
journalctl -xe -f | while read line; do
# Check if the line contains the pattern
if echo "$line" | grep -qE "$ERROR_PATTERN"; then
# Increment the error counter
((error_count++))
# Check if the error has occurred 4 times in a row
if [ $error_count -eq 4 ]; then
# Restart the bot service
systemctl restart nyxthebot
# Reset the error counter
error_count=0
fi
else
# Reset the error counter if the line does not contain the error
error_count=0
fi
done