Skip to content

Instantly share code, notes, and snippets.

View adzhurinskij's full-sized avatar

Alexandr Dzhurinskij adzhurinskij

View GitHub Profile
@adzhurinskij
adzhurinskij / sendmail.sh
Last active April 19, 2016 12:11
Swaks for Zabbix (use SMTP and TLS)
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOST=smtp.yandex.ru
USERNAME=username@yandex.ru
PASSWORD=password
PORT=465
TO=$1
SUBJECT=$2
@adzhurinskij
adzhurinskij / Documentation.md
Last active December 16, 2023 07:26
The fastest sync directory over ssh with tar

The fastest sync directory over ssh with tar

It's simple command for transfer a large number of small files over ssh.

You need to first go to directory, if you want to copy content of directory.

cd /var/www
tar cpf - ./ | ssh <user>@<dest_ip> "tar xpf - -C /var/www"

Preview speed copy with pv:

@adzhurinskij
adzhurinskij / sshrc
Last active December 7, 2023 05:01
/etc/ssh/sshrc example
#!/bin/bash
ip=`echo $SSH_CONNECTION | cut -d " " -f 1`
hostname=`hostname`
fqdn=`hostname -f`
logger -t ssh-wrapper $USER login from $ip
sendmail -t <<EOF
To: Alex <adzhurinskij@gmail.com>
@adzhurinskij
adzhurinskij / rc.conf
Created October 10, 2016 09:30
IPFW example
firewall_enable="YES"
firewall_script="/etc/rc.firewall"
firewall_logging="YES"
@adzhurinskij
adzhurinskij / telegram.php
Last active December 1, 2016 10:47
Alert script with telegram @crierbot bot for Zabbix
#!/usr/bin/env php
<?php
if (count($argv) == 4) {
$token = trim($argv[1]);
$subject = trim($argv[2]);
$body = trim($argv[3]);
$subject = str_replace("PROBLEM:", "\xF0\x9F\x93\x9B PROBLEM:", $subject);
$subject = str_replace("OK:", "\xE2\x9C\x85 OK:", $subject);
@adzhurinskij
adzhurinskij / aggregate.py
Created December 19, 2016 11:56
A utility to perform IPv4 & IPv6 prefix aggregation
#!/usr/bin/python
"""
ALK 2014-04-08
aggregate.py: IPv4 & IPv6 replacement (in spirit) for Joe Abley's 'aggregate' command
note: not a drop-in replacement for the original 'aggregate' command - command line flags are different
requirements: IPy class (debian: python-ipy package)
input: list of IPv4 and/or IPv6 addresses and/or subnets (filename or STDIN)
output: aggregated list if subnets (STDOUT)
@adzhurinskij
adzhurinskij / move_modx.sh
Last active February 4, 2019 19:24
Change MODX core path
#!/bin/bash
old_path='/home/old_site/public_html'
new_path='/home/new_site/public_html'
files="
./core/config/config.inc.php
./manager/config.core.php
./connectors/config.core.php
./config.core.php
@adzhurinskij
adzhurinskij / huawei_netconf.py
Created September 13, 2017 13:34
Huawei NetConf Example with paramiko
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import paramiko
from paramiko.ssh_exception import SSHException, BadHostKeyException
from paramiko.ssh_exception import AuthenticationException
from time import sleep
@adzhurinskij
adzhurinskij / rotate_old_radacct_detail_files_mtime_based.sh
Created September 14, 2017 09:00 — forked from ptomulik/rotate_old_radacct_detail_files_mtime_based.sh
Rotation script for freeradius accounting detail files. Shall be run as a cron script.
#! /bin/sh
########################################################################################
# Compresses old radacct detail files and removes very old compressed radacct files.
########################################################################################
# Author: P. Tomulik
########################################################################################
# Path to the programs used (for environments without $PATH set)
FIND=/usr/bin/find