linux 程序状态查询脚本
[root@localhost SaasHealth]# cat otoctl
#!/bin/bash
source /etc/profile
DOCKERCOMPOSE=/usr/local/bin/docker-compose
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
action=${1-}
#workdir=$PWD
#cd $workdir
#docker-compose ps
function GetApollo() {
echo ""
echo -e "\033[33m****************************************************Apollo状态****************************************************\033[0m"
$DOCKERCOMPOSE ps apollo-adminservice apollo-configservice apollo-portal
}
function GetNacos() {
echo ""
echo -e "\033[33m****************************************************Nacos状态****************************************************\033[0m"
$DOCKERCOMPOSE ps nacos
}
function GetRabbitMq(){
echo ""
echo -e "\033[33m****************************************************RabbitMq状态****************************************************\033[0m"
cd $SHELL_FOLDER
$DOCKERCOMPOSE ps rabbitmq
}
function GetDabases() {
echo ""
echo -e "\033[33m****************************************************Mysql状态****************************************************\033[0m"
cd $SHELL_FOLDER
$DOCKERCOMPOSE ps mysql8
}
function GetRedis() {
echo ""
echo -e "\033[33m****************************************************Redis状态****************************************************\033[0m"
cd $SHELL_FOLDER
$DOCKERCOMPOSE ps redis
}
function GetJavaApp() {
echo ""
echo -e "\033[33m****************************************************JavaApp状态****************************************************\033[0m"
cd $SHELL_FOLDER
$DOCKERCOMPOSE ps blade-deliver blade-log blade-commdity blade-gateway blade-boot blade-sms blade-data urule xxl-job medicine-km-service
}
function GetNginx() {
echo ""
echo -e "\033[33m****************************************************Nginx状态****************************************************\033[0m"
cd $SHELL_FOLDER
$DOCKERCOMPOSE ps nginx
}
function GetPythonApp() {
echo ""
echo -e "\033[33m****************************************************PythonApp状态****************************************************\033[0m"
cd $SHELL_FOLDER
$DOCKERCOMPOSE ps ChronicDiseaseTreatment IntelligentDiagnosis medicalNlp WjhtMessage WjhtSaasProject SaasAndUnicom #WjhtOcr
}
function usage() {
echo "$(gettext 'SAAS Deployment Management Script')"
echo
echo "Usage: "
echo " ./otoctl.sh [COMMAND] [ARGS...]"
echo " ./otoctl.sh --help"
echo
echo "Installation Commands: "
echo " install $(gettext 'Install container')"
echo
echo "Management Commands: "
echo " start $(gettext 'Start container')"
echo " stop $(gettext 'Stop container')"
echo " restart $(gettext 'Restart container')"
echo " status $(gettext 'Check container')"
echo " down $(gettext 'Offline container')"
echo
# echo "More Commands: "
# echo " load_image $(gettext 'Loading docker image')"
# echo " backup_db $(gettext 'Backup database')"
# echo " restore_db [file] $(gettext 'Data recovery through database backup file')"
# echo " raw $(gettext 'Execute the original docker-compose command')"
# echo " tail [service] $(gettext 'View log')"
echo
}
#usage
function install() {
$DOCKERCOMPOSE up -d
}
function start() {
$DOCKERCOMPOSE start ${target}
}
function stop() {
$DOCKERCOMPOSE stop
}
function restart() {
stop
echo -e "\n"
start
}
function main() {
if [[ "${action}" == "help" || "${action}" == "h" || "${action}" == "-h" || "${action}" == "--help" ]]; then
echo ""
else
echo ""
fi
case "${action}" in
install)
install
;;
start)
start
;;
restart)
restart
;;
stop)
stop
;;
down)
if [[ -z "${target}" ]]; then
${EXE} down -v
else
${EXE} stop "${target}" && ${EXE} rm -f "${target}"
fi
;;
status)
GetApollo
GetNacos
GetRabbitMq
GetDabases
GetRedis
GetJavaApp
GetPythonApp
GetNginx
;;
help)
usage
;;
--help)
usage
;;
-h)
usage
;;
*)
echo "No such command: ${action}"
usage
;;
esac
}
main "$@"
执行脚本
****************************************************Apollo状态****************************************************
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
apollo_adminservice apolloconfig/apollo-adminservice:1.9.2 "/apollo-adminservic…" apollo-adminservice 12 days ago Up 12 days 0.0.0.0:8090->8090/tcp, :::8090->8090/tcp
apollo_configservice apolloconfig/apollo-configservice:1.9.2 "/apollo-configservi…" apollo-configservice 12 days ago Up 12 days 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp
apollo_portal apolloconfig/apollo-portal:1.9.2 "/apollo-portal/scri…" apollo-portal 12 days ago Up 12 days 0.0.0.0:8070->8070/tcp, :::8070->8070/tcp
****************************************************Nacos状态****************************************************
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
nacos nacos/nacos-server:v2.1.0 "bin/docker-startup.…" nacos 12 days ago Up 12 days 0.0.0.0:8848->8848/tcp, :::8848->8848/tcp, 0.0.0.0:9848-9849->9848-9849/tcp, :::9848-9849->9848-9849/tcp
****************************************************RabbitMq状态****************************************************
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
rabbitmq_3_12 rabbitmq:3.12.6-management "docker-entrypoint.s…" rabbitmq 12 days ago Up 12 days 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp
****************************************************Mysql状态****************************************************
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mysql mysql:5.7 "docker-entrypoint.s…" mysql8 12 days ago Up 12 days 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp
****************************************************Redis状态****************************************************
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
redis redis:4.0.6 "docker-entrypoint.s…" redis 12 days ago Up 12 days 0.0.0.0:16379->6379/tcp, :::16379->6379/tcp
****************************************************JavaApp状态****************************************************
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
****************************************************PythonApp状态****************************************************
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
****************************************************Nginx状态****************************************************
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
nginx nginx "/docker-entrypoint.…" nginx 8 days ago Up 8 days 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。