I have just finished clearing out an old (cPanel) server and I’ve found a few little commandlets/scripts that other people may find useful.
This first one will list the top 10 largest databases, you may need to change “/var/lib/mysql/” if this is not your default mysql data directory. Changing the number at the end will limit the number you see. On the average server under most configurations, you will probably need root access to get anything useful out of it.
du -s /var/lib/mysql/* | sort -n| cut -f 2-|xargs -i du -sh {} |tail -10 |
I can’t quite recall why I put hacked this next bash script together, but I think it was something to do with darkmailer scripts or some other rogue cgi scripts. Running it will let you know what is running (I think). It looks like I was being lazy although it may have been tied into a cron or something. It may me useful for someone anyway :p
#!/bin/bash # Get the total number of cgi processes running a=`ps ax | grep -c cgi` # Remove 3 of them (2 for the main script, 1 for the "ps grep" let a=$a-3 # If $a is not 0 it means there is a cgi script running if [ "$a" -gt 0 ] then # If there are some processes running, output them thisScript=`basename $0` b=`ps ax | grep cgi | grep -v $thisScript | grep -v "grep cgi"` # Split the output of the above command into an array # This is basically just to make the output more readable IFS=" " c=( $b ) echo "$a cgi script(s) running : detais below"; for (( i = 0 ; i < ${#c[*]} ; i++ )) do case ${c[i]} in *"cgi") echo -e ${c[i]} "\t";; *) echo -ne ${c[i]} "\t";; esac done else # There are no CGI Scripts running echo "All is good, there are no CGI scripts running" fi |
As usual, these are provided “as-is” without warranty, by using these, you accept full responsibility for any damage they may cause. If you’ve found a use for them, let me know in the comments!




Leave a Reply