Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery
/
devops
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c5b5b498
authored
Nov 08, 2018
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add check for system down status
parent
14af8e57
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
11 deletions
docker/script/sys-check.sh
docker/script/sys-check.sh
View file @
c5b5b498
...
...
@@ -33,22 +33,28 @@ check_docker_up_status() {
NUM_OF_COMPONENTS
=
`
/usr/local/bin/docker-compose
-f
$DOCKER_FILE
ps |
grep
'docker_'
| wc
-l
`
NUM_OF_UP_COMPONENTS
=
`
/usr/local/bin/docker-compose
-f
$DOCKER_FILE
ps |
grep
'docker_'
|
grep
Up | wc
-l
`
if
[
$NUM_OF_UP_COMPONENTS
-eq
$NUM_OF_COMPONENTS
]
;
DOCKER_STATUS
=
"OK"
if
[
$NUM_OF_COMPONENTS
-eq
0
]
;
then
DOCKER_STATUS
=
"FAIL"
SYS_STATUS
=
"FAIL"
echo
-e
"
\e
[31mERROR:
${
DOCKER_FILE
}
is down
\e
[0m"
send_system_down_alert
return
fi
if
[
$NUM_OF_UP_COMPONENTS
-ne
$NUM_OF_COMPONENTS
]
;
then
DOCKER_STATUS
=
"OK"
else
DOCKER_STATUS
=
"FAIL"
SYS_STATUS
=
"FAIL"
echo
-e
"
\e
[31mERROR: Found status errors in
${
DOCKER_FILE
}
\e
[0m"
send_docker_status_alert
return
fi
;
if
[
"
$DOCKER_STATUS
"
==
"FAIL"
]
then
echo
-e
"
\e
[31mERROR: Found status errors in
${
DOCKER_FILE
}
\e
[0m"
send_docker_status_alert
else
echo
-e
"
\e
[32m
${
DOCKER_FILE
}
is up and running!
\e
[0m"
fi
echo
-e
"
\e
[32m
${
DOCKER_FILE
}
is up and running!
\e
[0m"
}
send_docker_status_alert
()
{
...
...
@@ -66,6 +72,20 @@ send_docker_status_alert() {
send_alert
}
send_system_down_alert
()
{
# title
HOST_NAME
=
`
cat
/proc/sys/kernel/hostname
`
EMAIL_TITLE
=
"MCX-ALERT(host:
${
HOST_NAME
}
) docker
${
DOCKER_FILE
}
is down!"
# message
cat
/dev/null
>
alert-msg.txt
echo
-e
"docker
${
DOCKER_FILE
}
is down"
>>
alert-msg.txt
echo
" "
>>
alert-msg.txt
send_alert
}
send_alert
()
{
echo
"To: ipgallery.alert@gmail.com"
>>
alert-mail.txt
...
...
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