#!/bin/bash
ops1 () {
case $1 in
a)
echo "A" ;;
b)
echo "B" ;;
*)
ccc
esac
}
ccc () {
echo "
写自己想写东西
比如说
A是什么功能
B是什么功能 都可以写
"
}
ops1 $@
#!/bin/bash
function ops() {
case $1 in
oob)
msn=`curl -s "localhost:7070/api/v3/column/m.sn?m.ip=${2}" |grep "m.sn" |awk -F'"' '{print $4}'`
docker exec `docker ps |grep oob |awk '{print $1}'` grep ${msn} /tmp/sn_ip_map ;;
sr)
curl -s "localhost:7070/api/v3/column/m.sr.id,m.ip?m.idc=am86"|grep -B1 -i ${2} ;;
sql)
curl -s http://localhost:7070/api/v3/column/service.res.result|awk -F'": "' '/db_password/{print $2}'|awk -F'"' '/"'$2'/{s="mysql -h"$40" -u"$36" -p"$4" -D"$44" -P"$12;gsub("\\\\","",s);print s}' ;;
machine)
curl -s "localhost:7070/api/v3/column/m.*?m.${2}=${3}" ;;
slb)
ssh 20.15.0.5 "ipvsadm -lnv |grep -A 5 ${2}" ;;
*)
printing ;;
esac
}
function printing() {
echo "Usage: ruiapi [OPTION] PATTERN ...
Search for PATTERN in API.
oob , search oob_ip by sn in oob_container
serverrole , search vm_ip by serverrole_name
sql , search the way of login by db_name
machine , search machine_info by PATTERN(up to need)
slb , search real_server by slb_ip
Example:
ruiapi oob 10.15.100.100
ruiapi sr tongque_nginx
ruiapi sql dbaas
ruiapi machine ip 10.15.100.100
ruiapi slb 10.15.100.110
Report bugs to <ex-ruidongdong@suzhoubank.com>. "
}
ops $@