JasonDaly.name

PHP, Ruby, Symfony, Rails, Doctrine, MooTools. Web Development.

Posts tagged with "apache"

March 30, 2009

Dumping the Number of Open Connection to Port 80 by IP Address

This displays the number of open connections to port 80 on a server, dumping the ip address/connection count pairs in ascending order.

netstat -anlp | grep :80 | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -n

This can be useful in combination with grep1 searches performed on

httpd fullstatus

to determine if a DOS attack is being performed on a server.

1 note Tags: apache netstat linux httpd awk grep connections load

March 25, 2009

Clear Hanging Apache Semaphores

Restarting httpd while trying to alleviate high load on one of the servers I manage, I was recently presented with the following error

(28)No space left on device: Couldn't create accept lock

After some research I found running the following command1

ipcs -s

showed there were a bunch of semaphores hanging around even though apache had been stopped normally via

service httpd restart

Similar to the code snippet mentioned by Major over at RackerHacker, the following command clears out those semaphores, letting httpd start up without a problem

ipcs -s | grep nobody | perl -e 'while (<STDIN>) { @a=split(/\s+/); print `ipcrm sem $a[1]`}'

1 note Tags: bash apache linux ipcs httpd load semaphore linux