initial commit of a *whole bunch* of old Egressive shell scripts, used to make many people redundant.
This commit is contained in:
commit
43e0f5b59e
329 changed files with 31937 additions and 0 deletions
78
egdbstatus/egdbstatus
Executable file
78
egdbstatus/egdbstatus
Executable file
|
@ -0,0 +1,78 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# egdbback, copyright 2008 Egressive Limited, http://egressive.com
|
||||
#
|
||||
# this script checks the status of a mysql database, eg. replication status...
|
||||
#
|
||||
#==========================================
|
||||
# The Variables - these must be define
|
||||
# before they're referenced
|
||||
#==========================================
|
||||
VERSION="0.1"
|
||||
EGDB_NAME=`basename $0`
|
||||
EGDB_DIR=/etc/egscripts/egdbstatus
|
||||
EGDB_CMD=$EGDB_DIR/egdbstatus
|
||||
SITE_CONF="$EGDB_DIR/site.conf"
|
||||
#
|
||||
# this provides values for MACHINE_NAME and EMAIL
|
||||
. $SITE_CONF
|
||||
#
|
||||
LOGS=/var/log
|
||||
LOGFILE=$LOGS/egdbstatus.log
|
||||
#
|
||||
LASTRUN=/tmp/.egdbstatus
|
||||
# required programs
|
||||
MAIL=`which mail`
|
||||
GREP=`which grep`
|
||||
LS=`which ls`
|
||||
ID=`which id`
|
||||
DATE=`which date`
|
||||
DF=`which df`
|
||||
GZIP=`which gzip`
|
||||
GZIPSUF=gz
|
||||
RM=`which rm`
|
||||
LN=`which ln`
|
||||
CUT=`which cut`
|
||||
AWK=`which awk`
|
||||
CP=`which cp`
|
||||
CAT=`which cat`
|
||||
FIND=`which find`
|
||||
#
|
||||
#==========================================
|
||||
# MySQL vars...
|
||||
MYSQL=`which mysql`
|
||||
|
||||
STATUS="[SUCCESS]"
|
||||
|
||||
date > $LOGFILE
|
||||
ERRNO=`echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Last_Errno" | $AWK '{ print $2; }'`
|
||||
if [ "$ERRNO" != "0" ]; then
|
||||
echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Last_Error" | $AWK '{ print $2; }' >> $LOGFILE
|
||||
STATUS="[ERROR]"
|
||||
fi
|
||||
|
||||
SLAVE_STATUS=`echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Slave_IO_State" | $AWK -F':' '{ print $2; }' | sed "s/^[ \t]*//g"`
|
||||
if [ "$SLAVE_STATUS" != "Waiting for master to send event" -a "$SLAVE_STATUS" != "Queueing master event to the relay log" ] ; then
|
||||
echo $SLAVE_STATUS >> $LOGFILE
|
||||
echo " See http://dev.mysql.com/doc/refman/5.0/en/slave-io-thread-states.html for more info" >> $LOGFILE
|
||||
STATUS="[ERROR]"
|
||||
fi
|
||||
|
||||
SECONDS_BEHIND=`echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Seconds_Behind_Master" | $AWK -F':' '{ print $2; }' | sed "s/^[ \t]*//g"`
|
||||
if [ "$SECONDS_BEHIND" = "NULL" -o `echo "$SECONDS_BEHIND > 3600" | bc` -ne 0 ] ; then
|
||||
echo "Slave is too far behind or null: $SECONDS_BEHIND" >> $LOGFILE
|
||||
STATUS="[ERROR]"
|
||||
fi
|
||||
|
||||
# We have found an error or we havn't reported in the 6 hours, report it
|
||||
if [ "$STATUS" == "[ERROR]" ] || [ ! -e $LASTRUN ] || [ -n "`$FIND $LASTRUN -mmin +359`" ]; then
|
||||
echo "+++++++++++++++++++++++++++++++++++++++++"
|
||||
echo " Full status of the slave"
|
||||
echo "+++++++++++++++++++++++++++++++++++++++++"
|
||||
echo
|
||||
echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD >> $LOGFILE
|
||||
HOST=`hostname`
|
||||
$CAT $LOGFILE | $MAIL -s "$STATUS Replication on $HOST" $EMAIL
|
||||
touch $LASTRUN
|
||||
fi
|
||||
|
8
egdbstatus/egdbstatus-cron
Executable file
8
egdbstatus/egdbstatus-cron
Executable file
|
@ -0,0 +1,8 @@
|
|||
# run the egdb backup programs every day to backup our MySQL database.
|
||||
# hourlies - every 15 minutes...
|
||||
*/15 * * * * root /etc/egscripts/egdbstatus/egdbstatus
|
||||
# Every 15 minutes, starting at 1 minute past the hour
|
||||
(1-59)/15 * * * * root /etc/egscripts/egdbstatus/egdbstatus-nerdelbaum
|
||||
# Every 15 minutes, starting at 2 minute past the hour
|
||||
(2-59)/15 * * * * root /etc/egscripts/egdbstatus/egdbstatus-pinchy
|
||||
|
80
egdbstatus/egdbstatus-nerdelbaum
Executable file
80
egdbstatus/egdbstatus-nerdelbaum
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# egdbback, copyright 2008 Egressive Limited, http://egressive.com
|
||||
#
|
||||
# this script checks the status of a mysql database, eg. replication status...
|
||||
#
|
||||
#==========================================
|
||||
# The Variables - these must be define
|
||||
# before they're referenced
|
||||
#==========================================
|
||||
VERSION="0.1"
|
||||
EGDB_NAME=`basename $0`
|
||||
EGDB_DIR=/etc/egscripts/egdbstatus
|
||||
EGDB_CMD=$EGDB_DIR/egdbstatus-nerdelbaum
|
||||
SITE_CONF="$EGDB_DIR/site-nerdelbaum.conf"
|
||||
#
|
||||
# this provides values for MACHINE_NAME and EMAIL
|
||||
. $SITE_CONF
|
||||
#
|
||||
LOGS=/var/log
|
||||
LOGFILE=$LOGS/egdbstatus-nerdelbaum.log
|
||||
#
|
||||
LASTRUN=/tmp/.egdbstatus-nerdelbaum
|
||||
# required programs
|
||||
MAIL=`which mail`
|
||||
GREP=`which grep`
|
||||
LS=`which ls`
|
||||
ID=`which id`
|
||||
DATE=`which date`
|
||||
DF=`which df`
|
||||
GZIP=`which gzip`
|
||||
GZIPSUF=gz
|
||||
RM=`which rm`
|
||||
LN=`which ln`
|
||||
CUT=`which cut`
|
||||
AWK=`which awk`
|
||||
CP=`which cp`
|
||||
CAT=`which cat`
|
||||
FIND=`which find`
|
||||
#
|
||||
#==========================================
|
||||
# MySQL vars...
|
||||
MYSQL=`which mysql`
|
||||
# Set the correct socket to use
|
||||
MYSQL="$MYSQL -S /var/run/mysqld/mysqld.nerdelbaum.sock"
|
||||
|
||||
STATUS="[SUCCESS]"
|
||||
|
||||
date > $LOGFILE
|
||||
ERRNO=`echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Last_Errno" | $AWK '{ print $2; }'`
|
||||
if [ "$ERRNO" != "0" ]; then
|
||||
echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Last_Error" | $AWK '{ print $2; }' >> $LOGFILE
|
||||
STATUS="[ERROR]"
|
||||
fi
|
||||
|
||||
SLAVE_STATUS=`echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Slave_IO_State" | $AWK -F':' '{ print $2; }' | sed "s/^[ \t]*//g"`
|
||||
if [ "$SLAVE_STATUS" != "Waiting for master to send event" -a "$SLAVE_STATUS" != "Queueing master event to the relay log" ] ; then
|
||||
echo $SLAVE_STATUS >> $LOGFILE
|
||||
echo " See http://dev.mysql.com/doc/refman/5.0/en/slave-io-thread-states.html for more info" >> $LOGFILE
|
||||
STATUS="[ERROR]"
|
||||
fi
|
||||
|
||||
SECONDS_BEHIND=`echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Seconds_Behind_Master" | $AWK -F':' '{ print $2; }' | sed "s/^[ \t]*//g"`
|
||||
if [ "$SECONDS_BEHIND" = "NULL" -o `echo "$SECONDS_BEHIND > 3600" | bc` -ne 0 ] ; then
|
||||
echo "Slave is too far behind or null: $SECONDS_BEHIND" >> $LOGFILE
|
||||
STATUS="[ERROR]"
|
||||
fi
|
||||
|
||||
# We have found an error or we havn't reported in the 6 hours, report it
|
||||
if [ "$STATUS" == "[ERROR]" ] || [ ! -e $LASTRUN ] || [ -n "`$FIND $LASTRUN -mmin +359`" ]; then
|
||||
echo "+++++++++++++++++++++++++++++++++++++++++"
|
||||
echo " Full status of the slave"
|
||||
echo "+++++++++++++++++++++++++++++++++++++++++"
|
||||
echo
|
||||
echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD >> $LOGFILE
|
||||
HOST=`hostname`
|
||||
$CAT $LOGFILE | $MAIL -s "$STATUS Replication on $HOST (Nerdelbaum)" $EMAIL
|
||||
touch $LASTRUN
|
||||
fi
|
||||
|
80
egdbstatus/egdbstatus-pinchy
Executable file
80
egdbstatus/egdbstatus-pinchy
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# egdbback, copyright 2008 Egressive Limited, http://egressive.com
|
||||
#
|
||||
# this script checks the status of a mysql database, eg. replication status...
|
||||
#
|
||||
#==========================================
|
||||
# The Variables - these must be define
|
||||
# before they're referenced
|
||||
#==========================================
|
||||
VERSION="0.1"
|
||||
EGDB_NAME=`basename $0`
|
||||
EGDB_DIR=/etc/egscripts/egdbstatus
|
||||
EGDB_CMD=$EGDB_DIR/egdbstatus-pinchy
|
||||
SITE_CONF="$EGDB_DIR/site-pinchy.conf"
|
||||
#
|
||||
# this provides values for MACHINE_NAME and EMAIL
|
||||
. $SITE_CONF
|
||||
#
|
||||
LOGS=/var/log
|
||||
LOGFILE=$LOGS/egdbstatus-pinchy.log
|
||||
#
|
||||
LASTRUN=/tmp/.egdbstatus-pinchy
|
||||
# required programs
|
||||
MAIL=`which mail`
|
||||
GREP=`which grep`
|
||||
LS=`which ls`
|
||||
ID=`which id`
|
||||
DATE=`which date`
|
||||
DF=`which df`
|
||||
GZIP=`which gzip`
|
||||
GZIPSUF=gz
|
||||
RM=`which rm`
|
||||
LN=`which ln`
|
||||
CUT=`which cut`
|
||||
AWK=`which awk`
|
||||
CP=`which cp`
|
||||
CAT=`which cat`
|
||||
FIND=`which find`
|
||||
#
|
||||
#==========================================
|
||||
# MySQL vars...
|
||||
MYSQL=`which mysql`
|
||||
# Set the correct socket to use
|
||||
MYSQL="$MYSQL -S /var/run/mysqld/mysqld.pinchy.sock"
|
||||
|
||||
STATUS="[SUCCESS]"
|
||||
|
||||
date > $LOGFILE
|
||||
ERRNO=`echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Last_Errno" | $AWK '{ print $2; }'`
|
||||
if [ "$ERRNO" != "0" ]; then
|
||||
echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Last_Error" | $AWK '{ print $2; }' >> $LOGFILE
|
||||
STATUS="[ERROR]"
|
||||
fi
|
||||
|
||||
SLAVE_STATUS=`echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Slave_IO_State" | $AWK -F':' '{ print $2; }' | sed "s/^[ \t]*//g"`
|
||||
if [ "$SLAVE_STATUS" != "Waiting for master to send event" -a "$SLAVE_STATUS" != "Queueing master event to the relay log" ] ; then
|
||||
echo $SLAVE_STATUS >> $LOGFILE
|
||||
echo " See http://dev.mysql.com/doc/refman/5.0/en/slave-io-thread-states.html for more info" >> $LOGFILE
|
||||
STATUS="[ERROR]"
|
||||
fi
|
||||
|
||||
SECONDS_BEHIND=`echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD | $GREP "Seconds_Behind_Master" | $AWK -F':' '{ print $2; }' | sed "s/^[ \t]*//g"`
|
||||
if [ "$SECONDS_BEHIND" = "NULL" -o `echo "$SECONDS_BEHIND > 3600" | bc` -ne 0 ] ; then
|
||||
echo "Slave is too far behind or null: $SECONDS_BEHIND" >> $LOGFILE
|
||||
STATUS="[ERROR]"
|
||||
fi
|
||||
|
||||
# We have found an error or we havn't reported in the 6 hours, report it
|
||||
if [ "$STATUS" == "[ERROR]" ] || [ ! -e $LASTRUN ] || [ -n "`$FIND $LASTRUN -mmin +359`" ]; then
|
||||
echo "+++++++++++++++++++++++++++++++++++++++++"
|
||||
echo " Full status of the slave"
|
||||
echo "+++++++++++++++++++++++++++++++++++++++++"
|
||||
echo
|
||||
echo "SHOW SLAVE STATUS\G" | $MYSQL -u $USER -p$PASSWORD >> $LOGFILE
|
||||
HOST=`hostname`
|
||||
$CAT $LOGFILE | $MAIL -s "$STATUS Replication on $HOST (Pinchy)" $EMAIL
|
||||
touch $LASTRUN
|
||||
fi
|
||||
|
7
egdbstatus/site-nerdelbaum.conf
Normal file
7
egdbstatus/site-nerdelbaum.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
# default email address to which to send status reports
|
||||
EMAIL=support@egressive.com
|
||||
# These are specific to the MySQL install on this machine
|
||||
HOST= # blank if localhost
|
||||
USER=egdbstatus
|
||||
PASSWORD=tbYu4ePYmWL5AdSn
|
||||
|
7
egdbstatus/site-pinchy.conf
Normal file
7
egdbstatus/site-pinchy.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
# default email address to which to send status reports
|
||||
EMAIL=support@egressive.com
|
||||
# These are specific to the MySQL install on this machine
|
||||
HOST= # blank if localhost
|
||||
USER=egdbstatus
|
||||
PASSWORD=5uLRTmP85Tze.dQK
|
||||
|
7
egdbstatus/site.conf
Normal file
7
egdbstatus/site.conf
Normal file
|
@ -0,0 +1,7 @@
|
|||
# default email address to which to send status reports
|
||||
EMAIL=support@egressive.com
|
||||
# These are specific to the MySQL install on this machine
|
||||
HOST= # blank if localhost
|
||||
USER=egdbstatus
|
||||
PASSWORD=tbYu4ePYmWL5AdSn
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue