Re: [Nagios-devel] nagiostats Config Parameters

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.
Locked
Guest

Re: [Nagios-devel] nagiostats Config Parameters

Post by Guest »

This is a multi-part message in MIME format.
--------------040509010000050403070809
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable

On 05/24/2012 11:30 AM, Andreas Ericsson wrote:
> On 05/18/2012 12:52 AM, Jochen Bern wrote:
>> On 05/11/2012 09:34 PM, Jochen Bern wrote:
>>> Everyone,
>>> I played with the "-c" and "-s" Parameters of a 3.2.3's nagiostats to=
day
>>> and noticed the odd behavior shown below. [...]
>> Any chance that the -s option might be reappropriated to read the
>> current status.dat files via read_status_file(), rather than a format
>> lost in the sands of time ... ?
>=20
> Sounds like you've already done a large part of the analysis, so it mig=
ht
> be good if you did the patch as well.

Very well. The attached patch is for 3.2.3, which is what I have at hand
right now both source- and real-world-example-data-wise. Does it happen
to apply cleanly to 3.4.1 ... ?

Kind regards,
J. Bern

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Running new tests against unpatched execut=
able =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

[root@nagios nagios-3.2.3+all]# make test-perl
[...]
705nagiostats.t ................. 9/10
# Failed test 'Explicit generated status file contains host(s)'
# at 705nagiostats.t line 37.
# '0
# '
# matches '/^0$/'
# Looks like you failed 1 test of 10.
[...]
Result: FAIL
[...]

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Compiling patched source and re-running te=
sts =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

[root@nagios nagios-3.2.3+all]# make all
cd ./base && make
make[1]: Entering directory `/root/nagios-3.2.3+all/base'
gcc -g -O2 -DHAVE_CONFIG_H -DNSCORE -o nagiostats nagiostats.c -lm
make[1]: Leaving directory `/root/nagios-3.2.3+all/base'
[...]
[root@nagios nagios-3.2.3+all]# make test-perl
[...]
705nagiostats.t ................. ok
[...]
Result: PASS
make[1]: Leaving directory `/root/nagios-3.2.3+all/t'
--=20
Jochen Bern, Systemingenieur --- LINworks GmbH
Postfach 100121, 64201 Darmstadt | Robert-Koch-Str. 9, 64331 Weiterstadt
PGP (1024D/4096g) FP =3D D18B 41B1 16C0 11BA 7F8C DCF7 E1D5 FAF4 444E 1C2=
7
Tel. +49 6151 9067-231, Zentr. -0, Fax -299 - Amtsg. Darmstadt HRB 85202
Unternehmenssitz Weiterstadt, Gesch=E4ftsf=FChrer Metin Dogan, Oliver Mic=
hel

--------------040509010000050403070809
Content-Type: text/plain;
name="nagios-3.2.3-nagiostats-s-option-patch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="nagios-3.2.3-nagiostats-s-option-patch.txt"

diff -Naur nagios-3.2.3/base/nagiostats.c nagios-3.2.3+all/base/nagiostats.c
--- nagios-3.2.3/base/nagiostats.c 2010-10-04 05:56:55.000000000 +0200
+++ nagios-3.2.3+all/base/nagiostats.c 2012-06-20 23:26:52.000000000 +0200
@@ -401,7 +401,14 @@

/* read pre-processed stats file */
if(nagiostats_file){
- result=read_nagiostats_file();
+ /* 20-Jun-2012 The format that read_nagiostats_file() tries to parse seems to have
+ been dropped entirely some time ago. Replace it with read_status_file() so that
+ the --statusfile option serves *some* purpose at least */
+ /* result=read_nagiostats_file(); */
+ if(status_file)
+ free(status_file);
+ status_file=strdup(nagiostats_file);
+ result=read_status_file();
if(result==ERROR && mrtg_mode==FALSE){
printf("Error reading stats file '%s': %s\n",nagiostats_file,strerror(errno));
return ERROR;
diff -Naur nagios-3.2.3/t/705nagiostats.t nagios-3.2.3+all/t/705nagiostats.t
--- nagios-3.2.3/t/705nagiostats.t 2009-05-15 01:52:42.000000000 +0200
+++ nagios-3.2.3+all/t/705nagiostats.t 2012-06-20 23:18:51.000000000 +0200
@@ -12,10 +12,11 @@
my $topdir = "$Bin/..";
my $nagiostats = "$topdir/base/nagiostats";
my $etc = "$Bin/etc";
+my $var = "$Bin/var";

-plan tests => 5;
+plan tests => 10;

-my $output = `$nagiostats -c "$etc/nagios-does-not-exit.cfg"`;
+my $output = `$nagiostats -c "$etc/nagios-does-not-exist.cfg"`;
isnt( $?, 0, "Bad return code with no config file" );
like( $output, "/Error processing config file/", "No config file" );

@@ -23,6 +24,14 @@
isnt( $?, 0, "Bad return code with no status file" )

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: Jochen.Bern@LINworks.de
Locked