mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 07:30:02 +00:00
Use _pidof() and _lsof() from Percona Monitoring Plugins. Use "" and "yes" exclusively in collect(). Don't exec cmds that need mysqld_pid unless mysqld_pid is defined. Use log() instead of echo.
This commit is contained in:
@@ -34,18 +34,17 @@ _seq() {
|
||||
}
|
||||
|
||||
_pidof() {
|
||||
local proc="$1" # process name
|
||||
local pat="${2:-""}" # pattern in case we must grep for proc
|
||||
|
||||
local pid=""
|
||||
local cmd="$1"
|
||||
if ! pidof "$cmd" 2>/dev/null; then
|
||||
ps -eo pid,ucomm | awk -v comm="$cmd" '$2 == comm { print $1 }'
|
||||
fi
|
||||
}
|
||||
|
||||
[ "$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
|
||||
_lsof() {
|
||||
local pid="$1"
|
||||
if ! lsof -p $pid 2>/dev/null; then
|
||||
/bin/ls -l /proc/$pid/fd 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# ###########################################################################
|
||||
|
Reference in New Issue
Block a user