fix check_mysqlnrpe #96
16
evocheck.sh
16
evocheck.sh
|
@ -891,17 +891,15 @@ check_mysqlmunin() {
|
||||||
}
|
}
|
||||||
check_mysqlnrpe() {
|
check_mysqlnrpe() {
|
||||||
if is_debian_stretch && is_installed mariadb-server; then
|
if is_debian_stretch && is_installed mariadb-server; then
|
||||||
nagios_home=$(getent passwd "nagios" | cut -d: -f6)
|
nagios_file=~nagios/.my.cnf
|
||||||
|
|||||||
nagios_file_abs="${nagios_home}/.my.cnf"
|
|
||||||
benpro
commented
Or you could add eval to evaluate the variable even if quoted.
This should works:
Or you could add eval to evaluate the variable even if quoted.
```
16:53:11 [bserie@mikubook:~] 130 % nagios_file="~bserie"
16:53:22 [bserie@mikubook:~] % echo $nagios_file
~bserie
16:53:28 [bserie@mikubook:~] % eval echo $nagios_file
/home/bserie
```
This should works:
~~~
eval test -f $nagios_file
~~~
jlecour
commented
I think it's overcomplicated :/ I think it's overcomplicated :/
benpro
commented
Huh? You take the actual check. You add Huh? You take the actual check. You add `eval` and its done.
benpro
commented
Any news? You don't agree? @vlaborie what's your point of view? Any news? You don't agree?
@vlaborie what's your point of view?
jlecour
commented
It's not that I disagree. I think adding an I offered another solution : simplifying the NRPE check by not checking the exact command parameters (which we don't care about). It's not that I disagree. I think adding an `eval` is technically correct but needlessly complicated.
I offered another solution : simplifying the NRPE check by not checking the exact command parameters (which we don't care about).
It verifies that there is an NRPE check for MySQL.
benpro
commented
Ok go for it. > It verifies that there is an NRPE check for MySQL.
Ok go for it.
|
|||||||
nagios_file_sym="~nagios/.my.cnf"
|
|
||||||
|
|
||||||
if ! test -f $nagios_file_abs; then
|
if ! test -f ${nagios_file}; then
|
||||||
failed "IS_MYSQLNRPE" "$nagios_file_abs is missing"
|
failed "IS_MYSQLNRPE" "${nagios_file} is missing"
|
||||||
elif [ "$(stat -c %U $nagios_file_abs)" != "nagios" ] \
|
elif [ "$(stat -c %U ${nagios_file})" != "nagios" ] \
|
||||||
|| [ "$(stat -c %a $nagios_file_abs)" != "600" ]; then
|
|| [ "$(stat -c %a ${nagios_file})" != "600" ]; then
|
||||||
failed "IS_MYSQLNRPE" "$nagios_file_abs has wrong permissions"
|
failed "IS_MYSQLNRPE" "${nagios_file} has wrong permissions"
|
||||||
else
|
else
|
||||||
grep -q -F "command[check_mysql]=/usr/lib/nagios/plugins/check_mysql -H localhost -f $nagios_file_sym" /etc/nagios/nrpe.d/evolix.cfg \
|
grep -q -F "command[check_mysql]=/usr/lib/nagios/plugins/check_mysql" /etc/nagios/nrpe.d/evolix.cfg \
|
||||||
|| failed "IS_MYSQLNRPE" "check_mysql is missing"
|
|| failed "IS_MYSQLNRPE" "check_mysql is missing"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue
It doesn't expands because you have put double quotes.
should works.
I'm not fond of checking
nagios_file_abs
andnagios_file_sym
. We should keep tilde expansion. (With no quotes of course).I understand, but without the quotes the variable holds the expanded value.
The nrpe check currently contains the non-expanded version so it's not easy to check without rewritting all nrpe configurations.
We can loosen the check a bit and only verify that a "check_mysql" is present and not the entire line.