Skip to content

Instantly share code, notes, and snippets.

View opmat's full-sized avatar

Matiluko Opeyemi Emmanuel opmat

View GitHub Profile
@opmat
opmat / max_auto_increment_tables.sql
Created November 23, 2023 02:49 — forked from utdrmac/max_auto_increment_tables.sql
Find db.table.columns that are > 90% auto_increment capacity
SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLUMN_TYPE,
(CASE DATA_TYPE
WHEN 'tinyint' THEN 255
WHEN 'smallint' THEN 65535
WHEN 'mediumint' THEN 16777215
WHEN 'int' THEN 4294967295
WHEN 'bigint' THEN 18446744073709551615
END >> IF(LOCATE('unsigned', COLUMN_TYPE) > 0, 0, 1)
) AS MAX_VALUE,
AUTO_INCREMENT AS CURRENT_VALUE,
@opmat
opmat / gracewatch.c
Created November 23, 2023 02:49 — forked from utdrmac/gracewatch.c
/*
* Gracewatch 1.0
* Matthew Boehm <matthew@matthewboehm.com>
*
* Gracewatch is a multi-threaded MySQL monitoring solution developed for
* a client that had no in-house monitoring team.
*
* Using libConfig (http://www.hyperrealm.com/libconfig/), gracewatch reads
* a list of servers and credentials and spawns a pthread for each server.
* The thread connects to the host and every minute preforms a mysql_ping()
@opmat
opmat / mysql_memory_usage.sql
Created November 23, 2023 02:48 — forked from utdrmac/mysql_memory_usage.sql
MySQL Memory Usage
SELECT CONCAT((@@key_buffer_size + @@query_cache_size + (@@innodb_buffer_pool_size * 1.05 + 20*1024*1024) + @@innodb_additional_mem_pool_size + @@innodb_log_buffer_size
+ @@max_connections * (@@read_buffer_size + @@read_rnd_buffer_size + @@sort_buffer_size + @@join_buffer_size + @@binlog_cache_size + @@tmp_table_size
+ @@thread_stack)) / 1024/1024/1024, ' GB') AS "POTENTIAL MEMORY USAGE";
@opmat
opmat / mysql_autoinc_checker.go
Created November 23, 2023 02:43 — forked from utdrmac/mysql_autoinc_checker.go
Checks AUTO_INCREMENT fields in MySQL to see if near MAXVALUE
/*
Copyright (c) 2014, Percona LLC and/or its affiliates. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@opmat
opmat / rds-repl-restart.py
Created November 23, 2023 02:42 — forked from utdrmac/rds-repl-restart.py
Quick-n-dirty script for watching RDS replication and skipping on specific error codes
import sys
import mysql.connector
from mysql.connector.errors import InterfaceError
from time import sleep
mydb = mysql.connector.connect(host="", user="", password="", database="mysql")
cursor = mydb.cursor(dictionary=True)
while True:
@opmat
opmat / monitor_mysql.pl
Created November 23, 2023 02:38 — forked from utdrmac/monitor_mysql.pl
Perl Script to Monitor MySQL Replication and Send Email on Failure
#!/usr/bin/perl
use DBI;
use Email::MIME;
use Log::Log4perl qw(get_logger :levels);
use Data::Dumper;
use strict;
# For backgrounding