oak-get-slave-lag

NAME

oak-get-slave-lag: print slave replication lag and terminate with respective exit code.

SYNOPSIS

Print slave lag, return 0 exit code:
oak-get-slave-lag --user=root --socket=/tmp/mysql.sock
Print slave lag, return 1 exit code if slave lag is greater than 60 seconds or slave is not replicating at all. Return 0 exit code when slave replicates and lag is less than or equal to 60 seconds.
oak-get-slave-lag --user=root --socket=/tmp/mysql.sock -e 60
Same as above, use defaults file:
oak-get-slave-lag --defaults-file=/home/myuser/.my-oak.cnf -e 60

DESCRIPTION

This tools prints out the slave lag and produces either 0 exit code on success or 1 on failure

When the --error-if-more-than-seconds option (-e short form) is specified, oak-get-slave-lag expects replication lag to be smaller than or equal to given value. If replication lags more than given number of seconds, or does not work at all, the tool exits with 1 exit code. Otherwise the tool is satisfied and returns with 0 exit code.

Replication lag is deduced from the Seconds_Behind_Master value on SHOW SLAVE STATUS. Mind that this value is not always correct. Unless replication heartbeat is present (MySQL >= 5.5), SHOW SLAVE STATUS may report a 0 lag when in fact it lags hours behind, for a limited period of time.

OPTIONS

--ask-pass

Prompt for password.

--debug

Print stack trace on error.

-e ERROR_IF_MORE_THAN_SECONDS, --error-if-more-than-seconds=ERROR_IF_MORE_THAN_SECONDS

Return with error exit code if slave lag is more than given number of seconds (default: disabled)

--defaults-file=DEFAULTS_FILE

Read from MySQL configuration file. Overrides --user, --password, --socket, --port.

Configuration needs to be in the following format:

[client]
user=my_user
password=my_pass
socket=/tmp/mysql.sock
port=3306

-H HOST, --host=HOST

MySQL host (default: localhost)

-p PASSWORD, --password=PASSWORD

MySQL password

-P PORT, --port=PORT

TCP/IP port (default: 3306)

-S SOCKET, --socket=SOCKET

MySQL socket file. Only applies when host is localhost

-u USER, --user=USER

MySQL user

-v, --verbose

Print user friendly messages

ENVIRONMENT

Requires MySQL 5.0 or newer, python 2.3 or newer. python-mysqldb must be installed in order to use this tool. You can
apt-get install python-mysqldb
or
yum install mysql-python

SEE ALSO

oak-show-replication-status

LICENSE

This tool is released under the BSD license.
Copyright (c) 2008 - 2010, Shlomi Noach
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

AUTHOR

Shlomi Noach
 
openark kit documentation