Skip to content

Commit f30b3ee

Browse files
jintaojujintaoju
authored andcommitted
add ums
1 parent ed1c241 commit f30b3ee

8 files changed

Lines changed: 173 additions & 0 deletions

File tree

nodejs/simple_server.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var http = require('http')
2+
http.createServer(function (request, response){
3+
response.writeHead(200,{'Content-Type':'text/plain'});
4+
response.end('Hello World\n');
5+
}).listen(8124);
6+
console.log('Server running at http://127.0.0.1:8124');

shell/case.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -
2+
select opt in `seq 1 10`
3+
do
4+
case $REPLY in
5+
1)
6+
echo one;;
7+
2)
8+
echo two;;
9+
esac
10+
done

shell/for.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash -
2+
echo <<EOF
3+
for i in
4+
for i in {1...10}
5+
for((statement;statement;statement))
6+
EOF
7+
for i in `seq 1 10`;
8+
do
9+
echo $i
10+
done
11+
12+
for((i=0;i<10;i++)); do
13+
echo $i
14+
done
15+
16+
for i in {1..10}; do
17+
echo $i
18+
done

shell/func.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash -
2+
3+
function e {
4+
echo $1
5+
}
6+
7+
f() {
8+
return `expr $1 + $2`
9+
}
10+
11+
e Hello
12+
f 2 3
13+
total=$?
14+
echo $total

shell/select.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash -
2+
OPTIONS=("Hello" "Quit")
3+
set -x
4+
select opt in ${OPTIONS[@]}
5+
do
6+
if [ $REPLY = "Quit" ]; then
7+
echo done
8+
exit
9+
elif [ $REPLY = "Hello" ]; then
10+
echo hello world
11+
else
12+
clear
13+
echo bad option
14+
fi
15+
done

shell/test_array.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash -
2+
cat <<EOF
3+
====成员====
4+
\${array[@]}
5+
====大小====
6+
\${#array[@]}
7+
====赋值====
8+
array[i]=k
9+
====删除====
10+
unset array[i]
11+
EOF
12+
set -x
13+
declare -a test
14+
test=("1" "2")
15+
echo ${test[@]}
16+
echo ${#test[*]}
17+
test[0]="3"
18+
echo ${test[@]}
19+
unset test[0]
20+
echo ${test[@]}
21+
set +x
22+

shell/variables.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash -
2+
echo <<EOF
3+
$$ = pid
4+
$? = exit status
5+
$0 = call program name
6+
$1 = first argument
7+
...
8+
$* = all the argument
9+
$# = number of command
10+
shift command to shift command line arguments
11+
12+
EOF
13+
echo ====pip====
14+
echo \$\$
15+
echo $$
16+
echo ====arguments====
17+
echo \$*
18+
echo $*
19+
echo ====numbeer====
20+
echo \$#
21+
echo $#
22+
until [ $# -eq 0 ]
23+
do
24+
echo $1
25+
shift
26+
done
27+

ums/sms_received_rate.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash -
2+
3+
get_mysql_result(){
4+
sql="select identity,code,verified,if(verified =1,verify_time - send_time,0) as period from t_verify_code where from_unixtime(send_time) like '$date%' and type=3 "
5+
echo "$sql" | $mysql > .sms.log
6+
}
7+
8+
check_result(){
9+
local sent=$(grep -E "^1" .sms.log|wc -l | tr "\t" " " | tr -s " ")
10+
local recv=$(grep -E "^1" .sms.log|awk -v period=$period 'BEGIN{m =0} {if($3 == 1 && $4 < period) {m++;}} END{printf("%d",m);}')
11+
local rate=$(echo "scale=2; $recv/$sent*100" | bc -l)
12+
echo "总数量: $sent"
13+
echo "收到的数量: $recv"
14+
echo "总抵达率: ${rate}%"
15+
}
16+
check_mobile(){
17+
local sent=$(grep -E "^1" .sms.log|grep -E "^13[4-9]|^147|^15[0-2]|^15[7-9]|^182|^183|^187|^188"|wc -l | tr "\t" " " | tr -s " ")
18+
local recv=$(grep -E "^1" .sms.log|grep -E "^13[4-9]|^147|^15[0-2]|^15[7-9]|^182|^183|^187|^188"|awk -v period=$period 'BEGIN{m=0} {if($3==1 && $4 < period) {m++}} END{print m;}')
19+
local rate=$(echo "scale=2; $recv/$sent*100" | bc -l)
20+
21+
echo "移动发送量:$sent"
22+
echo "移动收到量: $recv"
23+
echo "移动抵达率: ${rate}%"
24+
}
25+
26+
echo_help(){
27+
cat <<EOF
28+
./get_send_sms.sh period
29+
./get_send_sms.sh date period
30+
./get_send_sms.sh
31+
EOF
32+
}
33+
34+
declare date
35+
declare period
36+
if [[ $# == 1 && $1 == '?' ]]
37+
then
38+
echo_help
39+
exit 1
40+
fi
41+
42+
if [[ $# == 1 ]]
43+
then
44+
period=$1
45+
date=`date +%Y-%m-%d`
46+
echo "${period}秒内到达统计"
47+
elif [[ $# == 2 ]]
48+
then
49+
date=$1
50+
period=$2
51+
else
52+
date=`date +%Y-%m-%d`
53+
period=120
54+
echo "${period}秒内到达统计"
55+
fi
56+
57+
mysql='mysql -uroot -h172.17.0.2 uaccount -B -N '
58+
get_mysql_result
59+
check_result
60+
check_mobile
61+
exit 0

0 commit comments

Comments
 (0)