Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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-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 {
#!/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 / keepalived.conf
Last active January 3, 2016 04:59
keepalived.conf 1 writer and 1 reader VIP for Percona XtraDB Cluster
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id pxc-cluster
}
@dotmanila
dotmanila / gist:4564647
Created January 18, 2013 13:48
An automation script to use ibdconnect to dump orphan *.ibd files for tables from a specific list (db/tbl format).
#!/bin/bash
#BSE=/data/percona/Percona-Server-5.1.66-rel14.2-501.Linux.x86_64
BSE=/data/percona/Percona-Server-5.0.92-b23.85.Linux.x86_64
MYSQLD=$BSE/libexec/mysqld
DTA=/data/percona/data
SRC=/data/mysql.RECOVERED_FROM_2013_01_13_BACKUP
TBLS=/data/percona/tables.lst
TKIT=/data/percona/percona-data-recovery-tool-for-innodb
@dotmanila
dotmanila / monitor.sh
Last active October 11, 2015 04:57
mysql monitor
#!/bin/bash
WD=/root/monitor
USR=<mysqlrootuser>
PWD=<mysqlrootpass>
mkdir -p $WD
cd $WD
while [ 1 ]