Don't print errors in data files; let the general -output file catch them. Print TS lines before data. Try to find sysctl manually. Add _pidof() to alt_cmds.sh.

This commit is contained in:
Daniel Nichter
2012-01-27 17:37:59 -07:00
parent 81ae556f8b
commit e954505dd2
4 changed files with 177 additions and 90 deletions

View File

@@ -23,12 +23,31 @@
set -u
# Global variables.
CMD_PIDOF="$(which pidof)"
CMD_PGREP="$(which pgrep)"
# seq N, return 1, ..., 5
_seq() {
local i="$1"
awk "BEGIN { for(i=1; i<=$i; i++) print i; }"
}
_pidof() {
local proc="$1" # process name
local pat="${2:-""}" # pattern in case we must grep for proc
local pid=""
[ "$CMD_PIDOF" ] && pid=$(pidof -s "$proc");
[ -z "$pid" ] && [ "$CMD_PGREP" ] && pid=$(pgrep -o -x "$proc");
[ -z "$pid" ] && pid=$(ps -eaf | grep "$pat" | grep -v mysqld_safe | awk '{print $2}' | head -n1)
echo $pid
}
# ###########################################################################
# End alt_cmds package
# ###########################################################################