Skip to content

Instantly share code, notes, and snippets.

View catacs's full-sized avatar

Catalin Stanciu catacs

View GitHub Profile
@catacs
catacs / fail2ban-report
Created February 8, 2016 20:57
Fail2ban log statistics
#!/bin/bash
echo "Baned last log"
awk '($(NF-1) = /Ban/){print $NF}' /var/log/fail2ban.log | sort | uniq -c | sort -n
echo "------------ Baned in all files --------------"
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $NF}' | sort | uniq -c
echo "------------ Baned by subnet --------------------"
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $NF}' | awk -F\. '{print $1"."$2"."}' | sort | uniq -c | sort -n | tail
echo "------------ Baned by date -------------------------"
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $5,$1}' | sort | uniq -c
@catacs
catacs / system-backup
Last active February 7, 2016 23:38
Entire system backup
#!/bin/bash
cd /
tar cvpzf system-backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/system-backup.tgz --exclude=/mnt --exclude=/tmp --exclude=/sys /