Commit ffb50a7a by jajapi

trim webpmscript, add cmspmscript

parent 13d0e746
#!/bin/bash
#Hyun-gwan Seo
#Modified to Young-bin Cho [2018/11/02]
function DRAW_A_LINE()
{
echo -e "-----------------------------------------------"
}
function GET_DATE()
{
echo -e "\n------------------- date-------------------"
date
ntpq -p
}
function CHECK_MEMORY()
{
echo -e "\n-------------- Check memory --------------"
free -h
DRAW_A_LINE
}
function CHECK_PROCESS()
{
echo -e "\n-------------- Check Process --------------"
process=("nginx" "pengx" "ntp")
for ((idx=0; idx < ${#process[@]}; idx++))
do
echo "${process[$idx]}"
echo -e "`ps aux | grep ${process[$idx]}`"
echo ""
done
DRAW_A_LINE
}
function UXEN_DSTAT()
{
echo -e "\n-------------- dstat --------------"
python2 /usr/bin/dstat -lcdngy 1 10
python2 /usr/bin/dstat -nf 1 10
DRAW_A_LINE
}
function GET_VM_LIST()
{
echo -e "\n-------------- VM List Check --------------"
sudo xl li
DRAW_A_LINE
}
function DMESG_CHECK()
{
echo -e "\n-------------- Dmesg Check --------------"
dmesg -T | grep -i -E --color=yes '(ERROR|fail)' | tail
DRAW_A_LINE
}
UXEN_MAIN_VERSION=0
function CMS_UXEN_VERSION_CHECK()
{
echo -e "\n--------------- UXEN_VERSION Check ----------------"
UXEN_MAIN_VERSION=`cat /opt/uxen3/docs/VERSION`
}
function GET_XL_INFO()
{
echo -e "\n----------------- xl info(memory) --------------------"
xl info | grep -E "total_memory|free_memory"
DRAW_A_LINE
}
function VCPUS_RATIO_CHECK()
{
echo -e "\n------------ VCPUs Ration Check --------------"
cores=`sudo xl info | grep nr_cpus | awk -F ' ' '{ print $3 }'`
vcpus=`sudo xl li | sed '1d' | awk -F' ' '{ sum += $4; } END { print sum; }'`
vcpus_ratio=`echo "$vcpus $cores" | awk '{printf "%.2f \n", $1/$2}'`
echo -e "VCPUs 사용량(%) = $vcpus_ratio"
DRAW_A_LINE
}
function CHECK_BONDING()
{
echo -e "\n------------ Bonding Down Check --------------"
BONDNAME=("bond0" "bond1" "bond2" "bond3" "bond4" "bond5")
for arr_BOND in ${BONDNAME[*]}
do
echo -e "\033[41m"$arr_BOND"\033[0m"
cat /proc/net/bonding/$arr_BOND |sed 's/\(Slave Interface.*\)/\x1b[32m\1\x1b[0m/'|sed 's/\( up\)/\x1b[34m\1\x1b[0m/'|sed 's/\( down\)/\x1b[31m\1\x1b[0m/'|sed 's/\(1000\)/\x1b[36m\1\x1b[0m/'|sed 's/\(10000\)/\x1b[36m\1\x1b[0m/'
DRAW_A_LINE
done
}
function GET_BRIDGE()
{
echo -e "\n---------------- brctl show ------------------"
brctl show
DRAW_A_LINE
}
function CHECK_NFS()
{
echo -e "\n--------------- NFS Check ---------------"
nfsstat -m
DRAW_A_LINE
}
function CHECK_DF()
{
echo -e "\n---------------- df -Th ------------------"
df -Th
echo -e "\n---------------- df -i -------------------"
df -i
DRAW_A_LINE
}
LOG_HOME=/var/log
function REFINE_SYSLOG()
{
ENTIRE_SYSLOG=/tmp/entire_syslog
ls -r $LOG_HOME/syslog*.gz | xargs zcat > $ENTIRE_SYSLOG
sudo cat $LOG_HOME/syslog.1 >> $ENTIRE_SYSLOG
sudo cat $LOG_HOME/syslog >> $ENTIRE_SYSLOG
echo -e "\n\x1b[41m"SYSLOG"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire syslog"\x1b[0m---------------------\n"
tail $ENTIRE_SYSLOG | grep -Ev "CRON"
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_SYSLOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_syslog"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function REFINE_MESSAGES()
{
ENTIRE_MESSAGE_LOG=/tmp/entire_messages
ls -r $LOG_HOME/messages*.gz | xargs zcat > $ENTIRE_MESSAGE_LOG
sudo cat $LOG_HOME/messages.1 >> $ENTIRE_MESSAGE_LOG
sudo cat $LOG_HOME/messages >> $ENTIRE_MESSAGE_LOG
echo -e "\n\x1b[41m"MESSAGES"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire messages"\x1b[0m---------------------\n"
tail $ENTIRE_MESSAGE_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_MESSAGE_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_messages"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function REFINE_KERN_LOG()
{
ENTIRE_KERN_LOG=/tmp/entire_kern.log
ls -r $LOG_HOME/kern.log*.gz | xargs zcat > $ENTIRE_KERN_LOG
sudo cat $LOG_HOME/kern.log.1 >> $ENTIRE_KERN_LOG
sudo cat $LOG_HOME/kern.log >> $ENTIRE_KERN_LOG
echo -e "\n\x1b[41m"KERN"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire kernlog"\x1b[0m---------------------\n"
tail $ENTIRE_KERN_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_KERN_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_kern.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function REFINE_AUTH_LOG()
{
ENTIRE_AUTH_LOG=/tmp/entire_auth.log
ls -r $LOG_HOME/auth.log*.gz | xargs zcat > $ENTIRE_AUTH_LOG
sudo cat $LOG_HOME/auth.log.1 >> $ENTIRE_AUTH_LOG
sudo cat $LOG_HOME/auth.log >> $ENTIRE_AUTH_LOG
echo -e "\n\x1b[41m"AUTH"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire authlog"\x1b[0m---------------------\n"
tail $ENTIRE_AUTH_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_AUTH_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_auth.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function GET_SYSTEM_LOG()
{
REFINE_SYSLOG
REFINE_MESSAGES
REFINE_KERN_LOG
REFINE_AUTH_LOG
}
function GET_CMS_UXEN_LOG()
{
DEFAULT_UXEN3_API_LOG=/opt/uxen3/var/log/uxenapi.log*
DEFAULT_UWSGI_LOG=/opt/uxen3/var/log/uwsgi.log
ENTIRE_UXEN3_API_LOG=/tmp/entire_uxenapi.log
REFINED_UXEN3_API_LOG=/tmp/refined_uxenapi.log
REFINED_UWSGI_LOG=/tmp/uwsgi.log
ls -r $DEFAULT_UXEN3_API_LOG | xargs cat > $ENTIRE_UXEN3_API_LOG
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
tail $ENTIRE_UXEN3_API_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_UXEN3_API_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_uxenapi.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
echo -e "\n\x1b[45m"UWSGI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uwsgi"\x1b[0m---------------------\n"
tail $DEFAULT_UWSGI_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $DEFAULT_UWSGI_LOG | grep --color=yes -E "1.1 400" |grep --color=yes -E "2018"|grep --color=yes "Nov"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see $DEFAULT_UWSGI_LOG"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function GET_SUMMARY()
{
echo -e "\n"
ManagementIP=`sudo ifconfig | grep "inet addr:192.168." | awk -F ':' '{ print $2 }' | awk -F ' ' '{ print $1 }'`
SYSTEM_MANUFACTURER=`dmidecode -s system-manufacturer`
SYSTEM_PRODUCT_NAME=`dmidecode -s system-product-name`
PROCESSOR_VERSION=`dmidecode -s processor-version`
echo -e "\n---------------- 서버 정보 ------------------"
echo -e "$SYSTEM_MANUFACTURER $SYSTEM_PRODUCT_NAME\n"
echo -e "$SYSTEM_PRODUCT_NAME\n"
echo -e "$PROCESSOR_VERSION\n"
echo -e "\n\n호스트네임, UXEN 버전, 실행 중인 VM, 사용 IP"
echo "==================================================="
echo -e "`uname -n`, $UXEN_MAIN_VERSION, `sudo xl li | sed '1,2d' | wc -l`, $ManagementIP"
}
function MAIN()
{
GET_DATE
CHECK_PROCESS
UXEN_DSTAT
GET_VM_LIST
CMS_UXEN_VERSION_CHECK
GET_XL_INFO
VCPUS_RATIO_CHECK
CHECK_BONDING
CHECK_NFS
CHECK_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
GET_CMS_UXEN_LOG
GET_SUMMARY
}
MAIN
#!/bin/bash
#Hyun-gwan Seo
#Modified to Young-bin Cho [2018/11/02]
function DRAW_A_LINE()
{
echo -e "-----------------------------------------------"
}
function GET_DATE()
{
echo -e "\n------------------- date-------------------"
date
ntpq -p
}
function CHECK_MEMORY()
{
echo -e "\n-------------- Check memory --------------"
free -h
DRAW_A_LINE
}
function CHECK_PROCESS()
{
echo -e "\n-------------- Check Process --------------"
#process=("nginx" "uxen" "ntp")
process=("nginx" "pengx" "ntp") # YB uxen > pengx
for ((idx=0; idx < ${#process[@]}; idx++))
do
echo "${process[$idx]}"
echo -e "`ps aux | grep ${process[$idx]}`"
echo ""
done
DRAW_A_LINE
}
function RUN_DSTAT()
{
echo -e "\n-------------- dstat --------------"
#dstat -lcdngy 1 10
#dstat -nf 1 10
python2 /usr/bin/dstat -lcdngy 1 10 # YB error로 출력되지 않아 수정
python2 /usr/bin/dstat -nf 1 10
DRAW_A_LINE
}
function GET_VM_LIST()
{
echo -e "\n-------------- VM List Check --------------"
sudo xl li
DRAW_A_LINE
}
function DMESG_CHECK()
{
echo -e "\n-------------- Dmesg Check --------------"
#dmesg -T | grep -i --color=yes ERROR | tail
dmesg -T | grep -i -E --color=yes '(ERROR|fail)' | tail # YB ERROR 대소문자 구별 x, fail 추가
DRAW_A_LINE
}
UXEN_MAIN_VERSION=0
function UXEN_VERSION_CHECK() # YB version check function
{
echo -e "\n--------------- UXEN_VERSION Check ----------------"
UXEN_MAIN_VERSION=`cat /opt/pengx3/docs/VERSION`
}
:<<'END'
UXEN_MAIN_VERSION=0 # 전역 변수. 0으로 초기화
함.
# UXEN의 메인 버전을 확인하는 함수 (UXEN2인지 UXEN3인지 확인함)
function GET_UXEN_MAIN_VERSION()
{
if [[ -d /home/orchard/uxen || -d /home/orchard/uxen_new ]] # ||(OR)를 사용할 경우 세
미콜론을 붙이지 않는다.
then
UXEN_MAIN_VERSION="2" # 전역변수에 값을 할당할
때는 $를 붙이지 않는다.
elif [ -d /opt/uxen3 ]; then
UXEN_MAIN_VERSION="3" # 전역변수에 값을 할당할
때는 $를 붙이지 않는다.
fi
}
UXEN_DETAIL_VERSION=0 # 전역 변수. 0으로 초기화 함.
# UXEN의 세부 버전을 확인하는 함수
function GET_UXEN_DETAIL_VERSION()
{
GET_UXEN_MAIN_VERSION # GET_UXEN_MAIN_VERSION 함수에서 UXEN_MAIN_VERSION 값을 얻어온다.
echo -e "\n--------------- UXEN_VERSION Check ----------------"
if [[ $UXEN_MAIN_VERSION = "2" && -d /home/orchard/uxen ]]
then
UXEN_DETAIL_VERSION=`cat /home/orchard/uxen/docs/VERSION | sed '2d'` # uxen2 (Version number)
elif [[ $UXEN_MAIN_VERSION = "2" && -d /home/orchard/uxen_new ]]
then
UXEN_DETAIL_VERSION=`cat /home/orchard/uxen_new/docs/VERSION | sed '2d'` # uxen2 (Version number)
elif [[ $UXEN_MAIN_VERSION = "3" && -d /opt/uxen3 ]]
then
cat /opt/uxen3/docs/VERSION
UXEN_DETAIL_VERSION=`cat /opt/uxen3/docs/VERSION`
fi
echo $UXEN_DETAIL_VERSION # 버전 정보에 문자가 포함(i.e. 2.1 (rev584))되었기 때문에 return이 아닌 echo를 사용함.
}
END
# xl info 명령에서 메모리 정보를 가져오는 함수
function GET_XL_INFO()
{
echo -e "\n----------------- xl info(memory) --------------------"
xl info | grep -E "total_memory|free_memory"
DRAW_A_LINE
}
function VCPUS_RATIO_CHECK()
{
echo -e "\n------------ VCPUs Ration Check --------------"
cores=`sudo xl info | grep nr_cpus | awk -F ' ' '{ print $3 }'`
vcpus=`sudo xl li | sed '1d' | awk -F' ' '{ sum += $4; } END { print sum; }'`
#vcpus_ratio=`echo "scale=2; ($vcpus/$cores)*100" | bc`
vcpus_ratio=`echo "$vcpus $cores" | awk '{printf "%.2f \n", $1/$2}'`
echo -e "VCPUs 사용량(%) = $vcpus_ratio"
DRAW_A_LINE
}
#bonding check
function CHECK_BONDING() # YB Bonding Check function
{
echo -e "\n------------ Bonding Down Check --------------"
BONDNAME=("bond0" "bond1" "bond2" "bond3" "bond4" "bond5") # BONDNAME 배열에 값(bond0 ~ bond5) 저장
for arr_BOND in ${BONDNAME[*]} # 배열에 저장된 값을 한번씩 사용하는 반복문
do
echo -e "\033[41m"$arr_BOND"\033[0m"
cat /proc/net/bonding/$arr_BOND |sed 's/\(Slave Interface.*\)/\x1b[32m\1\x1b[0m/'|sed 's/\( up\)/\x1b[34m\1\x1b[0m/'|sed 's/\( down\)/\x1b[31m\1\x1b[0m/' |sed 's/\(1000\)/\x1b[36m\1\x1b[0m/'|sed 's/\(10000\)/\x1b[36m\1\x1b[0m/'
DRAW_A_LINE
done
}
:<<END
function CHECK_BONDING()
{
echo -e "\n------------ Bonding Down Check --------------"
grep --color=yes -r "down" /proc/net/bonding 2> /dev/null
DRAW_A_LINE
}
END
function GET_BRIDGE()
{
echo -e "\n---------------- brctl show ------------------"
brctl show
DRAW_A_LINE
}
:<<END
function CHECK_MULTI_PATH()
{
echo -e "\n--------------- Multi Path Check --------------"
sudo multipath -ll
DRAW_A_LINE
}
function CHECK_OCFS2()
{
echo -e "\n-------------- OCFS2 Check ---------------"
/etc/init.d/ocfs2 status
/etc/init.d/o2cb status
DRAW_A_LINE
}
END
function CHECK_NFS()
{
echo -e "\n--------------- NFS Check ---------------"
nfsstat -m
DRAW_A_LINE
}
function CHECK_DF()
{
echo -e "\n---------------- df -Th ------------------"
df -Th
echo -e "\n---------------- df -i -------------------"
df -i
DRAW_A_LINE
}
LOG_HOME=/var/log
# /var/log/syslog* 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_SYSLOG()
{
ENTIRE_SYSLOG=/tmp/entire_syslog
#REFINED_SYSLOG=/tmp/refined_syslog # YB refined변수는 사용하지 않는다.
ls -r $LOG_HOME/syslog*.gz | xargs zcat > $ENTIRE_SYSLOG
sudo cat $LOG_HOME/syslog.1 >> $ENTIRE_SYSLOG
sudo cat $LOG_HOME/syslog >> $ENTIRE_SYSLOG
# cron에 등록되면 자동으로 메일이 발송됨. 메일을 안쓰므로 no MTA installed 메시지는 무시해도 됨.
# 아래 필터에는 적용하지 않았지만 pdu 에러도 무시해도 됨.
#cat $ENTIRE_SYSLOG | grep -Ev "Connection from UDP|orchard|irqbalance|drop_caches|MTA|CRON|rsyslogd|normally" > $REFINED_SYSLOG # YB 저장하지 않고 바로 보여주게 한다. 또한 이렇게 로그를 저장하면 관련 로그에 문제가 생겼을 경우에 확인되지않으므로 문제의 로그를 찾는 형식으로 바꾼다.
echo -e "\n\x1b[41m"SYSLOG"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire syslog"\x1b[0m---------------------\n"
tail $ENTIRE_SYSLOG | grep -Ev "CRON"
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_SYSLOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_syslog"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
# /var/log/message* 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_MESSAGES()
{
ENTIRE_MESSAGE_LOG=/tmp/entire_messages
ls -r $LOG_HOME/messages*.gz | xargs zcat > $ENTIRE_MESSAGE_LOG
sudo cat $LOG_HOME/messages.1 >> $ENTIRE_MESSAGE_LOG
sudo cat $LOG_HOME/messages >> $ENTIRE_MESSAGE_LOG
#cat $ENTIRE_MESSAGE_LOG | grep -Ev "rsyslogd|forwarding|promiscuous|vif|IPv6|usb|USB|hub|entered" > /tmp/refined_messages
echo -e "\n\x1b[41m"MESSAGES"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire messages"\x1b[0m---------------------\n"
tail $ENTIRE_MESSAGE_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_MESSAGE_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_messages"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
# /var/log/kern.log* 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_KERN_LOG()
{
ENTIRE_KERN_LOG=/tmp/entire_kern.log
ls -r $LOG_HOME/kern.log*.gz | xargs zcat > $ENTIRE_KERN_LOG
sudo cat $LOG_HOME/kern.log.1 >> $ENTIRE_KERN_LOG
sudo cat $LOG_HOME/kern.log >> $ENTIRE_KERN_LOG
#cat $ENTIRE_KERN_LOG | grep -Ev "promiscuous|vif|IPv6|tg3|hub|usb|USB|entered|pdu" > /tmp/refined_kern.log
echo -e "\n\x1b[41m"KERN"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire kernlog"\x1b[0m---------------------\n"
tail $ENTIRE_KERN_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_KERN_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_kern.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
# /var/log/auth.log 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_AUTH_LOG()
{
ENTIRE_AUTH_LOG=/tmp/entire_auth.log
ls -r $LOG_HOME/auth.log*.gz | xargs zcat > $ENTIRE_AUTH_LOG
sudo cat $LOG_HOME/auth.log.1 >> $ENTIRE_AUTH_LOG
sudo cat $LOG_HOME/auth.log >> $ENTIRE_AUTH_LOG
#cat $ENTIRE_AUTH_LOG | grep -E "failure|FAILED" > /tmp/refined_auth.log # failure 또는 FAILED가 포함된 라인을 추출함
echo -e "\n\x1b[41m"AUTH"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire authlog"\x1b[0m---------------------\n"
tail $ENTIRE_AUTH_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_AUTH_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_auth.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function GET_SYSTEM_LOG()
{
REFINE_SYSLOG
REFINE_MESSAGES
REFINE_KERN_LOG
REFINE_AUTH_LOG
}
: ' uxenapi.log에서 불필요한 내용은 삭제하는 함수
최초 작성: 2017.02.06
TODO: ENTIRE_UXEN_API_LOG, REFINED_UXEN_API_LOG 파일을 만드는 함수를 각각 분리(?)
'
function REFINE_UXEN_LOG()
{
#DEFAULT_UXEN2_API_LOG=/home/orchard/uxen/var/log/uxenapi.log*
#DEFAULT_GUNICORN_LOG=/home/orchard/uxen/var/log/gunicorn-uxen-error.log
#DEFAULT_UXEN3_API_LOG=/opt/uxen3/var/log/uxenapi.log*
DEFAULT_UXEN3_API_LOG=/opt/pengx3/var/log/pengxapi.log* # YB web zone은 pengx3 이다.
#DEFAULT_UWSGI_LOG=/opt/uxen3/var/log/uwsgi.log
DEFAULT_UWSGI_LOG=/opt/pengx3/var/log/uwsgi.log
#SECOND_UXEN2_API_LOG=/var/www/uxen/var/log/uxenapi.log*
#SECOND_GUNICORN_LOG=/var/www/uxen/var/log/gunicorn-uxen-error.log
#ENTIRE_UXEN2_API_LOG=/tmp/entire_uxenapi.log # ENTIRE_UXEN2_API_LOG와 ENTIRE_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
ENTIRE_UXEN3_API_LOG=/tmp/entire_uxenapi.log
#REFINED_UXEN2_API_LOG=/tmp/refined_uxenapi.log # REFINED_UXEN2_API_LOG와 REFINED_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_UXEN3_API_LOG=/tmp/refined_uxenapi.log
#REFINED_GUNICORN_LOG=/tmp/refined_gunicorn-uxen-error.log
REFINED_UWSGI_LOG=/tmp/uwsgi.log
:<<END
if [[ $UXEN_MAIN_VERSION = "2" && -d /home/orchard/uxen2 ]] # uxen2에서 /home/orchard/uxen 디렉토리가 존재할 경우
then
echo -e "\n---------------- Refine $DEFAULT_UXEN2_API_LOG ------------------"
ls -r $DEFAULT_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG # uxenapi.log* 파일을 오름차순(시간) 1개로 합침
cat $ENTIRE_UXEN2_API_LOG | grep -Ev "models|viewsets|vmiface" > $REFINED_UXEN2_API_LOG # ENTIRE_UXEN2_API_LOG 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_UXEN2_API_LOG"
echo -e "\n---------------- Refine $DEFAULT_GUNICORN_LOG ------------------"
cat $DEFAULT_GUNICORN_LOG | grep -Ev "Starting|worker|Listening" > $REFINED_GUNICORN_LOG # gunicorn-uxen-error.log 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_GUNICORN_LOG"
elif [[ $UXEN_MAIN_VERSION = "2" && -d /var/www/uxen ]] # uxen2에서 /home/orchard/uxen_new 디렉토리가 존재할 경우
then
echo -e "\n---------------- Refine $SECOND_UXEN2_API_LOG ------------------"
ls -r $SECOND_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG # uxenapi.log* 파일을 오름차순(시간) 1개로 합침
cat $ENTIRE_UXEN2_API_LOG | grep -Ev "models|viewsets|vmiface" > $REFINED_UXEN2_API_LOG # ENTIRE_UXEN2_API_LOG 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_UXEN2_API_LOG"
echo -e "\n---------------- Refine $SECOND_GUNICORN_LOG ------------------"
cat $SECOND_GUNICORN_LOG | grep -Ev "Starting|worker|Listening" > $REFINED_GUNICORN_LOG # gunicorn-uxen-error.log 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_GUNICORN_LOG"
END
#elif [[ $UXEN_MAIN_VERSION = "3" && -d /opt/uxen3 ]] # uxen3에서 /opt/uxen3 디렉토리가 존재할 경우
#then
# echo -e "\n---------------- Refine $DEFAULT_UXEN3_API_LOG ------------------"
ls -r $DEFAULT_UXEN3_API_LOG | xargs cat > $ENTIRE_UXEN3_API_LOG # uxenapi.log* 파일을 오름차순(시간) 1개로 합침
#cat $ENTIRE_UXEN3_API_LOG | grep -Ev "models|viewsets|vmiface" > $REFINED_UXEN3_API_LOG # ENTIRE_UXEN3_API_LOG 파일에서 불필요한 내용을 제외함
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
tail $ENTIRE_UXEN3_API_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_UXEN3_API_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_uxenapi.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
echo -e "\n\x1b[45m"UWSGI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uwsgi"\x1b[0m---------------------\n"
tail $DEFAULT_UWSGI_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $DEFAULT_UWSGI_LOG | grep --color=yes -E "1.1 400" |grep --color=yes -E "2018"|grep --color=yes "Nov"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see $DEFAULT_UWSGI_LOG"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
#cat $DEFAULT_UWSGI_LOG | grep -Ev "generated" > $REFINED_UWSGI_LOG # uwsgi.log 파일에서 불필요한 내용을 제외함
#echo -e "Please see $REFINED_UWSGI_LOG"
#fi
}
: ' 역할: UXEN 로그를 가져오는 함수
세부 설명: MAIN 함수에서 좀 더 쉽게 이해할 수 있도록 REFINE_UXEN_LOG를 GET_UXEN_LOG로 wrapping 함.
최초 작성: 2017.02.06
'
function GET_UXEN_LOG()
{
#GET_UXEN_MAIN_VERSION # UXEN_MAIN_VERSION 변수에 uxen main version을 저장한다.
REFINE_UXEN_LOG # REFINE_UXEN_LOG 함수에서 UXEN_MAIN_VERSION 변수를 사용함.
}
: '
기능: 서버 점검 결과를 간단히 요약함.
TODO: ManagementIP를 가져오는 방법을 수정해야 함. mgmt ip의 네트워크 주소가 192.168.0인 경우도 있고 192.168.13인 경우, 172.17.237인 경우도 있다.
'
function GET_SUMMARY()
{
echo -e "\n"
ManagementIP=`sudo ifconfig | grep "inet addr:192.168." | awk -F ':' '{ print $2 }' | awk -F ' ' '{ print $1 }'`
SYSTEM_MANUFACTURER=`dmidecode -s system-manufacturer`
SYSTEM_PRODUCT_NAME=`dmidecode -s system-product-name`
PROCESSOR_VERSION=`dmidecode -s processor-version`
echo -e "\n---------------- 서버 정보 ------------------"
echo -e "$SYSTEM_MANUFACTURER $SYSTEM_PRODUCT_NAME\n"
echo -e "$SYSTEM_PRODUCT_NAME\n"
echo -e "$PROCESSOR_VERSION\n"
echo -e "\n\n호스트네임, UXEN 버전, 실행 중인 VM, 관리 IP"
echo "==================================================="
echo -e "`uname -n`, $UXEN_MAIN_VERSION, `sudo xl li | sed '1,2d' | wc -l`, $ManagementIP"
}
function MAIN()
{
GET_DATE
CHECK_PROCESS
RUN_DSTAT
GET_VM_LIST
UXEN_VERSION_CHECK
GET_XL_INFO
VCPUS_RATIO_CHECK
CHECK_BONDING
#CHECK_MULTI_PATH
#CHECK_OCFS2
CHECK_NFS
CHECK_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
GET_UXEN_LOG
GET_SUMMARY
}
MAIN
...@@ -7,6 +7,7 @@ function DRAW_A_LINE() ...@@ -7,6 +7,7 @@ function DRAW_A_LINE()
echo -e "-----------------------------------------------" echo -e "-----------------------------------------------"
} }
function GET_DATE() function GET_DATE()
{ {
echo -e "\n------------------- date-------------------" echo -e "\n------------------- date-------------------"
...@@ -26,8 +27,7 @@ function CHECK_PROCESS() ...@@ -26,8 +27,7 @@ function CHECK_PROCESS()
{ {
echo -e "\n-------------- Check Process --------------" echo -e "\n-------------- Check Process --------------"
#process=("nginx" "uxen" "ntp") process=("nginx" "pengx" "ntp")
process=("nginx" "pengx" "ntp") # YB uxen > pengx
for ((idx=0; idx < ${#process[@]}; idx++)) for ((idx=0; idx < ${#process[@]}; idx++))
do do
...@@ -38,17 +38,16 @@ function CHECK_PROCESS() ...@@ -38,17 +38,16 @@ function CHECK_PROCESS()
DRAW_A_LINE DRAW_A_LINE
} }
function RUN_DSTAT()
function UXEN_DSTAT()
{ {
echo -e "\n-------------- dstat --------------" echo -e "\n-------------- dstat --------------"
#dstat -lcdngy 1 10 python2 /usr/bin/dstat -lcdngy 1 10
#dstat -nf 1 10
python2 /usr/bin/dstat -lcdngy 1 10 # YB error로 출력되지 않아 수정
python2 /usr/bin/dstat -nf 1 10 python2 /usr/bin/dstat -nf 1 10
DRAW_A_LINE DRAW_A_LINE
} }
function GET_VM_LIST() function GET_VM_LIST()
{ {
echo -e "\n-------------- VM List Check --------------" echo -e "\n-------------- VM List Check --------------"
...@@ -56,67 +55,22 @@ function GET_VM_LIST() ...@@ -56,67 +55,22 @@ function GET_VM_LIST()
DRAW_A_LINE DRAW_A_LINE
} }
function DMESG_CHECK() function DMESG_CHECK()
{ {
echo -e "\n-------------- Dmesg Check --------------" echo -e "\n-------------- Dmesg Check --------------"
#dmesg -T | grep -i --color=yes ERROR | tail dmesg -T | grep -i -E --color=yes '(ERROR|fail)' | tail
dmesg -T | grep -i -E --color=yes '(ERROR|fail)' | tail # YB ERROR 대소문자 구별 x, fail 추가
DRAW_A_LINE DRAW_A_LINE
} }
UXEN_MAIN_VERSION=0
function UXEN_VERSION_CHECK() # YB version check function UXEN_MAIN_VERSION=0
function WEB_UXEN_VERSION_CHECK()
{ {
echo -e "\n--------------- UXEN_VERSION Check ----------------" echo -e "\n--------------- UXEN_VERSION Check ----------------"
UXEN_MAIN_VERSION=`cat /opt/pengx3/docs/VERSION` UXEN_MAIN_VERSION=`cat /opt/pengx3/docs/VERSION`
}
:<<'END'
UXEN_MAIN_VERSION=0 # 전역 변수. 0으로 초기화
함.
# UXEN의 메인 버전을 확인하는 함수 (UXEN2인지 UXEN3인지 확인함)
function GET_UXEN_MAIN_VERSION()
{
if [[ -d /home/orchard/uxen || -d /home/orchard/uxen_new ]] # ||(OR)를 사용할 경우 세
미콜론을 붙이지 않는다.
then
UXEN_MAIN_VERSION="2" # 전역변수에 값을 할당할
때는 $를 붙이지 않는다.
elif [ -d /opt/uxen3 ]; then
UXEN_MAIN_VERSION="3" # 전역변수에 값을 할당할
때는 $를 붙이지 않는다.
fi
}
UXEN_DETAIL_VERSION=0 # 전역 변수. 0으로 초기화 함.
# UXEN의 세부 버전을 확인하는 함수
function GET_UXEN_DETAIL_VERSION()
{
GET_UXEN_MAIN_VERSION # GET_UXEN_MAIN_VERSION 함수에서 UXEN_MAIN_VERSION 값을 얻어온다.
echo -e "\n--------------- UXEN_VERSION Check ----------------"
if [[ $UXEN_MAIN_VERSION = "2" && -d /home/orchard/uxen ]]
then
UXEN_DETAIL_VERSION=`cat /home/orchard/uxen/docs/VERSION | sed '2d'` # uxen2 (Version number)
elif [[ $UXEN_MAIN_VERSION = "2" && -d /home/orchard/uxen_new ]]
then
UXEN_DETAIL_VERSION=`cat /home/orchard/uxen_new/docs/VERSION | sed '2d'` # uxen2 (Version number)
elif [[ $UXEN_MAIN_VERSION = "3" && -d /opt/uxen3 ]]
then
cat /opt/uxen3/docs/VERSION
UXEN_DETAIL_VERSION=`cat /opt/uxen3/docs/VERSION`
fi
echo $UXEN_DETAIL_VERSION # 버전 정보에 문자가 포함(i.e. 2.1 (rev584))되었기 때문에 return이 아닌 echo를 사용함.
} }
END
# xl info 명령에서 메모리 정보를 가져오는 함수
function GET_XL_INFO() function GET_XL_INFO()
{ {
echo -e "\n----------------- xl info(memory) --------------------" echo -e "\n----------------- xl info(memory) --------------------"
...@@ -124,50 +78,33 @@ function GET_XL_INFO() ...@@ -124,50 +78,33 @@ function GET_XL_INFO()
DRAW_A_LINE DRAW_A_LINE
} }
function VCPUS_RATIO_CHECK() function VCPUS_RATIO_CHECK()
{ {
echo -e "\n------------ VCPUs Ration Check --------------" echo -e "\n------------ VCPUs Ration Check --------------"
cores=`sudo xl info | grep nr_cpus | awk -F ' ' '{ print $3 }'` cores=`sudo xl info | grep nr_cpus | awk -F ' ' '{ print $3 }'`
vcpus=`sudo xl li | sed '1d' | awk -F' ' '{ sum += $4; } END { print sum; }'` vcpus=`sudo xl li | sed '1d' | awk -F' ' '{ sum += $4; } END { print sum; }'`
#vcpus_ratio=`echo "scale=2; ($vcpus/$cores)*100" | bc`
vcpus_ratio=`echo "$vcpus $cores" | awk '{printf "%.2f \n", $1/$2}'` vcpus_ratio=`echo "$vcpus $cores" | awk '{printf "%.2f \n", $1/$2}'`
echo -e "VCPUs 사용량(%) = $vcpus_ratio" echo -e "VCPUs 사용량(%) = $vcpus_ratio"
DRAW_A_LINE DRAW_A_LINE
} }
function CHECK_BONDING()
#bonding check
function CHECK_BONDING() # YB Bonding Check function
{ {
echo -e "\n------------ Bonding Down Check --------------" echo -e "\n------------ Bonding Down Check --------------"
BONDNAME=("bond0" "bond1" "bond2" "bond3" "bond4" "bond5") # BONDNAME 배열에 값(bond0 ~ bond5) 저장 BONDNAME=("bond0" "bond1" "bond2" "bond3" "bond4" "bond5")
for arr_BOND in ${BONDNAME[*]}
for arr_BOND in ${BONDNAME[*]} # 배열에 저장된 값을 한번씩 사용하는 반복문
do do
echo -e "\033[41m"$arr_BOND"\033[0m" echo -e "\033[41m"$arr_BOND"\033[0m"
cat /proc/net/bonding/$arr_BOND |sed 's/\(Slave Interface.*\)/\x1b[32m\1\x1b[0m/'|sed 's/\( up\)/\x1b[34m\1\x1b[0m/'|sed 's/\( down\)/\x1b[31m\1\x1b[0m/' |sed 's/\(1000\)/\x1b[36m\1\x1b[0m/'|sed 's/\(10000\)/\x1b[36m\1\x1b[0m/' cat /proc/net/bonding/$arr_BOND |sed 's/\(Slave Interface.*\)/\x1b[32m\1\x1b[0m/'|sed 's/\( up\)/\x1b[34m\1\x1b[0m/'|sed 's/\( down\)/\x1b[31m\1\x1b[0m/'|sed 's/\(1000\)/\x1b[36m\1\x1b[0m/'|sed 's/\(10000\)/\x1b[36m\1\x1b[0m/'
DRAW_A_LINE DRAW_A_LINE
done done
} }
:<<END
function CHECK_BONDING()
{
echo -e "\n------------ Bonding Down Check --------------"
grep --color=yes -r "down" /proc/net/bonding 2> /dev/null
DRAW_A_LINE
}
END
function GET_BRIDGE() function GET_BRIDGE()
{ {
echo -e "\n---------------- brctl show ------------------" echo -e "\n---------------- brctl show ------------------"
...@@ -175,23 +112,6 @@ function GET_BRIDGE() ...@@ -175,23 +112,6 @@ function GET_BRIDGE()
DRAW_A_LINE DRAW_A_LINE
} }
:<<END
function CHECK_MULTI_PATH()
{
echo -e "\n--------------- Multi Path Check --------------"
sudo multipath -ll
DRAW_A_LINE
}
function CHECK_OCFS2()
{
echo -e "\n-------------- OCFS2 Check ---------------"
/etc/init.d/ocfs2 status
/etc/init.d/o2cb status
DRAW_A_LINE
}
END
function CHECK_NFS() function CHECK_NFS()
{ {
echo -e "\n--------------- NFS Check ---------------" echo -e "\n--------------- NFS Check ---------------"
...@@ -210,20 +130,14 @@ function CHECK_DF() ...@@ -210,20 +130,14 @@ function CHECK_DF()
LOG_HOME=/var/log LOG_HOME=/var/log
# /var/log/syslog* 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_SYSLOG() function REFINE_SYSLOG()
{ {
ENTIRE_SYSLOG=/tmp/entire_syslog ENTIRE_SYSLOG=/tmp/entire_syslog
#REFINED_SYSLOG=/tmp/refined_syslog # YB refined변수는 사용하지 않는다.
ls -r $LOG_HOME/syslog*.gz | xargs zcat > $ENTIRE_SYSLOG ls -r $LOG_HOME/syslog*.gz | xargs zcat > $ENTIRE_SYSLOG
sudo cat $LOG_HOME/syslog.1 >> $ENTIRE_SYSLOG sudo cat $LOG_HOME/syslog.1 >> $ENTIRE_SYSLOG
sudo cat $LOG_HOME/syslog >> $ENTIRE_SYSLOG sudo cat $LOG_HOME/syslog >> $ENTIRE_SYSLOG
# cron에 등록되면 자동으로 메일이 발송됨. 메일을 안쓰므로 no MTA installed 메시지는 무시해도 됨.
# 아래 필터에는 적용하지 않았지만 pdu 에러도 무시해도 됨.
#cat $ENTIRE_SYSLOG | grep -Ev "Connection from UDP|orchard|irqbalance|drop_caches|MTA|CRON|rsyslogd|normally" > $REFINED_SYSLOG # YB 저장하지 않고 바로 보여주게 한다. 또한 이렇게 로그를 저장하면 관련 로그에 문제가 생겼을 경우에 확인되지않으므로 문제의 로그를 찾는 형식으로 바꾼다.
echo -e "\n\x1b[41m"SYSLOG"\x1b[0m" echo -e "\n\x1b[41m"SYSLOG"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire syslog"\x1b[0m---------------------\n" echo -e "\n----------------\x1b[34m"entire syslog"\x1b[0m---------------------\n"
tail $ENTIRE_SYSLOG | grep -Ev "CRON" tail $ENTIRE_SYSLOG | grep -Ev "CRON"
...@@ -238,8 +152,6 @@ function REFINE_SYSLOG() ...@@ -238,8 +152,6 @@ function REFINE_SYSLOG()
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m" echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
} }
# /var/log/message* 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_MESSAGES() function REFINE_MESSAGES()
{ {
ENTIRE_MESSAGE_LOG=/tmp/entire_messages ENTIRE_MESSAGE_LOG=/tmp/entire_messages
...@@ -247,9 +159,6 @@ function REFINE_MESSAGES() ...@@ -247,9 +159,6 @@ function REFINE_MESSAGES()
ls -r $LOG_HOME/messages*.gz | xargs zcat > $ENTIRE_MESSAGE_LOG ls -r $LOG_HOME/messages*.gz | xargs zcat > $ENTIRE_MESSAGE_LOG
sudo cat $LOG_HOME/messages.1 >> $ENTIRE_MESSAGE_LOG sudo cat $LOG_HOME/messages.1 >> $ENTIRE_MESSAGE_LOG
sudo cat $LOG_HOME/messages >> $ENTIRE_MESSAGE_LOG sudo cat $LOG_HOME/messages >> $ENTIRE_MESSAGE_LOG
#cat $ENTIRE_MESSAGE_LOG | grep -Ev "rsyslogd|forwarding|promiscuous|vif|IPv6|usb|USB|hub|entered" > /tmp/refined_messages
echo -e "\n\x1b[41m"MESSAGES"\x1b[0m" echo -e "\n\x1b[41m"MESSAGES"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire messages"\x1b[0m---------------------\n" echo -e "\n----------------\x1b[34m"entire messages"\x1b[0m---------------------\n"
...@@ -266,7 +175,6 @@ function REFINE_MESSAGES() ...@@ -266,7 +175,6 @@ function REFINE_MESSAGES()
} }
# /var/log/kern.log* 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_KERN_LOG() function REFINE_KERN_LOG()
{ {
ENTIRE_KERN_LOG=/tmp/entire_kern.log ENTIRE_KERN_LOG=/tmp/entire_kern.log
...@@ -274,8 +182,6 @@ function REFINE_KERN_LOG() ...@@ -274,8 +182,6 @@ function REFINE_KERN_LOG()
ls -r $LOG_HOME/kern.log*.gz | xargs zcat > $ENTIRE_KERN_LOG ls -r $LOG_HOME/kern.log*.gz | xargs zcat > $ENTIRE_KERN_LOG
sudo cat $LOG_HOME/kern.log.1 >> $ENTIRE_KERN_LOG sudo cat $LOG_HOME/kern.log.1 >> $ENTIRE_KERN_LOG
sudo cat $LOG_HOME/kern.log >> $ENTIRE_KERN_LOG sudo cat $LOG_HOME/kern.log >> $ENTIRE_KERN_LOG
#cat $ENTIRE_KERN_LOG | grep -Ev "promiscuous|vif|IPv6|tg3|hub|usb|USB|entered|pdu" > /tmp/refined_kern.log
echo -e "\n\x1b[41m"KERN"\x1b[0m" echo -e "\n\x1b[41m"KERN"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire kernlog"\x1b[0m---------------------\n" echo -e "\n----------------\x1b[34m"entire kernlog"\x1b[0m---------------------\n"
...@@ -291,7 +197,6 @@ function REFINE_KERN_LOG() ...@@ -291,7 +197,6 @@ function REFINE_KERN_LOG()
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m" echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
} }
# /var/log/auth.log 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_AUTH_LOG() function REFINE_AUTH_LOG()
{ {
ENTIRE_AUTH_LOG=/tmp/entire_auth.log ENTIRE_AUTH_LOG=/tmp/entire_auth.log
...@@ -300,8 +205,6 @@ function REFINE_AUTH_LOG() ...@@ -300,8 +205,6 @@ function REFINE_AUTH_LOG()
sudo cat $LOG_HOME/auth.log.1 >> $ENTIRE_AUTH_LOG sudo cat $LOG_HOME/auth.log.1 >> $ENTIRE_AUTH_LOG
sudo cat $LOG_HOME/auth.log >> $ENTIRE_AUTH_LOG sudo cat $LOG_HOME/auth.log >> $ENTIRE_AUTH_LOG
#cat $ENTIRE_AUTH_LOG | grep -E "failure|FAILED" > /tmp/refined_auth.log # failure 또는 FAILED가 포함된 라인을 추출함
echo -e "\n\x1b[41m"AUTH"\x1b[0m" echo -e "\n\x1b[41m"AUTH"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire authlog"\x1b[0m---------------------\n" echo -e "\n----------------\x1b[34m"entire authlog"\x1b[0m---------------------\n"
tail $ENTIRE_AUTH_LOG tail $ENTIRE_AUTH_LOG
...@@ -324,58 +227,17 @@ function GET_SYSTEM_LOG() ...@@ -324,58 +227,17 @@ function GET_SYSTEM_LOG()
REFINE_AUTH_LOG REFINE_AUTH_LOG
} }
: ' uxenapi.log에서 불필요한 내용은 삭제하는 함수 function GET_WEB_UXEN_LOG()
최초 작성: 2017.02.06
TODO: ENTIRE_UXEN_API_LOG, REFINED_UXEN_API_LOG 파일을 만드는 함수를 각각 분리(?)
'
function REFINE_UXEN_LOG()
{ {
#DEFAULT_UXEN2_API_LOG=/home/orchard/uxen/var/log/uxenapi.log*
#DEFAULT_GUNICORN_LOG=/home/orchard/uxen/var/log/gunicorn-uxen-error.log
#DEFAULT_UXEN3_API_LOG=/opt/uxen3/var/log/uxenapi.log*
DEFAULT_UXEN3_API_LOG=/opt/pengx3/var/log/pengxapi.log* # YB web zone은 pengx3 이다. DEFAULT_UXEN3_API_LOG=/opt/pengx3/var/log/pengxapi.log* # YB web zone은 pengx3 이다.
#DEFAULT_UWSGI_LOG=/opt/uxen3/var/log/uwsgi.log
DEFAULT_UWSGI_LOG=/opt/pengx3/var/log/uwsgi.log DEFAULT_UWSGI_LOG=/opt/pengx3/var/log/uwsgi.log
#SECOND_UXEN2_API_LOG=/var/www/uxen/var/log/uxenapi.log*
#SECOND_GUNICORN_LOG=/var/www/uxen/var/log/gunicorn-uxen-error.log
#ENTIRE_UXEN2_API_LOG=/tmp/entire_uxenapi.log # ENTIRE_UXEN2_API_LOG와 ENTIRE_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
ENTIRE_UXEN3_API_LOG=/tmp/entire_uxenapi.log ENTIRE_UXEN3_API_LOG=/tmp/entire_uxenapi.log
#REFINED_UXEN2_API_LOG=/tmp/refined_uxenapi.log # REFINED_UXEN2_API_LOG와 REFINED_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_UXEN3_API_LOG=/tmp/refined_uxenapi.log REFINED_UXEN3_API_LOG=/tmp/refined_uxenapi.log
#REFINED_GUNICORN_LOG=/tmp/refined_gunicorn-uxen-error.log REFINED_UWSGI_LOG=/tmp/uwsgi.log
REFINED_UWSGI_LOG=/tmp/uwsgi.log
:<<END ls -r $DEFAULT_UXEN3_API_LOG | xargs cat > $ENTIRE_UXEN3_API_LOG
if [[ $UXEN_MAIN_VERSION = "2" && -d /home/orchard/uxen2 ]] # uxen2에서 /home/orchard/uxen 디렉토리가 존재할 경우
then
echo -e "\n---------------- Refine $DEFAULT_UXEN2_API_LOG ------------------"
ls -r $DEFAULT_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG # uxenapi.log* 파일을 오름차순(시간) 1개로 합침
cat $ENTIRE_UXEN2_API_LOG | grep -Ev "models|viewsets|vmiface" > $REFINED_UXEN2_API_LOG # ENTIRE_UXEN2_API_LOG 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_UXEN2_API_LOG"
echo -e "\n---------------- Refine $DEFAULT_GUNICORN_LOG ------------------"
cat $DEFAULT_GUNICORN_LOG | grep -Ev "Starting|worker|Listening" > $REFINED_GUNICORN_LOG # gunicorn-uxen-error.log 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_GUNICORN_LOG"
elif [[ $UXEN_MAIN_VERSION = "2" && -d /var/www/uxen ]] # uxen2에서 /home/orchard/uxen_new 디렉토리가 존재할 경우
then
echo -e "\n---------------- Refine $SECOND_UXEN2_API_LOG ------------------"
ls -r $SECOND_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG # uxenapi.log* 파일을 오름차순(시간) 1개로 합침
cat $ENTIRE_UXEN2_API_LOG | grep -Ev "models|viewsets|vmiface" > $REFINED_UXEN2_API_LOG # ENTIRE_UXEN2_API_LOG 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_UXEN2_API_LOG"
echo -e "\n---------------- Refine $SECOND_GUNICORN_LOG ------------------"
cat $SECOND_GUNICORN_LOG | grep -Ev "Starting|worker|Listening" > $REFINED_GUNICORN_LOG # gunicorn-uxen-error.log 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_GUNICORN_LOG"
END
#elif [[ $UXEN_MAIN_VERSION = "3" && -d /opt/uxen3 ]] # uxen3에서 /opt/uxen3 디렉토리가 존재할 경우
#then
# echo -e "\n---------------- Refine $DEFAULT_UXEN3_API_LOG ------------------"
ls -r $DEFAULT_UXEN3_API_LOG | xargs cat > $ENTIRE_UXEN3_API_LOG # uxenapi.log* 파일을 오름차순(시간) 1개로 합침
#cat $ENTIRE_UXEN3_API_LOG | grep -Ev "models|viewsets|vmiface" > $REFINED_UXEN3_API_LOG # ENTIRE_UXEN3_API_LOG 파일에서 불필요한 내용을 제외함
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m" echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n" echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
tail $ENTIRE_UXEN3_API_LOG tail $ENTIRE_UXEN3_API_LOG
...@@ -400,26 +262,8 @@ END ...@@ -400,26 +262,8 @@ END
echo -e "\nPlease see $DEFAULT_UWSGI_LOG" echo -e "\nPlease see $DEFAULT_UWSGI_LOG"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m" echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
#cat $DEFAULT_UWSGI_LOG | grep -Ev "generated" > $REFINED_UWSGI_LOG # uwsgi.log 파일에서 불필요한 내용을 제외함
#echo -e "Please see $REFINED_UWSGI_LOG"
#fi
}
: ' 역할: UXEN 로그를 가져오는 함수
세부 설명: MAIN 함수에서 좀 더 쉽게 이해할 수 있도록 REFINE_UXEN_LOG를 GET_UXEN_LOG로 wrapping 함.
최초 작성: 2017.02.06
'
function GET_UXEN_LOG()
{
#GET_UXEN_MAIN_VERSION # UXEN_MAIN_VERSION 변수에 uxen main version을 저장한다.
REFINE_UXEN_LOG # REFINE_UXEN_LOG 함수에서 UXEN_MAIN_VERSION 변수를 사용함.
} }
: '
기능: 서버 점검 결과를 간단히 요약함.
TODO: ManagementIP를 가져오는 방법을 수정해야 함. mgmt ip의 네트워크 주소가 192.168.0인 경우도 있고 192.168.13인 경우, 172.17.237인 경우도 있다.
'
function GET_SUMMARY() function GET_SUMMARY()
{ {
echo -e "\n" echo -e "\n"
...@@ -435,7 +279,7 @@ function GET_SUMMARY() ...@@ -435,7 +279,7 @@ function GET_SUMMARY()
echo -e "$PROCESSOR_VERSION\n" echo -e "$PROCESSOR_VERSION\n"
echo -e "\n\n호스트네임, UXEN 버전, 실행 중인 VM, 관리 IP" echo -e "\n\n호스트네임, UXEN 버전, 실행 중인 VM, 사용 IP"
echo "===================================================" echo "==================================================="
echo -e "`uname -n`, $UXEN_MAIN_VERSION, `sudo xl li | sed '1,2d' | wc -l`, $ManagementIP" echo -e "`uname -n`, $UXEN_MAIN_VERSION, `sudo xl li | sed '1,2d' | wc -l`, $ManagementIP"
} }
...@@ -444,14 +288,12 @@ function MAIN() ...@@ -444,14 +288,12 @@ function MAIN()
{ {
GET_DATE GET_DATE
CHECK_PROCESS CHECK_PROCESS
RUN_DSTAT UXEN_DSTAT
GET_VM_LIST GET_VM_LIST
UXEN_VERSION_CHECK WEB_UXEN_VERSION_CHECK
GET_XL_INFO GET_XL_INFO
VCPUS_RATIO_CHECK VCPUS_RATIO_CHECK
CHECK_BONDING CHECK_BONDING
#CHECK_MULTI_PATH
#CHECK_OCFS2
CHECK_NFS CHECK_NFS
CHECK_DF CHECK_DF
CHECK_MEMORY CHECK_MEMORY
...@@ -459,7 +301,7 @@ function MAIN() ...@@ -459,7 +301,7 @@ function MAIN()
DMESG_CHECK DMESG_CHECK
lastlog lastlog
GET_SYSTEM_LOG GET_SYSTEM_LOG
GET_UXEN_LOG GET_WEB_UXEN_LOG
GET_SUMMARY GET_SUMMARY
} }
......
#!/bin/bash
#Hyun-gwan Seo
#Modified to Young-bin Cho [2018/11/02]
function DRAW_A_LINE()
{
echo -e "-----------------------------------------------"
}
function GET_DATE()
{
echo -e "\n------------------- date-------------------"
date
ntpq -p
}
function CHECK_MEMORY()
{
echo -e "\n-------------- Check memory --------------"
free -h
DRAW_A_LINE
}
function CHECK_PROCESS()
{
echo -e "\n-------------- Check Process --------------"
#process=("nginx" "uxen" "ntp")
process=("nginx" "pengx" "ntp") # YB uxen > pengx
for ((idx=0; idx < ${#process[@]}; idx++))
do
echo "${process[$idx]}"
echo -e "`ps aux | grep ${process[$idx]}`"
echo ""
done
DRAW_A_LINE
}
function RUN_DSTAT()
{
echo -e "\n-------------- dstat --------------"
#dstat -lcdngy 1 10
#dstat -nf 1 10
python2 /usr/bin/dstat -lcdngy 1 10 # YB error로 출력되지 않아 수정
python2 /usr/bin/dstat -nf 1 10
DRAW_A_LINE
}
function GET_VM_LIST()
{
echo -e "\n-------------- VM List Check --------------"
sudo xl li
DRAW_A_LINE
}
function DMESG_CHECK()
{
echo -e "\n-------------- Dmesg Check --------------"
#dmesg -T | grep -i --color=yes ERROR | tail
dmesg -T | grep -i -E --color=yes '(ERROR|fail)' | tail # YB ERROR 대소문자 구별 x, fail 추가
DRAW_A_LINE
}
UXEN_MAIN_VERSION=0
function UXEN_VERSION_CHECK() # YB version check function
{
echo -e "\n--------------- UXEN_VERSION Check ----------------"
UXEN_MAIN_VERSION=`cat /opt/pengx3/docs/VERSION`
}
:<<'END'
UXEN_MAIN_VERSION=0 # 전역 변수. 0으로 초기화
함.
# UXEN의 메인 버전을 확인하는 함수 (UXEN2인지 UXEN3인지 확인함)
function GET_UXEN_MAIN_VERSION()
{
if [[ -d /home/orchard/uxen || -d /home/orchard/uxen_new ]] # ||(OR)를 사용할 경우 세
미콜론을 붙이지 않는다.
then
UXEN_MAIN_VERSION="2" # 전역변수에 값을 할당할
때는 $를 붙이지 않는다.
elif [ -d /opt/uxen3 ]; then
UXEN_MAIN_VERSION="3" # 전역변수에 값을 할당할
때는 $를 붙이지 않는다.
fi
}
UXEN_DETAIL_VERSION=0 # 전역 변수. 0으로 초기화 함.
# UXEN의 세부 버전을 확인하는 함수
function GET_UXEN_DETAIL_VERSION()
{
GET_UXEN_MAIN_VERSION # GET_UXEN_MAIN_VERSION 함수에서 UXEN_MAIN_VERSION 값을 얻어온다.
echo -e "\n--------------- UXEN_VERSION Check ----------------"
if [[ $UXEN_MAIN_VERSION = "2" && -d /home/orchard/uxen ]]
then
UXEN_DETAIL_VERSION=`cat /home/orchard/uxen/docs/VERSION | sed '2d'` # uxen2 (Version number)
elif [[ $UXEN_MAIN_VERSION = "2" && -d /home/orchard/uxen_new ]]
then
UXEN_DETAIL_VERSION=`cat /home/orchard/uxen_new/docs/VERSION | sed '2d'` # uxen2 (Version number)
elif [[ $UXEN_MAIN_VERSION = "3" && -d /opt/uxen3 ]]
then
cat /opt/uxen3/docs/VERSION
UXEN_DETAIL_VERSION=`cat /opt/uxen3/docs/VERSION`
fi
echo $UXEN_DETAIL_VERSION # 버전 정보에 문자가 포함(i.e. 2.1 (rev584))되었기 때문에 return이 아닌 echo를 사용함.
}
END
# xl info 명령에서 메모리 정보를 가져오는 함수
function GET_XL_INFO()
{
echo -e "\n----------------- xl info(memory) --------------------"
xl info | grep -E "total_memory|free_memory"
DRAW_A_LINE
}
function VCPUS_RATIO_CHECK()
{
echo -e "\n------------ VCPUs Ration Check --------------"
cores=`sudo xl info | grep nr_cpus | awk -F ' ' '{ print $3 }'`
vcpus=`sudo xl li | sed '1d' | awk -F' ' '{ sum += $4; } END { print sum; }'`
#vcpus_ratio=`echo "scale=2; ($vcpus/$cores)*100" | bc`
vcpus_ratio=`echo "$vcpus $cores" | awk '{printf "%.2f \n", $1/$2}'`
echo -e "VCPUs 사용량(%) = $vcpus_ratio"
DRAW_A_LINE
}
#bonding check
function CHECK_BONDING() # YB Bonding Check function
{
echo -e "\n------------ Bonding Down Check --------------"
BONDNAME=("bond0" "bond1" "bond2" "bond3" "bond4" "bond5") # BONDNAME 배열에 값(bond0 ~ bond5) 저장
for arr_BOND in ${BONDNAME[*]} # 배열에 저장된 값을 한번씩 사용하는 반복문
do
echo -e "\033[41m"$arr_BOND"\033[0m"
cat /proc/net/bonding/$arr_BOND |sed 's/\(Slave Interface.*\)/\x1b[32m\1\x1b[0m/'|sed 's/\( up\)/\x1b[34m\1\x1b[0m/'|sed 's/\( down\)/\x1b[31m\1\x1b[0m/' |sed 's/\(1000\)/\x1b[36m\1\x1b[0m/'|sed 's/\(10000\)/\x1b[36m\1\x1b[0m/'
DRAW_A_LINE
done
}
:<<END
function CHECK_BONDING()
{
echo -e "\n------------ Bonding Down Check --------------"
grep --color=yes -r "down" /proc/net/bonding 2> /dev/null
DRAW_A_LINE
}
END
function GET_BRIDGE()
{
echo -e "\n---------------- brctl show ------------------"
brctl show
DRAW_A_LINE
}
:<<END
function CHECK_MULTI_PATH()
{
echo -e "\n--------------- Multi Path Check --------------"
sudo multipath -ll
DRAW_A_LINE
}
function CHECK_OCFS2()
{
echo -e "\n-------------- OCFS2 Check ---------------"
/etc/init.d/ocfs2 status
/etc/init.d/o2cb status
DRAW_A_LINE
}
END
function CHECK_NFS()
{
echo -e "\n--------------- NFS Check ---------------"
nfsstat -m
DRAW_A_LINE
}
function CHECK_DF()
{
echo -e "\n---------------- df -Th ------------------"
df -Th
echo -e "\n---------------- df -i -------------------"
df -i
DRAW_A_LINE
}
LOG_HOME=/var/log
# /var/log/syslog* 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_SYSLOG()
{
ENTIRE_SYSLOG=/tmp/entire_syslog
#REFINED_SYSLOG=/tmp/refined_syslog # YB refined변수는 사용하지 않는다.
ls -r $LOG_HOME/syslog*.gz | xargs zcat > $ENTIRE_SYSLOG
sudo cat $LOG_HOME/syslog.1 >> $ENTIRE_SYSLOG
sudo cat $LOG_HOME/syslog >> $ENTIRE_SYSLOG
# cron에 등록되면 자동으로 메일이 발송됨. 메일을 안쓰므로 no MTA installed 메시지는 무시해도 됨.
# 아래 필터에는 적용하지 않았지만 pdu 에러도 무시해도 됨.
#cat $ENTIRE_SYSLOG | grep -Ev "Connection from UDP|orchard|irqbalance|drop_caches|MTA|CRON|rsyslogd|normally" > $REFINED_SYSLOG # YB 저장하지 않고 바로 보여주게 한다. 또한 이렇게 로그를 저장하면 관련 로그에 문제가 생겼을 경우에 확인되지않으므로 문제의 로그를 찾는 형식으로 바꾼다.
echo -e "\n\x1b[41m"SYSLOG"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire syslog"\x1b[0m---------------------\n"
tail $ENTIRE_SYSLOG | grep -Ev "CRON"
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_SYSLOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_syslog"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
# /var/log/message* 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_MESSAGES()
{
ENTIRE_MESSAGE_LOG=/tmp/entire_messages
ls -r $LOG_HOME/messages*.gz | xargs zcat > $ENTIRE_MESSAGE_LOG
sudo cat $LOG_HOME/messages.1 >> $ENTIRE_MESSAGE_LOG
sudo cat $LOG_HOME/messages >> $ENTIRE_MESSAGE_LOG
#cat $ENTIRE_MESSAGE_LOG | grep -Ev "rsyslogd|forwarding|promiscuous|vif|IPv6|usb|USB|hub|entered" > /tmp/refined_messages
echo -e "\n\x1b[41m"MESSAGES"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire messages"\x1b[0m---------------------\n"
tail $ENTIRE_MESSAGE_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_MESSAGE_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_messages"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
# /var/log/kern.log* 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_KERN_LOG()
{
ENTIRE_KERN_LOG=/tmp/entire_kern.log
ls -r $LOG_HOME/kern.log*.gz | xargs zcat > $ENTIRE_KERN_LOG
sudo cat $LOG_HOME/kern.log.1 >> $ENTIRE_KERN_LOG
sudo cat $LOG_HOME/kern.log >> $ENTIRE_KERN_LOG
#cat $ENTIRE_KERN_LOG | grep -Ev "promiscuous|vif|IPv6|tg3|hub|usb|USB|entered|pdu" > /tmp/refined_kern.log
echo -e "\n\x1b[41m"KERN"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire kernlog"\x1b[0m---------------------\n"
tail $ENTIRE_KERN_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_KERN_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_kern.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
# /var/log/auth.log 파일을 하나로 합치고 불필요한 로그를 삭제함.
function REFINE_AUTH_LOG()
{
ENTIRE_AUTH_LOG=/tmp/entire_auth.log
ls -r $LOG_HOME/auth.log*.gz | xargs zcat > $ENTIRE_AUTH_LOG
sudo cat $LOG_HOME/auth.log.1 >> $ENTIRE_AUTH_LOG
sudo cat $LOG_HOME/auth.log >> $ENTIRE_AUTH_LOG
#cat $ENTIRE_AUTH_LOG | grep -E "failure|FAILED" > /tmp/refined_auth.log # failure 또는 FAILED가 포함된 라인을 추출함
echo -e "\n\x1b[41m"AUTH"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire authlog"\x1b[0m---------------------\n"
tail $ENTIRE_AUTH_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_AUTH_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_auth.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function GET_SYSTEM_LOG()
{
REFINE_SYSLOG
REFINE_MESSAGES
REFINE_KERN_LOG
REFINE_AUTH_LOG
}
: ' uxenapi.log에서 불필요한 내용은 삭제하는 함수
최초 작성: 2017.02.06
TODO: ENTIRE_UXEN_API_LOG, REFINED_UXEN_API_LOG 파일을 만드는 함수를 각각 분리(?)
'
function REFINE_UXEN_LOG()
{
#DEFAULT_UXEN2_API_LOG=/home/orchard/uxen/var/log/uxenapi.log*
#DEFAULT_GUNICORN_LOG=/home/orchard/uxen/var/log/gunicorn-uxen-error.log
#DEFAULT_UXEN3_API_LOG=/opt/uxen3/var/log/uxenapi.log*
DEFAULT_UXEN3_API_LOG=/opt/pengx3/var/log/pengxapi.log* # YB web zone은 pengx3 이다.
#DEFAULT_UWSGI_LOG=/opt/uxen3/var/log/uwsgi.log
DEFAULT_UWSGI_LOG=/opt/pengx3/var/log/uwsgi.log
#SECOND_UXEN2_API_LOG=/var/www/uxen/var/log/uxenapi.log*
#SECOND_GUNICORN_LOG=/var/www/uxen/var/log/gunicorn-uxen-error.log
#ENTIRE_UXEN2_API_LOG=/tmp/entire_uxenapi.log # ENTIRE_UXEN2_API_LOG와 ENTIRE_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
ENTIRE_UXEN3_API_LOG=/tmp/entire_uxenapi.log
#REFINED_UXEN2_API_LOG=/tmp/refined_uxenapi.log # REFINED_UXEN2_API_LOG와 REFINED_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_UXEN3_API_LOG=/tmp/refined_uxenapi.log
#REFINED_GUNICORN_LOG=/tmp/refined_gunicorn-uxen-error.log
REFINED_UWSGI_LOG=/tmp/uwsgi.log
:<<END
if [[ $UXEN_MAIN_VERSION = "2" && -d /home/orchard/uxen2 ]] # uxen2에서 /home/orchard/uxen 디렉토리가 존재할 경우
then
echo -e "\n---------------- Refine $DEFAULT_UXEN2_API_LOG ------------------"
ls -r $DEFAULT_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG # uxenapi.log* 파일을 오름차순(시간) 1개로 합침
cat $ENTIRE_UXEN2_API_LOG | grep -Ev "models|viewsets|vmiface" > $REFINED_UXEN2_API_LOG # ENTIRE_UXEN2_API_LOG 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_UXEN2_API_LOG"
echo -e "\n---------------- Refine $DEFAULT_GUNICORN_LOG ------------------"
cat $DEFAULT_GUNICORN_LOG | grep -Ev "Starting|worker|Listening" > $REFINED_GUNICORN_LOG # gunicorn-uxen-error.log 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_GUNICORN_LOG"
elif [[ $UXEN_MAIN_VERSION = "2" && -d /var/www/uxen ]] # uxen2에서 /home/orchard/uxen_new 디렉토리가 존재할 경우
then
echo -e "\n---------------- Refine $SECOND_UXEN2_API_LOG ------------------"
ls -r $SECOND_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG # uxenapi.log* 파일을 오름차순(시간) 1개로 합침
cat $ENTIRE_UXEN2_API_LOG | grep -Ev "models|viewsets|vmiface" > $REFINED_UXEN2_API_LOG # ENTIRE_UXEN2_API_LOG 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_UXEN2_API_LOG"
echo -e "\n---------------- Refine $SECOND_GUNICORN_LOG ------------------"
cat $SECOND_GUNICORN_LOG | grep -Ev "Starting|worker|Listening" > $REFINED_GUNICORN_LOG # gunicorn-uxen-error.log 파일에서 불필요한 내용을 제외함
echo -e "Please see $REFINED_GUNICORN_LOG"
END
#elif [[ $UXEN_MAIN_VERSION = "3" && -d /opt/uxen3 ]] # uxen3에서 /opt/uxen3 디렉토리가 존재할 경우
#then
# echo -e "\n---------------- Refine $DEFAULT_UXEN3_API_LOG ------------------"
ls -r $DEFAULT_UXEN3_API_LOG | xargs cat > $ENTIRE_UXEN3_API_LOG # uxenapi.log* 파일을 오름차순(시간) 1개로 합침
#cat $ENTIRE_UXEN3_API_LOG | grep -Ev "models|viewsets|vmiface" > $REFINED_UXEN3_API_LOG # ENTIRE_UXEN3_API_LOG 파일에서 불필요한 내용을 제외함
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
tail $ENTIRE_UXEN3_API_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_UXEN3_API_LOG | grep --color=yes -E "error|fail|failure"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/entire_uxenapi.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
echo -e "\n\x1b[45m"UWSGI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uwsgi"\x1b[0m---------------------\n"
tail $DEFAULT_UWSGI_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $DEFAULT_UWSGI_LOG | grep --color=yes -E "1.1 400" |grep --color=yes -E "2018"|grep --color=yes "Nov"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see $DEFAULT_UWSGI_LOG"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
#cat $DEFAULT_UWSGI_LOG | grep -Ev "generated" > $REFINED_UWSGI_LOG # uwsgi.log 파일에서 불필요한 내용을 제외함
#echo -e "Please see $REFINED_UWSGI_LOG"
#fi
}
: ' 역할: UXEN 로그를 가져오는 함수
세부 설명: MAIN 함수에서 좀 더 쉽게 이해할 수 있도록 REFINE_UXEN_LOG를 GET_UXEN_LOG로 wrapping 함.
최초 작성: 2017.02.06
'
function GET_UXEN_LOG()
{
#GET_UXEN_MAIN_VERSION # UXEN_MAIN_VERSION 변수에 uxen main version을 저장한다.
REFINE_UXEN_LOG # REFINE_UXEN_LOG 함수에서 UXEN_MAIN_VERSION 변수를 사용함.
}
: '
기능: 서버 점검 결과를 간단히 요약함.
TODO: ManagementIP를 가져오는 방법을 수정해야 함. mgmt ip의 네트워크 주소가 192.168.0인 경우도 있고 192.168.13인 경우, 172.17.237인 경우도 있다.
'
function GET_SUMMARY()
{
echo -e "\n"
ManagementIP=`sudo ifconfig | grep "inet addr:192.168." | awk -F ':' '{ print $2 }' | awk -F ' ' '{ print $1 }'`
SYSTEM_MANUFACTURER=`dmidecode -s system-manufacturer`
SYSTEM_PRODUCT_NAME=`dmidecode -s system-product-name`
PROCESSOR_VERSION=`dmidecode -s processor-version`
echo -e "\n---------------- 서버 정보 ------------------"
echo -e "$SYSTEM_MANUFACTURER $SYSTEM_PRODUCT_NAME\n"
echo -e "$SYSTEM_PRODUCT_NAME\n"
echo -e "$PROCESSOR_VERSION\n"
echo -e "\n\n호스트네임, UXEN 버전, 실행 중인 VM, 관리 IP"
echo "==================================================="
echo -e "`uname -n`, $UXEN_MAIN_VERSION, `sudo xl li | sed '1,2d' | wc -l`, $ManagementIP"
}
function MAIN()
{
GET_DATE
CHECK_PROCESS
RUN_DSTAT
GET_VM_LIST
UXEN_VERSION_CHECK
GET_XL_INFO
VCPUS_RATIO_CHECK
CHECK_BONDING
#CHECK_MULTI_PATH
#CHECK_OCFS2
CHECK_NFS
CHECK_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
GET_UXEN_LOG
GET_SUMMARY
}
MAIN
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment