percona-monitoring-plugins
percona-monitoring-plugins copied to clipboard
pmp-check-mysql-deleted-files has no support for sudo
In the code for pmp-check-mysql-deleted-files, there is this bit:
# If lsof exists, but you run it as non-root, you'll get a file with a
# bunch of this stuff:
# mysqld 15287 ... /proc/15287/cwd (readlink: Permission denied)
# We have to detect this and return UNK.
if grep -v -e denied -e COMMAND "${TEMP}" >/dev/null 2>&1; then
local FILES=$(check_deleted_files "${TEMP}" "${OPT_TMPDIR}")
NOTE="open but deleted files: ${FILES}"
if [ "${FILES}" -a -z "${OPT_WARN}" ]; then
NOTE="CRIT $NOTE"
elif [ "${FILES}" ]; then
NOTE="WARN $NOTE"
else
NOTE="OK no deleted files"
fi
else
NOTE="UNK You must execute lsof with root privileges"
fi
So, the script acknowledges that running lsof requires root privileges, enough to give the condition its own error message. But, what then? There is no switch to fix the lsof command to use sudo.
NRPE shouldn't ever be ran as root, so I'm not even considering that option. Although, it seems like this script is expected to run as root.
The only other option is to set the UID bit on lsof but that enables it system-wide to all users.
Or you could allow nrpe to run the script using sudo
I have a patch to add a --sudo switch. Just need a round of internal code reviews and approvals first, and I'll share it.
@SineSwiper thanks for the PR - please take a look at the comments and requested changes