Skip to content

Instantly share code, notes, and snippets.

View fduran's full-sized avatar

Fernando Duran fduran

View GitHub Profile
@fduran
fduran / tail log file in browser
Created October 1, 2014 17:17
tail follow log file in browser
# tail log file in browser
# go to server.example.com:777
pip install tailon
tailon -f /var/log/example.log -b 0:0:0:0:777 &
@fduran
fduran / check and alert if mysql slave is not running
Created October 1, 2014 17:15
Check and alert if mysql slave is not running
#!/bin/bash
# check if mysql slave is running
log=/var/log/mysqlslave.log
email=user@example.com
date >> $log
res=`mysql -u root -pPassword -h db.example.com -N -B -e "show status like 'Slave_running'"|cut -f2`
if [ $res = 'ON' ]
@fduran
fduran / WordPress Error establishing database connection
Last active August 29, 2015 14:07
WordPress Error establishing database connection
# WP "Error establishing database connection"
# substitute with site's index static page (when it's up, not with the error duh)
wget http://example.com -O [/path/to/wp]/wp-content/db-error.php
@fduran
fduran / calculate mysql schema disk size
Created October 1, 2014 17:14
Calculate MySQL schema disk size
# calculate mysql schemas disk size
mysql -h dbhost.example.com -u theuser -pThePassword -e 'select table_schema as DB, round(sum((data_length+index_length)/1024/1024),1) as MB from information_schema.tables group by table_schema order by MB desc'
@fduran
fduran / mysql optimization
Created October 1, 2014 17:11
MySQL Optimization
# see http://mysqltuner.com/
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
perl mysqltuner.pl
@fduran
fduran / Linux Server Utilization.sh
Created February 20, 2012 17:52
Linux Server Utilization
#!/bin/bash
# www.fduran.com
date;
echo "uptime:"
uptime
echo "Currently connected:"
w
echo "--------------------"
echo "Last logins:"
last -a |head -3
@fduran
fduran / gist:1870471
Created February 20, 2012 18:21
Linux SSH Filesystem
# Use SSH filesystem to mount locally a remote directory through SSH
# www.fduran.com
# at local server:
apt-get update; apt-get install sshfs
mkdir /path/to/local/dir
# Mounting -persists on logout- (for other ssh port add: -p port):
sshfs remoteserver.example.com:/path/to/remote/dir /path/to/local/dir
@fduran
fduran / gist:1870484
Created February 20, 2012 18:23
Linux Passwordless SSH
# ssh without passwords, useful for unattended automatic scp/rsync-over-ssh copies etc
# www.fduran.com
# Create public key without password in origin server:
ssh-keygen -t dsa
# if ssh target port is not 22, add it (ex: -p 2020) in ssh-copy-id after 'ssh':
# nano /usr/bin/ssh-copy-id
# Upload public key to remote target server:
@fduran
fduran / gist:1870444
Created February 20, 2012 18:17
Linux server stats with munin
# munin stats http://munin-monitoring.org/
# www.fduran.com
apt-get update; apt-get install munin munin-node
# Apache: add at the end of .conf file or as new sites-available:
# Alias /munin "/var/www/munin"
# you may want to password-protect the directory
/etc/init.d/munin-node start
@fduran
fduran / gist:1870451
Created February 20, 2012 18:18
Linux file integrity with tripwire
# crucial files integrity check with tripwire http://sourceforge.net/projects/tripwire/
# www.fduran.com
apt-get update
apt-get install tripwire (enter 2 passwords)
# in /etc/tripwire/twpol.txt :
# a) in /root section comment out all of them minus result of:
ls -la /root
# ex:: .bash_history , .bashrc , .profile