Skip to content

Instantly share code, notes, and snippets.

View sitano's full-sized avatar

Ivan Prisyazhnyy sitano

View GitHub Profile
@sitano
sitano / swapped.sh
Created August 19, 2014 15:12
Get current swap usage for all running processes
#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
# Modified by Mikko Rantalainen 2012-08-09
# Pipe the output to "sort -nk3" to get sorted output
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+"`
do
PID=`echo $DIR | cut -d / -f 3`
@sitano
sitano / io-load-test-16k.sh
Created August 19, 2014 15:15
sysbench async iops 50gb test for RDBS (16k x 8io x async x direct x 64split x rndrw)
sz=50G
sysbench --test=fileio --file-total-size=$sz --file-num=64 prepare
sysbench --test=fileio --file-total-size=$sz --file-test-mode=rndwr --max-time=180000 --max-requests=0 --num-threads=8 --rand-init=on --file-num=64 --file-io-mode=async --file-extra-flags=direct --file-fsync-freq=0 --file-block-size=16384 --report-interval=10 run
@sitano
sitano / numa-maps-summary.pl
Last active June 5, 2024 10:21
Show numa maps distribution
#!/usr/bin/perl
# Copyright (c) 2010, Jeremy Cole <[email protected]>
# Modified (c) 2014, Ivan Prisyazhniy <[email protected]>
# - top [num] - mode to print numa map distribution from mem top
# This program is free software; you can redistribute it and/or modify it
# under the terms of either: the GNU General Public License as published
# by the Free Software Foundation; or the Artistic License.
#
@sitano
sitano / jvm-bootstrap.sh
Last active August 29, 2015 14:05
JVM bootstrap script
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2014 Ivan Prisyazhniy <[email protected]>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@sitano
sitano / rebuild.sh
Created August 29, 2014 11:18
hg, fpm, prm, virtualenv rebuild deb package script
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2014 Ivan Prisyazhniy <[email protected]>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@sitano
sitano / html_pretty.py
Created March 31, 2015 14:50
HTML Python Prettifier with Beautiful Soup
# The current release is Beautiful Soup 4.3.2 (October 2, 2013).
# You can install it with pip install beautifulsoup4 or easy_install beautifulsoup4.
# It's also available as the python-beautifulsoup4 package in recent versions of Debian, Ubuntu, and Fedora .
from bs4 import BeautifulSoup as bs
import fileinput
import sys
for line in fileinput.input(sys.argv[1]):
print bs(line).prettify()
@sitano
sitano / rust_file_copy_test.rs
Last active August 29, 2015 14:20
Sample file copy / temp / creation in RUST (1.0.0-beta2)
#[allow(unused_imports)]
use std::io;
use std::path::Path;
use std::fs::File;
type IoResult<T> = std::io::Result<T>;
extern crate tempdir;
extern crate rustc_serialize;
extern crate docopt;
@sitano
sitano / glog-rotate.sh
Last active August 29, 2015 14:21
glog rotation + gzip
#!/bin/bash
NAME="service"
LIMIT="8000"
DELETELIMIT="500"
# Packing
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) && cd $DIR
FILES=`ls -A1Lct ${NAME}.* | grep -v '.sh$' | grep -v '.zip$' | grep -v '.gz$'`
TYPES=`echo "$FILES" | grep -E '.[A-Z]+$' | wc -l`
@sitano
sitano / consul.wan.join.sh
Created May 18, 2015 13:09
Consul 0.4.x startup WAN reconnect script
#!/bin/bash
. /etc/environment
PUBLIC_IPV4=`cat /etc/network/interfaces | grep -A 2 'iface eth0' | head -n +2 | tail -n 1 | awk '{print $2}'`
PRIVATE_IPV4=`cat /etc/network/interfaces | grep -A 2 'iface eth1' | head -n +2 | tail -n 1 | awk '{print $2}'`
SERVERS=(DATACENTER1 DATACENTER2 DATACENTER3)
for SERVER in "${SERVERS[@]}"; do
curl http://${PRIVATE_IPV4}:8500/v1/agent/join/${SERVER}.mysupercompany.com:8302?wan=1
@sitano
sitano / redis.backup.sh
Created May 18, 2015 13:57
Force redis sync rdb snapshot, backup, tar gzip pack and rotate older then 5 days
#!/bin/bash
# 25 0 * * * /root/redis.backup.sh
PRIVATE_IPV4=`cat /etc/network/interfaces | grep -A 2 'iface eth1' | head -n +2 | tail -n 1 | awk '{print $2}'`
# 1. Dump RDB
(printf "select 2\r\nsave\r\n" | nc ${PRIVATE_IPV4} 6379) || exit 1
# 2. Copy dump
SRCPATH="/var/lib/redis/6379"