[PATCH] NDO - Check for configuration file availability
Stephen Gran
steve at lobefin.net
Fri Jan 7 10:52:21 CET 2011
On Wed, Jan 05, 2011 at 03:45:55PM -0200, Ricardo Maraschini said:
> Hello,
>
> I don't know if this is the right list for NDO, but i'll learn it on
> the hard way, though. I installed NDO into a CentOS, and when i
> started Nagios i received the following message at nagios.log:
>
> ndomod: Could not open data sink! I'll keep trying, but some output
> may get lost...
>
> I figured out that nagios' user couldn't access NDO configuration file
> due to a permission issue. It took me some time to discover the source
> of the problem, so i thought that maybe an accurate error message can
> help on this.
>
> I've applied the patch below against ndoutils-1.4b9.
>
> --- ndomod.c 2009-10-27 01:08:29.000000000 -0700
> +++ ndomod.c-modified 2011-01-05 03:40:08.000000000 -0800
> @@ -330,10 +330,15 @@
> ndo_mmapfile *thefile=NULL;
> char *buf=NULL;
> int result=NDO_OK;
> + char temp_buffer[NDOMOD_MAX_BUFLEN];
>
> /* open the file */
> - if((thefile=ndo_mmap_fopen(filename))==NULL)
> + if((thefile=ndo_mmap_fopen(filename))==NULL) {
> + snprintf(temp_buffer,sizeof(temp_buffer)-1,"ndomod: Unable to open configuration file, please check permissions.\n");
> + temp_buffer[sizeof(temp_buffer)-1]='\x0';
> + ndomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE);
> return NDO_ERROR;
> + }
>
> /* process each line of the file */
> while((buf=ndo_mmap_fgets(thefile))){
Hi,
I'd be quite happy to see this display the actual error instead of
hardcoding a suggestion that may be inaccurate.
Something like:
snprintf(temp_buffer,sizeof(temp_buffer)-1,"ndomod: Unable to open configuration file %s: %s\n", filename, strerror(errno))
Cheers,
--
--------------------------------------------------------------------------
| Stephen Gran | Don't vote -- it only encourages them! |
| steve at lobefin.net | |
| http://www.lobefin.net/~steve | |
--------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20110107/ad902914/attachment.sig>
-------------- next part --------------
------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web. Learn how to
best implement a security strategy that keeps consumers' information secure
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel
More information about the Developers
mailing list