#!/usr/bin/ksh # # zoneflogcpu - Flog the CPUs in non-global zones. Solaris 10. # # This generates CPU load in each non-global zone by running # multiple CPU bound perl processes in each. # # 25-Mar-2005, ver 0.80 # # USAGE: zoneflogcpu { start | stop } # eg, # zoneflogcpu start # zoneflogcpu stop # # # Standard Disclaimer: This is freeware, use at your own risk. # # 25-Mar-2005 Brendan Gregg Created this. # MAX_CPUs=8 # Maximum number of CPUs in a zone. # We run this many processes in each zone. # # Process Arguments # PATH=/usr/bin:/usr/sbin verbose=0 if [[ "$1" == "-v" ]]; then shift; verbose=1 fi action="$1" if [[ "$action" == "start" ]]; then ### Define Start Command cmd="perl -e 'while (1) { \$cpuflog++ }' &" count=$MAX_CPUs elif [[ "$action" == "stop" ]]; then ### Run Stop Command ps -eo pid,args | awk '/cpuflo[g]/ { print $1 }' | xargs kill if (( verbose == 1 )); then echo "stopped on all zones."; fi exit 0 else ### Usage echo >&2 "USAGE: $0 { start | stop }" exit 1 fi # # Run Start Commands # for zone in `zoneadm list` do if [[ "$zone" = "global" ]]; then continue; fi if (( verbose == 1 )); then echo "$zone, \c"; fi typeset -i num=0 while (( num <= count )); do zlogin -S $zone "$cmd" num=num+1 done if (( verbose == 1 )); then echo "started."; fi done