Skip to content

Instantly share code, notes, and snippets.

View myaut's full-sized avatar

Sergey Klyaus myaut

  • Yandex
  • Serbia, Belgrade
View GitHub Profile
global tm_fork_start_par[128], tm_fork_start[128], tm_fork_end[128],
tm_exec_start[128], tm_exec_end[128], p_argstr[128];
global fork[128], postfork[128], exec[128], proc[128];
probe syscall.fork {
tm_fork_start_par[tid()] = local_clock_ns();
}
probe syscall.fork.return {
if($return > 1) {
tm_fork_start[$return] = tm_fork_start_par[tid()];
@myaut
myaut / gist:c0fb34d30d9d084731ef
Created January 23, 2015 08:39
kdevelop-incpaths.py
from PyQt4 import QtCore
import sys
PROJECTS = ['lib/libtsload', 'lib/libtsjson', 'lib/libtsfile', 'lib/libtscommon', 'lib/libtsagent',
'lib/libhostinfo', 'lib/libtsobj', 'cmd/swat-import', 'cmd/tsgenuuid', 'cmd/tsloadd',
'cmd/tsfutil', 'cmd/tsexperiment', 'cmd/tsgenmodsrc', 'cmd/tshostinfo']
BASEID = 1
for projid, proj in enumerate(PROJECTS):
path = '/pool/devel/TSLoad/tsload/agent/' + proj + '/include'
@myaut
myaut / lxcpatch.py
Created January 29, 2015 19:15
Patching multiple Debian 6 LXC containers
#!/usr/bin/python
import os, sys
import subprocess
LXC_BASE = '/var/lib/lxc'
def patch_sources_list(path):
lts_lines = ['# LTS repository',
'deb http://http.debian.net/debian/ squeeze-lts main contrib non-free',
{
"name": "duality",
"steps": {
"manager": {
"num_steps": 60,
"num_requests": 20,
},
"worker": {
"num_steps": 60,
"num_requests": 120,
@myaut
myaut / bench.py
Created March 3, 2015 15:53
Python module that runs stat collectors (like iostat, mpstat) on background
import os, subprocess
import errno
import time
import shutil
import signal
from string import maketrans
from datetime import datetime
from threading import Thread
@myaut
myaut / aas.c
Created March 6, 2015 19:28
Auto-allocated strings
#include <stdlib.h>
#include <string.h>
#ifdef AAS_STRICT
typedef struct { char a; } *aas_t;
#else
typedef char *aas_t;
#endif
#define AAS_DYNAMIC 'D'
@myaut
myaut / nodemem.c
Created March 10, 2015 10:10
nodemem.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <linux/perf_event.h>
#include <sys/syscall.h>
#include <asm/unistd.h>
#include <sys/mman.h>
#include <numaif.h>
#include <unordered_map>
#include <mutex>
#include <list>
#include <future>
#include <iostream>
#include <chrono>
#include <algorithm>
#include <atomic>
#include "tbb/concurrent_unordered_map.h"
@myaut
myaut / sol11-dupip.md
Created March 17, 2015 20:38
How to create duplicate IP addresses on network interface in Solaris 11

Consider following configuration (Solaris 11):

root@sol112:~# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000 
net0: flags=100001000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,PHYSRUNNING> mtu 1500 index 2
        inet 192.168.24.33 netmask ffffff00 broadcast 192.168.24.255
        ether 8:0:27:75:c9:5d 
net1: flags=100001000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,PHYSRUNNING> mtu 1500 index 3
        inet 192.168.100.16 netmask ffffff00 broadcast 192.168.100.255
@myaut
myaut / stap-debian.txt
Created March 30, 2015 07:22
Example of usage of SystemTap in Debian
root@r520:~# apt-get update
Hit http://mirror.yandex.ru wheezy Release.gpg
Hit http://mirror.yandex.ru wheezy Release
Hit http://mirror.yandex.ru wheezy/main Sources
Hit http://mirror.yandex.ru wheezy/main amd64 Packages
Hit http://mirror.yandex.ru wheezy/main i386 Packages
Hit http://mirror.yandex.ru wheezy/main Translation-en
Reading package lists... Done
root@r520:~# stap -e 'probe kprocess.exec { println(argstr); }'