Page 1 of 1

[Nagios-devel] Major speedup of CGI

Posted: Thu Sep 04, 2003 6:01 pm
by Guest
--Y7xTucakfITjPcLV
Content-Type: multipart/mixed; boundary="ibTvN161/egqYuK8"
Content-Disposition: inline


--ibTvN161/egqYuK8
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Attached is another patch to Nagios 1.1 which hugely speeds up the CGIs.
This is a big benefit when monitoring a lot (~ 7000) of services, but there
will be a benefit for a smaller number too.

Profiling shows that most of the time taken to run the CGI is in loading
the list of services and sticking them into a sorted list.

This patch turns loading the service list into a 2 step process:

1. Load the services into a binary tree (glib)
2. Flatten the tree down into the sorted list.

Before, the CGI took between 3-10 seconds to run, now it takes 0.2 seconds.

FYI I didn't write this patch, my boss did. I'm just submitting it.

--=20
Regards,
David Parrish
0410 586 121

--ibTvN161/egqYuK8
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="nagios-1.1-bintree.patch"
Content-Transfer-Encoding: quoted-printable

Index: base/Makefile.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/cvs/repos/nagios_source/base/Makefile.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile.in
--- base/Makefile.in 23 Jun 2003 01:56:10 -0000 1.1.1.1
+++ base/Makefile.in 5 Sep 2003 01:45:51 -0000
@@ -10,9 +10,9 @@
SRC_XDATA=3D../xdata
=20
CC=3D@CC@
-CFLAGS=3D@CFLAGS@ @DEFS@ -DNSCORE
+CFLAGS=3D@CFLAGS@ @DEFS@ -DNSCORE `glib-config --cflags`
#CFLAGS=3D-O3 -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wst=
rict-prototypes -Wmissing-prototypes -Wnested-externs -DHAVE_CONFIG_H -DNSC=
ORE
-LDFLAGS=3D@LDFLAGS@ @LIBS@
+LDFLAGS=3D@LDFLAGS@ @LIBS@ `glib-config --libs`
=20
prefix=3D@prefix@
exec_prefix=3D@exec_prefix@
Index: cgi/Makefile.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/cvs/repos/nagios_source/cgi/Makefile.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile.in
--- cgi/Makefile.in 23 Jun 2003 01:56:10 -0000 1.1.1.1
+++ cgi/Makefile.in 5 Sep 2003 01:45:51 -0000
@@ -25,9 +25,9 @@
=20
CP=3D@CP@
CC=3D@CC@
-CFLAGS=3D@CFLAGS@ @DEFS@ -DNSCGI
+CFLAGS=3D@CFLAGS@ @DEFS@ -DNSCGI `glib-config --cflags`
#CFLAGS=3D-O3 -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wst=
rict-prototypes -Wmissing-prototypes -Wnested-externs -DHAVE_CONFIG_H -DNSC=
GI
-LDFLAGS=3D@LDFLAGS@ @LIBS@
+LDFLAGS=3D@LDFLAGS@ @LIBS@ `glib-config --libs`
=20
CGIS=3Davail.cgi cmd.cgi config.cgi extinfo.cgi history.cgi notifications.=
cgi outages.cgi showlog.cgi status.cgi statuswml.cgi summary.cgi tac.cgi $(=
CGIEXTRAS)
=20
Index: common/common.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/cvs/repos/nagios_source/common/common.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 common.h
--- common/common.h 23 Jun 2003 01:57:24 -0000 1.1.1.2
+++ common/common.h 5 Sep 2003 01:45:51 -0000
@@ -208,8 +208,12 @@
#define OK 0
#define ERROR -2 /* value was changed from -1 so as to not interfere wi=
th STATUS_UNKNOWN plugin result */
=20
+#ifndef TRUE
#define TRUE 1
+#endif
+#ifndef FALSE
#define FALSE 0
+#endif
=20
=20
/****************** HOST CONFIG FILE READING OPTIONS ********************/
Index: common/config.h.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/cvs/repos/nagios_source/common/config.h.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 config.h.in
--- common/config.h.in 23

...[email truncated]...


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