Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
orchard
/
CSCS
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ae323133
authored
Nov 08, 2018
by
jajapi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add kpflocalscript
parent
2e4f2d39
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
318 additions
and
0 deletions
GuestPM/kpf_local/kpf_local_check.sh
GuestPM/kpf_local/kpf_local_check.sh
0 → 100644
View file @
ae323133
#!/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
"
\0
33[41m"
$arr_BOND
"
\0
33[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\x
1b[41m"
SYSLOG
"
\x
1b[0m"
echo
-e
"
\n
----------------
\x
1b[34m"
entire syslog
"
\x
1b[0m---------------------
\n
"
grep
-Ev
"CRON"
$ENTIRE_SYSLOG
|tail
echo
-e
"
\n
----------------
\x
1b[34m"
error fail log
"
\x
1b[0m--------------------
\n
"
cat
$ENTIRE_SYSLOG
|
grep
--color
=
yes
-E
"error|fail|failure"
echo
-e
"
\n
----------------
\x
1b[34m"
detail log
"
\x
1b[0m------------------------
\n
"
echo
-e
"
\n
Please see /tmp/entire_syslog"
echo
-e
"
\n\x
1b[31m"
-------------------------------------------------------------------------------------------
"
\x
1b[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\x
1b[41m"
MESSAGES
"
\x
1b[0m"
echo
-e
"
\n
----------------
\x
1b[34m"
entire messages
"
\x
1b[0m---------------------
\n
"
tail
$ENTIRE_MESSAGE_LOG
echo
-e
"
\n
----------------
\x
1b[34m"
error fail log
"
\x
1b[0m--------------------
\n
"
cat
$ENTIRE_MESSAGE_LOG
|
grep
--color
=
yes
-E
"error|fail|failure"
echo
-e
"
\n
----------------
\x
1b[34m"
detail log
"
\x
1b[0m------------------------
\n
"
echo
-e
"
\n
Please see /tmp/entire_messages"
echo
-e
"
\n\x
1b[31m"
-------------------------------------------------------------------------------------------
"
\x
1b[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\x
1b[41m"
KERN
"
\x
1b[0m"
echo
-e
"
\n
----------------
\x
1b[34m"
entire kernlog
"
\x
1b[0m---------------------
\n
"
tail
$ENTIRE_KERN_LOG
echo
-e
"
\n
----------------
\x
1b[34m"
error fail log
"
\x
1b[0m--------------------
\n
"
cat
$ENTIRE_KERN_LOG
|
grep
--color
=
yes
-E
"error|fail|failure"
echo
-e
"
\n
----------------
\x
1b[34m"
detail log
"
\x
1b[0m------------------------
\n
"
echo
-e
"
\n
Please see /tmp/entire_kern.log"
echo
-e
"
\n\x
1b[31m"
-------------------------------------------------------------------------------------------
"
\x
1b[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\x
1b[41m"
AUTH
"
\x
1b[0m"
echo
-e
"
\n
----------------
\x
1b[34m"
entire authlog
"
\x
1b[0m---------------------
\n
"
tail
$ENTIRE_AUTH_LOG
echo
-e
"
\n
----------------
\x
1b[34m"
error fail log
"
\x
1b[0m--------------------
\n
"
cat
$ENTIRE_AUTH_LOG
|
grep
--color
=
yes
-E
"error|fail|failure"
echo
-e
"
\n
----------------
\x
1b[34m"
detail log
"
\x
1b[0m------------------------
\n
"
echo
-e
"
\n
Please see /tmp/entire_auth.log"
echo
-e
"
\n\x
1b[31m"
-------------------------------------------------------------------------------------------
"
\x
1b[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\x
1b[45m"
UXENAPI
"
\x
1b[0m"
echo
-e
"
\n
----------------
\x
1b[34m"
entire uxenapi
"
\x
1b[0m---------------------
\n
"
tail
$ENTIRE_UXEN2_API_LOG
echo
-e
"
\n
----------------
\x
1b[34m"
error fail log
"
\x
1b[0m--------------------
\n
"
cat
$ENTIRE_UXEN2_API_LOG
|
grep
-E
"error|fail|failure"
echo
-e
"
\n
----------------
\x
1b[34m"
detail log
"
\x
1b[0m------------------------
\n
"
echo
-e
"
\n
Please see /tmp/entire_uxenapi.log"
echo
-e
"
\n\x
1b[31m"
-------------------------------------------------------------------------------------------
"
\x
1b[0m"
echo
-e
"
\n\x
1b[45m"
GUNICORN
"
\x
1b[0m"
echo
-e
"
\n
----------------
\x
1b[34m"
entire gunicorn
"
\x
1b[0m---------------------
\n
"
tail
$SECOND_GUNICORN_LOG
echo
-e
"
\n
----------------
\x
1b[34m"
error fail log
"
\x
1b[0m--------------------
\n
"
cat
$SECOND_GUNICORN_LOG
|
grep
-Ev
" Starting|worker|Listening"
echo
-e
"
\n
----------------
\x
1b[34m"
detail log
"
\x
1b[0m------------------------
\n
"
echo
-e
"
\n
Please see /tmp/refined_gunicorn-uxen-error.log"
echo
-e
"
\n\x
1b[31m"
-------------------------------------------------------------------------------------------
"
\x
1b[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_DF
CHECK_MEMORY
DMESG_CHECK
lastlog
GET_SYSTEM_LOG
GET_UXEN_LOG
GET_SUMMARY
}
MAIN
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment