Hi,

I have the following Script in /var/prtg/scripts/mysqld_openfiles.sh to monitor the open files from the mysqld process.

#!/bin/bash


num_proc="$(lsof -p $(pidof mysqld) | wc -l)"

ret=0
retstring="mysqld open_files normal"

if (("$num_proc" > 300)); then
        ret=1
        retstring="Warning! mysqld open_files critical! $num_proc"
fi

if (("$num_proc" > 4000)); then
        ret=2
        retstring="Error! mysqld open_files too high! $num_proc"
fi


echo "$ret:$num_proc:$retstring"

which currently gives me the following output

# /var/prtg/scripts/mysqld_openfiles.sh 1:742:Warning! mysqld open_files critical! 742

However in PRTG the status is shown as green with message "mysqld open_files normal" and always value of 5. I already refreshed the script several times and also waited for 15 minutes to trigger a normal recheck but the status did not change.

Am I missing something?

By this KB question the Status should switch to yellow and value should be the 742.

Thanks for your help.


Article Comments

Hi

found the problem. The script runs as a different user in our PRTG setup. This user needs the ability to start lsof with password less sudo.

Changed num_proc="$(lsof -p $(pidof mysqld) | wc -l)" to num_proc="$(sudo /usr/bin/lsof -p $(pidof mysqld) | wc -l)" and added the following line to etc/sudoers prtguser ALL= NOPASSWD: /usr/bin/lsof


Aug, 2016 - Permalink

Thanks for sharing the solution, glad you found it out :)


Aug, 2016 - Permalink