Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ### ----------
- ### test_stack
- ### ----------
- ###
- ### AUTH: Greg Chavez, greg.chavez@gmail.com
- ###
- ### DESC: Prints out complete status of each OpenStack daemon configured
- ### in the QUADS array, including:
- ###
- ### 1) service daemon status
- ### 2) date/time of most recent successful start
- ### 3) all error log messages since the last start
- ###
- ######################################################################
- ### CONFIGURE HERE
- ######################################################################
- # For each daemon, fill out a single line with four space-separated
- # array values:
- # 1) Service code name (nova, quantum, etc.)
- # 2) Service name as it appears in /etc/init.d
- # 3) Log filename (ommit directory)
- # 4) Log line that indicates a successful service start (must be
- # quoted!)
- #
- # NB: Blank lines are ignored
- QUADS=(
- nova nova-api nova-api.log "wsgi starting up"
- nova nova-scheduler nova-scheduler.log "Starting scheduler node"
- glance glance-api api.log "Using /var/lib/glance/keystone-signing as cache directory for signing certificate"
- glance glance-registry registry.log "Using /var/lib/glance/keystone-signing as cache directory for signing certificate"
- quantum quantum-server server.log "wsgi starting up"
- cinder cinder-api cinder-api.log "Started osapi_volume on"
- cinder cinder-scheduler cinder-scheduler.log "Creating Consumer connection for Service cinder-scheduler start"
- cinder cinder-volume cinder-volume.log "Creating Consumer connection for Service cinder-volume start"
- )
- ######################################################################
- ### Colors
- ######################################################################
- txtbld=$(tput bold) # Bold
- bldred=${txtbld}$(tput setaf 1) # Red
- bldgrn=${txtbld}$(tput setaf 2) # Green
- bldylw=${txtbld}$(tput setaf 3) # Yellow
- txtrst=$(tput sgr0) # Reset
- ######################################################################
- ### Functions
- ######################################################################
- function stat_me {
- CN=$1 # Code Name
- SN=$2 # Service Name
- LF=$3 # Log File
- SM="$4" # Start Message
- log="/var/log/${CN:-xxx}/${LF:-xxx}"
- err=0
- if [ ! -f "/etc/init.d/$SN" ]; then
- echo "${bldylw}ERR: Service $SN not found${txtrst}"
- err=1
- elif [ ! -r $log ]; then
- echo "${bldylw}ERR: Log $log not found${txtrst}"
- err=1
- fi
- [ $err -gt 0 ] && return $err
- LG=$(grep -n "$SM" $log | tail -1) # log line
- LN=$(echo $LG| awk -F: '{print $1}') # line number
- ERR=$(awk 'NR > ln && /ERR/' ln=$LN $log) # err messages
- if service $SN status | grep -q running 2>/dev/null ; then
- ST=${bldgrn}OK${txtrst}
- else
- ST=${bldred}FAILED${txtrst}
- fi
- printf "%-15s%s\n" "SERVICE:" "$SN"
- printf "%-15s%s\n" "STATUS:" "$ST"
- printf "%-15s" "LAST START:"; echo ${LG:-none} | sed "s/^$LN://" | awk '{print $1, $2}'
- echo "ERRORS:"; [ -n "$ERR" ] && echo "$ERR" | sed 's/^/ /'
- echo "--------------------------------------------------"
- }
- ######################################################################
- ### Main
- ######################################################################
- echo "--------------------------------------------------"
- idx=0
- for Q in "${QUADS[@]}"; do
- if [ $idx == 0 ]; then
- code=$Q
- elif [ $idx == 1 ]; then
- svc=$Q
- elif [ $idx == 2 ]; then
- log=$Q
- elif [ $idx == 3 ]; then
- msg="$Q"
- stat_me $code $svc $log "$msg"
- idx=0
- continue
- fi
- let "idx += 1"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement