Skip to content

Instantly share code, notes, and snippets.

View ilyaevseev's full-sized avatar

Ilya Evseev ilyaevseev

  • Loyaltyplant.com
  • Nazareth, Israel
  • 19:05 (UTC +03:00)
  • LinkedIn in/ilyaevseev
View GitHub Profile
@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" ;;
@ilyaevseev
ilyaevseev / ldap-replicas-checksum-compare.sh
Last active June 18, 2018 16:34
Quick and dirty Zabbix check for replication status between OpenLDAP master and slave. Should be called on slave.
#!/bin/sh
CONFIG="/etc/openldap/slapd.d/cn=config/olcDatabase={2}hdb.ldif"
Return() { echo $@; exit; }
test -s "$CONFIG" || Return "BAD_CONF"
URL="$(sed -n 'H; ${ x; s/\n//; s/\n //g; p}' "$CONFIG" | awk 'match($0, "provider=([^ ]+)", m) { print m[1] }')" ; test -z "$URL" && Return "BAD_URL" #'
DN="$(sed -n 'H; ${ x; s/\n//; s/\n //g; p}' "$CONFIG" | awk 'match($0, "binddn=\"([^ ]+)\"", m) { print m[1] }')" ; test -z "$DN" && Return "BAD_DN" #'
@ilyaevseev
ilyaevseev / teamcheck.sh
Last active June 1, 2018 16:17
Zabbix check for status of aggregated links under Linux
#!/bin/sh
FAILED=""
SLAVES_COUNTER=""
cd /sys/class/net/
Check_iface() {
local master="$1" slave="$2" mask="$3"
#echo "DEBUG: check_iface $master:$slave"