Steve's Power Systems BlogPower BlogContactLog inRegister
  • Power Blog
  • Contact

  • Register

IBM Power Systems Blog

Power Systems
  • Front Page
  • Categories
  • Archives
  • Latest comments
  • « Script to check and show MPIO path priorities
  • Reading VLANs from the SEA Adapter »

Show the last cluster start, stop and fail-over date and time

Posted by steve on 19 Sep 2011 in AIX Tips, Scripts and One Liners, PowerHA Tips

Show the last cluster start, stop and fail-over date and time.

 

#!/usr/bin/ksh
#
# When was the last cluster fail-over, start-up and shutdown?
# Written by Stephen Diwell - capacityreports.net

[[ -n ${DEBUG} ]] && set -x

LOCAL_NODE=$( /usr/es/sbin/cluster/utilities/get_local_nodename )
PRIMARY_NODE=$( /usr/es/sbin/cluster/utilities/clshowres | awk '/Participating Node Name/ { print $4 }' )
OTHER_NODES=$( /usr/es/sbin/cluster/utilities/clnodename | egrep -v ${PRIMARY_NODE} )
LOG_DIR=$( /usr/es/sbin/cluster/utilities/cllog -g cluster.mmddyyyy | awk -F: '/cluster/ { print $4 }' )
LOG_FILES=cluster.????????

get_dates() {
[[ -n ${DEBUG} ]] && set -x

FOUND_CLUSTER_START_DATE=FALSE
FOUND_APPLICATION_START_DATE=FALSE
FOUND_APPLICATION_STOP_DATE=FALSE
FILE_LIST=$( cd ${LOG_DIR} ; ls -1t ${LOG_FILES} )

for FILE in $( print ${FILE_LIST} )
do

[[ ${FOUND_CLUSTER_START_DATE} = "FALSE" ]] && {
if grep -q "EVENT START: site_up_local" ${LOG_DIR}/${FILE}
then
# Found node cluster start.
CLUSTER_START_TIME=$( grep "EVENT START: site_up_local" ${LOG_DIR}/${FILE} | tail -1 | awk '{ print $3 }' )
CLUSTER_START_DATE=$( print ${FILE} | awk -F\. '{ print $2 }' )
CLUSTER_START_DD=$( print ${CLUSTER_START_DATE} | cut -c3-4 )
CLUSTER_START_MM=$( print ${CLUSTER_START_DATE} | cut -c1-2 )
CLUSTER_START_YY=$( print ${CLUSTER_START_DATE} | cut -c5-8 )
FOUND_CLUSTER_START_DATE=TRUE
fi
}

[[ ${FOUND_APPLICATION_START_DATE} = "FALSE" ]] && {
if grep -q "EVENT START: start_server" ${LOG_DIR}/${FILE}
then
# Found start server event
APP_START_TIME=$( grep "EVENT START: start_server" ${LOG_DIR}/${FILE} | tail -1 | awk '{ print $3 }' )
APP_START_DATE=$( print ${FILE} | awk -F\. '{ print $2 }' )
APP_START_DD=$( print ${APP_START_DATE} | cut -c3-4 )
APP_START_MM=$( print ${APP_START_DATE} | cut -c1-2 )
APP_START_YY=$( print ${APP_START_DATE} | cut -c5-8 )
FOUND_APPLICATION_START_DATE=TRUE
fi
}

[[ ${FOUND_APPLICATION_STOP_DATE} = "FALSE" ]] && {
if grep -q "EVENT START: stop_server" ${LOG_DIR}/${FILE}
then
# Found stop server event
APP_STOP_TIME=$( grep "EVENT START: stop_server" ${LOG_DIR}/${FILE} | tail -1 | awk '{ print $3 }' )
APP_STOP_DATE=$( print ${FILE} | awk -F\. '{ print $2 }' )
APP_STOP_DD=$( print ${APP_STOP_DATE} | cut -c3-4 )
APP_STOP_MM=$( print ${APP_STOP_DATE} | cut -c1-2 )
APP_STOP_YY=$( print ${APP_STOP_DATE} | cut -c5-8 )
FOUND_APPLICATION_STOP_DATE=TRUE
fi
}

done
}

ROLE="Secondary node ${LOCAL_NODE} :"
[[ ${LOCAL_NODE} = ${PRIMARY_NODE} ]] && ROLE="Primary node ${LOCAL_NODE} :"

get_dates

print "${ROLE} Cluster Services started: ${CLUSTER_START_DD}-${CLUSTER_START_MM}-${CLUSTER_START_YY} at ${CLUSTER_START_TIME}"
print "${ROLE} Application last stopped: ${APP_STOP_DD}-${APP_STOP_MM}-${APP_STOP_YY} at ${APP_STOP_TIME}"
print "${ROLE} Application last started: ${APP_START_DD}-${APP_START_MM}-${APP_START_YY} at ${APP_START_TIME}
"
exit 0

 

Tags: HACMPPowerHA

No feedback yet


Form is loading...

July 2026
Mon Tue Wed Thu Fri Sat Sun
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
 << <   > >>

IBM Power Systems Blog

IBM Power Systems - Administration, Tuning and Optimisation. These posts are my own personal opinions and comments only.

Search

Categories

  • All
  • AIX Tips
  • AIX Tuning
  • Command Line Tips
  • HMC Tips
  • LPM Information
  • NIM Tips
  • Performance Testing
  • Power System Affinity
  • PowerHA Tips
  • SRIOV and vNIC
  • Scripts and One Liners
  • VIO Server Tips

Recent Posts

  • AIX NIM Hints and Tips
  • Finding Multiple Install Sources for AIX
  • PowerHA and EMC Busy Devices
  • AIX Random Password Generation
  • VIO Server 3.1.0 and ssh host keys
  • VIO Server 3.1.0 Items to Review
  • Just when you thought you understood idle CPU time!!
  • 40Gbit Adapter Performance Testing
  • LPM Copy Time Statistics
  • IBM HMC Upgrades

Recent Comments

  • steve on How to configure IBM SRIOV Adapters
  • Howard Coles on How to configure IBM SRIOV Adapters
  • steve on AIX mpstat and lssrad part 1
  • Charin Kumjudpai on AIX mpstat and lssrad part 1
  • Gagandeep on LPM and multiple vSwitches
  • Fant Steele on VIO Server 3.1.0 and ssh host keys
  • steve on AIX NIM Hints and Tips
  • alan wilcox on AIX NIM Hints and Tips
  • steve on AIX buf_mode attribute for Virtual Ethernet Adapters
  • Bernhar on AIX buf_mode attribute for Virtual Ethernet Adapters
  • Gery on Reading VLANs from the SEA Adapter
  • steve on Reading VLANs from the SEA Adapter
  • patrice on Reading VLANs from the SEA Adapter
  • steve on Reading VLANs from the SEA Adapter
  • steve on AIX buf_mode attribute for Virtual Ethernet Adapters
  • Chris K. on AIX buf_mode attribute for Virtual Ethernet Adapters
  • jovi on AIX or VIOS Errors: 29FA8C20 and 7BFEEA1F
  • steve on AIX or VIOS Errors: 29FA8C20 and 7BFEEA1F
  • jovi on AIX or VIOS Errors: 29FA8C20 and 7BFEEA1F
  • steve on Creating EtherChannel Devices from Command Line

This collection ©2026 by Stephen Diwell • Contact • Help • Build your own site!

Community CMS
Cookies are required to enable core site functionality.