[Nagios-devel] Xml status cgi for nagios3

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Xml status cgi for nagios3

Post by Guest »


--Apple-Mail-17-184131161
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit

Hi everybody,

I wrote a modified version of the nagios core cgi status.c to produce
XML output,
to feed this to Ajax websites like Google Maps, where status
informations get displayed.


The attached code (statusXML.patch) will, when used on a nagios3.0
source , create a new cgi,
called statusXML.c and change the corresponging entry in the Makefile...


I think it could be put into the nagios3 package, as it's a core cgi
that uses the same functions
as the other statusXYZ.c and nees to get compiled with the same
options anyhow.

Please test it, feedback is very welcome.

Attached are the source patch and an example xml output..

br,
Matthias


--Apple-Mail-17-184131161
Content-Disposition: attachment;
filename=statusXML.patch
Content-Type: application/octet-stream; x-unix-mode=0644;
name="statusXML.patch"
Content-Transfer-Encoding: 7bit

Index: cgi/Makefile.in
===================================================================
--- cgi/Makefile.in (revision 1)
+++ cgi/Makefile.in (revision 19)
@@ -39,7 +39,7 @@
LDFLAGS=@LDFLAGS@
LIBS=@LIBS@ @GLIB_LIBS@

-CGIS=avail.cgi cmd.cgi config.cgi extinfo.cgi history.cgi notifications.cgi outages.cgi showlog.cgi status.cgi statuswml.cgi summary.cgi tac.cgi $(CGIEXTRAS)
+CGIS=avail.cgi cmd.cgi config.cgi extinfo.cgi history.cgi notifications.cgi outages.cgi showlog.cgi status.cgi statusXML.cgi statuswml.cgi summary.cgi tac.cgi $(CGIEXTRAS)

# External data I/O code and headers
XSDC=@XSDC@
@@ -157,6 +157,9 @@
status.cgi: status.c $(CGIDEPS) $(CDATADEPS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ status.c $(CGILIBS) $(CDATALIBS) $(LIBS)

+statusXML.cgi: statusXML.c $(CGIDEPS) $(CDATADEPS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ statusXML.c $(CGILIBS) $(CDATALIBS) $(LIBS)
+
statuswml.cgi: statuswml.c $(CGIDEPS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ statuswml.c $(CGILIBS) $(LIBS)

Index: cgi/statusXML.c
===================================================================
--- cgi/statusXML.c (revision 0)
+++ cgi/statusXML.c (revision 19)
@@ -0,0 +1,1750 @@
+/**************************************************************************
+ *
+ * STATUS.C - Nagios Status CGI
+ *
+ * Copyright (c) 1999-2008 Ethan Galstad ([email protected])
+ * Changed to prodce XML output by Matthias Haider ([email protected])
+ * Last Modified: 03-14-2008
+ *
+ * License:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *************************************************************************/
+
+#include "../include/config.h"
+#include "../include/common.h"
+#include "../include/objects.h"
+#include "../include/comments.h"
+#include "../include/macros.h"
+#include "../include/statusdata.h"
+
+#include "../include/cgiutils.h"
+#include "../include/getcgi.h"
+#include "../include/cgiauth.h"
+
+extern int refresh_rate;
+extern time_t program_start;
+
+extern char main_config_file[MAX_FILENAME_LENGTH];
+extern char url_html_path[MAX_FILENAME_LENGTH];
+extern char url_docs_path[MAX_FILENAME_LENGTH];
+extern char url_images_path[MAX_FILENAME_LENGTH];
+extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
+extern char url_logo_images_path[MAX_FILENAME_LENGTH];
+extern char url_media_path[MAX_FILENAME_LENGTH];
+extern char log_file[MAX_FILENAME_LENGTH];
+
+extern char *service_critical_sound;
+extern char *service_warning_sound;
+extern char *service_unknown_sound;
+extern char *host_down_sou

...[email truncated]...


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