- Backup scripts
Storage location: Native
Function: Regularly back up database files to/home/data/databak
mysql_db_bak.sh
#!/bin/sh
#by Xiayang
Export path=path=/usr/lib64/qt-
3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
echo Mysql DB backup script!
find/home/data/databak/-mtime +30-type D | Xargs RM-RF
Datetime= ' Date ' +%y%m%d "'
datetime2= ' Date ' +%y%m%d%h%m "'
Hostname= "localhost"
Username= "Root"
Password= "Qianxing"
Bak_dir= "/home/data/databak"
dbnames= ' mysql-u$username-p$password-d mysql-e "show databases;" | grep DDT |grep
-V Log '
if [!-d "$bak _dir"/"$DATETIME"]; Then
Mkdir-p "$bak _dir"/"$DATETIME"
Fi
For dbname in $dbnames; Do
Echo
echo Start Backup $dbname .....
Mysqldump-h $hostname-u$username-p$password--lock-all-tables-r $dbname >
"$bak _dir"/"$DATETIME"/"$dbname" _ "$DATETIME 2" _bak.sql
Sleep 5
Echo
echo Start Compress $dbname .....
CD $bak _dir/$DATETIME
Tar jcf "$dbname" _ "$DATETIME 2" _bak.tar.bz2 "$dbname" _ "$DATETIME 2" _bak.sql
Rm-rf "$dbname" _ "$DATETIME 2" _bak.sql
Done
Echo
Echo done.
2, Disk utilization monitoring
Storage location: Native
Function: Check the system hard disk usage regularly, more than 70% send alarm mail
diskused.sh
#!/bin/bash
partitions=$ (Df-h|awk ' {print $} ' |grep-v ' use% ')
[Email protected]
I=0
For partition in $partitions
Do
i=$ ((i+1))
percent=$ (Echo $partition |tr-d '% ')
If [$percent-ge ' 70 '];
Then
showmenu=$ (df-h|sed-n "1p")
showpartition=$ (df-h|grep-v ' use% ' |sed-n "${i}p")
partitionname=$ (df-h|grep-v ' use% ' |awk ' {print $6} ' |sed-n "${i}p")
Echo-e "attention! $HOSTNAME ' s $partitionname Disk occupancy rate have exceeded 70%,please notes!! \n\n$showmenu\n$showpartition\n\n "|mail-s" $HOSTNAME Partition Usage alert!! "$recipients
Fi
Done
- Server Port Monitoring
Storage location: Native
Function: Check the game on the server regularly, the MySQL port is normal, do not send alarm message
ncports.sh
#!/bin/bash
#检测服务器端口是否开放, Success will return 0 value display OK, failure will return 1 value show fail
[Email Protected],[email protected]
Cat/opt/check/ip-ports.txt | While Read line
Do
Nc-w 10-z $line >/dev/null 2>&1
If [$?-eq 0]
Then
echo $line: OK
Else
echo $line: Fail
echo "website Inquiry platform 203.90.234.16 $line Port does not pass, please deal with it ASAP! " | Mail-s "Network query platform 203.90.234.16 $line Port does not pass" $recipients
Fi
Done
Ip-ports.txt
127.0.0.1 3306
127.0.0.1 1723
127.0.0.1 8005
127.0.0.1 8009
127.0.0.1 80
127.0.0.1 9527
127.0.0.1 1723
4. mysql Monitoring
Storage location: Native
function: Check MySQL connection status regularly
Game server uses various scripts