Commit f61256f7 by jajapi

add Integration script

parent 0d20eb19
No preview for this file type
#!/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 KPF_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 CHECK_PROCESS()
{
echo -e "\n-------------- Check Process --------------"
process=("nginx" "uxen" "ntp")
for ((idx=0; idx < ${#process[@]}; idx++))
do
echo "${process[$idx]}"
echo -e "`ps aux | grep ${process[$idx]}`"
echo ""
done
DRAW_A_LINE
}
function KPF_RUN_DSTAT()
{
echo -e "\n-------------- dstat --------------"
dstat -lcdngy 1 10
dstat -nf 1 10
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()
{
UXEN_MAIN_VERSION=`cat /opt/uxen3/docs/VERSION`
}
function WEB_UXEN_VERSION_CHECK()
{
UXEN_MAIN_VERSION=`cat /opt/pengx3/docs/VERSION`
}
function KPF_VERSION_CHECK()
{
UXEN_MAIN_VERSION=`cat /home/orchard/uxen_new/docs/VERSION`
}
function KPF_LOCAL_VERSION_CHECK()
{
UXEN_MAIN_VERSION=`cat /home/orchard/uxen/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_MULTI_PATH()
{
echo -e "\n--------------- Multi Path Check --------------"
sudo multipath -ll |sed 's/\(active\)/\x1b[34m\1\x1b[0m/'
DRAW_A_LINE
}
function CHECK_OCFS2()
{
echo -e "\n-------------- OCFS2 Check ---------------"
/etc/init.d/ocfs2 status
/etc/init.d/o2cb status |sed 's/\(Online\)/\x1b[34m\1\x1b[0m/'|sed 's/\(Active\)/\x1b[34m\1\x1b[0m/'
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"
grep -Ev "CRON" $ENTIRE_SYSLOG |tail
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_WEB_UXEN_LOG()
{
DEFAULT_UXEN3_API_LOG=/opt/pengx3/var/log/pengxapi.log* # YB web zone은 pengx3 이다.
DEFAULT_UWSGI_LOG=/opt/pengx3/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 KPF_UXEN_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의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_UXEN2_API_LOG=/tmp/refined_uxenapi.log # REFINED_UXEN2_API_LOG와 REFINED_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_GUNICORN_LOG=/tmp/refined_gunicorn-uxen-error.log
ls -r $SECOND_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG
cat $ENTIRE_UXEN2_API_LOG | grep -E "error|fail|failure"
echo -e "\n---------------- Refine $SECOND_GUNICORN_LOG ------------------"
cat $SECOND_GUNICORN_LOG | grep -Ev " Starting|worker|Listening"
echo -e "Please see $REFINED_GUNICORN_LOG"
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
tail $ENTIRE_UXEN2_API_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_UXEN2_API_LOG | grep -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"GUNICORN"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire gunicorn"\x1b[0m---------------------\n"
tail $SECOND_GUNICORN_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $SECOND_GUNICORN_LOG | grep -Ev " Starting|worker|Listening"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/refined_gunicorn-uxen-error.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function KPF_LOCAL_UXEN_LOG()
{
SECOND_UXEN2_API_LOG=/home/orchard/uxen/var/log/uxenapi.log*
SECOND_GUNICORN_LOG=/home/orchard/uxen/var/log/gunicorn-uxen-error.log
ENTIRE_UXEN2_API_LOG=/tmp/entire_uxenapi.log # ENTIRE_UXEN2_API_LOG와 ENTIRE_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_UXEN2_API_LOG=/tmp/refined_uxenapi.log # REFINED_UXEN2_API_LOG와 REFINED_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_GUNICORN_LOG=/tmp/refined_gunicorn-uxen-error.log
ls -r $SECOND_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG
cat $ENTIRE_UXEN2_API_LOG | grep -E "error|fail|failure"
echo -e "\n---------------- Refine $SECOND_GUNICORN_LOG ------------------"
cat $SECOND_GUNICORN_LOG | grep -Ev " Starting|worker|Listening"
echo -e "Please see $REFINED_GUNICORN_LOG"
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
tail $ENTIRE_UXEN2_API_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_UXEN2_API_LOG | grep -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"GUNICORN"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire gunicorn"\x1b[0m---------------------\n"
tail $SECOND_GUNICORN_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $SECOND_GUNICORN_LOG | grep -Ev " Starting|worker|Listening"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/refined_gunicorn-uxen-error.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 CMS_MAIN()
{
GET_DATE
CMS_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
}
function WEB_MAIN()
{
GET_DATE
WEB_CHECK_PROCESS
UXEN_DSTAT
GET_VM_LIST
WEB_UXEN_VERSION_CHECK
GET_XL_INFO
VCPUS_RATIO_CHECK
CHECK_BONDING
CHECK_NFS
CHECK_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
GET_WEB_UXEN_LOG
GET_SUMMARY
}
function KPF_MAIN()
{
GET_DATE
KPF_CHECK_PROCESS
KPF_RUN_DSTAT
GET_VM_LIST
KPF_VERSION_CHECK
GET_XL_INFO
VCPUS_RATIO_CHECK
CHECK_BONDING
CHECK_MULTI_PATH
CHECK_OCFS2
CHECK_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
KPF_UXEN_LOG
GET_SUMMARY
}
function KPF_LOCAL_MAIN()
{
GET_DATE
KPF_CHECK_PROCESS
KPF_RUN_DSTAT
GET_VM_LIST
KPF_LOCAL_VERSION_CHECK
GET_XL_INFO
VCPUS_RATIO_CHECK
CHECK_BONDING
CHECK_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
KPF_LOCAL_UXEN_LOG
GET_SUMMARY
}
if[-e /opt/uxen3]
then
CMS_MAIN
elif[-e /opt/pengx3]
WEB_MAIN
elif[-e /home/orchard/uxen_new]
KPF_MAIN()
else
KPF_LOCAL_MAIN
if
#!/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 WEB_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 WEB_UXEN_VERSION_CHECK()
{
UXEN_MAIN_VERSION=`cat /opt/pengx3/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"
grep -Ev "CRON" $ENTIRE_SYSLOG | tail
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_WEB_UXEN_LOG()
{
DEFAULT_UXEN3_API_LOG=/opt/pengx3/var/log/pengxapi.log* # YB web zone은 pengx3 이다.
DEFAULT_UWSGI_LOG=/opt/pengx3/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
WEB_CHECK_PROCESS
UXEN_DSTAT
GET_VM_LIST
WEB_UXEN_VERSION_CHECK
GET_XL_INFO
VCPUS_RATIO_CHECK
CHECK_BONDING
CHECK_NFS
CHECK_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
GET_WEB_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 KPF_CHECK_PROCESS()
{
echo -e "\n-------------- Check Process --------------"
process=("nginx" "uxen" "ntp")
for ((idx=0; idx < ${#process[@]}; idx++))
do
echo "${process[$idx]}"
echo -e "`ps aux | grep ${process[$idx]}`"
echo ""
done
DRAW_A_LINE
}
function KPF_RUN_DSTAT()
{
echo -e "\n-------------- dstat --------------"
dstat -lcdngy 1 10
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 KPF_VERSION_CHECK()
{
UXEN_MAIN_VERSION=`cat /home/orchard/uxen_new/docs/VERSION`
}
# 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
}
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_MULTI_PATH()
{
echo -e "\n--------------- Multi Path Check --------------"
sudo multipath -ll |sed 's/\(active\)/\x1b[34m\1\x1b[0m/'
DRAW_A_LINE
}
function CHECK_OCFS2()
{
echo -e "\n-------------- OCFS2 Check ---------------"
/etc/init.d/ocfs2 status
/etc/init.d/o2cb status |sed 's/\(Online\)/\x1b[34m\1\x1b[0m/'|sed 's/\(Active\)/\x1b[34m\1\x1b[0m/'
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
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"
grep -Ev "CRON" $ENTIRE_SYSLOG |tail
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
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
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
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 KPF_UXEN_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의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_UXEN2_API_LOG=/tmp/refined_uxenapi.log # REFINED_UXEN2_API_LOG와 REFINED_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_GUNICORN_LOG=/tmp/refined_gunicorn-uxen-error.log
ls -r $SECOND_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG
cat $ENTIRE_UXEN2_API_LOG | grep -E "error|fail|failure"
echo -e "\n---------------- Refine $SECOND_GUNICORN_LOG ------------------"
cat $SECOND_GUNICORN_LOG | grep -Ev " Starting|worker|Listening"
echo -e "Please see $REFINED_GUNICORN_LOG"
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
tail $ENTIRE_UXEN2_API_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_UXEN2_API_LOG | grep -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"GUNICORN"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire gunicorn"\x1b[0m---------------------\n"
tail $SECOND_GUNICORN_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $SECOND_GUNICORN_LOG | grep -Ev " Starting|worker|Listening"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/refined_gunicorn-uxen-error.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function GET_UXEN_LOG()
{
KPF_UXEN_LOG # REFINE_UXEN_LOG 함수에서 UXEN_MAIN_VERSION 변수를 사용함.
}
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
KPF_CHECK_PROCESS
KPF_RUN_DSTAT
GET_VM_LIST
KPF_VERSION_CHECK
GET_XL_INFO
VCPUS_RATIO_CHECK
CHECK_BONDING
CHECK_MULTI_PATH
CHECK_OCFS2
CHECK_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
GET_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 KPF_CHECK_PROCESS()
{
echo -e "\n-------------- Check Process --------------"
process=("nginx" "uxen" "ntp")
for ((idx=0; idx < ${#process[@]}; idx++))
do
echo "${process[$idx]}"
echo -e "`ps aux | grep ${process[$idx]}`"
echo ""
done
DRAW_A_LINE
}
function KPF_RUN_DSTAT()
{
echo -e "\n-------------- dstat --------------"
dstat -lcdngy 1 10
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 KPF_LOCAL_VERSION_CHECK()
{
UXEN_MAIN_VERSION=`cat /home/orchard/uxen/docs/VERSION`
}
# 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 "$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_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
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"
grep -Ev "CRON" $ENTIRE_SYSLOG |tail
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
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
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
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 KPF_LOCAL_UXEN_LOG()
{
SECOND_UXEN2_API_LOG=/home/orchard/uxen/var/log/uxenapi.log*
SECOND_GUNICORN_LOG=/home/orchard/uxen/var/log/gunicorn-uxen-error.log
ENTIRE_UXEN2_API_LOG=/tmp/entire_uxenapi.log # ENTIRE_UXEN2_API_LOG와 ENTIRE_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_UXEN2_API_LOG=/tmp/refined_uxenapi.log # REFINED_UXEN2_API_LOG와 REFINED_UXEN3_API_LOG의 경로는 같지만 직관적으로 이해하기 쉽도록 변수를 별도로 선언함
REFINED_GUNICORN_LOG=/tmp/refined_gunicorn-uxen-error.log
ls -r $SECOND_UXEN2_API_LOG | xargs cat > $ENTIRE_UXEN2_API_LOG
cat $ENTIRE_UXEN2_API_LOG | grep -E "error|fail|failure"
echo -e "\n---------------- Refine $SECOND_GUNICORN_LOG ------------------"
cat $SECOND_GUNICORN_LOG | grep -Ev " Starting|worker|Listening"
echo -e "Please see $REFINED_GUNICORN_LOG"
echo -e "\n\x1b[45m"UXENAPI"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire uxenapi"\x1b[0m---------------------\n"
tail $ENTIRE_UXEN2_API_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $ENTIRE_UXEN2_API_LOG | grep -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"GUNICORN"\x1b[0m"
echo -e "\n----------------\x1b[34m"entire gunicorn"\x1b[0m---------------------\n"
tail $SECOND_GUNICORN_LOG
echo -e "\n----------------\x1b[34m"error fail log"\x1b[0m--------------------\n"
cat $SECOND_GUNICORN_LOG | grep -Ev " Starting|worker|Listening"
echo -e "\n----------------\x1b[34m"detail log"\x1b[0m------------------------\n"
echo -e "\nPlease see /tmp/refined_gunicorn-uxen-error.log"
echo -e "\n\x1b[31m"-------------------------------------------------------------------------------------------"\x1b[0m"
}
function GET_UXEN_LOG()
{
KPF_LOCAL_UXEN_LOG # REFINE_UXEN_LOG 함수에서 UXEN_MAIN_VERSION 변수를 사용함.
}
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
KPF_CHECK_PROCESS
KPF_RUN_DSTAT
GET_VM_LIST
KPF_LOCAL_VERSION_CHECK
GET_XL_INFO
VCPUS_RATIO_CHECK
CHECK_BONDING
CHECK_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
GET_UXEN_LOG
GET_SUMMARY
}
MAIN
...@@ -80,8 +80,6 @@ function VCPUS_RATIO_CHECK() ...@@ -80,8 +80,6 @@ function VCPUS_RATIO_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
......
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