#!/bin/bash #title :rolling_perfstat #description :This script combines a single run of perfstat and #description :a rolling perfstat for an intermittent issue. #author :Adly Taibi #date :2016/02/10 #version :1.0 #usage :bash rolling_perfstat #notes :Needs perfstat8, ssh and ssh-keygen #========================================================================= case="2000000000" clstr="clustermgmt" iterations=5 sample=5 useradmin="admin" dstpath="." ##### Should'nt need to change anything below ##### export LD_LIBRARY_PATH=libs keysdir="perfstat_sshkey" keyname="perf" line=$(printf '#%.s' {1..27}) if [ ! -d ${keysdir} ]; then mkdir ${keysdir} fi if [ ! -f ${keysdir}/${keyname} ]; then ssh-keygen -t rsa -b 1024 -C "" -N "" -f ${keysdir}/${keyname} > /dev/null fi ssh -o StrictHostKeychecking=no -o NumberOfPasswordPrompts=0 -i ${keysdir}/${keyname} -l perfstat ${clstr} version > /dev/null 2>&1 if [ $? != 0 ]; then echo -e "The key is not on the cluster.\nPlease provide ${useradmin} password for ${clstr}" pubkey=$(cat ${keysdir}/${keyname}.pub) ssh -o StrictHostKeychecking=no -l ${useradmin} ${clstr} 'security login create -username perfstat -application ssh -authmethod publickey -role admin;security login publickey create -username perfstat -publickey "'${pubkey}'"' > /dev/null 2>&1 fi ssh -o StrictHostKeychecking=no -o NumberOfPasswordPrompts=0 -i ${keysdir}/${keyname} -l perfstat ${clstr} version if [ $? == 0 ]; then while true do output=$(date +%Y%m%d%H%M) echo -e "\n\n${line}\n# Working on ${output} #\n${line}" ./perfstat8 ${clstr} -s --sshprivatekey-file ${keysdir}/${keyname} -m c -t ${sample} -i ${iterations} -z -o ${dstpath}/${case}_${output} if [ -f stop ]; then exit fi done else echo "Something went wrong and the ssh key is not working." fi