linux 程序状态查询脚本
#!/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 "$@"
标签:脚本,function,DOCKERCOMPOSE,ps,gettext,查询,linux,033,echo
From: https://www.cnblogs.com/sddll/p/18070062