Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
WRITER_VIP=192.168.56.83
READER_VIP=192.168.56.84
PXC_CHECK='/usr/bin/clustercheck clustercheck password 0'
SCRIPT=$1
WEIGHT=101
case $SCRIPT in
'bad_pxc')
@dotmanila
dotmanila / pcs-data.sh
Created December 10, 2014 03:25
Data Collection Script
#!/bin/bash
dir=$1
duration=$2
outputdir="${dir}/second_samples_output_$(date +%Y-%m-%d_%H-%M-%S)"
min_free_bytes=1073741824 # 1GB
min_free_pct=10 # 10%
function usage {
@dotmanila
dotmanila / ddoss.out
Last active August 29, 2015 14:22
DDoS Script Found
[root@acme ~]# netstat -plant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1270/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2043/master
tcp 0 0 192.254.64.50:50611 103.240.141.54:3505 ESTABLISHED 722/whoami
tcp 0 268 192.254.64.50:22 122.2.123.122:54675 ESTABLISHED 15580/sshd: revin [
tcp6 0 0 :::22 :::* LISTEN 1270/sshd
tcp6 0 0 ::1:25 :::* LISTEN 2043/master
[root@acme ~]# w
@dotmanila
dotmanila / pcs-collect-metrics.sh
Created July 8, 2015 03:18
Metrics Collection
#!/bin/bash
dir=$1
duration=$2
if [ "$3" == "" ]; then
savedir=$(hostname)
else
savedir="$3"
fi
@dotmanila
dotmanila / latency.stp
Created July 16, 2015 08:00
systemtap Measuring mysqld functions latency
#!/bin/env stap
#
global latency, latency_histogram
probe begin {
printf("Begin.\n")
}
probe process("/usr/sbin/mysqld").function("*") {
latency[probefunc()] = gettimeofday_s()
@dotmanila
dotmanila / php-mysqlnd-LONGBLOB-test.php
Last active August 29, 2015 14:27
LONGBLOB and mysqlnd seems to be slower.
<?php
//mysql> insert into t (t) values (repeat('a',1048576));
//Query OK, 1 row affected (0.14 sec)
//mysql> show create table t \G
//*************************** 1. row ***************************
// Table: t
//Create Table: CREATE TABLE `t` (
// `t` longtext
@dotmanila
dotmanila / mysqlnd-stats-to src-constant.txt
Created August 25, 2015 07:50
mysqlnd stats name to source code constant mapping
bytes_sent STAT_BYTES_SENT
bytes_received STAT_BYTES_RECEIVED
packets_sent STAT_PACKETS_SENT
packets_received STAT_PACKETS_RECEIVED
protocol_overhead_in STAT_PROTOCOL_OVERHEAD_IN
protocol_overhead_out STAT_PROTOCOL_OVERHEAD_OUT
bytes_received_ok_packet STAT_BYTES_RECEIVED_OK
bytes_received_eof_packet STAT_BYTES_RECEIVED_EOF
bytes_received_rset_header_packet STAT_BYTES_RECEIVED_RSET_HEADER
bytes_received_rset_field_meta_packet STAT_BYTES_RECEIVED_RSET_FIELD_META
@dotmanila
dotmanila / python-check-binlogs.py
Created August 29, 2015 02:44
Check create timestamp of binary logs
#!/usr/bin/python
import os, time
from struct import unpack
from datetime import datetime
d = '/home/mysql/backup_data/backup_str/binlogs'
x = 180
oldest = int(time.time())-(90*24*60*60)
@dotmanila
dotmanila / mysql-partition-manager.sh
Created October 22, 2015 22:48
Manage partitions on a table partition with RANGE on datetime column
#!/bin/bash
MYCMD="mysql"
MAX_OLD=3
MIN_NEW=3
SCHEMA=sphinx
TABLE=search_query_log
LOGFILE=/tmp/search_query_log_partitions.log
DISKPATH=/sphinx/search_query_log_archive
ERRTO="[email protected]"
@dotmanila
dotmanila / pareto_in.php
Created November 29, 2015 06:00
Pareto Distribution Simulator in PHP
<?php
$pareto_power = log(0.7) / log(1.0-0.7);
function sb_rand_pareto($a, $b) {
global $pareto_power;
return $a + ($b - $a + 1) * pow((double)(rand() % 4294967295) / 4294967295, $pareto_power);
}
for($i=0; $i<=1000; $i++) {