Game server uses various scripts

Source: Internet
Author: User

    1. 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

    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.