Skip to content

Instantly share code, notes, and snippets.

View fduran's full-sized avatar

Fernando Duran fduran

View GitHub Profile
# www.fduran.com
# exclude a process from being killed by oom killer
echo -17 > /proc/$PID/oom_adj
# The possible values of oom_adj range from -17 to +15. The higher the score, more likely the associated process is to be killed by OOM-killer: https://lwn.net/Articles/317814/
@fduran
fduran / gist:1870502
Created February 20, 2012 18:26
Linux monitor & react to event in log file
# Linux. Act upon an event in a log file
# www.fduran.com
apt-get upgrade; apt-get install inotify-tools
# create file myalert.sh:
# example finding Exception in tomcat log and sending email
#!/bin/bash
while inotifywait -e modify /path/to/file.log; do
@fduran
fduran / gist:1870522
Created February 20, 2012 18:29
Mysql status, check & repair
# www.fduran.com
# mysql status summary
mysqladmin -u root -pthepasswd process status
# check database mydb
/etc/init.d/mysqld stop; cd /var/lib/mysql; myisamchk --silent --force mydb/*.MYI
# repair mydb
/etc/init.d/mysqld start; mysqlcheck -u root -pthepassed --auto-repair --check --optimize --databases mydb
@fduran
fduran / gist:4622779
Created January 24, 2013 15:09
MySQL Master-Slave Replication
# www.fduran.com
MySQL Master-Slave Replication Notes
Master
/etc/mysql/my.cnf
server-id = 100
log_bin = /var/log/mysql/mysql-bin.log
binlog-do-db = wpdb
binlog-ignore-db = mysql
@fduran
fduran / gist:1870546
Created February 20, 2012 18:32
Linux check DNS cache snooping
# www.fduran.com
# Linux check DNS cache snooping
# check if somedomain (try popular ones like google.com etc) is cached in a dns_server
# with nslookup
nslookup -norecurse somedomain dns_server
# with dig
dig @dns_server somedomain A +norecurse
@fduran
fduran / gist:4543001
Last active May 9, 2018 18:35
Python script to test/monitor if a Django site using authentication is up
# www.fduran.com
# python script to test/monitor if a Django site using authentication is up
# with logging output to a file including response times
# use in cronjob and output to log file, for ex: python /path/to/script.py >> /var/log/webmonitor.log
# bash: install pip if not already in system
apt-get install python-setuptools python-dev build-essential
easy_install -U pip
# bash: install requests
@fduran
fduran / gist:1870507
Created February 20, 2012 18:27
Apache find IPs with most connections
# www.fduran.com
# Number of top 10 current TCP connections per IP
netstat -tan| grep -v 'LISTEN'| awk '{print $5}'| grep -v 'and' |grep -v 'Address' |cut -d':' -f1 |sort -n | uniq -c | sort -rn | head -n10
# Top 10 IPs in Apache log files
cd /var/log/apache2; for i in ./access.log*; do echo $i; cat $i | awk '{print $1}'| sort -n | uniq -c | sort -rn | head -n10; done
@fduran
fduran / gist:1870446
Created February 20, 2012 18:18
Linux server monitoring with monit
# monit monitoring http://mmonit.com/monit/
# www.fduran.com
apt-get update; apt-get install monit
cp /etc/monit/monitrc /etc/monit/monitrc.orig
# edit /etc/monit/monitrc see examples at http://mmonit.com/wiki/Monit/ConfigurationExamples
# Respawn:
@fduran
fduran / django_install_apache.md
Last active February 12, 2017 15:34
Django Install - Apache

Django Install - Apache

Once per server:

apt-get update && apt-get upgrade
apt-get install libapache2-mod-wsgi
apt-get install python-setuptools python-dev build-essential
easy_install -U pip

Keybase proof

I hereby claim:

  • I am fduran on github.
  • I am fduran (https://keybase.io/fduran) on keybase.
  • I have a public key whose fingerprint is 07EC 2F80 E146 5882 ED6E A260 21CB C38A 8E89 7D06

To claim this, I am signing this object: