本文共 3460 字,大约阅读时间需要 11 分钟。
#!/bin/bash export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/binexport HOSTS=$(hostname)mysql_user='root'mysql_pass='123.com'mail="xuel@51idc.com"data=$(date +%Y-%m-%d-%H:%M)netstat -lntup|egrep ":3306"|grep -v grep>/dev/null0if [ $? -eq 0 ];thenSlave_IO=`mysql -u${mysql_user} -p${mysql_pass} -e "show slave status\G"|grep "Slave_IO_Running:"|awk -F": " '{print $2}'`Slave_SQL=`mysql -u${mysql_user} -p${mysql_pass} -e "show slave status\G"|grep "Slave_SQL_Running:"|awk -F": " '{print $2}'`if [ "$Slave_IO" == "Yes" ] && [ "$Slave_SQL" == "Yes" ];thenSTAT=1 && echo "$data mysql-status is ok">>/var/log/mysql-status.logelseSTAT=0 && echo "$data mysql-status is error">>/var/log/mysql-status.logfielseSTAT=0 && echo "$data mysql-status is error">>/var/log/mysql-status.logfi/scripts/cms_post.sh 1931875513165389 mysql_status $STAT status=$HOSTS
#!/bin/bash##########################################Usage: sh cms_post.sh#Author: CMS Dev Team#Company: Aliyun Inc.#Version: 1.0##########################################parameters instructions# $1: ali_uid, $2: metric_name, $3: metric_value, $4:fields#convert current time to millisecondsif [[ ! "$#" -eq 4 ]];thenecho "usage: $0 userId, metricName, value, dimensions"echo "--multiple dimensions like 'ip=111.111.111.111,hostname=cms'"exit 1fi#biz timetimestamp=`date +%s%N | cut -b1-13`#build dimensions jsonarr=(${4//,/ })dimensions="{"for i in "${arr[@]}"; dokv=(${i//=/ }) dimensions=${dimensions}'"'${kv[0]}'":"'${kv[1]}'",'donedimensions=${dimensions%,*}dimensions=${dimensions}'}'#build namespace and metricsuserId="$1"namespace="acs/custom/$1"metrics='[{"metricName":"'"$2"'","value":'"$3"',"unit":"None","timestamp":'"$timestamp"',"dimensions":'"$dimensions"'}]'url="http://openNaNs.aliyun.com/metrics/put"params="userId=$userId&namespace=$namespace&metrics=$metrics"echo "params: ${params}"curl -v ${url} --data ${params}
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpmyum install zabbix-sender -y#!/bin/bashmysql_user='root'mysql_pass='123.com'mail="xuel@51idc.com"data=$(date +%Y-%m-%d-%H:%M)netstat -lntup|egrep ":3306"|grep -v grep>/dev/null0if [ $? -eq 0 ];thenSlave_IO=`mysql -u${mysql_user} -p${mysql_pass} -e "show slave status\G"|grep "Slave_IO_Running:"|awk -F": " '{print $2}'`Slave_SQL=`mysql -u${mysql_user} -p${mysql_pass} -e "show slave status\G"|grep "Slave_SQL_Running:"|awk -F": " '{print $2}'`if [ "$Slave_IO" == "Yes" ] && [ "$Slave_SQL" == "Yes" ];thenSTAT=1 && echo "$data mysql-status is ok">>/var/log/mysql-status.logelseSTAT=0 && echo "$data mysql-status is error">>/var/log/mysql-status.logfielseSTAT=0 && echo "$data mysql-status is error">>/var/log/mysql-status.logfizabbix_sender -z 192.168.1.234 -s "test-mysql-status" -k mysql -o $STAT
转载地址:http://lquaa.baihongyu.com/