. /usr/src/m2/framework/bash_functions.sh . /usr/src/m2/framework/settings.sh k_config_details # ---- VARS ----- VERSION="1.1.3" SCRIPT_NAME="MySQL Partitions Check" TEST=0 # ---- FUNCTIONS ----- # ---- MAIN ----- k_start read_m2_settings if [[ "$DB_PRESENT" != "1" ]]; then report "DB not present on this server. Not checking for partitions cron." 0 k_exit 0 fi if [[ "$MAIN_DB" == "0" ]]; then report "This is not MAIN_DB. Not checking for partitions cron." 3 k_exit 0 elif [[ "$MAIN_DB" == "-1" ]]; then report "MAIN_DB is not set. MAIN_DB must be set for all DB servers" 1 EXIT_CODE=1 k_exit $EXIT_CODE fi if [[ -e /etc/cron.d/m2_partitions ]]; then report "Partitions cron already exists" 0 k_exit 0 fi set_database_variables if /usr/bin/mysql -V | grep -Eq 'Distrib 5\.[15]'; then p_opt="--password=$DB_PASSWORD" else p_opt="" fi partitons_supported=$(MYSQL_PWD="$DB_PASSWORD" /usr/bin/mysql -h "$DB_HOST" -u "$DB_USERNAME" $p_opt "$DB_NAME" -sNe "SELECT count(*) FROM information_schema.partitions WHERE TABLE_SCHEMA='m2' AND TABLE_NAME = 'calls' AND PARTITION_NAME='future'") if [[ -n $partitons_supported ]]; then if (( partitons_supported > 0)); then report "Partitions are supported, but partition cron is absent" 1 report " Check here http://doc.kolmisoft.com/display/kolmisoft/Partitions+are+supported%2C+but+partition+cron+is+absent " 1 EXIT_CODE=1 else report "Please consider moving to DB with partition support" 2 EXIT_CODE=2 fi fi k_exit $EXIT_CODE