[unofficial] Ark Node | Mail Log Watcher - Script



  • hi ppl,

    i made some simple email monitoring script for crawling the ark node log. it will send out an warning email when some keywords are found in the logfile.
    its nothing special or very complicated and i`m sure there are many ppl here which could write something better or already did so.
    nevertheless i want to share it.

    Howto:

    all things in < > with “edit this” or sth. like that must be edited by you.

    • get a gmail account (only tested with gmail)
    • do sudo-apt get update && sudo apt-get upgrade
    • do sudo apt-get install sendemail on your ark node (yes! its sendemail, not sendmail) ;-)
    • do sudo apt-get install swatch on your ark node
    • do sudo ufw allow 587/tcp on your node
    1. create /etc/init.d/swatch and copy the following lines in there.

    #!/bin/sh
    case “$1” in
    ’start’)
    /usr/bin/swatch --daemon --config-file=/etc/swatch.conf --tail-file=
    <edit this. path to your ark.log. if u installed in home dir path could be ~/ark-node/logs/ark.log>* --pid-file=/var/run/swatch.pid
    ;;
    ‘stop’)
    PID=`cat /var/run/swatch.pid`
    kill $PID
    ;;
    )
    echo “Usage: $0 { start | stop }”
    ;;
    esac
    exit 0

    1. do the following commands:

    sudo chmod 755 /etc/init.d/swatch
    sudo ln -s /etc/init.d/swatch /etc/rc2.d/S99swatch
    sudo ln -s /etc/init.d/swatch /etc/rc3.d/S99swatch
    sudo ln -s /etc/init.d/swatch /etc/rc5.d/S99swatch

    1. create /etc/swatch.conf and copy the following lines in there. you can edit keywords which should be watched for in the watchfor section. threshold can be tuned by you. look into swatch manpage.

    watchfor /error|ERROR|FATAL|WARNING|warning|NOT FORGING|not forging|Blockchain not ready to receive block/
    pipe "echo “$_” >>/home/
    <edit this - put name of local user here>/nodewatch.mail"
    exec "/home/
    <edit this - put name of local user here>/nodewatch.sh"
    threshold track_by=$1:$2:$3:$4:$5:$6:$7:$8:$9:$10,type=limit, count=1,seconds=60

    1. create ~/nodewatch.sh and enter the following lines in there.

    sendemail -f <edit this - sender mail> -t <edit this - receipient> -u NODEWATCH INFO -s smtp.gmail.com:587 -o tls=yes -xu <edit this - sender mail> -xp <edit this - sender mail password> -o message-file=/home/<edit this>/nodewatch.mail

    you can start the whole thing with:
    sudo /etc/init.d/swatch start
    and stop it with:
    sudo /etc/init.d/swatch stop

    after a server reboot it will start automatic.

    in case of any bugs or so do a ps aux | grep swatch, get the id and kill the process.

    regards,

    picard


Log in to reply

Looks like your connection to [unofficial] Ark Node | Mail Log Watcher - Script was lost, please wait while we try to reconnect.