Skip to content

Instantly share code, notes, and snippets.

👪
I might be slow on response, as my newborn child consumes all the free time :-)

Vladimir Melnik melnik13

👪
I might be slow on response, as my newborn child consumes all the free time :-)
Block or report user

Report or block melnik13

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View remove_extra_snapshots.sh
for dir in $(find /export/secondary2/snapshots -wholename '/export/secondary2/snapshots/*/*' -type d); do { files=$(ls "${dir}" | wc -l); if [[ "${files}" -gt 2 ]]; then echo $dir; ls -tl "${dir}"; for file in $(ls -t "${dir}" | tail --lines +3); do { read -p "Remove ${file}?" -n 1 -r; if [[ "${REPLY}" =~ ^[Yy]$ ]]; then echo " ... removing ${dir}/${file}"; rm "${dir}/${file}"; else echo " ... skipping ${dir}/${file}"; fi; } done; fi; } done
for dir in $(find /export/secondary2/snapshots -wholename '/export/secondary2/snapshots/*/*' -type d -mtime +21); do { if [[ "$(ls ${dir} | wc -l)" -lt 1 ]]; then continue; fi; ls -tl "${dir}"; read -p "Remove ${dir}?" -n 1 -r; if [[ "${REPLY}" =~ ^[Yy]$ ]]; then echo " ... removing ${dir}"; rm -rf "${dir}"; else echo " ... skipping ${dir}"; fi; } done
View rsync-backup.sh
#!/bin/sh
PATH=/bin:/usr/bin
HOME=~
HOSTNAME=$(hostname)
USER=$(echo "${HOSTNAME}" | sed "s/\.tucha13\.net$//")
INCLUDES="/etc/rsync-backup.includes"
EXCLUDES="/etc/rsync-backup.excludes"
BSERVERADDR="backup.z2.tucha13.net"
BSERVERPORT="22"
View ip-keeper.pl
#!/usr/bin/env perl
#
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=perl
#
use strict;
use warnings;
use DBI;
View mtr-mon.sh
#!/bin/bash
function log {
echo "[$(date +%F\ %T)]" $* >&2
}
function warn {
log "[!]" $*
}
@melnik13
melnik13 / sockping.sh
Last active May 7, 2016
To establish a TCP-connection and be keeping it alive
View sockping.sh
#!/bin/bash
function log {
echo $(date) ' >> ' $* >&2
}
function die {
echo $* >&2
exit 1
}
@melnik13
melnik13 / pingmon.sh
Last active Apr 16, 2016
Ping the Host and Trace the Route
View pingmon.sh
TARGET=13.13.13.13; while :; do { PL=$(ping -c 10 -W 1 "${TARGET}" | sed -n -r 's/^.+ ([0-9]{1,3})% packet loss.+/\1/gp'); if [[ "${PL}" -gt 25 ]]; then { echo "$(date): ${PL}% of requests haven't got any responses"; mtr -i 0.1 -r -c 10 "${TARGET}"; echo; } fi; } done
View check_sensors.sh
#!/bin/bash
CODE_OK=0
CODE_UNKNOWN=1
CODE_WARNING=2
CODE_CRITICAL=3
WARNING_THRESHOLD="80%"
CRITICAL_THRESHOLD="100%"
DEBUG=0
@melnik13
melnik13 / pingtrace.sh
Last active Sep 29, 2015
When you can't install the mtr utility, but need to determine on which hop your datagrams are being lost
View pingtrace.sh
#/bin/bash
HST="8.8.8.8"
CNT="100"
DIR="$(mktemp -d /tmp/ping_XXXXXXXX)"
echo "Results will be stored to the ${DIR} directory"
for HOP in $(traceroute -n "${HST}" | sed -nr 's/^[[:space:]]*([[:digit:]]+)[[:space:]]+([[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3})[[:space:]]+.*$/\1:\2/gp'); do
IFS_OLD="${IFS}"; IFS=":"; read -a ARR <<< "${HOP}"; IFS="${IFS_OLD}"
@melnik13
melnik13 / .bash_today
Last active Aug 29, 2015
.bash_today: This simple script lists today’s tasks every time you log in (or create a new window in your screen)
View .bash_today
# Just add me to your .bashrc:
# [ -x ~/.bashrc_today ] && . ~/.bashrc_today
TODAYD="${HOME}/.today.d"
if [ ! -d "${TODAYD}/today" ]; then
mkdir -p "${TODAYD}/today"
fi
TODAY=$(date +%F)
@melnik13
melnik13 / aarping.sh
Last active Aug 29, 2015
Need to check some host's availability by arping, but have no time to look up which network intrface you need? aarping.sh is here to help you.
View aarping.sh
#!/bin/sh
if [ -z "${1}" ]; then
echo "Chocho?" >&2
exit 1
fi
HOSTIP="${@: -1}"
ROUTE=$(ip route get "${HOSTIP}")
You can’t perform that action at this time.