Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
soarpenguin committed May 25, 2015
2 parents 9e39162 + d277231 commit 99dab2b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
10 changes: 10 additions & 0 deletions bashrc/AUTHORS.sh
@@ -0,0 +1,10 @@
#! /bin/sh

# Create the AUTHORS file, by searching the git history.

# Run as "AUTHORS.sh" to get complete history
# Run with "AUTHORS.sh commitish..commitish" for history between tags

# shortlog will canonicalize the names using the file .mailmap
git shortlog -s ${1-} |
cut -b8- # strip the commit counts
6 changes: 6 additions & 0 deletions bashrc/oneline_cmd
Expand Up @@ -197,3 +197,9 @@ ps aux | awk '{if($1=="root") print $(NF-1)}'
#127.0.0.1:6379> config set maxclients 10000
#127.0.0.1:6379> monitor

# rpm usage
# rpm -qa --nosignature | grep elastic # skip signature query
# rpm -e -vv --nosignature elasticsearch-1.5.2-1 # skip signature uninstall
# cd /var/lib/rpm && rm -rf __db* # rm lock file for rpm no respose.
# rpm -ivh -vv --force --nosignature elasticsearch-1.5.1.rpm

23 changes: 20 additions & 3 deletions bashrc/threads.sh
Expand Up @@ -11,10 +11,14 @@ CURDIR=$(cd "$(dirname "$0")"; pwd);
g_HOST_LIST=$1
g_THREAD_NUM=300
g_PORT=22
g_LIMIT=0
TMPFILE="pipe.$$"
SSH="ssh -n -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o ConnectTimeout=5 "
SCP='scp -q -r -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o ConnectTimeout=5 '

RET_OK=0
RET_FAIL=1

##################### function #########################
_report_err() { echo "${MYNAME}: Error: $*" >&2 ; }

Expand Down Expand Up @@ -46,6 +50,7 @@ Options:
-c, --concurrent num Thread Nummber for run the command at same time, default: 1.
-s, --ssh Use ssh authorized_keys to login without password query from DB.
-p, --port Use port instead of defult port:22.
-l, --limit Limit num for host to run when limit less then all host num.
-h, --help Print this help infomation.
Require:
Expand All @@ -56,7 +61,7 @@ Notice:
please check the result output under log/hostname.
USAGE

exit 1
exit $RET_OK
}

#
Expand All @@ -81,6 +86,10 @@ _parse_options()
g_PORT=${2}
shift 2
;;
-l|--limit)
g_LIMIT=${2}
shift 2
;;
-h|--help)
usage
exit
Expand All @@ -103,7 +112,7 @@ _parse_options()

case ${#argv[@]} in
2)
g_HOST_LIST=$(readlink -f "${argv[0]}")
command -v greadlink >/dev/null 2>&1 && g_HOST_LIST=$(greadlink -f "${argv[0]}") || g_HOST_LIST=$(readlink -f "${argv[0]}")
g_CMD="${argv[1]}"
;;
0|*)
Expand Down Expand Up @@ -148,6 +157,7 @@ INDEX=0

while read -r HOST
do
HOST=${HOST#*(:space:)}
(( INDEX++ ))
fchar=`echo ${HOST} | cut -c -1`

Expand All @@ -162,10 +172,17 @@ do
fi
unset fchar

if [ "x$g_LIMIT" != "x0" ]; then
if [ "$g_LIMIT" -lt "$INDEX" ]; then
_trace "Reach limit num of $g_LIMIT"
break
fi
fi

_trace "[$INDEX] start ${HOST} ......"
read <&9

ping -c 1 -w 3 ${HOST} &>/dev/null
ping -c 1 -W 3 ${HOST} &>/dev/null

if [ $? -ne 0 ]; then
_print_fatal "[$INDEX] Error: ${HOST} is unreachable."
Expand Down

0 comments on commit 99dab2b

Please sign in to comment.