Cassandra Shell Scripts Technologies

Shell Script to monitor Cassandra system.log for errors :

Grep current hour and last one hour statements from logfile:
Get last one hour messages from logfile using sed command:

Crontab entry:

00,05,10,15,20,25,30,35,40,45,50,55 * * * * /u01/scripts/ 1> /u01/logs/system_log_check.log 2>&1

#! /bin/sh
Script Name : system_log_check.ksh
By : Kishore Uppala
Date : 8/8/2019
Description : Sends alert, if "Too many pending remote requests" error found in system log .

Version : Initial
export CONTENT="/tmp/system_log_check.html"
export SUBJECT="[CRITICAL] : Errors found in system log of $HOSTNAME [hostname -i] at date. Please check immediatly"
echo "Errors in System Log" > /tmp/system_log_check.html
echo "<pre>-------------------------------------------------------------</pre> " >/tmp/system_log_check.out
#Search Present hour, last hour log statements for keyword "Too Many Pending" and append the matched statements to the file.

sed -n "/$(date -d -1hour +"%Y-%m-%d %H:")/,/$(date +"%Y-%m-%d %H:") /p" /var/log/cassandra/system.log|grep -i "Too many pending"|tail >>/tmp/system_log_check.out

echo "Script Last Ran @ " `date `

echo "<HTML>
<TABLE border="1">
`cat /tmp/system_log_check.out`

strings=`grep -i 'Too many' /tmp/system_log_check.html | wc -l`

if [ $strings -ne 0 ]
echo "TO :$MailId"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
cat $CONTENT) | /usr/lib/sendmail -r 'Cassandra-DBA' $MailId

Comments Rating 0 (0 reviews)

About the author


Add Comment

Click here to post a comment