Last active
June 1, 2021 09:27
-
-
Save mitio/8536402 to your computer and use it in GitHub Desktop.
A few tiny shell scripts for quick diagnostics of possible web server problems
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
grep -E '^Listen ' /etc/apache2/ports.conf | sed 's/:/./' | sed 's/Listen //' | \ | |
ruby -e 'conns = []; while conn = gets; conns << conn.strip; end; system "netstat -an|grep tcp|grep -v LISTEN|grep -E \"\\b#{conns.join "\\b|\\b"}\\b\"";' | awk '{ print $5 }' | ruby -e 'conns = Hash.new(0); while conn = gets; parts = conn.strip.split(":"); ip = parts[0]; port = parts[-1]; conns[ip] += 1; end; conns.sort_by { |ip, count| -count }.each { |ip, count| puts "IP: #{ip.ljust(25)} connections: #{count.to_s.ljust(8)}" } ;nil' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
iptables -I INPUT -s $1 -j DROP | |
sh -c "iptables-save > /etc/network/iptables.save" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
netstat -an | grep tcp | grep -v LISTEN | awk '{ print $5 }' | \ | |
ruby -e 'conns = Hash.new(0); while conn = gets; parts = conn.strip.split(":"); ip = parts[0]; port = parts[-1]; conns[ip] += 1; end; conns.sort_by { |ip, count| -count }.each { |ip, count| puts "IP: #{ip.ljust(25)} connections: #{count.to_s.ljust(8)}" } ;nil' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
/home/pyfmi/.rbenv/versions/2.0.0-p247/bin/passenger-status --verbose | |
/home/pyfmi/.rbenv/versions/2.0.0-p247/bin/passenger-memory-stats |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
netstat='netstat -an' | |
ps='ps aux' | |
echo MySQL connections: `$netstat|grep mysql|wc -l` | |
echo Apache processes: `$ps|grep apache|grep -v grep|wc -l` | |
echo TCP connections: `$netstat|grep tcp|wc -l` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment