Skip to content

Instantly share code, notes, and snippets.

View Bigben83's full-sized avatar

Benjamin Harris Bigben83

  • Scottsdale, Tasmania, Australia
View GitHub Profile
@OliverBailey
OliverBailey / MySQL Replication Check
Last active August 24, 2023 10:50 — forked from ssimpson89/MySQL Replication Check
Just a simple Mysql Replication Health Check script I wrote. You can put this in a cron.
#!/bin/bash
### VARIABLES ### \
EMAIL=""
SERVER=$(hostname)
MYSQL_CHECK=$(mysql --login-path=mysql_login -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
STATUS_LINE=$(mysql --login-path=mysql_login -e "SHOW SLAVE STATUS\G")"1"
LAST_ERRNO=$(grep "Last_Errno" <<< "$STATUS_LINE" | awk '{ print $2 }')
SECONDS_BEHIND_MASTER=$( grep "Seconds_Behind_Master" <<< "$STATUS_LINE" | awk '{ print $2 }')
IO_IS_RUNNING=$(grep "Slave_IO_Running:" <<< "$STATUS_LINE" | awk '{ print $2 }')
@niraj-shah
niraj-shah / replicate_db.sh
Last active June 25, 2024 11:41
Script to Replicate Database from Remote to Local
#!/bin/bash
# replicate_db.sh (c) by Niraj Shah
# replicate_db.sh is licensed under a
# Creative Commons Attribution-ShareAlike 4.0 International License.
# You should have received a copy of the license along with this
# work. If not, see <http://creativecommons.org/licenses/by-sa/4.0/>.
# https://www.webniraj.com/2017/01/13/replicating-a-remote-mysql-database-to-local-environment-server/
@islander
islander / asterisk.cdr.sql
Last active February 15, 2023 00:27
Asterisk import Master.csv CDR ot MySQL
USE asterisk;
GRANT ALL PRIVILEGES ON asterisk.* TO 'asterisk'@'localhost' IDENTIFIED BY 'change_me';
FLUSH PRIVILEGES;
CREATE TABLE IF NOT EXISTS cdr (
id BIGINT(20) NOT NULL AUTO_INCREMENT,
accountcode VARCHAR(30),
src VARCHAR(64),
dst VARCHAR(64),
dcontext VARCHAR(32),
clid VARCHAR(64),
@hwdsl2
hwdsl2 / README.md
Last active March 17, 2023 00:57
My IPTables rules for securing the Asterisk VoIP server
@ssimpson89
ssimpson89 / MySQL Replication Check
Last active July 21, 2024 15:05
Just a simple Mysql Replication Health Check script I wrote. You can put this in a cron.
#!/bin/bash
### VARIABLES ### \
EMAIL=""
SERVER=$(hostname)
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
LAST_ERRNO=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Last_Errno" | awk '{ print $2 }')
SECONDS_BEHIND_MASTER=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"| grep "Seconds_Behind_Master" | awk '{ print $2 }')
IO_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_IO_Running" | awk '{ print $2 }')
SQL_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_SQL_Running" | awk '{ print $2 }')