SSH tools

Her webmaster'ın elinde bulundurması gereken bir kaç programcık vereceğim.

SSH MySQL yedek ;

#!/bin/bash

if [ $# -ne 1 ]
then
    echo "Usage : $0 [database_name]"
    exit 1
fi

NAME=$1
USER="dbname"
PASSWORD="dbpassword"
FILE=$NAME.backup.`date "+%Y%m%d"`.sql.gz
DIRECTORY=/home/webtest/mysql_backups
#KEEP="30 day"
KEEP=30

if [ ! -d $DIRECTORY ] 
then
    mkdir $DIRECTORY
fi


mysqldump -u $USER -p$PASSWORD $NAME | gzip -9 > $DIRECTORY/$FILE

if [ $? -eq 0 ]
then
echo "$NAME başarıyla yedeklendi..."
else
echo "$NAME yedeklenemedi"
rm -rf $DIRECTORY/$FILE
exit 1
fi

echo "$KEEP günden eski yedekler siliniyor..."
find $DIRECTORY/ -name $NAME.backup.* -mtime +$KEEP -exec rm {} \;

# DELETE=$NAME.backup.`date +%Y%m%d -d "$KEEP ago"`.sql
# if [ -f $DIRECTORY/$DELETE ]
# then
#     echo "Eski yedek siliniyor..."
#     echo "$DIRECTORY/$DELETE siliniyor..."
#     rm -rf "$DIRECTORY/$DELETE"
# fi
# exit 0
Server durum ;

#/usr/bin/!
echo
echo "Merhaba ben Durumcan sana serverinin ne durumda oldugunu bilgilendirmek icin yaziyorum.."
echo
echo "CPU Load ve Ram Kullanimlari"
echo "------------------------------------------------"
echo
top -b -n 1 | head -n 10
echo
echo "------------------------------------------------"
echo
echo "Apache durumunuz"
echo "------------------------------------------------"
echo
httpd status | grep Port
echo
echo "------------------------------------------------"
echo
echo "IP ve Portlarin durumu.."
echo "------------------------------------------------"
echo
netstat -nap | grep :27015 | awk '{print $4}' | cut -d: -f1 | sort | uniq -c | sort -n
echo
echo "------------------------------------------------"
echo
echo "Saygilar iyi calismalar optum..."