[Nagios-devel] Patch to use a database as the history log

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] Patch to use a database as the history log

Post by Guest »

This is a multipart MIME message.

--==_Exmh_-6859155680
Content-Type: text/plain; charset=us-ascii


This is a large patch to get nagios to use a mysql database (if someone
wants to volunteer to add postgres support I'm sure it would be
appreciated) for storing and retrieving history information.

This makes it significantly faster for larger sites as instead of
having to do lots of expensive string operations for every line of
every log file, you can just do one SELECT() and pull out exactly what
information is required, so you are not wasting cycles processing
information that you aren't interested in.

I haven't had a chance to test it extensively yet, but a few people
mailed expressing interest in it, so I thought I had better ship it.
Hopefully there aren't too many segfaults left in it :) If you find any
gotchas please mail them to me and I'll fix them up.

There is a simple python script (logconv.py) included in the contrib
directory which will read in your old logs and output the sql commands
necessary to put them into your database.

--
Dougal Scott Connect Internet Solutions
dwagon@connect.com.au 9/114 Albert Rd
Senior Systems Administrator South Melbourne, Australia, 3205


--==_Exmh_-6859155680
Content-Type: text/plain ; name="xlogdb.diffs"; charset=us-ascii
Content-Description: xlogdb.diffs
Content-Disposition: attachment; filename="xlogdb.diffs"

Index: configure.in
===================================================================
RCS file: /cvsroot/nagios/nagios/configure.in,v
retrieving revision 1.27
diff -r1.27 configure.in
109a110
> XLOGTYPE=default
117a119
> XLOGCOMMENT=
129a132
> XLOGTYPE=mysql
139a143
> XLOGTYPE=pgsql
202a207,233
> dnl Should we use a database for logging history? If so which one?
> AC_ARG_WITH(mysql-historylog,--with-mysql-historylog enables use of MySQL database to store the service history log, XLOGTYPE=mysql)
> AC_ARG_WITH(pgsql-historylog,--with-pgsql-historylog enables use of PostgreSQL database to store the service history log, XLOGTYPE=pgsql)
> AC_ARG_WITH(default-historylog,--with-default-historylog disables use of a database to store service history logs,XLOGTYPE=default)
> if test $XLOGTYPE = mysql; then
> AC_DEFINE_UNQUOTED(USE_XLOGDB)
> AC_DEFINE_UNQUOTED(USE_XLOGMYSQL)
> USE_MYSQL=yes
> XLOGC="xlogdb.c"
> XLOGH="xlogdb.h"
> echo "We'll use MySQL database routines (in xdata/xlogdb.*) for history log"
> XLOGCOMMENT="Database (MySQL)"
> elif test $XLOGTYPE = pgsql; then
> AC_DEFINE_UNQUOTED(USE_XLOGDB)
> AC_DEFINE_UNQUOTED(USE_XLOGPGSQL)
> USE_PGSQL=yes
> XLOGC="xlogdb.c"
> XLOGH="xlogdb.h"
> echo "We'll use PostgreSQL database routines (in xdata/xlogdb.*) for history log"
> XLOGCOMMENT="Database (PostgreSQL)"
> else
> XLOGCOMMENT="Default (external text file)"
> XLOGC="xlogdefault.c"
> echo "Not using databases to service check history"
> fi
> AC_SUBST(XLOGC)
> AC_SUBST(XLOGH)
785a817
> AC_MSG_RESULT([ History Log data: $XLOGCOMMENT])
Index: base/Makefile.in
===================================================================
RCS file: /cvsroot/nagios/nagios/base/Makefile.in,v
retrieving revision 1.4
diff -r1.4 Makefile.in
49a50
> XLOGC=@XLOGC@
86a88,89
> # History Log commands
> XLOGLIBS=$(SRC_XDATA)/$(XLOGC)
88c91
OBJS=checks.o config.o commands.o flapping.o logging.o notifications.o sehandlers.o utils.o $(RDATALIBS) $(CDATALIBS) $(ODATALIBS) $(SDATALIBS) $(PDATALIBS) $(DDATALIBS) $(BASEEXTRALIBS) $(SNPRINTF_O) $(XLOGLIBS)
Index: base/logging.c
===================================================================
RCS file: /cvsroot/nagios/nagios/base/logging.c,v
retrieving revision 1.1.1.1
diff -r1.1.1.1 logging.c
192a193,196
> #ifdef USE_XLOGDB
> xlogdb_log_service_event(svc, macro_service_state, (state_type==SOFT_STATE)?"SOFT":"HARD");
> #endif
>
246a251,255
>
> #ifdef USE_XLOGDB
> xlogdb_log_host_even

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: dwagon@connect.com.au
Locked