More fixes:

- pt-mysql-summary's --read-samples shouldn't need an active connection
- Bunch of pt-summary bugs, particularly several relating to disks.
This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-03-27 12:53:31 -03:00
parent 64b52c9399
commit ae6c1e3789
11 changed files with 50 additions and 47 deletions

View File

@@ -1036,7 +1036,7 @@ parse_mysqld_instances () {
echo " ===== ========================== ==== === ======" echo " ===== ========================== ==== === ======"
grep '/mysqld ' "$file" | while read line; do grep '/mysqld ' "$file" | while read line; do
local pid=$(echo "$line" | awk '{print $2;}') local pid=$(echo "$line" | awk '{print $1;}')
for word in ${line}; do for word in ${line}; do
if echo "${word}" | grep -- "--socket=" > /dev/null; then if echo "${word}" | grep -- "--socket=" > /dev/null; then
socket="$(echo "${word}" | cut -d= -f2)" socket="$(echo "${word}" | cut -d= -f2)"
@@ -2260,7 +2260,9 @@ if [ "${0##*/}" = "$TOOL" ] \
fi fi
# Check if mysql and mysqldump are there, otherwise bail out early. # Check if mysql and mysqldump are there, otherwise bail out early.
check_mysql # But don't if they passed in --read-samples, since we don't need
# a connection then.
[ "$OPT_READ_SAMPLES" ] || check_mysql
main "$@" main "$@"
fi fi

View File

@@ -13,6 +13,13 @@ TOOL="pt-summary"
POSIXLY_CORRECT=1 POSIXLY_CORRECT=1
export POSIXLY_CORRECT export POSIXLY_CORRECT
# Begin by setting the $PATH to include some common locations that are not
# always in the $PATH, including the "sbin" locations, and some common
# locations for proprietary management software, such as RAID controllers.
export PATH="${PATH}:/usr/local/bin:/usr/bin:/bin:/usr/libexec"
export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
export PATH="${PATH}:/usr/StorMan/:/opt/MegaRAID/MegaCli/";
# ########################################################################### # ###########################################################################
# log_warn_die package # log_warn_die package
# This package is a copy without comments from the original. The original # This package is a copy without comments from the original. The original
@@ -856,7 +863,7 @@ linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
echo "dirtystatus $(awk '/vm.dirty_bytes/{print $3}' "$data_dir/sysctl"), $(awk '/vm.dirty_background_bytes/{print $3}' "$data_dir/sysctl")" >> "$data_dir/summary" echo "dirtystatus $(awk '/vm.dirty_bytes/{print $3}' "$data_dir/sysctl"), $(awk '/vm.dirty_background_bytes/{print $3}' "$data_dir/sysctl")" >> "$data_dir/summary"
fi fi
schedulers_and_queue_size "$data_dir/summary" "$data_dir/partitioning" schedulers_and_queue_size "$data_dir/summary" > "$data_dir/partitioning"
for file in dentry-state file-nr inode-nr; do for file in dentry-state file-nr inode-nr; do
echo "${file} $(cat /proc/sys/fs/${file} 2>&1)" >> "$data_dir/summary" echo "${file} $(cat /proc/sys/fs/${file} 2>&1)" >> "$data_dir/summary"
@@ -1103,15 +1110,14 @@ find_raid_controller_lspci () { local PTFUNCNAME=find_raid_controller_lspci;
schedulers_and_queue_size () { local PTFUNCNAME=schedulers_and_queue_size; schedulers_and_queue_size () { local PTFUNCNAME=schedulers_and_queue_size;
local file="$1" local file="$1"
local disk_partitioning_file="$2"
local disks="$(ls /sys/block/ | grep -v -e ram -e loop -e 'fd[0-9]')" local disks="$(ls /sys/block/ | grep -v -e ram -e loop -e 'fd[0-9]' | xargs echo)"
echo "disks $disks" >> "$file" echo "internal::disks $disks" >> "$file"
echo "" > "$disk_partitioning_file"
for disk in $disks; do for disk in $disks; do
if [ -e "/sys/block/${disk}/queue/scheduler" ]; then if [ -e "/sys/block/${disk}/queue/scheduler" ]; then
echo "internal::${disk} $(cat /sys/block/${disk}/queue/scheduler | grep -o '\[.*\]') $(cat /sys/block/${disk}/queue/nr_requests)" >> "$file" echo "internal::${disk} $(cat /sys/block/${disk}/queue/scheduler | grep -o '\[.*\]') $(cat /sys/block/${disk}/queue/nr_requests)" >> "$file"
fdisk -l "/dev/${disk}" >> "$disk_partitioning_file" 2>/dev/null fdisk -l "/dev/${disk}" 2>/dev/null
fi fi
done done
} }
@@ -1135,7 +1141,7 @@ top_processes () { local PTFUNCNAME=top_processes;
notable_processes_info () { local PTFUNCNAME=notable_processes_info; notable_processes_info () { local PTFUNCNAME=notable_processes_info;
local format="%5s %+2d %s\n" local format="%5s %+2d %s\n"
local sshd_pid=$(_pidof "/usr/sbin/sshd") local sshd_pid=$(ps -eo pid,args | awk '$2 ~ /\/usr\/sbin\/sshd/ { print $1; exit }')
echo " PID OOM COMMAND" echo " PID OOM COMMAND"
@@ -1506,7 +1512,7 @@ parse_filesystems () { local PTFUNCNAME=parse_filesystems;
parse_fdisk () { local PTFUNCNAME=parse_fdisk; parse_fdisk () { local PTFUNCNAME=parse_fdisk;
local file="$1" local file="$1"
[ -e "$file" ] || return [ -e "$file" -a -s "$file" ] || return
awk ' awk '
BEGIN { BEGIN {
@@ -1972,9 +1978,10 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
if [ "${platform}" = "Linux" ]; then if [ "${platform}" = "Linux" ]; then
section "Disk_Schedulers_And_Queue_Size" section "Disk_Schedulers_And_Queue_Size"
local disks="$( get_var disks "$data_dir/summary" )" local disks="$( get_var "internal::disks" "$data_dir/summary" )"
for disk in ${disks}; do for disk in $disks; do
name_val "${disk}" "$( get_var "internal::${disk}" "$data_dir/summary" )" local scheduler="$( get_var "internal::${disk}" "$data_dir/summary" )"
name_val "${disk}" "${scheduler:-"UNREADABLE"}"
done done
section "Disk_Partioning" section "Disk_Partioning"
@@ -2063,13 +2070,6 @@ main () { local PTFUNCNAME=main;
_d "Starting $0 $RAN_WITH" _d "Starting $0 $RAN_WITH"
# Begin by setting the $PATH to include some common locations that are not
# always in the $PATH, including the "sbin" locations, and some common
# locations for proprietary management software, such as RAID controllers.
export PATH="${PATH}:/usr/local/bin:/usr/bin:/bin:/usr/libexec"
export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
export PATH="${PATH}:/usr/StorMan/:/opt/MegaRAID/MegaCli/";
# Set up temporary files. # Set up temporary files.
mk_tmpdir mk_tmpdir

View File

@@ -147,7 +147,7 @@ linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
echo "dirtystatus $(awk '/vm.dirty_bytes/{print $3}' "$data_dir/sysctl"), $(awk '/vm.dirty_background_bytes/{print $3}' "$data_dir/sysctl")" >> "$data_dir/summary" echo "dirtystatus $(awk '/vm.dirty_bytes/{print $3}' "$data_dir/sysctl"), $(awk '/vm.dirty_background_bytes/{print $3}' "$data_dir/sysctl")" >> "$data_dir/summary"
fi fi
schedulers_and_queue_size "$data_dir/summary" "$data_dir/partitioning" schedulers_and_queue_size "$data_dir/summary" > "$data_dir/partitioning"
for file in dentry-state file-nr inode-nr; do for file in dentry-state file-nr inode-nr; do
echo "${file} $(cat /proc/sys/fs/${file} 2>&1)" >> "$data_dir/summary" echo "${file} $(cat /proc/sys/fs/${file} 2>&1)" >> "$data_dir/summary"
@@ -417,15 +417,14 @@ find_raid_controller_lspci () { local PTFUNCNAME=find_raid_controller_lspci;
schedulers_and_queue_size () { local PTFUNCNAME=schedulers_and_queue_size; schedulers_and_queue_size () { local PTFUNCNAME=schedulers_and_queue_size;
local file="$1" local file="$1"
local disk_partitioning_file="$2"
local disks="$(ls /sys/block/ | grep -v -e ram -e loop -e 'fd[0-9]')" local disks="$(ls /sys/block/ | grep -v -e ram -e loop -e 'fd[0-9]' | xargs echo)"
echo "disks $disks" >> "$file" echo "internal::disks $disks" >> "$file"
echo "" > "$disk_partitioning_file"
for disk in $disks; do for disk in $disks; do
if [ -e "/sys/block/${disk}/queue/scheduler" ]; then if [ -e "/sys/block/${disk}/queue/scheduler" ]; then
echo "internal::${disk} $(cat /sys/block/${disk}/queue/scheduler | grep -o '\[.*\]') $(cat /sys/block/${disk}/queue/nr_requests)" >> "$file" echo "internal::${disk} $(cat /sys/block/${disk}/queue/scheduler | grep -o '\[.*\]') $(cat /sys/block/${disk}/queue/nr_requests)" >> "$file"
fdisk -l "/dev/${disk}" >> "$disk_partitioning_file" 2>/dev/null fdisk -l "/dev/${disk}" 2>/dev/null
fi fi
done done
} }
@@ -449,7 +448,7 @@ top_processes () { local PTFUNCNAME=top_processes;
notable_processes_info () { local PTFUNCNAME=notable_processes_info; notable_processes_info () { local PTFUNCNAME=notable_processes_info;
local format="%5s %+2d %s\n" local format="%5s %+2d %s\n"
local sshd_pid=$(_pidof "/usr/sbin/sshd") local sshd_pid=$(ps -eo pid,args | awk '$2 ~ /\/usr\/sbin\/sshd/ { print $1; exit }')
echo " PID OOM COMMAND" echo " PID OOM COMMAND"

View File

@@ -114,7 +114,7 @@ parse_mysqld_instances () {
echo " ===== ========================== ==== === ======" echo " ===== ========================== ==== === ======"
grep '/mysqld ' "$file" | while read line; do grep '/mysqld ' "$file" | while read line; do
local pid=$(echo "$line" | awk '{print $2;}') local pid=$(echo "$line" | awk '{print $1;}')
for word in ${line}; do for word in ${line}; do
# Some grep doesn't have -o, so I have to pull out the words I want by # Some grep doesn't have -o, so I have to pull out the words I want by
# looking at each word # looking at each word

View File

@@ -384,7 +384,7 @@ parse_filesystems () { local PTFUNCNAME=parse_filesystems;
parse_fdisk () { local PTFUNCNAME=parse_fdisk; parse_fdisk () { local PTFUNCNAME=parse_fdisk;
local file="$1" local file="$1"
[ -e "$file" ] || return [ -e "$file" -a -s "$file" ] || return
awk ' awk '
BEGIN { BEGIN {
@@ -922,9 +922,10 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
if [ "${platform}" = "Linux" ]; then if [ "${platform}" = "Linux" ]; then
section "Disk_Schedulers_And_Queue_Size" section "Disk_Schedulers_And_Queue_Size"
local disks="$( get_var disks "$data_dir/summary" )" local disks="$( get_var "internal::disks" "$data_dir/summary" )"
for disk in ${disks}; do for disk in $disks; do
name_val "${disk}" "$( get_var "internal::${disk}" "$data_dir/summary" )" local scheduler="$( get_var "internal::${disk}" "$data_dir/summary" )"
name_val "${disk}" "${scheduler:-"UNREADABLE"}"
done done
section "Disk_Partioning" section "Disk_Partioning"

View File

@@ -1364,6 +1364,7 @@ Architecture | CPU = 32-bit, OS = 32-bit
udev 995M 1% devtmpfs rw,mode=0755 /dev udev 995M 1% devtmpfs rw,mode=0755 /dev
# Disk Schedulers And Queue Size ############################# # Disk Schedulers And Queue Size #############################
sda | [cfq] 128 sda | [cfq] 128
sdb | [cfq] 128
# Disk Partioning ############################################ # Disk Partioning ############################################
Device Type Start End Size Device Type Start End Size
============ ==== ========== ========== ================== ============ ==== ========== ========== ==================
@@ -1383,7 +1384,7 @@ dentry-state | 78471 67588 45 0 0 0
file-nr | 9248 0 203574 file-nr | 9248 0 203574
inode-nr | 70996 10387 inode-nr | 70996 10387
# LVM Volumes ################################################ # LVM Volumes ################################################
No volume groups found No volume groups found
# RAID Controller ############################################ # RAID Controller ############################################
Controller | No RAID controller detected Controller | No RAID controller detected
# Network Config ############################################# # Network Config #############################################
@@ -1432,6 +1433,7 @@ No volume groups found
EOF EOF
report_system_summary "$samples/Linux/001" | tail -n +3 > "$TMPDIR/got" report_system_summary "$samples/Linux/001" | tail -n +3 > "$TMPDIR/got"
cp "$TMPDIR/got" yadda.txt
no_diff "$TMPDIR/got" "$TMPDIR/expected" "report_system_summary works with samples from Linux (Ubuntu)" no_diff "$TMPDIR/got" "$TMPDIR/expected" "report_system_summary works with samples from Linux (Ubuntu)"
report_system_summary "$samples/Linux/002" | tail -n +3 > "$TMPDIR/got" report_system_summary "$samples/Linux/002" | tail -n +3 > "$TMPDIR/got"

View File

@@ -15,8 +15,7 @@ rss 1233723392
swappiness 60 swappiness 60
dirtypolicy 20, 10 dirtypolicy 20, 10
raid_controller No RAID controller detected raid_controller No RAID controller detected
disks sda internal::disks sda sdb
sdb
internal::sda [cfq] 128 internal::sda [cfq] 128
internal::sdb [cfq] 128 internal::sdb [cfq] 128
dentry-state 78471 67588 45 0 0 0 dentry-state 78471 67588 45 0 0 0

View File

@@ -11,11 +11,7 @@ raid_controller No RAID controller detected
threading NPTL 2.5 threading NPTL 2.5
getenforce No SELinux detected getenforce No SELinux detected
swappiness swappiness
disks dm-0 internal::disks dm-0 dm-1 hda hdc md0
dm-1
hda
hdc
md0
internal::hda [cfq] 128 internal::hda [cfq] 128
internal::hdc [cfq] 128 internal::hdc [cfq] 128
dentry-state 9392 7451 45 0 0 0 dentry-state 9392 7451 45 0 0 0

View File

@@ -11,11 +11,7 @@ raid_controller No RAID controller detected
threading NPTL 2.5 threading NPTL 2.5
getenforce No SELinux detected getenforce No SELinux detected
swappiness swappiness
disks dm-0 internal::disks dm-0 dm-1 hda hdc md0
dm-1
hda
hdc
md0
internal::hda [cfq] 128 internal::hda [cfq] 128
internal::hdc [cfq] 128 internal::hdc [cfq] 128
dentry-state 9175 7239 45 0 0 0 dentry-state 9175 7239 45 0 0 0

View File

@@ -29,7 +29,11 @@ Architecture | CPU = 32-bit, OS = 32-bit
/dev/mapper/VolGroup00-LogVol00 5.7G 20% ext3 rw / /dev/mapper/VolGroup00-LogVol00 5.7G 20% ext3 rw /
tmpfs 506M 0% tmpfs rw /dev/shm tmpfs 506M 0% tmpfs rw /dev/shm
# Disk Schedulers And Queue Size ############################# # Disk Schedulers And Queue Size #############################
dm-0 | dm-0 | UNREADABLE
dm-1 | UNREADABLE
hda | [cfq] 128
hdc | [cfq] 128
md0 | UNREADABLE
# Disk Partioning ############################################ # Disk Partioning ############################################
Device Type Start End Size Device Type Start End Size
============ ==== ========== ========== ================== ============ ==== ========== ========== ==================

View File

@@ -29,7 +29,11 @@ Architecture | CPU = 32-bit, OS = 32-bit
/dev/mapper/VolGroup00-LogVol00 5.7G 20% ext3 rw / /dev/mapper/VolGroup00-LogVol00 5.7G 20% ext3 rw /
tmpfs 506M 0% tmpfs rw /dev/shm tmpfs 506M 0% tmpfs rw /dev/shm
# Disk Schedulers And Queue Size ############################# # Disk Schedulers And Queue Size #############################
dm-0 | dm-0 | UNREADABLE
dm-1 | UNREADABLE
hda | [cfq] 128
hdc | [cfq] 128
md0 | UNREADABLE
# Disk Partioning ############################################ # Disk Partioning ############################################
Device Type Start End Size Device Type Start End Size
============ ==== ========== ========== ================== ============ ==== ========== ========== ==================