fix check_mysqlnrpe #96

Merged
benpro merged 2 commits from fix-mysqlnrpe into master 2019-06-21 14:00:41 +02:00
Owner

the shell doesn't expand "~nagios", which makes the first test fail.
the grep wasn't looking for the nrpe config file :/

the shell doesn't expand "~nagios", which makes the first test fail. the grep wasn't looking for the nrpe config file :/
benpro reviewed 2019-06-18 14:13:13 +02:00
@ -891,12 +891,19 @@ check_mysqlmunin() {
}
check_mysqlnrpe() {
if is_debian_stretch && is_installed mariadb-server; then
nagios_file="~nagios/.my.cnf"
Contributor

It doesn't expands because you have put double quotes.

nagios_file=~nagios/.my.cnf

should works.

14:03:05 [bserie@huit:/tmp] % bash -c 'echo ~bserie'
/home/bserie
14:12:54 [bserie@huit:/tmp] % bash -c 'echo "~bserie"'
~bserie
14:12:59 [bserie@huit:/tmp] %                                       
It doesn't expands because you have put double quotes. ~~~ nagios_file=~nagios/.my.cnf ~~~ should works. ~~~ 14:03:05 [bserie@huit:/tmp] % bash -c 'echo ~bserie' /home/bserie 14:12:54 [bserie@huit:/tmp] % bash -c 'echo "~bserie"' ~bserie 14:12:59 [bserie@huit:/tmp] % ~~~
Contributor

I'm not fond of checking nagios_file_abs and nagios_file_sym. We should keep tilde expansion. (With no quotes of course).

I'm not fond of checking `nagios_file_abs` and `nagios_file_sym`. We should keep tilde expansion. (With no quotes of course).
Author
Owner

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.

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.
Author
Owner

We can loosen the check a bit and only verify that a "check_mysql" is present and not the entire line.

We can loosen the check a bit and only verify that a "check_mysql" is present and not the entire line.
benpro added the
bug
label 2019-06-18 14:17:18 +02:00
benpro reviewed 2019-06-18 16:56:17 +02:00
@ -892,4 +892,2 @@
check_mysqlnrpe() {
if is_debian_stretch && is_installed mariadb-server; then
nagios_file="~nagios/.my.cnf"
{ test -f $nagios_file \
Contributor

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

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 ~~~
Author
Owner

I think it's overcomplicated :/

I think it's overcomplicated :/
Contributor

Huh? You take the actual check. You add eval and its done.

Huh? You take the actual check. You add `eval` and its done.
Contributor

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?
Author
Owner

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.

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.
Contributor

It verifies that there is an NRPE check for MySQL.

Ok go for it.

> It verifies that there is an NRPE check for MySQL. Ok go for it.
benpro approved these changes 2019-06-21 14:00:15 +02:00
benpro closed this pull request 2019-06-21 14:00:41 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: evolix/evocheck#96
No description provided.