Development Tips

useful tips

install

 yum --enablerepo=epel -y install inotify-tools 

monitor.sh

#!/bin/bash
TARGET=$1
ACTION=$2
while inotifywait -e modify ${TARGET}; do
        /bin/bash ${ACTION} ${TARGET}
done

action.sh

#!/bin/bash
#/var/log/nginx/error.log

TARGET=$1
cat ${TARGET} | grep 'limiting requests' | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | cut -d ' ' -f 4 | sort -u

use it:

./monitor.sh /var/log/nginx/error.log ./action.sh