有赞测试文章读后感

有赞的发布系统为公交车发布系统,我们的发布系统为极品飞车发布系统将来肯定会比他们的牛逼。目前我们的极品飞车系统还在起步阶段,分支发布还在开发过程当中,但整个发布系统功能跟有赞类似,我们的平台将来还要与docker平台,监控系统对接,这是有赞公交车系统所没有的;感觉他们的分支发布好像不是自动编译的,现在我们运维平台实现了自动编译功能,发布项目挺快的;他们的发布流程很长,也不知道他们发布一个项目需要多长时间。

值得借鉴的是他们的整个发布过程已经跟测试打通,整个发布流程相当于是一条龙服务,全程自动化,平台界面展示效果较好。我们的平台现在还没有达到这种地步,但是肯定会的,很看好我们的平台!

zabbix agent 安装脚本

#!/bin/bash

#define color variables
RED=’\E[1;31m’
GRN=’\E[1;32m’
YEL=’\E[1;33m’
MAG=’\E[1;35m’
RES=’\E[0m’
#define environment variables
ZB_NAME=”zabbix”
ZB_VERSION=”3.2.4″
ZB_SOFT=”${ZB_NAME}-${ZB_VERSION}.tar.gz”
ZB_SOURCE_DIR=”/data/usr/src”
ZB_INSTALL_DIR=”/data/usr/local”
ZB_SOFT_DIR=”/data/soft”
ZB_CONF_FILE=”${ZB_INSTALL_DIR}/${ZB_NAME}/etc/zabbix_agentd.conf”
ZB_SER_IP=’10.26.83.53′
ZB_PUBLIC_DIR=”/mnt/zabbix”
ZB_LOG_DIR=”${ZB_PUBLIC_DIR}/zabbix_agentd.log”
ZB_PID_DIR=”${ZB_PUBLIC_DIR}/zabbix_agentd.pid”
ZB_PORT=’10050′
ZB_HOSTNAME=`hostname`
ZB_USER=`cat /etc/passwd |grep zabbix| wc -l`

check_dependency () {

NUM=`lsof -i :${ZB_PORT} | grep “LISTEN” | grep -v grep | wc -l`
if [ ${NUM} -ne 0 ];then
echo -e “${GRN}zabbix agent is install,${RES}”
exit 1
fi

if [ ${ZB_USER} -eq 0 ];then
useradd -s /sbin/nologin zabbix
fi
[ ${UID} -ne 0 ] && echo -e “${RED}need to be root to that${RES}” && exit 1
[ ! -d ${ZB_SOFT_DIR} ] && echo -e “${RED}no ${ZB_SOFT_DIR},Create a directory…${RES}” && mkdir -pv ${ZB_SOFT_DIR}
[ ! -f ${ZB_SOFT_DIR}/${ZB_SOFT} ] && echo -e “${RED}not fount file ${ZB_SOFT}… , please check…${RES}” && exit 1
[ ! -d ${ZB_SOURCE_DIR} ] && echo -e “${RED}no ${ZB_SOURCE_DIR},Create a directory…${RES}” && mkdir -pv ${ZB_SOURCE_DIR}
[ ! -d ${ZB_INSTALL_DIR} ] && echo -e “${RED}no ${ZB_INSTALL_DIR},Create a directory…${RES}” && mkdir -pv ${ZB_INSTALL_DIR}
[ ! -d ${ZB_PUBLIC_DIR} ] && echo -e “${RED}no ${ZB_PUBLIC_DIR},Create a directory…${RES}” && mkdir -pv ${ZB_PUBLIC_DIR} && chown -R ${ZB_NAME}.${ZB_NAME} ${ZB_PUBLIC_DIR}
PUBLIC_DIR_OMNER=`stat -c %G ${ZB_PUBLIC_DIR}`
PUBLIC_DIR_GROUP=`stat -c %G ${ZB_PUBLIC_DIR}`
if [ “${PUBLIC_DIR_OMNER}” != “${ZB_NAME}” ] || [ “${PUBLIC_DIR_GROUP}” != “${ZB_NAME}” ];then
chown -R ${ZB_NAME}.${ZB_NAME} ${ZB_PUBLIC_DIR}
fi
}

start_install () {
[ -d ${ZB_SOURCE_DIR}/${ZB_NAME}-${ZB_VERSION} ] && rm -rf ${ZB_SOURCE_DIR}/${ZB_NAME}-${ZB_VERSION}
[ -d ${ZB_INSTALL_DIR}/${ZB_NAME} ] && rm -rf ${ZB_INSTALL_DIR}/${ZB_NAME}
tar xf ${ZB_SOFT_DIR}/${ZB_SOFT} -C ${ZB_SOURCE_DIR}
cd ${ZB_SOURCE_DIR}/${ZB_NAME}-${ZB_VERSION}
if [ $? -eq 0 ];then
yum -y install gcc curl lsof
if [ $? -eq 0 ];then
./configure –prefix=${ZB_INSTALL_DIR}/${ZB_NAME} –enable-agent
if [ $? -eq 0 ];then
make
if [ $? -eq 0 ];then
make install
if [ $? -eq 0 ];then
echo -e “${GRN}zabbix agent install success${RES}”
else
echo -e “${RED}zabbix agent install faild,MAKE INSTALL faild,please check…${RES}”
exit 1
fi
else
echo -e “${RED}zabbix agent install faild,MAKE faild,please check…${RES}”
exit 1
fi
else
echo -e “${RED}zabbix agent install faild,CONFIGURE faild,please check…${RES}”
exit 1
fi
else
echo -e “${RED}yum set faild…,please check yum…${RES}”
exit 1
fi
else
echo -e “${RED}directory change faild or zabbix source directory not fount,please check…${RES}”
exit 1
fi
}

start_configure () {
# backup zabbix agent configure file
cp ${ZB_CONF_FILE} ${ZB_CONF_FILE}\-bak
sed -i “s#\# PidFile=/tmp/zabbix_agentd.pid#PidFile=${ZB_PID_DIR}#g” ${ZB_CONF_FILE}
sed -i “s#LogFile=/tmp/zabbix_agentd.log#LogFile=${ZB_LOG_DIR}#g” ${ZB_CONF_FILE}
sed -i “s#Server=127.0.0.1#Server=${ZB_SER_IP}#g” ${ZB_CONF_FILE}
sed -i “s#ServerActive=127.0.0.1#ServerActive=${ZB_SER_IP}#g” ${ZB_CONF_FILE}
sed -i “s#Hostname=Zabbix server#Hostname=${ZB_HOSTNAME}#g” ${ZB_CONF_FILE}
}

start_zabbix_agent () {
${ZB_INSTALL_DIR}/${ZB_NAME}/sbin/zabbix_agentd
NUM=`lsof -i :${ZB_PORT} | grep “LISTEN” | grep -v grep | wc -l`
if [ ${NUM} -ne 0 ];then
echo -e “${GRN}zabbix agent start success${RES}”
else
echo -e “${RED}zabbix agent start faild${RES}”
fi
}

check_dependency
start_install
start_configure
start_zabbix_agent

重启service脚本

PID=`ps aux | grep $1 | grep -v grep | grep -v $0 | awk ‘{print $2}’`
export JAVA_HOME=/usr/lib/jvm/jdk7
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
if [ -z $PID ];then
sh $1/student-service/bin/start.sh
if [ $? -eq 0 ];then
echo “service start success”
else

echo “service start failed”
fi
else
kill -9 $PID
sh $1/student-service/bin/start.sh
if [ $? -eq 0 ];then
echo “service start success”
else

echo “service start failed”
fi
fi

重启Tomcat脚本

PID=`ps aux | grep $1 | grep -v grep | grep -v $0 | awk ‘{print $2}’`
export JAVA_HOME=/usr/lib/jvm/jdk7
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
if [ -z $PID ];then
sh $1/bin/startup.sh
if [ $? -eq 0 ];then
echo “tomcat start success”
else

echo “tomcat start failed”
fi
else
kill -9 $PID
sh $1/bin/startup.sh
if [ $? -eq 0 ];then
echo “tomcat start success”
else

echo “tomcat start failed”
fi
fi

向七牛上传zip包

# -*- coding: utf-8 -*-
# flake8: noqa
from qiniu import Auth
from qiniu import BucketManager
import mysql.connector
sumr = 0
count = 0
real_count = 0
access_key = ‘WR5JtPxdsdYOgladSBDXZl3idmqjBzqkX5E-UDfG’
secret_key = ‘QOsocxMR2BN9eNZek3gjKeP2j_KznEl-H0JOg5g9’
# 初始化Auth状态
q = Auth(access_key, secret_key)
# 初始化BucketManager
bucket = BucketManager(q)
# 你要测试的空间, 并且这个key在你空间中存在
bucket_name = ‘axx-homework’

conn = mysql.connector.connect(user=’aixuexidball’, password=’aixuexi_2016dball’,host=’rm-2zefci7s9f4bpy9gt.mysql.rds.aliyuncs.com’, database=’managesystemv1.0′)
cursor = conn.cursor()
cursor.execute(
“SELECT correct_result FROM c_student_homework_answer_record WHERE correct_result LIKE ‘%http://image1.aixuexi.com%'”)

values = cursor.fetchall()
cursor.close()
conn.close()
values_set = set()
for value in values:
count+=1
values_set.add(value)

for value in values_set:
real_value = value[0].split(‘/’)[-1]
real_count+=1
# print(real_value)
# real_value = value[0].replace(‘http://image1.aixuexi.com/’, ”)
try:
ret, info = bucket.stat(bucket_name, real_value)
if info.status_code == 612:
sumr+=1
print(real_value)
f=open(‘goods.txt’, ‘a’)
f.write(str(real_value+’\n’))
f.close()
except BaseException as e:
print(“111”)
continue
f=open(‘goods.txt’, ‘a’)
f.write(“共计:”+str(count)+’\n’+”真实共计:”+str(real_count)+’\n’+”不存在共计:”+str(sumr))
f.close()
print(“共计:”+str(count))
print(“真实共计:”+str(real_count))
print(“不存在共计:”+str(sumr))

七牛课件重命名

# -*- coding: utf-8 -*-
# flake8: noqa
from qiniu import Auth
from qiniu import BucketManager
import mysql.connector
import time
localtime = time.asctime(time.localtime(time.time()))
current_date = time.strftime(‘%Y-%m-%d’,time.localtime(time.time()))
access_key = ‘WR5JtPxdsdYOgladSBDXZl3idmqjBzqkX5E-UDfG’
secret_key = ‘QOsocxMR2BN9eNZek3gjKeP2j_KznEl-H0JOg5g9’
# 初始化Auth状态
q = Auth(access_key, secret_key)
# 初始化BucketManager
bucket = BucketManager(q)
# 你要测试的空间, 并且这个key在你空间中存在
bucket_name = ‘axx-courseware’

conn = mysql.connector.connect(user=’aixuexidball’, password=’aixuexi_2016dball’,host=’rm-2zefci7s9f4bpy9gt.mysql.rds.aliyuncs.com’, database=’managesystemv1.0′)
cursor = conn.cursor()
cursor.execute(“select DISTINCT(filePath) from coursenote where createTime like ‘” + current_date + “%’ and filePath like ‘kjqn%’;”)

values = cursor.fetchall()
cursor.close()
conn.close()
#print(values)
for val in values:
for real_val in val:
html5_val = real_val.decode()+’/html5.html’
index_val = real_val.decode()+’/index.html’
flash_val = real_val.decode()+’/flash.html’
ret, html5_info = bucket.stat(bucket_name, html5_val)
ret, index_info = bucket.stat(bucket_name, index_val)
ret, flash_info = bucket.stat(bucket_name, flash_val)

if html5_info.status_code != 200 and index_info.status_code == 200 and flash_info.status_code == 200:
ret, info = bucket.move(bucket_name, index_val, bucket_name, html5_val)
if info.status_code == 200:
f=open(‘rename_kejian.log’, ‘a’)
f.write(localtime+” rename:”+str(index_val)+”–>”+str(html5_val)+’\n’)
f.close()
else:
f=open(‘rename_kejian.log’, ‘a’)
f.write(localtime+” faild:”+str(index_val)+”–>”+str(html5_val)+’\n’)
f.write(localtime+” error:”+info+’\n’)
f.close()

ret, info = bucket.move(bucket_name, flash_val, bucket_name, index_val)
if info.status_code == 200:
f=open(‘rename_kejian.log’, ‘a’)
f.write(localtime+” rename:”+str(flash_val)+”–>”+str(index_val)+’\n’)
f.close()
else:
f=open(‘rename_kejian.log’, ‘a’)
f.write(localtime+” faild:”+str(flash_val)+”–>”+str(index_val)+’\n’)
f.write(localtime+” error:”+info+’\n’)
f.close()
elif html5_info.status_code != 200 and index_info.status_code != 200 and flash_info.status_code != 200:
f=open(‘rename_kejian.log’, ‘a’)
f.write(localtime+” lose:”+html5_val+”&”+index_val+”&”+flash_val+’\n’)
f.close()
elif html5_info.status_code != 200 and index_info.status_code == 200 and flash_info.status_code != 200:
f=open(‘rename_kejian.log’, ‘a’)
f.write(localtime+” lose:”+html5_val+”&”+flash_val+’\n’)
f.close()
elif html5_info.status_code != 200 and index_info.status_code != 200 and flash_info.status_code == 200:
f=open(‘rename_kejian.log’, ‘a’)
f.write(localtime+” lose:”+html5_val+”&”+index_val+’\n’)
f.close()