Skip to content

Instantly share code, notes, and snippets.

View ilyaevseev's full-sized avatar

Ilya Evseev ilyaevseev

  • Loyaltyplant.com
  • Nazareth, Israel
  • 12:11 (UTC +03:00)
  • LinkedIn in/ilyaevseev
View GitHub Profile
@ilyaevseev
ilyaevseev / ffmpeg-cuda-install.sh
Created August 13, 2019 16:07
Try to automate CUDA dependencies installation for https://cdnnow.ru/blog/ffmpeg-cuda/
#!/bin/sh
yum -y install epel-release
yum -y install curl
rpm -q docker-release >/dev/null 2>&1 ||
yum install -y http://repo.docker.ru/pub/linux/centos/7/noarch/docker-release-1-1.el7.noarch.rpm
yum -y install ffmpeg-cuda
@ilyaevseev
ilyaevseev / 00-autoinstall-i40e-driver.sh
Last active November 5, 2019 09:45
Autoinstall latest driver for Intel 10/40 GbE network cards from official site under CentOS 7.
#!/bin/sh -e
# Autoinstall latest driver for Intel 10/40 GbE network cards from official site under CentOS 7
# Written by ilya.evseev@gmail.com
# Distributed as public domain
# Last updated on 09-March-2019
INSTALL_ME_SO='
yum install -y wget make gcc "$(rpm -qf --qf '%{NAME}' /boot/vmlinuz-$(uname -r))-devel" &&
cd /etc/kernel/postinst.d/ &&
@ilyaevseev
ilyaevseev / QemuServer.pm.diff
Created July 30, 2019 03:26
ProxmoxVE patch for Ceph RBD tuning.Taken from https://pve.proxmox.com/pipermail/pve-devel/2018-June/032787.html with debugging output
diff -u /usr/share/perl5/PVE/QemuServer.pm*
--- /usr/share/perl5/PVE/QemuServer.pm0 2019-05-25 12:40:24.000000000 +0300
+++ /usr/share/perl5/PVE/QemuServer.pm 2019-06-24 07:06:34.825186937 +0300
@@ -1881,6 +1881,18 @@
$device .= ",serial=$serial";
}
+ my $volid = $drive->{file};
+ if ($volid && $drive->{discard}) {
+ my $storage_name = PVE::Storage::parse_volume_id($volid);
SELECT nspname || '.' || relname AS "relation",
pg_total_relation_size(C.oid) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
LEFT OUTER JOIN pg_inherits I ON (C.relfilenode = I.inhrelid OR C.relfilenode = I.inhparent)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
AND I.inhrelid is null
UNION ALL
@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 / vrf1.sh
Last active April 28, 2019 23:40
VRF in Linux using namespaces
#!/bin/sh
# 2017-feb-13
NSNAME="vrf1"
LINK1="${NSNAME}_10" # ..my link to VRF
LINK2="${NSNAME}_11" # ..VRF link to me
IP1="10.20.30.10"
IP2="10.20.30.11"
MASK="24"
@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 / Cloudflare-Nginx-RealIP-Update.sh
Created May 30, 2018 13:59
/etc/cron.daily/Cloudflare-Nginx-RealIP-Update -- update Nginx config by list of Cloudflare frontends.
#!/bin/sh -e
# https://support.cloudflare.com/hc/en-us/articles/200170706-How-do-I-restore-original-visitor-IP-with-Nginx-
STATEDIR="${1:-/var/log/${0##*/}}"
mkdir -p "$STATEDIR"
CONFDIR="${2:-/etc/nginx/conf.d}"
test -d "$CONFDIR" || { echo "missing confdir: $CONFDIR" 1>&2; exit 1; }