<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>ndoutils with zlib</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Hello Developers,<BR>
<BR>
we are happily using ndomod on more than 1000 machines distributed to multiple locations, but the traffic (over leased lines) is tremendous. To reduce this traffic I was told to embed zlib into ndoutils (ndoutils-1.4b7).<BR>
<BR>
What did I do?<BR>
<BR>
To make ndomod.c more readable, I refactored some of its functionality.<BR>
<BR>
First, I moved the option-parsing to extra files parseopt.[c|h]<BR>
parseopt.h defines a struct to hold all configuration data for ndomod, replacing various global variables in ndomod.c.<BR>
parseopt.c does the option-parsing with parameters given by nagios and the configuration file. It also contains the default values, formerly kept in ndomod.c.<BR>
For zipped tcp Streams, the option output_type now understands the new value 'tcpsocketzip'.<BR>
<BR>
Second, I refactored io.[c|h].<BR>
Handing filedescriptors around is no option, when you need a gz_file-Structure.<BR>
In order to fix this I declared a new struct ndo_sink_description_struct, which is holding the filedescriptor, the pointer to gz_file and some status-variables, intended to replace sink-related global variables in ndomod.c (is_open, previously_open).<BR>
Also io.h defines the new sink-type NDO_SINK_TCPSOCKETZIP.<BR>
<BR>
I replaced all sink-related functions (ndo_sink_open, ndo_sink_write, ndo_sink_write_newline, ndo_sink_flush, ndo_sink_close) by new functions (ndo_sink_init2, ndo_sink_open2, ndo_sink_write2, ndo_sink_write_newline2, ndo_sink_flush2, ndo_sink_close2) which take a pointer to a ndo_sink_description_struct as their first argument.<BR>
I admit, this is kind of object-oriented, but not knowing all compilers and target platforms of nagios I resisted zo use real Objects. I also tried to keep the strange indention scheme, although editor & brain support seems broken, as the mixed usage of tabs and spaces in the given sources prooves. (In real life I'm a wimpy java programmer, so I prefer KR)<BR>
<BR>
Compression works best, if there is a some amount of data to compress, so I introcduced some slight changes to ndomod.c concerning the (re-)opening of the sink:<BR>
If the sink-Buffer is empty (and if the sink prefers blockwise data, as zipped tcp does) the connection will be closed. It will be reopened after the usual reconnect interval. (src/ndomod.c line 596ff)<BR>
This implies that reconnect_time and output_buffer_items should be set to reasonable values, otherwise data will get lost. Also the logfile may contain some unnecessary warnings.<BR>
<BR>
I patched all other programs (ndo2db, file2sock, log2ndo) according to the new possiblities.<BR>
ndo2db will automatically detect a zipped tcp stream, file2sock and log2ndo both have changed command line parameters. I also altered their help-texts.<BR>
<BR>
Finally I _tried_ to fix the build-process. (Here I need help)<BR>
I managed to extend src/Makefile.in and include/config.h.in.<BR>
config.h.in now has a section for zlib, similar to those for the databases.<BR>
I peppered the whole project with #ifdef HAVE_ZLIBs, so that it will compile (and work!) with and without HAVE_ZLIB.<BR>
<BR>
This is where I need your help:<BR>
I was unable to adapt the configure-Script, so that it automatically recognizes if zlib-support could be built in.<BR>
Currently, after ./configure, I have to fix the created include/config.h to #define USE_ZLIB 1 (line  272 ff)<BR>
<BR>
Please help me to fix this issue.<BR>
<BR>
I would be happy if these changes would be included into a new version of ndoutils. Also I am open to your comments and further improvements. Beyond the configure-issue the code is working in our current setup for several days.<BR>
<BR>
I tried to build a .diff-file, but I doubt the attached file is really usefull.<BR>
I published the whole changed ndoutils at <A HREF="http://joey.in-ulm.de/2008/ndoutils">http://joey.in-ulm.de/2008/ndoutils</A><BR>
Please have a look at it.<BR>
<BR>
<BR>
anticipating your comments,<BR>
Joey5337<BR>
</FONT>
</P>

</BODY>
</HTML>