#!/bin/bash # # Script to get status all process khanat # Copyright (C) 2017 AleaJactaEst # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . declare NOCOLOR=0 declare RED="" declare GREEN="" declare NORMAL="" usage() { cat << EOF usage:$0 [options] Script to launch khaganat options: -h, --help : Show this help -d, --debug : Show debug message -n, --no-color : disable color EOF } status_program() { name=$1 printf "%15s %-30s" "$1" "$2" color="" color2="" pid=$(cat /home/gameserver/khanat/server/$1/$1.pid 2>/dev/null) if [[ -n "$pid" ]] then ps -p $pid >/dev/null if [[ $? -eq 0 ]] then pidstate=" ok " color=$GREEN else pidstate="*ko*" color=$RED fi else pidstate="*ko*" color=$RED fi printf " pid:%-8s %4s" "$pid" "${color}${pidstate}${NORMAL}" state=$(cat /home/gameserver/khanat/server/$1/$1.state 2>/dev/null) if [[ -n "$state" ]] then if [[ "$state" == "RUNNING" ]] then color2=$GREEN else color2=$RED fi else state="NOT STARTED" color2=$RED fi printf " %s\n" "${color2}[${state}]${NORMAL}" } status_all() { # aes : admin_executor_service.log status_program 'aes' 'ryzom_admin_service' # bms_master : backup_service.log status_program 'bms_master' 'ryzom_backup_service' # bms_pd_master # status_program 'bms_pd_master' 'ryzom_backup_service' # egs : entities_game_service.log status_program 'egs' 'ryzom_entities_game_service' # gpms : gpm_service.log status_program 'gpms' 'ryzom_gpm_service' # ios : input_output_service.log status_program 'ios' 'ryzom_ios_service' # rns : naming_service.log status_program 'rns' 'ryzom_naming_service' # rws : welcome_service.log status_program 'rws' 'ryzom_welcome_service' # ts : tick_service.log status_program 'ts' 'ryzom_tick_service' # ms : mirror_service.log status_program 'ms' 'ryzom_mirror_service' # ais_newbyland : ai_service.log status_program 'ais_newbyland' 'ryzom_ai_service' # mfs : mail_forum_service.log status_program 'mfs' 'ryzom_mail_forum_service' # su : shard_unifier_service.log status_program 'su' 'ryzom_shard_unifier_service' # fes : frontend_service.log status_program 'fes' 'ryzom_frontend_service' # sbs : session_browser_server.log status_program 'sbs' 'ryzom_session_browser_service' # lgs : logger_service.log status_program 'lgs' 'ryzom_logger_service' # mos # status_program 'mos' 'ryzom_monitor_service' # pdss #status_program 'pdss' 'ryzom_pd_support_service' # ras : admin_service.log status_program 'ras' 'ryzom_admin_service' } ##################### # MAIN ##################### source /opt/ext/servercontainer_function.sh msg_info "START : $(basename $0)" while test $# -gt 0 do case "$1" in -h|--help) usage exit 1 ;; -d|--debug) set_debug 1 shift ;; -n|--no-color) NOCOLOR=1 shift ;; *) msg_error "options '$1' not recognize" usage exit 1 ;; esac done if [[ $NOCOLOR -eq 0 ]] then RED=$(tput setaf 1) GREEN=$(tput setaf 2) NORMAL=$(tput sgr0) fi status_all