decent-im / decent.im

XMPP public service with gateways to other IM networks
https://decent.im
2 stars 0 forks source link

send errors from logs to dev chat #28

Open andrey-utkin opened 7 years ago

andrey-utkin commented 7 years ago

use sendxmpp and tail -F

andrey-utkin commented 7 years ago
#!/bin/bash
set -x

function say() {
    echo "$1" | sendxmpp --tls --tls-ca-path /etc/ssl/certs/ andrey.utkin@decent.im

    # Failure injection and testing
    #echo "$1"
    #return $((RANDOM % 2)) # failure injection
}
export -f say

function say_retrying() {
    for x in `seq 1 10`
    do
        say "$@" && break
        date
        echo "Retrying transmission of $@"
        sleep 60
    done
}
export -f say_retrying

xargs -n1 -d'\n' -I {} bash -c 'say_retrying "$@"' _ {}
tail -F -n0 /var/log/jabber/prosody.err | grep '^[A-Z]' | buffer | ~/log_to_sendxmpp.sh
andrey-utkin commented 7 years ago

TODO: