plugin output ommited

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: plugin output ommited

Post by scottwilkerson »

danjoh wrote:Try running the command from the command line and add "| hexdump -C" at the end to make sure there are no "special" characters that Nagios "chokes" on.

Code: Select all

su nagios
./check_mssql_health --server SQLSERVER --username 'domain\usernagios' --password '123456789' --mode=database-data-free --name=datanexus --commit 2>&1 | hexdump -C
good idea
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

Re: plugin output ommited

Post by amprantino »

Code: Select all

00000000  4f 4b 20 2d 20 64 61 74  61 62 61 73 65 20 44 61  |OK - database Da|
00000010  74 61 4e 65 78 75 73 20  68 61 73 20 32 33 2e 30  |taNexus has 23.0|
00000020  39 25 20 66 72 65 65 20  73 70 61 63 65 20 6c 65  |9% free space le|
00000030  66 74 20 7c 20 27 64 62  5f 64 61 74 61 6e 65 78  |ft | 'db_datanex|
00000040  75 73 5f 66 72 65 65 5f  70 63 74 27 3d 32 33 2e  |us_free_pct'=23.|
00000050  30 39 25 3b 31 30 3a 3b  35 3a 3b 30 3b 31 30 30  |09%;10:;5:;0;100|
00000060  20 27 64 62 5f 64 61 74  61 6e 65 78 75 73 5f 66  | 'db_datanexus_f|
00000070  72 65 65 27 3d 32 34 35  34 33 39 2e 31 32 4d 42  |ree'=245439.12MB|
00000080  3b 31 30 36 32 38 34 2e  32 36 32 35 3a 3b 35 33  |;106284.2625:;53|
00000090  31 34 32 2e 31 33 31 32  3a 3b 30 3b 31 30 36 32  |142.1312:;0;1062|
000000a0  38 34 32 2e 36 32 35 20  27 64 62 5f 64 61 74 61  |842.625 'db_data|
000000b0  6e 65 78 75 73 5f 61 6c  6c 6f 63 61 74 65 64 5f  |nexus_allocated_|
000000c0  70 63 74 27 3d 38 32 2e  31 36 25 3b 3b 3b 30 3b  |pct'=82.16%;;;0;|
000000d0  31 30 30 0a                                       |100.|
000000d4
Error should be after "OK", but nothing look suspicious there:
20 hex = Space
2d hex = dash
danjoh
Posts: 73
Joined: Mon Dec 07, 2015 10:43 am
Location: Zürich, Switzerland
Contact:

Re: plugin output ommited

Post by danjoh »

OK, could you try something different...

Can you add " | tee -a /tmp/check_mssql_health.log" to the end of the command_line

Code: Select all

command_line $USER1$/check_mssql_health --server $ARG1$ $USER9$ --mode $ARG2$ $ARG3$ --nooffline --commit | tee -a /tmp/check_mssql_health.log
And then run a check through Nagios (not command line) and post the contents of /tmp/check_mssql_health.log.
--
D/\N
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

Re: plugin output ommited

Post by amprantino »

As root:

# command | tee -a /tmp/check_mssql_health.log
OK - database DataNexus has 23.09% free space left | 'db_datanexus_free_pct'=23.09%;10:;5:;0;100 'db_datanexus_free'=245428.88MB;106311.4625:;53155.7312:;0;1063114.625 'db_datanexus_allocated_pct'=82.14%;;;0;100

# cat /tmp/check_mssql_health.log
OK - database DataNexus has 23.09% free space left | 'db_datanexus_free_pct'=23.09%;10:;5:;0;100 'db_datanexus_free'=245428.88MB;106311.4625:;53155.7312:;0;1063114.625 'db_datanexus_allocated_pct'=82.14%;;;0;100
And as nagios user (I changed the path because I dont have permissions to /tmp):

Code: Select all

nagios@davinci:/usr/local/nagios/libexec$ command | hexdump -C
00000000  4f 4b 20 2d 20 64 61 74  61 62 61 73 65 20 44 61  |OK - database Da|
00000010  74 61 4e 65 78 75 73 20  68 61 73 20 32 33 2e 30  |taNexus has 23.0|
00000020  38 25 20 66 72 65 65 20  73 70 61 63 65 20 6c 65  |8% free space le|
00000030  66 74 20 7c 20 27 64 62  5f 64 61 74 61 6e 65 78  |ft | 'db_datanex|
00000040  75 73 5f 66 72 65 65 5f  70 63 74 27 3d 32 33 2e  |us_free_pct'=23.|
00000050  30 38 25 3b 31 30 3a 3b  35 3a 3b 30 3b 31 30 30  |08%;10:;5:;0;100|
00000060  20 27 64 62 5f 64 61 74  61 6e 65 78 75 73 5f 66  | 'db_datanexus_f|
00000070  72 65 65 27 3d 32 34 35  33 34 30 2e 36 32 4d 42  |ree'=245340.62MB|
00000080  3b 31 30 36 33 31 31 2e  34 36 32 35 3a 3b 35 33  |;106311.4625:;53|
00000090  31 35 35 2e 37 33 31 32  3a 3b 30 3b 31 30 36 33  |155.7312:;0;1063|
000000a0  31 31 34 2e 36 32 35 20  27 64 62 5f 64 61 74 61  |114.625 'db_data|
000000b0  6e 65 78 75 73 5f 61 6c  6c 6f 63 61 74 65 64 5f  |nexus_allocated_|
000000c0  70 63 74 27 3d 38 32 2e  31 34 25 3b 3b 3b 30 3b  |pct'=82.14%;;;0;|
000000d0  31 30 30 0a                                       |100.|
nagios@davinci:/usr/local/nagios/libexec$ command_here | tee -a /usr/local/nagios/libexec/temp.log
OK - database DataNexus has 23.09% free space left | 'db_datanexus_free_pct'=23.09%;10:;5:;0;100 'db_datanexus_free'=245423.50MB;106311.4625:;53155.7312:;0;1063114.625 'db_datanexus_allocated_pct'=82.14%;;;0;100

