Page 1 of 1

Re: [Nagios-devel] Nagios2JSON

Posted: Sun Jun 15, 2008 8:52 am
by Guest
This is a multi-part message in MIME format.
--------------040402050906020209070802
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 14/06/08 11:16 PM, Yann JOUANIN wrote:
> I finished coding the XSDJSON backend for Nagios, it works on Nagios 2 (I'm
> finishing the Nagios3 version).
> Now by enabling USE_XSDJSON, the file status.dat is formatted in JSON format
> and the CGI are reading status from this format.
>
> For the ones who want to test it, file are available on :
>
> http://nagios2json.svn.sourceforge.net/ ... trunk/NAGI
> OS2/

Awesome work!

I made it as a single patch for 2.x-cvs which also includes configure.in
modifications.

After applying the patch, be sure to run "autoconf" then you can
configure Nagios with JSON routines with:

./configure --enable-xsdjson

Configure will print the following near the end:
We'll use JSON routines (in xdata/xsdjson.*) for status data I/O...

Then usual make and make install to get everything installed.

I haven't tested it yet (lack of time) but it does build successfully
with JSON routines.

Enjoy :)

Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIVUi26dZ+Kt5BchYRAqWcAJ40Eco7ZBoYPZMRb5y++rCSBey8TQCg4k0c
nQv0AzVIcDBDUIeptwoTLGg=
=oDjl
-----END PGP SIGNATURE-----

--------------040402050906020209070802
Content-Type: text/x-diff;
name="nagios2.JSON_Status-beta1.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios2.JSON_Status-beta1.patch"

diff -uNr nagios.orig/common/statusdata.c nagios/common/statusdata.c
--- nagios.orig/common/statusdata.c 2008-06-15 12:29:27.000000000 -0400
+++ nagios/common/statusdata.c 2008-06-15 09:44:14.000000000 -0400
@@ -43,6 +43,10 @@
#include "../xdata/xsddefault.h" /* default routines */
#endif

+#ifdef USE_XSDJSON
+#include "../xdata/xsdjson.h" /* JSON routines */
+#endif
+

#ifdef NSCORE
extern int aggregate_status_updates;
@@ -75,6 +79,9 @@
result=xsddefault_initialize_status_data(config_file);
#endif

+#ifdef USE_XSDJSON
+ result=xsdjson_initialize_status_data(config_file);
+#endif
return result;
}

@@ -93,6 +100,10 @@
result=xsddefault_save_status_data();
#endif

+#ifdef USE_XSDJSON
+ result=xsdjson_save_status_data();
+#endif
+
#ifdef USE_EVENT_BROKER
/* send data to event broker */
broker_aggregated_status_data(NEBTYPE_AGGREGATEDSTATUS_ENDDUMP,NEBFLAG_NONE,NEBATTR_NONE,NULL);
@@ -114,6 +125,10 @@
result=xsddefault_cleanup_status_data(config_file,delete_status_data);
#endif

+#ifdef USE_XSDJSON
+ result=xsdjson_cleanup_status_data(config_file,delete_status_data);
+#endif
+
return result;
}

@@ -201,6 +216,9 @@
#ifdef USE_XSDDB
result=xsddb_read_status_data(config_file,options);
#endif
+#ifdef USE_XSDJSON
+ result=xsdjson_read_status_data(config_file,options);
+#endif

return result;
}
diff -uNr nagios.orig/configure.in nagios/configure.in
--- nagios.orig/configure.in 2008-06-15 12:29:27.000000000 -0400
+++ nagios/configure.in 2008-06-15 12:12:26.000000000 -0400
@@ -219,11 +219,24 @@
USE_PGSQL=no

dnl Status data
-AC_DEFINE_UNQUOTED(USE_XSDDEFAULT)
-XSDC="xsddefault.c"
-XSDH="xsddefault.h"
-XSDCOMMENT="Default (text file)"
-echo "We'll use default routines (in xdata/xsddefault.*) for status data I/O..."
+AC_ARG_ENABLE(xsdjson,
+ AC_HELP_STRING([--enable-xsdjson],
+ [Enables JSON format for status file (default: no)]),
+ [enable_xsdjson=$enableval],
+ [enable_xsdjson=no])
+if test "$enable_xsdjson" = "yes" ; then
+ AC_DEFINE_UNQUOTED(USE_XSDJSON)
+ XSDC="xsdjson.c"
+ XSDH="xsdjson.h"
+ XSDCOMMENT="JSON"
+ echo "We'll use JSON routines (in xdata/xsdjson.*) for status data I/O..."
+else
+ AC_DEFINE_UNQUOTED(USE_XSDDEFAULT)
+ XSDC="xsddefault.c"
+ XSDH="xsddefault.h"
+ XSDCOMMENT="Default (text file)"
+ echo "We'll use default routines (in xdata/xsddefault.*) for status data I/O..."
+fi
AC_SUBST(XSDC)
AC_SUBST(XSDH)

diff -uNr nagios.orig/xdata/xsdjson.c nagios/xdata/xsdjson.c
--- nagios.orig/xdata/xsdjson.c 196

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]