Aside

IP address Apache access logs

If You want find out which ip address occurs the most in apache logs (to determine bot attack) run :

cat access_log | awk '{print $1}' | sort | uniq -c | sort -n | tail

To determine if given IP occurs in iptables rules:

iptables -L -n -v | grep [ip_address]

That helped me a lot lately…

Aside

Centos 6 – Adding EPEL repository

wget http://ftp.ps.pl/pub/Linux/fedora-epel/RPM-GPG-KEY-EPEL-6
rpm --import RPM-GPG-KEY-EPEL-6
rm -f RPM-GPG-KEY-EPEL-6

Now create /etc/yum.repos.d/EPEL.repo and paste:

[epel]
name=EPEL RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.ps.pl/pub/Linux/fedora-epel/$releasever/$basearch/
gpgcheck=1
enabled=0

Now when You want to use repository You just do it like this:

yum --enablerepo=epel install [pakage]
Aside

MySQL high CPU usage

Recently my servers CPU gone wild. After running a top command MySQL was using up to 80% of CPU while mytop was showing no connections.

It turned out that the problem was ntp service and a leap second which was added to UTC time to compensate for the slowing rotation of the Earth.

The same problem I had with ruby on local development server.

Solution:

service ntpd stop
date -s "`date`"
service ntpd start
Aside

Quick Tip: Watch Me!

Very, very, very useful command!

Let’s say You want to observe the result of something being done every 5 seconds. For example list directory contents in which You’re creating backups in other thread. How to do this? Simply – use watch command:

watch -n5 'ls -lh /srv/backups'

Remember that brackets are very important and command in brackets can’t be alias (like ll for ls -l).