nagios@davinci:/usr/local/nagios/libexec$ cat /usr/local/nagios/libexec/temp.log
OK - database DataNexus has 23.09% free space left | 'db_datanexus_free_pct'=23.09%;10:;5:;0;100 'db_datanexus_free'=245423.50MB;106311.4625:;53155.7312:;0;1063114.625 'db_datanexus_allocated_pct'=82.14%;;;0;100
danjoh
Posts: 73
Joined: Mon Dec 07, 2015 10:43 am
Location: Zürich, Switzerland
Contact:

Re: plugin output ommited

Post by danjoh »

What I was asking for was you to change the command definition in Nagios and let Nagios execute the check once - then post the output of the "log" file.
What you could also try i to put '2>&1' in the command definition before "| tee .." .

And that you are not allowed to write in /tmp seems strange to me - that would be (one of) the normal place(s) to write temporary data when executing a script.
--
D/\N
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

Re: plugin output ommited

Post by amprantino »

The plugin writes its temp data to path: /var/tmp/check_mssql_health
define command {
command_name check_mssql_health2
command_line $USER1$/check_mssql_health --server $ARG1$ $USER9$ --mode $ARG2$ --name $ARG3$ --nooffline --commit 2>&1 | tee -a /tmp/TEST1
}

tail -f /tmp/TEST1
OK


define command {
command_name check_mssql_health2
command_line $USER1$/check_mssql_health --server $ARG1$ $USER9$ --mode $ARG2$ --name $ARG3$ --nooffline --commit | tee -a /tmp/TEST2
}

tail -f /tmp/TEST2
OK
danjoh
Posts: 73
Joined: Mon Dec 07, 2015 10:43 am
Location: Zürich, Switzerland
Contact:

Re: plugin output ommited

Post by danjoh »

This is (for me) a clear indication that the commend does not output the same data when run from the commandline as when run from Nagios.

Could you try running it like this from the commandline (not as check_command):

Code: Select all

su nagios
./check_mssql_health --server SQLSERVER --username 'domain\usernagios' --password '123456789' --mode=database-data-free --name=datanexus --commit </dev/null
and

Code: Select all

su nagios
./check_mssql_health --server SQLSERVER --username 'domain\usernagios' --password '123456789' --mode=database-data-free --name=datanexus --nooffline --commit

What does the "--nooffline" command parameter do? In your command-definition you have it set but when you run the command from the commandline you do not have it set.
--
D/\N
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

Re: plugin output ommited

Post by amprantino »

Cheking the script, line 5915:

Code: Select all

 if ($self->opts->units eq "%") {
    $self->set_thresholds(metric => $metric_pct, warning => "10:", critical => "5:");
    ($warning_pct, $critical_pct) = ($self->get_thresholds(metric => $metric_pct));
    ($warning_units, $critical_units) = map {
        $_ =~ s/://g; ($_ * $self->{size} / 100).":";
    } map { my $tmp = $_; $tmp; } ($warning_pct, $critical_pct); # sonst schnippelt der von den originalen den : weg
    $self->set_thresholds(metric => $metric_units, warning => $warning_units, critical => $critical_units);
    $self->add_message($self->check_thresholds(metric => $metric_pct, value => $self->{free_space_pct}),
        sprintf("disk %s has %.2f%s free space left", $self->{name}, $self->{free_space_pct}, $self->opts->units)); <<<<<<<<<<<<<<<<<<<<<<
  } else {
    $self->set_thresholds(metric => $metric_units, warning => "5:", critical => "10:");
    ($warning_units, $critical_units) = ($self->get_thresholds(metric => $metric_units));
    ($warning_pct, $critical_pct) = map {
        $_ =~ s/://g; (100 * $_ / $self->{size}).":";
    } map { my $tmp = $_; $tmp; } ($warning_units, $critical_units);
    $self->set_thresholds(metric => $metric_pct, warning => $warning_pct, critical => $critical_pct);
    $self->add_message($self->check_thresholds(metric => $metric_units, value => $self->{free_space}),
        sprintf("disk %s has %.2f%s free space left", $self->{name}, $self->{free_space}, $self->opts->units));
  }
Do you see anything strange to the output?
danjoh
Posts: 73
Joined: Mon Dec 07, 2015 10:43 am
Location: Zürich, Switzerland
Contact:

Re: plugin output ommited

Post by danjoh »

May I ask where you have downloaded this check?

The one I find @ConSol Labs does not have some of the command-line parameters that you use (E.g. --mode=database-data-free, --commit and --nooffline).
--
D/\N
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: plugin output ommited

Post by scottwilkerson »

I agree something certainly is not correct, the examples with | tee -a /tmp/TEST1 shows the command is displaying in Nagios exactly what is being output from the command when Nagios runs it.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked