De Wiki Clusterlab.com.br
Ir para navegação
Ir para pesquisar
#!/bin/bash
GET_COUNT() {
cat /var/log/messages | \
egrep "ERROR - my specific message of fail 1|ERROR - my specific message of fail 2" | \
awk '{ print $1 " " $2 " "$3 } ' | \
while read -r line
do
date -d "$line" +"%s"
done | \
while read EPOCH
do
if [ $EPOCH -gt $1 ]
then
echo $EPOCH
fi
done | wc -l | awk '{print $1} '
}
RESTART_APP() {
date
systemctl restart MYAPP.service
echo service restarted
}
export WINDOW=$1
export NOW=$(date +"%s")
export SINCE=$(expr $(date +"%s") - $WINDOW)
if [ $(GET_COUNT $SINCE) -gt 0 ]
then
RESTART_APP
fi