Skip to content

Instantly share code, notes, and snippets.

View alexalouit's full-sized avatar

Alexandre Alouit alexalouit

View GitHub Profile
@alexalouit
alexalouit / httpd-errors.sh
Last active February 19, 2018 10:22
HTTPD (Apache and Nginx) regular email report, vhosts in errors reported
#!/bin/bash
#
# cron ex: 0 * * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/httpd-errors.sh >> /root/scripts/cron.log
email=""
if [ -f /etc/apache2/sites-available/*.err ]
then
CONTAIN=$(ls -lah /etc/apache2/sites-available/*.err)
echo -e "Erreur du serveur apache, vhost:\n $CONTAIN" | mail -s "Rapport d'erreur Apache" $email
@alexalouit
alexalouit / coast-guard-observer.sh
Last active February 19, 2018 10:22
Checks for annoying occurrences in the content of websites & database
#!/bin/sh
#
# cron ex: 0 */6 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/coast-guard-observer.sh >> /root/scripts/cron.log
dir="/tmp/"
file="/var/www/clients/client*/web*/web"
email=""
pattern="vicodin|viagra|xanax|valium|silagra|kamagra|propranolol|celexa|albendazole|propecia|ampicillin|amoxil|neurontin|levitra|pharmacy|rolex|casino|cialis " # Need regexp for occurence like cialis (prevent specialist word)
# TODO: Add whitelist
#whitelist=""
@alexalouit
alexalouit / backup-dbispconfig.sh
Last active November 4, 2016 16:34
Backup ISPConfig database (manual)
#!/bin/bash
#
# cron ex: 0 3 1 * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/backup-dbispconfig.sh >> /root/scripts/cron.log
DIR="/root/backup/"
MYSQLUSER="" # FOR SECURITY REASONS, CREATE AN READ ONLY USER FOR BACKUP!
# eg (as root): CREATE USER 'backup'@'localhost' IDENTIFIED BY 'RANDOMPASSWORD'; GRANT SELECT ON dbispconfig.* TO 'backup'@'localhost'; FLUSH PRIVILEGES;
MYSQLPASSWORD=""
MYSQLDATABASE="dbispconfig"
DATE=$(date +"%Y%m%d")
@alexalouit
alexalouit / mysql-health.sh
Last active April 22, 2018 08:40
Automatically repair and optimize MySQL
#!/bin/sh
#
# cron ex: 0 0 1 * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/mysql-health.sh >> /root/scripts/cron.log
/usr/bin/mysqlcheck --silent --defaults-file=/etc/mysql/debian.cnf --auto-repair --optimize --all-databases
@alexalouit
alexalouit / vzdump-purge.sh
Last active February 16, 2016 09:50
Automatic purge of proxmox/vzdump that are aged 14 days over
#!/bin/bash
#
# cron ex: 15 5 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/vzdump-purge.sh >> /root/scripts/cron.log
path=''
# Search files more than 14 days and remove it
find $path -type f -ctime +14 -delete
@alexalouit
alexalouit / fail2ban.conf
Created August 10, 2015 13:30
fail2ban logstash config & grok pattern
input {
file {
path => "/var/log/fail2ban.log"
type => "fail2ban"
}
}
filter {
if [type] == "fail2ban" {
grok {
@alexalouit
alexalouit / iostat-extended.conf
Created September 29, 2015 09:51 — forked from 4BitBen/iostat-extended.conf
logstash-iostat
# Processes iostat output
# >iostat -d -m -x sda sdb 1 | bin/logstash -f iostat.conf
#
# Sample Output:
#
# Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %util
# sda 3.36 174.28 9.64 183.71 65.17 1431.99 15.49 0.61 3.16 0.09 1.65
# sdb 0.00 0.00 742.87 4110.46 5830.48 16441.82 9.18 4.90 0.98 0.11 55.45
@alexalouit
alexalouit / gzed-log-purge.sh
Created October 5, 2015 14:28
Automatic purge compressed logs that are aged 7 days over
#!/bin/bash
#
# cron ex: 25 5 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/gzed-log-purge.sh >> /root/scripts/cron.log
# Search files more than 14 days with .gz extension and remove it
find /var/log -type f -ctime +7 -regex ".*\.gz$" -delete
@alexalouit
alexalouit / survey-semaphore-ispconfig.sh
Last active February 19, 2018 10:22
ISPConfig survey lock file (semaphore)
#!/bin/bash
#
# cron ex: */30 * * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/survey-semaphore-ispconfig.sh >> /root/scripts/cron.log
email=""
# file exist?
if [ -f /usr/local/ispconfig/server/temp/.ispconfig_lock ]
then
# have a correct ttl?
@alexalouit
alexalouit / check-mountpoint.sh
Last active February 19, 2018 10:21
mountpoint checker/alert/remounter
#!/bin/sh
#
# cron ex: * * * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/check-mountpoint.sh >> /root/scripts/cron.log
# mountpoint must be present in fstab
mountpoint=" /mnt/endpoint" # use space before (prevent mountpoint as source)
email=""
if [ -z "$(grep $mountpoint /proc/mounts)" ]; then
# we use space before, prevent mountpoint as source