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" ); like( $output, "/Error reading status file 'var/status.dat.no.such.file': No such file or directory/", "No config file" ); -$output = `$nagiostats -c "$etc/nagios-no-status.cfg" -m NUMHSTUP`; +$output = `$nagiostats -c "$etc/nagios-no-status.cfg" -m -d NUMHSTUP`; isnt( $?, 0, "Bad return code with no status file in MRTG mode" ); +like( $output, "/^0\$/", "No UP host when no status file" ); +$output = `$nagiostats -c "$etc/nagios-with-generated-status.cfg" -m -d NUMHOSTS`; +is( $?, 0, "Bad return code with implied status file in MRTG mode" ); +unlike( $output, "/^0\$/", "Implied generated status file contains host(s)" ); + +$output = `$nagiostats -s "$var/status-generated.dat" -m -d NUMHOSTS`; +is( $?, 0, "Bad return code with explicit status file in MRTG mode" ); +unlike( $output, "/^0\$/", "Explicit generated status file contains host(s)" );