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
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