More quoting and tweaking re Baron's review.

This commit is contained in:
Daniel Nichter
2012-01-13 10:02:17 -07:00
parent a9afea4506
commit cfce6e6eb2
3 changed files with 14 additions and 13 deletions

View File

@@ -37,8 +37,8 @@ CMD_TCPDUMP=${CMD_TCPDUMP:-"tcpdump"}
CMD_VMSTAT=${CMD_VMSTAT:-"vmstat"} CMD_VMSTAT=${CMD_VMSTAT:-"vmstat"}
collect() { collect() {
local d=$1 # directory to save results in local d="$1" # directory to save results in
local p=$2 # prefix for each result file local p="$2" # prefix for each result file
# Get pidof mysqld; pidof doesn't exist on some systems. We try our best... # Get pidof mysqld; pidof doesn't exist on some systems. We try our best...
local mysqld_pid=$(pidof -s mysqld); local mysqld_pid=$(pidof -s mysqld);
@@ -50,7 +50,7 @@ collect() {
fi fi
# Get memory allocation info before anything else. # Get memory allocation info before anything else.
if [ -x "$CMD_PMAP" -a "$mysqld_pid" ]; then if [ "$mysqld_pid" ]; then
if $CMD_PMAP --help 2>&1 | grep -- -x >/dev/null 2>&1 ; then if $CMD_PMAP --help 2>&1 | grep -- -x >/dev/null 2>&1 ; then
$CMD_PMAP -x $mysqld_pid > "$d/$p-pmap" $CMD_PMAP -x $mysqld_pid > "$d/$p-pmap"
else else
@@ -160,7 +160,7 @@ collect() {
local have_lock_waits_table=0 local have_lock_waits_table=0
$CMD_MYSQL $EXT_ARGV -e "SHOW TABLES FROM INFORMATION_SCHEMA" \ $CMD_MYSQL $EXT_ARGV -e "SHOW TABLES FROM INFORMATION_SCHEMA" \
| grep -qi "INNODB_LOCK_WAITS" | grep -i "INNODB_LOCK_WAITS" >/dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
have_lock_waits_table=1 have_lock_waits_table=1
fi fi

View File

@@ -24,10 +24,10 @@
set -u set -u
disk_space() { disk_space() {
local filesystem=${1:-"$PWD"} local filesystem="${1:-$PWD}"
# Filesystem 1024-blocks Used Available Capacity Mounted on # Filesystem 1024-blocks Used Available Capacity Mounted on
# /dev/disk0s2 118153176 94409664 23487512 81% / # /dev/disk0s2 118153176 94409664 23487512 81% /
df -P -k $filesystem df -P -k "$filesystem"
} }
# Sub: check_disk_space # Sub: check_disk_space
@@ -44,18 +44,18 @@ disk_space() {
# Returns: # Returns:
# 0 if there is/will be enough disk space, else 1. # 0 if there is/will be enough disk space, else 1.
check_disk_space() { check_disk_space() {
local file=$1 local file="$1"
local mb=${2:-"0"} local mb="${2:-0}"
local pc=${3:-"0"} local pc="${3:-0}"
local mb_margin=${4:-"0"} local mb_margin="${4:-0}"
# Convert MB to KB because the df output should be in 1k blocks. # Convert MB to KB because the df output should be in 1k blocks.
local kb=$(($mb * 1024)) local kb=$(($mb * 1024))
local kb_margin=$(($mb_margin * 1024)) local kb_margin=$(($mb_margin * 1024))
local kb_used=$(cat $file | awk '/^\//{print $3}'); local kb_used=$(cat "$file" | awk '/^\//{print $3}');
local kb_free=$(cat $file | awk '/^\//{print $4}'); local kb_free=$(cat "$file" | awk '/^\//{print $4}');
local pc_used=$(cat $file | awk '/^\//{print $5}' | sed -e 's/%//g'); local pc_used=$(cat "$file" | awk '/^\//{print $5}' | sed -e 's/%//g');
if [ "$kb_margin" -gt "0" ]; then if [ "$kb_margin" -gt "0" ]; then
local kb_total=$(($kb_used + $kb_free)) local kb_total=$(($kb_used + $kb_free))

View File

@@ -20,6 +20,7 @@
2011_12_05-opentables1 2011_12_05-opentables1
2011_12_05-opentables2 2011_12_05-opentables2
2011_12_05-output 2011_12_05-output
2011_12_05-pmap
2011_12_05-processlist 2011_12_05-processlist
2011_12_05-procstat 2011_12_05-procstat
2011_12_05-procvmstat 2011_12_05-procvmstat