robotframework-demo/Project/task4/Script/SC7_Plateform/check_container.sh

39 lines
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
################################生成日志文件########################################
if [ -f "/Log/Check_Container.csv" ];then
echo "Monitor File Exist"
else
touch /Log/Check_Container.csv
fi
head_char_now=`sed -n '1p;1q' /Log/Check_Container.csv`
head_char_check="Ram_total"
if [[ $head_char_now == *$head_char_check* ]];then
echo "Character Exist!"
else
echo 'Time','Dedupname','Container num','Recycling container num'>> /Log/Check_Container.csv
fi
################################生成日志文件########################################
if [ $# -eq 0 ];then
echo "Input Dedupserver Name! "
exit 1
fi
dedupname=$1
dbname="${dedupname}containerdb"
cmd1="db.$dbname.find().count()"
cmd2="db.$dbname.find({container_sign:2}).count()"
getcontainer1=$(/opt/bksoft/ubackup/bin/mongo -uunary -pmonGo1223 dedup_db --eval ${cmd1} | awk 'END{print}')
getcontainer2=$(/opt/bksoft/ubackup/bin/mongo -uunary -pmonGo1223 dedup_db --eval ${cmd2} | awk 'END{print}')
#echo $getcontainer1
#echo $getcontainer2
time=$(date "+%Y-%m-%d %H:%M:%S")
echo "$time,$dedupname,$getcontainer1,$getcontainer2" >> /Log/Check_Container.csv