Skip to content

Instantly share code, notes, and snippets.

View ilyaevseev's full-sized avatar

Ilya Evseev ilyaevseev

  • Loyaltyplant.com
  • Nazareth, Israel
  • 14:35 (UTC +03:00)
  • LinkedIn in/ilyaevseev
View GitHub Profile
@ilyaevseev
ilyaevseev / es-delete-old-indexes.sh
Created June 4, 2019 16:23
Delete old time-based indexes from ElasticSearch
#!/bin/sh
MAX_DAYS="30"
ES_ADDR="127.0.0.1"
D0="$(date -d "$MAX_DAYS days ago" +%s)"
curl -sS "http://$ES_ADDR:9200/_cat/indices" |
awk 'match($3, /-([0-9][0-9][0-9][0-9])[\.\-]([0-9][0-9])[\.\-]([0-9][0-9])$/, m) { printf "%s-%s-%s %s\n", m[1],m[2],m[3],$3 }' |
while read D1 idx; do
@ilyaevseev
ilyaevseev / psiprobe-htmltoplain.pl
Created May 6, 2019 15:48
Read apps list from PSI-Probe HTML output and print as plain text
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
die "Usage: $0 file.html\n" if @ARGV != 1;
my $dom = XML::LibXML->load_html(
@ilyaevseev
ilyaevseev / zabbix-wrong-items.sh
Created April 7, 2019 20:27
Zabbix report wrong items, should be called from cron.daily
#!/bin/sh -e
MAILTO="" # ..put here your email, empty = mail skipped
DIR="/var/log/zabbix-wrong-items"
LOG="$DIR/$(date +%Y-%m-%d).log"
mkdir -p "$DIR"
# MySQL under Debian/Ubuntu:
@ilyaevseev
ilyaevseev / ngx_log_cputicks.patch
Created February 9, 2019 11:11
Inspired by https://forum.nginx.org/read.php?21,282919 -- print CPU ticks to Nginx debug log
diff -r 992bf7540a98 src/core/ngx_log.c
--- a/src/core/ngx_log.c Thu Feb 07 19:39:35 2019 +0300
+++ b/src/core/ngx_log.c Sat Feb 09 13:14:06 2019 +0300
@@ -16,6 +16,8 @@ static void ngx_log_insert(ngx_log_t *lo
#if (NGX_DEBUG)
+static u_char *ngx_log_cputicks(u_char *p, u_char *last);
+
static void ngx_log_memory_writer(ngx_log_t *log, ngx_uint_t level,
@ilyaevseev
ilyaevseev / ngx_times.c.patch
Created February 5, 2019 07:14
Try to put Nginx error_log records with millisecond measurement (NOT TESTED!!)
hg diff -p
diff -r e72c8a8a8b10 src/core/ngx_times.c
--- a/src/core/ngx_times.c Thu Jan 31 19:36:51 2019 +0300
+++ b/src/core/ngx_times.c Tue Feb 05 10:12:03 2019 +0300
@@ -47,7 +47,7 @@ static ngx_int_t cached_gmtoff;
static ngx_time_t cached_time[NGX_TIME_SLOTS];
static u_char cached_err_log_time[NGX_TIME_SLOTS]
- [sizeof("1970/09/28 12:00:00")];
+ [sizeof("1970/09/28 12:00:00.000")];
@ilyaevseev
ilyaevseev / Remove-old-Zabbix-metrics-from-ElasticSearch.sh
Last active December 22, 2018 05:38
Initialize Elasticsearch maps (database schema) for use it as Zabbix history storage.
#!/bin/sh -e
MAX_DAYS="93"
LOG_DAYS="93"
LOG_DIR="/var/log/zbx-es-metrics-cleanup"
LOGFILE="$LOG_DIR/$(date +%Y-%m-%d-%H%M).log"
mkdir -p "$LOG_DIR"
D0="$(date -d "$MAX_DAYS days ago" +%s)"
@ilyaevseev
ilyaevseev / rancid-dlink-websmart.sh
Last active November 23, 2018 04:52
Script for storing D-Link websmart configs in Rancid via TFTP.
@ilyaevseev
ilyaevseev / ffmpeg-nvenc-parbench.sh
Created October 18, 2018 12:13
Benchmark concurrent ffmpeg-nvenc instances.
#!/bin/sh
test $# = 1 || { echo "Usage: ${0##*/} num-loops"; exit 1; }
D="/tmp/${0##*/}"
F="$HOME/lord-inquisitor.mp4"
rm -rf "$D" || :
mkdir -p "$D"
@ilyaevseev
ilyaevseev / update-resolv-conf.sh
Created June 29, 2018 20:01
Quick and dirty update-resolv-conf for OpenVPN under Fedora
#!/bin/sh
test -z "$dev" && exit 0
DNS="$(printenv | awk '/^foreign_option_.*=dhcp-option DNS / { print $NF; exit; }')"
test -z "$DNS" && exit 0
# Error: Reading applied connection from device 'tun0' (/org/freedesktop/NetworkManager/Devices/6) failed: Device is not activated
# When called manually after connection esablished: removes all routes!
@ilyaevseev
ilyaevseev / otrs-new-package.sh
Created June 18, 2018 16:36
Check, install, update OTRS package under CentOS 7. Requires lftp.
#!/bin/sh
FPATH="$(lftp -e 'cls -q -1 -D --sort=date /pub/otrs/RPMS/rhel/7/otrs*.noarch.rpm; exit' http://ftp.otrs.org/ 2>&1 | tail -1)"
LATEST="${FPATH##*/}" #"
LATEST="${LATEST%.rpm}"
CURRENT="$(rpm -q otrs)"
case "$1" in
install|reinstall ) yum "$1" "http://ftp.otrs.org/$FPATH" ;;
geturl ) echo "http://ftp.otrs.org/$FPATH" ;;