Jump to content

Recommended Posts

Guest romanrsr
Posted

Hello friends, as they are? First of all sorry for my poor English. I tell them what is my problem. I have the following script, which is basically what makes error search for a pattern within a folder containing logs. The script works fine, the problem is that whenever I find a pattern of new error, I send an email with all faults, and I just want to send me new errors found. Can anyone give me a hand? Thank you!

 

Code:

errors=$(grep "System Error Pattern Here" /var/log/)

echo "$errors" > /tmp/current-errors.log

 

if [ -e "/tmp/prior-errors.log" ]

then echo "prior-errors.log Exists" > /dev/null

else

touch /tmp/prior-errors.log | echo "" > /tmp/prior-errors.log

fi

 

newentries=$(diff --suppress-common-lines -u /tmp/prior-errors.log /tmp/current-errors.log | grep '+[0-9]')

 

if

test "$newentries" != "" && test "$errors" = ""

then echo "No New Errors" > /dev/null

elif

test "$newentries" != ""

then echo "$errors" | mailx -s "WARNING: Error Messages Detected"

echo "$errors" > /tmp/prior-errors.log

fi

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...