#!/bin/bash

# wminfo plugin: monitors /var/log/syslog file

# command: wminfo -p syslog.wmi -u 10 -b#000000 -f#ff0000

#
# CONFIGURATION SECTION BEGINS HERE
#

hostname=`hostname`

file="/var/log/syslog"

lines="10"

#
# CONFIGURATION SECTION ENDS HERE
#

if [ -r $file ]
then
    tac $file | perl -pe "m/$hostname/;s/.* $hostname .*?: [\[0-9\.\]]+ //;s/^\n$//" | head -n $lines
    echo
else
    echo "$0: can not read $file file."
    echo -e "         \n         \n         \n         \n"
fi

