Skip to content

Instantly share code, notes, and snippets.

View genothomas's full-sized avatar
🎯
Focusing

Geno Thomas genothomas

🎯
Focusing
View GitHub Profile
@genothomas
genothomas / diskhogs.sh
Created June 22, 2021 06:36 — forked from khmarochos/diskhogs.sh
Ever craved for a tool to monitor what files are growing faster than other ones? Just run it by cron: diskhogs.sh /var/lib/libvirt/images
#!/bin/sh
# Checking the spool directory
SPOOL=/var/spool/diskhogs
if [ ! -e "${SPOOL}" ]; then
mkdir -p "${SPOOL}"
fi
if [ ! -d "${SPOOL}" ]; then
echo "There are no ${SPOOL} directory" >&2
exit 1
@genothomas
genothomas / .bash_today
Created June 22, 2021 06:36 — forked from khmarochos/.bash_today
.bash_today: This simple script lists today’s tasks every time you log in (or create a new window in your screen)
# 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)
#!/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"
@genothomas
genothomas / nginx-tuning.md
Created June 2, 2021 14:03 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@genothomas
genothomas / nginx.conf
Created May 31, 2021 07:30 — forked from v0lkan/nginx.conf
Configuring NGINX for Maximum Throughput Under High Concurrency
user web;
# One worker process per CPU core.
worker_processes 8;
# Also set
# /etc/security/limits.conf
# web soft nofile 65535
# web hard nofile 65535
# /etc/default/nginx
@genothomas
genothomas / backup.sh
Created May 24, 2021 06:42 — forked from nherment/backup.sh
Backup and restore an Elastic search index (shamelessly copied from http://tech.superhappykittymeow.com/?p=296)
#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`
@genothomas
genothomas / delete_older_than_example.pl
Created May 21, 2021 13:34 — forked from johnhaitas/delete_older_than_example.pl
Perl - delete files in folder older than ...
#!/usr/bin/perl
use File::Find;
my $backup_root = "/path/to/folder"
# purge backups older than AGE in days
my @file_list;
my @find_dirs = ($backup_root); # directories to search
my $now = time(); # get current time
my $days = 30; # how many days old
@genothomas
genothomas / mongobackup.sh
Created May 16, 2021 13:32 — forked from colinmollenhour/mongobackup.sh
Simple daily dump of mongo databases.
#!/bin/bash
cd /media/dumps
name=$(date +%b-%d)
year=$(date +%Y)
[ -d $year ] || mkdir $year || { echo "Could not create directory '$year'"; exit 1; }
mongodump --db t3_mage --out $name &> mongodump.log
if [ $? ]; then
tar -czf snapshots/$year/$name.tgz $name
if [ $(($(date +%d | sed 's/^0*//') % 10)) == 0 ]; then
@genothomas
genothomas / mysqlsnapshot.sh
Created May 16, 2021 13:32 — forked from colinmollenhour/mysqlsnapshot.sh
MySQL Snapshot Script
#!/bin/bash
DBNAME=mydb
SNAPSHOT_DAYS=2
ARCHIVE_DAYS=0
COMPRESS_INPLACE=1
mysqldump='docker exec mysql_mysql_1 mysqldump'
gzip=/bin/gzip
@genothomas
genothomas / log_deadlocks.sh
Created May 16, 2021 13:31 — forked from colinmollenhour/log_deadlocks.sh
Log Innodb Deadlocks
#!/bin/bash
dir=/root/deadlocks
[ -d $dir ] || mkdir -p $dir
cd $dir || { echo "Could not cd to $dir"; exit 1; }
mysql -be 'show engine innodb status;' \
| sed 's/\\n/\n/g' \
| awk '/TRANSACTIONS/{flag=0}flag;/LATEST DETECTED DEADLOCK/{flag=1}' \
> latest.txt