Created
January 16, 2017 16:28
-
-
Save Neolot/ef7fce2518a8ec71bbe09beb9381ee95 to your computer and use it in GitHub Desktop.
Send logwatch report to Telegram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Config | |
day=$(date +%Y-%m-%d) | |
filename=/var/cache/logwatch/$day-logwatch.txt | |
token=<YOUR BOT TOKEN> | |
chat_id=<YOUR CHAT_ID> | |
#Check if removed-but-not-purged | |
test -x /usr/share/logwatch/scripts/logwatch.pl || exit 0 | |
#execute | |
/usr/sbin/logwatch --output file --filename $filename | |
chmod 644 $filename | |
mv $filename /root/logwatch/ | |
curl -F chat_id="$chat_id" -F document=@"/root/logwatch/$day-logwatch.txt" https://api.telegram.org/bot$token/sendDocument >/dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment