Introducing SNMP4Nagios
Peter Gritsch
s4nag at no-where.at
Mon Jan 30 19:04:31 CET 2006
On Monday 30 January 2006 11:45, Andre Heine wrote:
Okay, here is what I found:
The interface did indeed change. Quote rrd.h:
* Revision 1.7 2003/11/12 22:14:26 oetiker
* allow to pass an open filehandle into rrd_graph as an extra
argument
/Quote
> [...]
> But I get some problems to compile it with RRDtool 1.2.11.
>
> gcc -O2 -I. `net-snmp-config --cflags` -ansi -pedantic -Wall
> -D_GNU_SOURCE -DRRDDIR='"/usr/local/nagios/perflog/rrd"'
> -DPNGDIR='"/usr/local/nagios/perflog/img"' -c -o rrdif.o rrdif.c
> rrdif.c: In function ‘RRDGraph’:
> rrdif.c:545: error: syntax error before ‘/’ token
> rrdif.c:545:13: error: too many decimal points in number
> rrdif.c:546: error: too few arguments to function ‘rrd_graph’
> rrdif.c:546: error: syntax error before ‘/’ token
> make: *** [rrdif.o] Fehler 1
> [...]
I looks different on my test machine (a Debian Sarge this time,
using home-built rrdtool 1.2.12:
gcc -O2 -I. `net-snmp-config --cflags` -ansi -pedantic -Wall
-D_GNU_SOURCE -DRRDDIR='"/usr/local/nagios/perflog/rrd"'
-DPNGDIR='"/usr/local/nagios/perflog/img"' -c -o rrdif.o rrdif.c
rrdif.c: In function `RRDGraph':
rrdif.c:545: error: too few arguments to function `rrd_graph'
make: *** [rrdif.o] Error 1
but it is basically the same error.
> [...]
> chk = rrd_graph (aParamCnt, aParams, &results, &w, &h, NULL,
> NULL,NULL);
>
> Now, it compiles cleanly. But it's untested yet...
The function is declare like this:
rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int
*ysize,
FILE *stream, double *ymin, double *ymax)
"stream" is only used this way:
im.graphhandle = stream;
"im.graphhandle" in turn is used like this:
=== BEGIN ===
if (strcmp(im->graphfile,"-")==0) {
fo = im->graphhandle ? im->graphhandle : stdout;
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
/* Change translation mode for stdout to BINARY */
_setmode( _fileno( fo ), O_BINARY );
#endif
} else {
if ((fo = fopen(im->graphfile,"wb")) == NULL) {
rrd_set_error("Opening '%s' for write: %s",im->graphfile,
rrd_strerror(errno));
return (-1);
}
}
gfx_render (im->canvas,im->ximg,im->yimg,0x00000000,fo);
=== END ===
Which roughly translates to:
If the filename is equal to "-" and "stream" is not NULL, then write
the graph to the file "stream". So NULL would be ok 'cause the
filename is never set to "-"
"ymin" and "ymax" are only used like this:
*ymin=im.minval;
*ymax=im.maxval;
IOW: They are used to pass values back to the caller.
Now I'm no C guru at all but dereferencing a NULL pointer
seems like a bad idea to me. Sorry, my test maching just crashed,
the Mainboard hangs during POST and I can't find the manual
(of course) so I can't give you a decent diff for now.
However replacing the head of RRDGraph with this should work:
void RRDGraph ( int aParamCnt, char** aParams, tFN* aFN, tPP* aPP )
{
int chk = -1;
int w;
int h;
char** results;
int j = 0;
double junk1;
double junk2;
LogParams ( aParamCnt, aParams );
optind = 1; /* rrd_*'s weired interface */
rrd_clear_error ();
/* rrd_* functions return 0 on success. */
chk = rrd_graph ( aParamCnt, aParams, &results, &w, &h,
NULL, &junk1, &junk2 );
I'll fix it in the release once I've figured out how to check for
the version of rrd.h (without actually using autoconf/automake right
now).
So long,
Peter
--
Peter Gritsch
mail: s4nag at no-where.at
web: http://snmp4nagios.sourceforge.net/
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list