Skip to content

Instantly share code, notes, and snippets.

@WoZ
WoZ / README.md
Last active January 6, 2020 10:52
Strace reads and writes analyzer

Usage: node strace_log_analyzer.js strace.log /tmp

This scripts parses input file that must contain strace log from a single thread. Then script calculates:

  • execution time of read/write syscall for each file descriptor and summarize execution time for each 1 sec period,
  • calulates amount of read/write syscalls for each file descriptor

strace log must be collcted with -t -T -f options.

@WoZ
WoZ / dts_and_realtime.gp
Created January 4, 2018 08:53
Gnuplot script for ffprobe analysis
reset
set ylabel "Frames in period"
set xlabel "Time"
set xdata time
set timefmt "%s"
set format x "%H:%M:%S"
set grid
set style line 1 lc rgb '#388e3c' lt 1 lw 1 pt 5 ps 0.5
set style line 2 lc rgb '#6a1b9a' lt 1 lw 1 pt 5 ps 0.5
@WoZ
WoZ / ffprobe_analyzer.js
Last active November 9, 2020 07:45
Simple script to parse ffprobe data with custom real-time markers
const readline = require('readline');
const fs = require('fs');
const argv = process.argv.slice(2);
if (argv.length !== 1) {
console.error('Invalid list of arguments');
process.exit(1);
}
const filename = argv[0];
@WoZ
WoZ / wowza_origin_edge_retries.log
Created May 11, 2017 10:43
wowza_origin_edge_retries.log
2017-05-09 20:51:49 UTC comment server WARN 200 - LiveMediaStreamReceiver.doWatchdog: streamTimeout[origin/_definst_/51881f4ba218c305419d91c3cd56197c_bc2_hd]: Resetting connection: wowz://10.2.1.239:1935/origin/_definst_/51881f4ba218c305419d91c3cd56197c_bc2_hd - - - 4280289.269 - - - - - - - - - - - - - - - - - - - - - - - - -
2017-05-09 20:51:49 UTC comment server INFO 200 - LiveMediaStreamReceiver.resetConnection: SSL:false url:wowz://10.2.1.239:1935/origin/_definst_/51881f4ba218c305419d91c3cd56197c_bc2_hd - - - 4280289.27 - - - - - - - - - - - - - - - - - - - - - - - - -
2017-05-09 20:51:49 UTC comment server INFO 200 - CupertinoStreamerLiveRepeaterReceiver.resetStream[edge/_definst_/wowz#3A#2F#2F10.2.1.239#3A1935#2Forigin#2F51881f4ba218c305419d91c3cd56197c_bc2_hd:cupertinostreamingpacketizer] - - - 4280289.27 - - - - - - - - - - - - - - - - - - - - - - - - -
2017-05-09 20:51:49 UTC comment server INFO 200 - LiveMediaStreamReceiver.sessionClosed[origin/_definst_/51881f4ba218c305419d91c3cd56197c_bc2_hd] - -
var amqp = require('amqp');
var exchangeName = 'nonpresent.exchange';
var connection = amqp.createConnection({host: 'localhost'});
connection.on('ready', function() {
connection.on('error', function(err) {
console.log('connection error:', err);
});
var exch = connection.exchange(exchangeName, {passive: true});
@WoZ
WoZ / mongophpdriver.php
Created October 17, 2012 11:05
PHP driver of MongoDB: test
<?php
$c = new Mongo();
$db = $c->demo;
$db->bugs->drop();
var_dump(PHP_INT_MAX);
$db->demo->bugs->insert(array('foo' => PHP_INT_MAX));
$db->demo->bugs->findOne();
import resource
iterations = 10000000
data = {}
for i in xrange(0, iterations):
data['iteration' + str(i)] = []
memoryUsed = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024.0
print "Memory used: ", str(round(memoryUsed, 2)) + 'MB'
<?php
ini_set('memory_limit', '8192M');
$iterations = 10000000;
$data = array();
for ($i = 0; $i < $iterations; $i++) {
$data['iteration' . $i] = array();
}
echo sprintf("Memory used: %0.2f MB\n", memory_get_peak_usage(true) / floatval(1024 * 1024));
@WoZ
WoZ / lvmbackup.sh
Created February 21, 2012 18:22
simple lvm backuper
#!/bin/bash
# Dmitry Menshikov <d.menshikov@creators.com.ua>
# http://menshikov.mp
PATH_TO_VG="/dev/mainvg"
BACKUP_PATH="/media/Reservation/.backups/zoidberg"
BACKUP_PATH=$BACKUP_PATH/`date +"%d_%m_%Y"`
if [[ $EUID -ne 0 ]]; then
echo "You must be a root user" 2>&1
@WoZ
WoZ / gist:1810148
Created February 12, 2012 18:40 — forked from anonymous/gist:1810066
<?php
// ниже пример, когда существенно превышает длина строки 80 символов
// тут строка короче, но смысл тот же
// Вариант 1
if (! $memcache->waitForUnlock($mKey)
|| ! $b0 = $memcache->get($mKey)
) {
$memcache->log("$mKey unlocked but cache is empty");
$b0 = null;