added support for operf if present, and if CMD_OPCONTROL is not set

This commit is contained in:
Fernando Ipar
2017-01-24 16:04:37 -03:00
parent 020771b419
commit b53a9a76fe
2 changed files with 31 additions and 8 deletions

View File

@@ -779,6 +779,7 @@ CMD_MPSTAT="${CMD_MPSTAT:-"$(_which mpstat)"}"
CMD_MYSQL="${CMD_MYSQL:-"$(_which mysql)"}" CMD_MYSQL="${CMD_MYSQL:-"$(_which mysql)"}"
CMD_MYSQLADMIN="${CMD_MYSQLADMIN:-"$(_which mysqladmin)"}" CMD_MYSQLADMIN="${CMD_MYSQLADMIN:-"$(_which mysqladmin)"}"
CMD_OPCONTROL="${CMD_OPCONTROL:-"$(_which opcontrol)"}" CMD_OPCONTROL="${CMD_OPCONTROL:-"$(_which opcontrol)"}"
[ -z "$CMD_OPCONTROL" ] && CMD_OPCONTROL=$(_which operf)
CMD_OPREPORT="${CMD_OPREPORT:-"$(_which opreport)"}" CMD_OPREPORT="${CMD_OPREPORT:-"$(_which opreport)"}"
CMD_PMAP="${CMD_PMAP:-"$(_which pmap)"}" CMD_PMAP="${CMD_PMAP:-"$(_which pmap)"}"
CMD_STRACE="${CMD_STRACE:-"$(_which strace)"}" CMD_STRACE="${CMD_STRACE:-"$(_which strace)"}"
@@ -853,9 +854,15 @@ collect() {
local have_oprofile="" local have_oprofile=""
if [ "$CMD_OPCONTROL" -a "$OPT_COLLECT_OPROFILE" ]; then if [ "$CMD_OPCONTROL" -a "$OPT_COLLECT_OPROFILE" ]; then
if $CMD_OPCONTROL --init; then if [ $(echo $CMD_OPCONTROL|grep -c opcontrol) -gt 0 ]; then
$CMD_OPCONTROL --start --no-vmlinux # use legacy opcontrol
have_oprofile="yes" if $CMD_OPCONTROL --init; then
$CMD_OPCONTROL --start --no-vmlinux
have_oprofile="yes"
fi
else
$CMD_OPCONTROL -p `pidof mysqld` &
OPERF_PID=$!
fi fi
elif [ "$CMD_STRACE" -a "$OPT_COLLECT_STRACE" -a "$mysqld_pid" ]; then elif [ "$CMD_STRACE" -a "$OPT_COLLECT_STRACE" -a "$mysqld_pid" ]; then
$CMD_STRACE -T -s 0 -f -p $mysqld_pid -o "$d/$p-strace" & $CMD_STRACE -T -s 0 -f -p $mysqld_pid -o "$d/$p-strace" &
@@ -951,6 +958,7 @@ collect() {
log "Loop end: $(date +'TS %s.%N %F %T')" log "Loop end: $(date +'TS %s.%N %F %T')"
if [ "$have_oprofile" ]; then if [ "$have_oprofile" ]; then
if [ $(echo $CMD_OPCONTROL|grep -c opcontrol) -gt 0 ]; then
$CMD_OPCONTROL --stop $CMD_OPCONTROL --stop
$CMD_OPCONTROL --dump $CMD_OPCONTROL --dump
@@ -963,6 +971,9 @@ collect() {
$CMD_OPCONTROL --save=pt_collect_$p $CMD_OPCONTROL --save=pt_collect_$p
else
kill -SIGINT $OPERF_PID
fi
local mysqld_path=$(_which mysqld); local mysqld_path=$(_which mysqld);
if [ "$mysqld_path" -a -f "$mysqld_path" ]; then if [ "$mysqld_path" -a -f "$mysqld_path" ]; then
$CMD_OPREPORT \ $CMD_OPREPORT \
@@ -985,7 +996,7 @@ collect() {
kill -s 15 $strace_pid kill -s 15 $strace_pid
[ "$mysqld_pid" ] && kill -s 18 $mysqld_pid [ "$mysqld_pid" ] && kill -s 18 $mysqld_pid
fi fi
innodb_status 2 innodb_status 2
tokudb_status 2 tokudb_status 2
$CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status2" & $CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status2" &

View File

@@ -34,6 +34,7 @@ CMD_MPSTAT="${CMD_MPSTAT:-"$(_which mpstat)"}"
CMD_MYSQL="${CMD_MYSQL:-"$(_which mysql)"}" CMD_MYSQL="${CMD_MYSQL:-"$(_which mysql)"}"
CMD_MYSQLADMIN="${CMD_MYSQLADMIN:-"$(_which mysqladmin)"}" CMD_MYSQLADMIN="${CMD_MYSQLADMIN:-"$(_which mysqladmin)"}"
CMD_OPCONTROL="${CMD_OPCONTROL:-"$(_which opcontrol)"}" CMD_OPCONTROL="${CMD_OPCONTROL:-"$(_which opcontrol)"}"
[ -z "$CMD_OPCONTROL" ] && CMD_OPCONTROL=$(_which operf)
CMD_OPREPORT="${CMD_OPREPORT:-"$(_which opreport)"}" CMD_OPREPORT="${CMD_OPREPORT:-"$(_which opreport)"}"
CMD_PMAP="${CMD_PMAP:-"$(_which pmap)"}" CMD_PMAP="${CMD_PMAP:-"$(_which pmap)"}"
CMD_STRACE="${CMD_STRACE:-"$(_which strace)"}" CMD_STRACE="${CMD_STRACE:-"$(_which strace)"}"
@@ -128,9 +129,16 @@ collect() {
# The --init should be a no-op if it has already been init-ed. # The --init should be a no-op if it has already been init-ed.
local have_oprofile="" local have_oprofile=""
if [ "$CMD_OPCONTROL" -a "$OPT_COLLECT_OPROFILE" ]; then if [ "$CMD_OPCONTROL" -a "$OPT_COLLECT_OPROFILE" ]; then
if $CMD_OPCONTROL --init; then if [ $(echo $CMD_OPCONTROL|grep -c opcontrol) -gt 0 ]; then
$CMD_OPCONTROL --start --no-vmlinux # use legacy opcontrol
have_oprofile="yes" if $CMD_OPCONTROL --init; then
$CMD_OPCONTROL --start --no-vmlinux
have_oprofile="yes"
fi
else
# use operf, may fail under VirtualBox or old processor models (see http://oprofile.sourceforge.net/doc/perf_events.html)
$CMD_OPCONTROL -p `pidof mysqld` &
OPERF_PID=$!
fi fi
elif [ "$CMD_STRACE" -a "$OPT_COLLECT_STRACE" -a "$mysqld_pid" ]; then elif [ "$CMD_STRACE" -a "$OPT_COLLECT_STRACE" -a "$mysqld_pid" ]; then
# Don't run oprofile and strace at the same time. # Don't run oprofile and strace at the same time.
@@ -245,6 +253,7 @@ collect() {
log "Loop end: $(date +'TS %s.%N %F %T')" log "Loop end: $(date +'TS %s.%N %F %T')"
if [ "$have_oprofile" ]; then if [ "$have_oprofile" ]; then
if [ $(echo $CMD_OPCONTROL|grep -c opcontrol) -gt 0 ]; then
$CMD_OPCONTROL --stop $CMD_OPCONTROL --stop
$CMD_OPCONTROL --dump $CMD_OPCONTROL --dump
@@ -257,6 +266,9 @@ collect() {
$CMD_OPCONTROL --save=pt_collect_$p $CMD_OPCONTROL --save=pt_collect_$p
else
kill -SIGINT $OPERF_PID
fi
# Attempt to generate a report; if this fails, then just tell the user # Attempt to generate a report; if this fails, then just tell the user
# how to generate the report. # how to generate the report.
local mysqld_path=$(_which mysqld); local mysqld_path=$(_which mysqld);
@@ -282,7 +294,7 @@ collect() {
# Sometimes strace leaves threads/processes in T status. # Sometimes strace leaves threads/processes in T status.
[ "$mysqld_pid" ] && kill -s 18 $mysqld_pid [ "$mysqld_pid" ] && kill -s 18 $mysqld_pid
fi fi
innodb_status 2 innodb_status 2
tokudb_status 2 tokudb_status 2
$CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status2" & $CMD_MYSQL $EXT_ARGV -e "$mutex" >> "$d/$p-mutex-status2" &