Skip to content

Instantly share code, notes, and snippets.

for i in `db2 list db directory | grep Indirect -B 5 |grep "Database name" |awk {'print $4'} |sort -u | uniq`; do echo -ne $i" ";db2 get db cfg for $i | grep DATABASE_MEM|awk {'print $9'}|sed s/AUTOMATIC\(//g |sed s/\)//g ; donefor i in `db2 list db directory | grep Indirect -B 5 |grep "Database name" |awk {'print $4'} |sort -u | uniq`; do echo -ne $i" ";db2 get db cfg for $i | grep DATABASE_MEM|awk {'print $9'}|sed s/AUTOMATIC\(//g |sed s/\)//g ; done
@gokycat
gokycat / perpetual-rsync.sh
Created September 25, 2018 02:28 — forked from pwenzel/perpetual-rsync.sh
Automatically resume rsync over SSH after broken connection
#!/bin/bash
while [ 1 ]
do
rsync -avz --partial source dest
if [ "$?" = "0" ] ; then
echo "rsync completed normally"
exit
else
echo "Rsync failure. Backing off and retrying..."
@gokycat
gokycat / gist:5e1904b971102d81dd002d5efb8d69ed
Created September 22, 2018 18:25
db2 Force applications script
userid=$1
stmt="SELECT APPLICATION_HANDLE, substr(APPLICATION_NAME,1,20), CLIENT_PID, substr(SYSTEM_AUTH_ID,1,20), (CLIENT_IDLE_WAIT_TIME/1000/60) CLIENT_IDLE_WAIT_TIME_SECS, UOW_COMP_STATUS, timestampdiff(2,char(current timestamp - COALESCE(UOW_STOP_TIME, UOW_START_TIME))) as idle_time_SECS, round((CURRENT TIMESTAMP - CONNECTION_START_TIME),2) as duration_seconds FROM TABLE(MON_GET_CONNECTION(CAST(NULL AS BIGINT), -1)) WHERE NUM_LOCKS_HELD = 0 and timestampdiff(2,char(current timestamp - COALESCE(UOW_STOP_TIME, UOW_START_TIME))) > 300 and SYSTEM_AUTH_ID not in ('DB2INST1', 'CDCADMIN') and SYSTEM_AUTH_ID = '$userid'"
echo $stmt
for x in `db2 +o connect to rxprod;db2 -x $stmt | awk {'print $1'}`;
do db2 "force application($x)";
done;
@gokycat
gokycat / gist:e4da173e4021d5e276fe0806d3fa7868
Created December 9, 2016 16:28 — forked from soapplied/gist:5899230
DB2 export DB tables
db2 connect to MYDB
db2 -x "select tabname from syscat.tables where TABSCHEMA='MYSCHEMA'
and type='T'" > tableNames
while read TABLE; do
db2 EXPORT TO ./exported/$TABLE.del OF DEL lobs to ./exported/lobs
lobfile $TABLE xml to ./exported/xml xmlfile $TABLE
modified by lobsinsepfiles xmlinsepfiles MESSAGES ./exported/$TABLE.txt
"SELECT * FROM MYSCHEMA.$TABLE"
done < tableNames
@gokycat
gokycat / notes.md
Created March 10, 2016 15:48 — forked from DavidWittman/notes.md
A Brief Introduction to Fabric

A Brief Introduction to Fabric

Fabric is a deployment management framework written in Python which makes remotely managing multiple servers incredibly easy. If you've ever had to issue a change to a group servers, this should look pretty familiar:

for s in $(cat servers.txt); do ssh $s service httpd graceful; done

Fabric improves on this process by providing a suite of functions to run commands on the servers, as well as a number of other features which just aren't possible in a simple for loop. While a working knowledge of Python is helpful when using Fabric, it certainly isn't necessary. This tutorial will cover the steps necessary to get started with the framework and introduce how it can be used to improve on administering groups of servers.

@gokycat
gokycat / gist:0e37b79a189399872f4b
Last active August 26, 2015 20:37 — forked from adomado/gist:1226159
Example mongodb script
db = connect("localhost:27017/test");
var cursor = db.unicorns.find({gender : "m"});
var total = 0;
while(cursor.hasNext()) {
var obj = cursor.next();
total += (obj.hits || 0);
}
print(total);
@gokycat
gokycat / run.sh
Last active August 29, 2015 14:25 — forked from irasally/run.sh
[mongodb] run command 'compact' for all collections
#!/bin/sh
mongo localhost:27017/mongo run_command.js
mongo localhost:27018/mongo run_command.js
mongo localhost:27019/mongo run_command.js
# if you don't need connection infomation etc., use --quiet option.
# http://www.mongodb.org/display/DOCS/--quiet

OSX Developer System installation

This guide assumes a fresh install of Mac OSX 10.7 Lion.

Brew User

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname