diff --git a/find-in-jars.sh b/find-in-jars.sh index 5b76ca36..25382cdb 100755 --- a/find-in-jars.sh +++ b/find-in-jars.sh @@ -46,10 +46,8 @@ done [ -z "$1" ] && { echo No find file pattern! ; usage 1; } dir=${dir:-.} -find ${dir} -iname '*.jar' | while read jarFile -do - jar tf ${jarFile} | egrep "$1" | while read file - do - echo "${jarFile}"\!"${file}" - done +find ${dir} -iname '*.jar' | while read jarFile; do + jar tf ${jarFile} | egrep "$1" | while read file; do + echo "${jarFile}"\!"${file}" + done done diff --git a/monitor-host.sh b/monitor-host.sh new file mode 100755 index 00000000..d1f4164b --- /dev/null +++ b/monitor-host.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# @Function +# monitor host:network io memory cpu +# +# @Usage +# $ ./monitor-host.sh +# +# @author Bryant Hang + +DELAY=10 +COUNT=60 + +LOG_PATH='monitor_path' + +if ! [ -d $monitor_log_path ]; then + mkdir -p $monitor_log_path +fi + +cur_date="`date +%Y%m%d`" + +top_log_path=$LOG_PATH'/top_'$cur_date'.log' +memory_log_path=$LOG_PATH'/memory_'$cur_date'.log' +cpu_log_path=$LOG_PATH'/cpu_'$cur_date'.log' +io_log_path=$LOG_PATH'/io_'$cur_date'.log' +network_log_path=$LOG_PATH'/network_'$cur_date'.log' + +# total performance check +top -b -d $DELAY -n $COUNT > top_log_path 2>&1 & + +# memory check +vmstat $DELAY $COUNT > memory_log_path 2>&1 & + +# cpu check +sar -u $DELAY $COUNT > cpu_log_path 2>&1 & + +# IO check +iostat $DELAY $COUNT > io_log_path 2>&1 & + +# network check +sar -n DEV $DELAY $COUNT > network_log_path 2>&1 & \ No newline at end of file diff --git a/show-cpu-and-memory.sh b/show-cpu-and-memory.sh new file mode 100755 index 00000000..f8187dc8 --- /dev/null +++ b/show-cpu-and-memory.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# @Function +# Show total and every process's memory and cpu usage +# +# @Usage +# $ ./show-cpu-and-memory.sh +# +# @author Bryant Hang +cur_date="`date +%Y%m%d`" + +total_mem="`free -m | grep 'Mem'`" +total_cpu="`top -n 1 | grep 'Cpu'`" + +echo '**********'$cur_date'**********' + +echo '' + +echo $total_mem +echo $total_cpu + +echo '' + +for i in `ps -ef | grep -v "awk|$0" | awk '{print $2}'` +do + # not pid + if [[ $i == *[!0-9]* ]]; then + continue + fi + + mem=`cat /proc/$i/status 2> /dev/null | grep VmRSS | awk '{print $2" " $3}'` + cpu=`top -n 1 -b | awk '$1=='$i'{print $9}'` + + echo 'pid: '$i', memory: '$mem', cpu:'$cpu'%' +done \ No newline at end of file