m7v
3/16/2015 - 5:26 AM

Notify developer via system about new watchdog.

Notify developer via system about new watchdog.

#!/bin/bash

log='/var/log/syslog'
regex='drupal: ([^\|]*)\|[^\|]*\|([^\|]*)[^\|]*\|[^\|]*\|[^\|]*\|[^\|]*\|[^\|]*\|[^\|]*\|(.*)'

while inotifywait -e modify $log; do
  if tail -1 $log | grep drupal; then
    line=`tail -1 $log`

    [[ $line =~ $regex ]]
    host="${BASH_REMATCH[1]}"
    type="${BASH_REMATCH[2]}"
    message="${BASH_REMATCH[3]}"

    notify-send "$host: $type" "$message"
  fi
done