View vip_move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If the host with the VIP is up, this removes it | |
ip addr del 10.20.43.184/32 dev eth2 | |
// Add VIP to new host | |
ip addr add 10.20.43.184/32 dev eth2 | |
/sbin/arping -c 5 -U -I eth2 10.20.43.184 |
View max_auto_increment_tables.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
View order-by-rand.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Option 1 | |
SELECT * | |
FROM title t | |
WHERE kind_id = 1 AND id >= FLOOR(1 + RAND() * (SELECT MAX(id) FROM title)) LIMIT 1; | |
-- Option 2 | |
SELECT id, title | |
FROM title t RIGHT JOIN | |
(SELECT CEIL(RAND() * (SELECT MAX(id) FROM title WHERE kind_id = 1)) AS id) h USING (id); |
View per-engine-size.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(*) TABLES, | |
concat(round(sum(table_rows)/1000000,2),'M') rows, | |
concat(round(sum(data_length)/(1024*1024*1024),2),'G') DATA, | |
concat(round(sum(index_length)/(1024*1024*1024),2),'G') idx, | |
concat(round(sum(data_length+index_length)/(1024*1024*1024),2),'G') total_size, | |
round(sum(index_length)/sum(data_length),2) idxfrac, engine | |
FROM information_schema.TABLES | |
WHERE table_type != 'VIEW' AND table_schema NOT IN ('mysql', 'performance_schema', 'information_schema') | |
GROUP BY engine; |
View pushbullet_slave_monitor.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A title for the notification | |
title="Slave - ${HOSTNAME}" | |
# PushBullet API Token | |
# https://www.pushbullet.com/#settings/account | |
token="C17CdC7b0XXXXXXXX1idCdATgVjbfEY" | |
# Send a notification every X minutes |
View monitor_mysql.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use DBI; | |
use Email::MIME; | |
use Log::Log4perl qw(get_logger :levels); | |
use Data::Dumper; | |
use strict; | |
# For backgrounding |
View gracewatch.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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() |
View mysql55_timestamp_columns.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT t.table_schema, t.engine, t.table_name, c.column_name, c.column_type | |
FROM information_schema.tables AS t | |
INNER JOIN information_schema.columns AS c ON c.table_schema = t.table_schema | |
AND c.table_name = t.table_name | |
LEFT OUTER JOIN information_schema.innodb_sys_tables AS ist | |
ON ist.name = concat(t.table_schema,'/',t.table_name) | |
LEFT OUTER JOIN information_schema.innodb_sys_columns AS isc | |
ON isc.table_id = ist.table_id AND isc.name = c.column_name | |
WHERE c.column_type IN ('time','timestamp','datetime') | |
AND t.table_schema NOT IN ('mysql','information_schema','performance_schema') |
View mysql_memory_usage.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
View queue.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
include 'config.php'; | |
/* This is the EC2 API Client object */ | |
$sqs = Aws\Sqs\SqsClient::factory(array( | |
'key' => $aws_key, | |
'secret' => $aws_secret, | |
'region' => 'us-west-2', |
OlderNewer