[-]
[+]
|
Changed |
nagios-mod_gearman.changes
|
|
[-]
[+]
|
Changed |
nagios-mod_gearman.spec
^
|
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/Changes
^
|
@@ -1,5 +1,11 @@
This file documents the revision history for mod_gearman.
+1.0.8 Fri Jul 22 22:21:34 CEST 2011
+ - use identifier for error messages if set
+ - fixed ld options (fixes debian bug #632431) thanks Ilya Barygin
+ - fixed memory leak in gearman_top
+ - fixed memory leak when reloading neb module
+
1.0.7 Sun Jul 3 15:18:16 CEST 2011
- show plugin output for exit codes > 3
- fixed send_multi timestamps when client clock is screwed
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/Makefile.am
^
|
@@ -53,14 +53,17 @@
gearman_top_SOURCES = $(common_SOURCES) \
tools/gearman_top.c
-gearman_top_LDFLAGS = -lncurses
+gearman_top_LDADD = -lncurses
# tests
-check_PROGRAMS = 01_utils 02_full 03_exec 04_log
+check_PROGRAMS = 01_utils 02_full 03_exec 04_log 05_neb
01_utils_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/01-utils.c
02_full_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/02-full.c
03_exec_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/03-exec_checks.c
04_log_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/04-log.c
+05_neb_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/05-neb.c
+05_neb_LDADD = -ldl
+05_neb_LDFLAGS = --export-dynamic -rdynamic
TESTS = $(check_PROGRAMS)
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/Makefile.in
^
|
@@ -46,7 +46,7 @@
send_multi$(EXEEXT) check_gearman$(EXEEXT) \
gearman_top$(EXEEXT)
check_PROGRAMS = 01_utils$(EXEEXT) 02_full$(EXEEXT) 03_exec$(EXEEXT) \
- 04_log$(EXEEXT)
+ 04_log$(EXEEXT) 05_neb$(EXEEXT)
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
@@ -114,15 +114,19 @@
t/04-log.$(OBJEXT)
04_log_OBJECTS = $(am_04_log_OBJECTS)
04_log_LDADD = $(LDADD)
+am_05_neb_OBJECTS = $(am__objects_1) t/tap.$(OBJEXT) \
+ t/05-neb.$(OBJEXT)
+05_neb_OBJECTS = $(am_05_neb_OBJECTS)
+05_neb_DEPENDENCIES =
+05_neb_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(05_neb_LDFLAGS) \
+ $(LDFLAGS) -o $@
am_check_gearman_OBJECTS = $(am__objects_1) \
tools/check_gearman.$(OBJEXT)
check_gearman_OBJECTS = $(am_check_gearman_OBJECTS)
check_gearman_LDADD = $(LDADD)
am_gearman_top_OBJECTS = $(am__objects_1) tools/gearman_top.$(OBJEXT)
gearman_top_OBJECTS = $(am_gearman_top_OBJECTS)
-gearman_top_LDADD = $(LDADD)
-gearman_top_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(gearman_top_LDFLAGS) $(LDFLAGS) -o $@
+gearman_top_DEPENDENCIES =
am_mod_gearman_worker_OBJECTS = $(am__objects_1) \
worker/worker_client.$(OBJEXT) worker/worker.$(OBJEXT)
mod_gearman_worker_OBJECTS = $(am_mod_gearman_worker_OBJECTS)
@@ -144,14 +148,14 @@
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(mod_gearman_so_SOURCES) $(01_utils_SOURCES) \
$(02_full_SOURCES) $(03_exec_SOURCES) $(04_log_SOURCES) \
- $(check_gearman_SOURCES) $(gearman_top_SOURCES) \
- $(mod_gearman_worker_SOURCES) $(send_gearman_SOURCES) \
- $(send_multi_SOURCES)
+ $(05_neb_SOURCES) $(check_gearman_SOURCES) \
+ $(gearman_top_SOURCES) $(mod_gearman_worker_SOURCES) \
+ $(send_gearman_SOURCES) $(send_multi_SOURCES)
DIST_SOURCES = $(mod_gearman_so_SOURCES) $(01_utils_SOURCES) \
$(02_full_SOURCES) $(03_exec_SOURCES) $(04_log_SOURCES) \
- $(check_gearman_SOURCES) $(gearman_top_SOURCES) \
- $(mod_gearman_worker_SOURCES) $(send_gearman_SOURCES) \
- $(send_multi_SOURCES)
+ $(05_neb_SOURCES) $(check_gearman_SOURCES) \
+ $(gearman_top_SOURCES) $(mod_gearman_worker_SOURCES) \
+ $(send_gearman_SOURCES) $(send_multi_SOURCES)
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
@@ -299,11 +303,14 @@
gearman_top_SOURCES = $(common_SOURCES) \
tools/gearman_top.c
-gearman_top_LDFLAGS = -lncurses
+gearman_top_LDADD = -lncurses
01_utils_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/01-utils.c
02_full_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/02-full.c
03_exec_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/03-exec_checks.c
04_log_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/04-log.c
+05_neb_SOURCES = $(common_SOURCES) t/tap.h t/tap.c t/05-neb.c
+05_neb_LDADD = -ldl
+05_neb_LDFLAGS = --export-dynamic -rdynamic
TESTS = $(check_PROGRAMS)
GEARMANDS = /usr/sbin/gearmand /opt/sbin/gearmand
replace_vars = sed -e 's:%CONFIG%:$(sysconfdir)/mod_gearman.conf:g' \
@@ -502,6 +509,10 @@
04_log$(EXEEXT): $(04_log_OBJECTS) $(04_log_DEPENDENCIES)
@rm -f 04_log$(EXEEXT)
$(LINK) $(04_log_OBJECTS) $(04_log_LDADD) $(LIBS)
+t/05-neb.$(OBJEXT): t/$(am__dirstamp) t/$(DEPDIR)/$(am__dirstamp)
+05_neb$(EXEEXT): $(05_neb_OBJECTS) $(05_neb_DEPENDENCIES)
+ @rm -f 05_neb$(EXEEXT)
+ $(05_neb_LINK) $(05_neb_OBJECTS) $(05_neb_LDADD) $(LIBS)
tools/$(am__dirstamp):
@$(MKDIR_P) tools
@: > tools/$(am__dirstamp)
@@ -517,7 +528,7 @@
tools/$(DEPDIR)/$(am__dirstamp)
gearman_top$(EXEEXT): $(gearman_top_OBJECTS) $(gearman_top_DEPENDENCIES)
@rm -f gearman_top$(EXEEXT)
- $(gearman_top_LINK) $(gearman_top_OBJECTS) $(gearman_top_LDADD) $(LIBS)
+ $(LINK) $(gearman_top_OBJECTS) $(gearman_top_LDADD) $(LIBS)
worker/$(am__dirstamp):
@$(MKDIR_P) worker
@: > worker/$(am__dirstamp)
@@ -556,6 +567,7 @@
-rm -f t/02-full.$(OBJEXT)
-rm -f t/03-exec_checks.$(OBJEXT)
-rm -f t/04-log.$(OBJEXT)
+ -rm -f t/05-neb.$(OBJEXT)
-rm -f t/tap.$(OBJEXT)
-rm -f tools/check_gearman.$(OBJEXT)
-rm -f tools/gearman_top.$(OBJEXT)
@@ -579,6 +591,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@t/$(DEPDIR)/02-full.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@t/$(DEPDIR)/03-exec_checks.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@t/$(DEPDIR)/04-log.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@t/$(DEPDIR)/05-neb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@t/$(DEPDIR)/tap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/check_gearman.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/gearman_top.Po@am__quote@
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/README
^
|
@@ -21,6 +21,17 @@
http://labs.consol.de/wp-content/uploads/2010/09/Mod-Gearman.pdf[Have a look at the slides from the Nagios Workshop 2011 in Hannover]
+Download
+--------
+
+* Latest stable release http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.8.tar.gz[version
+ 1.0.8] from on July 22 2011
+* Mod Gearman is available for download at: http://labs.consol.de/nagios/mod-gearman
+* Source is available at GitHub: http://github.com/sni/mod_gearman
+* Older versions are available in the <<_archive,download archive>>.
+
+
+
Support & Questions
-------------------
@@ -34,16 +45,16 @@
How does it work
----------------
-When the broker module is loaded, it captures all servicecheck,
-hostcheck and the eventhandler events. Eventhandler are sent to a
-generic 'eventhandler' queue. Checks for hosts which are in one of the
-specified hostgroups, are sent into a seperate hostgroup queue. All
-non matching hosts are sent to a generic 'hosts' queue. Checks for
-services are first checked against the list of servicegroups, then
-against the hostgroups and if none matches they will be sent into a
-generic 'service' queue.
-The NEB module starts a single thread, which monitors the
-'check_results' where all results come in.
+When the Mod-Gearman broker module is loaded, it intercepts all
+servicechecks, hostchecks and the eventhandler events. Eventhandler
+are then sent to a generic 'eventhandler' queue. Checks for hosts
+which are in one of the specified hostgroups, are sent into a seperate
+hostgroup queue. All non matching hosts are sent to a generic 'hosts'
+queue. Checks for services are first checked against the list of
+servicegroups, then against the hostgroups and if none matches they
+will be sent into a generic 'service' queue. The NEB module starts a
+single thread, which monitors the 'check_results' where all results
+come in.
++++
<a title="mod gearman architecture" rel="lightbox[mod_gm]" href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-e1284455350110.png"><img src="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-e1284455350110.png" alt="mod_gearman architecture" width="480" height="300" style="float:none" /></a>
@@ -222,7 +233,7 @@
see <<_configuration,Configuration>> for details on all parameters
-The last step is to start one or more worker. You may use the same
+The next step is to start one or more worker. You may use the same
configuration file as for the neb module.
--------------------------------------
@@ -232,7 +243,7 @@
NOTE: Make sure you have started your Gearmand job server. Usually
-it can be started with
+it can be started with
--------------------------------------
/usr/sbin/gearmand -t 10 -j 0
@@ -249,11 +260,11 @@
use an older version.
It is not possible to distribute eventhandler with Nagios versions
-prior 3.2.2. Just apply the patch from the patches directory to your
-Nagios sources and build Nagios again if you want to use an older
-version. You only need to replace the nagios binary. Nothing else has
-changed. If you plan to distribute only Host/Servicechecks, no patch
-is needed.
+prior 3.2.2. Just apply the patch from the ./extras/patches directory
+to your Nagios sources and build Nagios again if you want to use an
+older version. You only need to replace the nagios binary. Nothing
+else has changed. If you plan to distribute only Host/Servicechecks,
+no patch is needed.
@@ -460,14 +471,15 @@
perfdata::
-defines if the module should distribute perfdata to gearman. Note: processing
-of perfdata is not part of mod_gearman. You will need additional worker for
-handling performance data. For example: http://www.pnp4nagios.org[PNP4Nagios]
-Performance data is just written to the gearman queue.
+Defines if the module should distribute perfdata to gearman.
+
====
perfdata=yes
====
+NOTE: processing of perfdata is not part of mod_gearman. You will need
+additional worker for handling performance data. For example:
+http://www.pnp4nagios.org[PNP4Nagios]. Performance data is just
+written to the gearman queue.
perfdata_mode::
@@ -680,6 +692,29 @@
<a title="mod gearman performance" rel="lightbox[mod_gm]" href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman_performance_1.png"><img src="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman_performance_1.png" alt="mod_gearman performance" width="424" height="176" style="float:none" /></a>
++++
+
+Exports
+-------
+Exports export data structures from the Nagios core as JSON data. For
+each configurable event one job will be created. At the moment, the
+only useful event type is the logdata event which allows you to create
+a json data job for every logged line. This can be very useful for
+external reporting tools.
+
+exports::
+Set the queue name to create the jobs in. The return code will be sent
+back to the core (Not all callbacks support return codes). Callbacks
+are a list of callbacks for which you want to export json data.
++
+====
+ export=<queue>:<returncode>:<callback>[,<callback>,...]
+
+ export=log_queue:1:NEBCALLBACK_LOG_DATA
+====
+
+
+
+
How To
------
@@ -770,17 +805,10 @@
-Download
---------
-
-* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.7.tar.gz[version 1.0.7 - July 03 2011]
-* Mod Gearman is available for download at: http://labs.consol.de/nagios/mod-gearman
-* The source is available at GitHub: http://github.com/sni/mod_gearman
-
-
Archive
-~~~~~~~
+-------
+* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.8.tar.gz[version 1.0.8 - July 22 2011]
* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.7.tar.gz[version 1.0.7 - July 03 2011]
* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.6.tar.gz[version 1.0.6 - June 04 2011]
* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.5.tar.gz[version 1.0.5 - May 17 2011]
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/common/gearman_utils.c
^
|
@@ -128,6 +128,7 @@
/* skip the dummy queue if its empty */
if(!strcmp( name, "dummy") && func->total == 0) {
+ free(func->queue);
free(func);
continue;
}
@@ -145,7 +146,7 @@
/* free a status structure */
void free_mod_gm_status_server(mod_gm_server_status_t *stats) {
- int x = 0;
+ int x;
for(x=0; x<stats->function_num;x++) {
free(stats->function[x]->queue);
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/common/utils.c
^
|
@@ -1130,15 +1130,17 @@
/* execute this command with given timeout */
-int execute_safe_command(gm_job_t * exec_job, int fork_exec, char * hostname) {
+int execute_safe_command(gm_job_t * exec_job, int fork_exec, char * identifier) {
int pdes[2];
int return_code;
int pclose_result;
char *plugin_output;
+ char *bufdup;
char buffer[GM_BUFFERSIZE];
sigset_t mask;
struct timeval start_time,end_time;
pid_t pid = 0;
+ buffer[0] = '\x0';
gm_log( GM_LOG_TRACE, "execute_safe_command()\n" );
@@ -1188,16 +1190,18 @@
if(pclose_result == -1) {
char error[GM_BUFFERSIZE];
- snprintf(error, sizeof(error), "error on %s: %s", hostname, strerror(errno));
+ snprintf(error, sizeof(error), "error on %s: %s", identifier, strerror(errno));
if(write(pdes[1], error, strlen(error)+1) <= 0)
perror("write");
}
return_code = real_exit_code(pclose_result);
+ free(plugin_output);
exit(return_code);
}
else {
snprintf( buffer, sizeof( buffer )-1, "%s", plugin_output );
+ free(plugin_output);
}
}
@@ -1220,25 +1224,29 @@
/* file not executable? */
if(return_code == 126) {
return_code = STATE_CRITICAL;
- snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of 126 is out of bounds. Make sure the plugin you're trying to run is executable. (worker: %s)", hostname);
+ snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of 126 is out of bounds. Make sure the plugin you're trying to run is executable. (worker: %s)", identifier);
}
/* file not found errors? */
else if(return_code == 127) {
return_code = STATE_CRITICAL;
- snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of 127 is out of bounds. Make sure the plugin you're trying to run actually exists. (worker: %s)", hostname);
+ snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of 127 is out of bounds. Make sure the plugin you're trying to run actually exists. (worker: %s)", identifier);
}
/* signaled */
else if(return_code >= 128 && return_code < 144) {
char * signame = nr2signal((int)(return_code-128));
- snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of %d is out of bounds. Plugin exited by signal %s. (worker: %s)\n%s", (int)(return_code), signame, hostname, buffer);
+ bufdup = strdup(buffer);
+ snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of %d is out of bounds. Plugin exited by signal %s. (worker: %s)\n%s\n", (int)(return_code), signame, identifier, bufdup);
return_code = STATE_CRITICAL;
+ free(bufdup);
free(signame);
}
/* other error codes > 3 */
else if(return_code > 3) {
gm_log( GM_LOG_INFO, "check exited with exit code > 3. Exit: %d\n", (int)(return_code));
gm_log( GM_LOG_INFO, "stdout: %s\n", buffer);
- snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of %d is out of bounds. (worker: %s)\n%s\n", (int)(return_code), hostname, buffer);
+ bufdup = strdup(buffer);
+ snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of %d is out of bounds. (worker: %s)\n%s\n", (int)(return_code), identifier, bufdup);
+ free(bufdup);
return_code = STATE_CRITICAL;
}
@@ -1261,9 +1269,10 @@
exec_job->return_code = 2;
exec_job->early_timeout = 1;
if ( !strcmp( exec_job->type, "service" ) )
- snprintf( buffer, sizeof( buffer ) -1, "(Service Check Timed Out On Worker: %s)", hostname);
+ snprintf( buffer, sizeof( buffer ) -1, "(Service Check Timed Out On Worker: %s)\n", identifier);
if ( !strcmp( exec_job->type, "host" ) )
- snprintf( buffer, sizeof( buffer ) -1, "(Host Check Timed Out On Worker: %s)", hostname);
+ snprintf( buffer, sizeof( buffer ) -1, "(Host Check Timed Out On Worker: %s)\n", identifier);
+ free(exec_job->output);
exec_job->output = strdup( buffer );
}
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/configure
^
|
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.65 for mod_gearman 1.0.7.
+# Generated by GNU Autoconf 2.65 for mod_gearman 1.0.8.
#
# Report bugs to <sven.nierlein@consol.de>.
#
@@ -552,8 +552,8 @@
# Identity of this package.
PACKAGE_NAME='mod_gearman'
PACKAGE_TARNAME='mod_gearman'
-PACKAGE_VERSION='1.0.7'
-PACKAGE_STRING='mod_gearman 1.0.7'
+PACKAGE_VERSION='1.0.8'
+PACKAGE_STRING='mod_gearman 1.0.8'
PACKAGE_BUGREPORT='sven.nierlein@consol.de'
PACKAGE_URL=''
@@ -1249,7 +1249,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures mod_gearman 1.0.7 to adapt to many kinds of systems.
+\`configure' configures mod_gearman 1.0.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1315,7 +1315,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of mod_gearman 1.0.7:";;
+ short | recursive ) echo "Configuration of mod_gearman 1.0.8:";;
esac
cat <<\_ACEOF
@@ -1412,7 +1412,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-mod_gearman configure 1.0.7
+mod_gearman configure 1.0.8
generated by GNU Autoconf 2.65
Copyright (C) 2009 Free Software Foundation, Inc.
@@ -1875,7 +1875,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by mod_gearman $as_me 1.0.7, which was
+It was created by mod_gearman $as_me 1.0.8, which was
generated by GNU Autoconf 2.65. Invocation command line was
$ $0 $@
@@ -2683,7 +2683,7 @@
# Define the identity of the package.
PACKAGE='mod_gearman'
- VERSION='1.0.7'
+ VERSION='1.0.8'
cat >>confdefs.h <<_ACEOF
@@ -5923,7 +5923,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by mod_gearman $as_me 1.0.7, which was
+This file was extended by mod_gearman $as_me 1.0.8, which was
generated by GNU Autoconf 2.65. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5989,7 +5989,7 @@
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-mod_gearman config.status 1.0.7
+mod_gearman config.status 1.0.8
configured by $0, generated by GNU Autoconf 2.65,
with options \\"\$ac_cs_config\\"
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/configure.ac
^
|
@@ -3,7 +3,7 @@
##############################################
AC_PREREQ([2.59])
-AC_INIT([mod_gearman], [1.0.7], [sven.nierlein@consol.de])
+AC_INIT([mod_gearman], [1.0.8], [sven.nierlein@consol.de])
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
AC_CONFIG_SRCDIR([neb_module/mod_gearman.c],[worker/worker.c],[tools/send_gearman.c],[tools/check_gearman.c],[tools/gearman_top.c])
AC_CONFIG_HEADER([config.h])
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/docs/QUICKSTART
^
|
@@ -52,9 +52,9 @@
--------------------------------------
#> cd /tmp
-#> wget "http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.7.tar.gz"
-#> tar zxf mod_gearman-1.0.7.tar.gz
-#> cd mod_gearman-1.0.7
+#> wget "http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.8.tar.gz"
+#> tar zxf mod_gearman-1.0.8.tar.gz
+#> cd mod_gearman-1.0.8
#> ./configure --prefix=/opt --with-gearman=/opt --with-user=nagios --with-init-dir=/etc/init.d
#> make
#> make install
@@ -118,7 +118,7 @@
--------------------------------------
#> grep mod_gearman /var/log/nagios3/nagios.log
-[1295003042] mod_gearman: Version 1.0.7
+[1295003042] mod_gearman: Version 1.0.8
[1295003042] Event broker module '/opt/lib/mod_gearman/mod_gearman.o' initialized successfully.
--------------------------------------
@@ -152,7 +152,7 @@
--------------------------------------
#> /opt/bin/check_gearman -H localhost -q worker_`hostname` -t 10 -s check
-check_gearman OK - debian64 has 1 worker and is working on 0 jobs. Version: 1.0.7|worker=1 jobs=2c
+check_gearman OK - debian64 has 1 worker and is working on 0 jobs. Version: 1.0.8|worker=1 jobs=2c
--------------------------------------
The interesting number is the last one, '2c' in our case, which means there
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/docs/QUICKSTART.html
^
|
@@ -606,9 +606,9 @@
<div class="listingblock">
<div class="content">
<pre><tt>#> cd /tmp
-#> wget "http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.7.tar.gz"
-#> tar zxf mod_gearman-1.0.7.tar.gz
-#> cd mod_gearman-1.0.7
+#> wget "http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.8.tar.gz"
+#> tar zxf mod_gearman-1.0.8.tar.gz
+#> cd mod_gearman-1.0.8
#> ./configure --prefix=/opt --with-gearman=/opt --with-user=nagios --with-init-dir=/etc/init.d
#> make
#> make install
@@ -666,7 +666,7 @@
<div class="listingblock">
<div class="content">
<pre><tt>#> grep mod_gearman /var/log/nagios3/nagios.log
-[1295003042] mod_gearman: Version 1.0.7
+[1295003042] mod_gearman: Version 1.0.8
[1295003042] Event broker module '/opt/lib/mod_gearman/mod_gearman.o' initialized successfully.</tt></pre>
</div></div>
</div>
@@ -693,7 +693,7 @@
<div class="listingblock">
<div class="content">
<pre><tt>#> /opt/bin/check_gearman -H localhost -q worker_`hostname` -t 10 -s check
-check_gearman OK - debian64 has 1 worker and is working on 0 jobs. Version: 1.0.7|worker=1 jobs=2c</tt></pre>
+check_gearman OK - debian64 has 1 worker and is working on 0 jobs. Version: 1.0.8|worker=1 jobs=2c</tt></pre>
</div></div>
<div class="paragraph"><p>The interesting number is the last one, <em>2c</em> in our case, which means there
have been already 2 jobs executed by this worker.</p></div>
@@ -733,7 +733,7 @@
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Last updated 2011-06-27 12:20:00 CEST
+Last updated 2011-07-09 11:51:30 CEST
</div>
</div>
</body>
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/docs/README.html
^
|
@@ -587,6 +587,32 @@
</ul></div>
<div class="paragraph"><p><a href="http://labs.consol.de/wp-content/uploads/2010/09/Mod-Gearman.pdf">Have a look at the slides from the Nagios Workshop 2011 in Hannover</a></p></div>
</div>
+<h2 id="_download">Download</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+Latest stable release <a href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.8.tar.gz">version
+ 1.0.8</a> from on July 22 2011
+</p>
+</li>
+<li>
+<p>
+Mod Gearman is available for download at: <a href="http://labs.consol.de/nagios/mod-gearman">http://labs.consol.de/nagios/mod-gearman</a>
+</p>
+</li>
+<li>
+<p>
+Source is available at GitHub: <a href="http://github.com/sni/mod_gearman">http://github.com/sni/mod_gearman</a>
+</p>
+</li>
+<li>
+<p>
+Older versions are available in the <a href="#_archive">download archive</a>.
+</p>
+</li>
+</ul></div>
+</div>
<h2 id="_support_amp_questions">Support & Questions</h2>
<div class="sectionbody">
<div class="ulist"><ul>
@@ -616,16 +642,16 @@
</div>
<h2 id="_how_does_it_work">How does it work</h2>
<div class="sectionbody">
-<div class="paragraph"><p>When the broker module is loaded, it captures all servicecheck,
-hostcheck and the eventhandler events. Eventhandler are sent to a
-generic <em>eventhandler</em> queue. Checks for hosts which are in one of the
-specified hostgroups, are sent into a seperate hostgroup queue. All
-non matching hosts are sent to a generic <em>hosts</em> queue. Checks for
-services are first checked against the list of servicegroups, then
-against the hostgroups and if none matches they will be sent into a
-generic <em>service</em> queue.
-The NEB module starts a single thread, which monitors the
-<em>check_results</em> where all results come in.</p></div>
+<div class="paragraph"><p>When the Mod-Gearman broker module is loaded, it intercepts all
+servicechecks, hostchecks and the eventhandler events. Eventhandler
+are then sent to a generic <em>eventhandler</em> queue. Checks for hosts
+which are in one of the specified hostgroups, are sent into a seperate
+hostgroup queue. All non matching hosts are sent to a generic <em>hosts</em>
+queue. Checks for services are first checked against the list of
+servicegroups, then against the hostgroups and if none matches they
+will be sent into a generic <em>service</em> queue. The NEB module starts a
+single thread, which monitors the <em>check_results</em> where all results
+come in.</p></div>
<a title="mod gearman architecture" rel="lightbox[mod_gm]" href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-e1284455350110.png"><img src="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-e1284455350110.png" alt="mod_gearman architecture" width="480" height="300" style="float:none" /></a>
<div class="paragraph"><p>A simple example queue would look like:</p></div>
<div class="listingblock">
@@ -793,7 +819,7 @@
<pre><tt>broker_module=.../mod_gearman.o server=localhost:4730 eventhandler=yes services=yes hosts=yes</tt></pre>
</div></div>
<div class="paragraph"><p>see <a href="#_configuration">Configuration</a> for details on all parameters</p></div>
-<div class="paragraph"><p>The last step is to start one or more worker. You may use the same
+<div class="paragraph"><p>The next step is to start one or more worker. You may use the same
configuration file as for the neb module.</p></div>
<div class="listingblock">
<div class="content">
@@ -825,11 +851,11 @@
</tr></table>
</div>
<div class="paragraph"><p>It is not possible to distribute eventhandler with Nagios versions
-prior 3.2.2. Just apply the patch from the patches directory to your
-Nagios sources and build Nagios again if you want to use an older
-version. You only need to replace the nagios binary. Nothing else has
-changed. If you plan to distribute only Host/Servicechecks, no patch
-is needed.</p></div>
+prior 3.2.2. Just apply the patch from the ./extras/patches directory
+to your Nagios sources and build Nagios again if you want to use an
+older version. You only need to replace the nagios binary. Nothing
+else has changed. If you plan to distribute only Host/Servicechecks,
+no patch is needed.</p></div>
</div>
<h2 id="_configuration">Configuration</h2>
<div class="sectionbody">
@@ -1178,10 +1204,7 @@
</dt>
<dd>
<p>
-defines if the module should distribute perfdata to gearman. Note: processing
-of perfdata is not part of mod_gearman. You will need additional worker for
-handling performance data. For example: <a href="http://www.pnp4nagios.org">PNP4Nagios</a>
-Performance data is just written to the gearman queue.
+Defines if the module should distribute perfdata to gearman.
</p>
<div class="exampleblock">
<div class="exampleblock-content">
@@ -1191,6 +1214,19 @@
</div></div>
</div></div>
</dd>
+</dl></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">processing of perfdata is not part of mod_gearman. You will need
+additional worker for handling performance data. For example:
+<a href="http://www.pnp4nagios.org">PNP4Nagios</a>. Performance data is just
+written to the gearman queue.</td>
+</tr></table>
+</div>
+<div class="dlist"><dl>
<dt class="hdlist1">
perfdata_mode
</dt>
@@ -1510,6 +1546,37 @@
<a title="mod gearman performance" rel="lightbox[mod_gm]" href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman_performance_2.png"><img src="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman_performance_2.png" alt="mod_gearman performance" width="473" height="122" style="float:none" /></a>
<a title="mod gearman performance" rel="lightbox[mod_gm]" href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman_performance_1.png"><img src="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman_performance_1.png" alt="mod_gearman performance" width="424" height="176" style="float:none" /></a>
</div>
+<h2 id="_exports">Exports</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Exports export data structures from the Nagios core as JSON data. For
+each configurable event one job will be created. At the moment, the
+only useful event type is the logdata event which allows you to create
+a json data job for every logged line. This can be very useful for
+external reporting tools.</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+exports
+</dt>
+<dd>
+<p>
+Set the queue name to create the jobs in. The return code will be sent
+back to the core (Not all callbacks support return codes). Callbacks
+are a list of callbacks for which you want to export json data.
+</p>
+<div class="exampleblock">
+<div class="exampleblock-content">
+<div class="literalblock">
+<div class="content">
+<pre><tt>export=<queue>:<returncode>:<callback>[,<callback>,...]</tt></pre>
+</div></div>
+<div class="literalblock">
+<div class="content">
+<pre><tt>export=log_queue:1:NEBCALLBACK_LOG_DATA</tt></pre>
+</div></div>
+</div></div>
+</dd>
+</dl></div>
+</div>
<h2 id="_how_to">How To</h2>
<div class="sectionbody">
<h3 id="_how_to_monitor_job_server_and_worker">How to Monitor Job Server and Worker</h3><div style="clear:left"></div>
@@ -1616,29 +1683,16 @@
</li>
</ul></div>
</div>
-<h2 id="_download">Download</h2>
+<h2 id="_archive">Archive</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
-<a href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.7.tar.gz">version 1.0.7 - July 03 2011</a>
+<a href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.8.tar.gz">version 1.0.8 - July 22 2011</a>
</p>
</li>
<li>
<p>
-Mod Gearman is available for download at: <a href="http://labs.consol.de/nagios/mod-gearman">http://labs.consol.de/nagios/mod-gearman</a>
-</p>
-</li>
-<li>
-<p>
-The source is available at GitHub: <a href="http://github.com/sni/mod_gearman">http://github.com/sni/mod_gearman</a>
-</p>
-</li>
-</ul></div>
-<h3 id="_archive">Archive</h3><div style="clear:left"></div>
-<div class="ulist"><ul>
-<li>
-<p>
<a href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.7.tar.gz">version 1.0.7 - July 03 2011</a>
</p>
</li>
@@ -1713,7 +1767,7 @@
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Last updated 2011-07-03 15:20:39 CEST
+Last updated 2011-07-22 22:45:23 CEST
</div>
</div>
</body>
|
[-]
[+]
|
Added |
mod_gearman-1.0.8.tar.bz2/etc/mod_gearman.conf
^
|
@@ -0,0 +1,163 @@
+###############################################################################
+#
+# mod_gearman - distribute checks with gearman
+#
+# Copyright (c) 2010 Sven Nierlein
+#
+# Sample Worker / NEB Module Config
+#
+###############################################################################
+
+# use debug to increase the verbosity of the module.
+# Possible values are:
+# 0 = only errors
+# 1 = debug messages
+# 2 = trace messages
+# 3 = trace and all gearman related logs are going to stdout.
+# Default is 0.
+debug=0
+
+
+# sets the addess of your gearman job server. Can be specified
+# more than once to add more server.
+server=localhost:4730
+
+
+# sets the address of your 2nd (duplicate) gearman job server. Can
+# be specified more than once o add more servers.
+#dupserver=<host>:<port>
+
+
+# defines if the module should distribute execution of
+# eventhandlers.
+eventhandler=yes
+
+
+# defines if the module should distribute execution of
+# service checks.
+services=yes
+
+
+# defines if the module should distribute execution of
+# host checks.
+hosts=yes
+
+
+# sets a list of hostgroups which will go into seperate
+# queues. Either specify a comma seperated list or use
+# multiple lines.
+#hostgroups=name1
+#hostgroups=name2,name3
+
+
+# sets a list of servicegroups which will go into seperate
+# queues.
+#servicegroups=name1,name2,name3
+
+# Set this to 'no' if you want Mod-Gearman to only take care about
+# servicechecks. No hostchecks will be processed by Mod-Gearman. Use
+# this option to disable hostchecks and still have the possibility to
+# use hostgroups for easy configuration of your services.
+# If set to yes, you still have to define which hostchecks should be
+# processed by either using 'hosts' or the 'hostgroups' option.
+# Default is Yes.
+do_hostchecks=yes
+
+# enables or disables encryption. It is strongly
+# advised to not disable encryption. Anybody will be
+# able to inject packages to your worker.
+# Encryption is enabled by default and you have to
+# explicitly disable it.
+# When using encryption, you will either have to
+# specify a shared password with key=... or a
+# keyfile with keyfile=...
+# Default is On.
+encryption=yes
+
+
+# A shared password which will be used for
+# encryption of data pakets. Should be at least 8
+# bytes long. Maximum length is 32 characters.
+key=should_be_changed
+
+
+# The shared password will be read from this file.
+# Use either key or keyfile. Only the first 32
+# characters will be used.
+#keyfile=/path/to/secret.file
+
+
+###############################################################################
+#
+# NEB Module Config
+#
+# the following settings are for the neb module only and
+# will be ignored by the worker.
+#
+###############################################################################
+
+# sets a list of hostgroups which will not be executed
+# by gearman. They are just passed through.
+# Default is none
+localhostgroups=
+
+
+# sets a list of servicegroups which will not be executed
+# by gearman. They are just passed through.
+# Default is none
+localservicegroups=
+
+
+# Number of result worker threads. Usually one is
+# enough. You may increase the value if your
+# result queue is not processed fast enough.
+# Default: 1
+result_workers=1
+
+
+# defines if the module should distribute perfdata
+# to gearman.
+# Note: processing of perfdata is not part of
+# mod_gearman. You will need additional worker for
+# handling performance data. For example: pnp4nagios
+# Performance data is just written to the gearman
+# queue.
+# Default no
+perfdata=no
+
+
+###############################################################################
+#
+# Worker Config
+#
+# the following settings are for the worker only and
+# will be ignored by the neb module.
+#
+###############################################################################
+
+# Path to the pidfile. Usually set by the init script
+#pidfile=/usr/local/var/mod_gearman/mod_gearman_worker.pid
+
+# Path to the logfile.
+logfile=/usr/local/var/mod_gearman/mod_gearman_worker.log
+
+# Minimum number of worker processes which should
+# run at any time.
+min-worker=1
+
+# Maximum number of worker processes which should
+# run at any time. You may set this equal to
+# min-worker setting to disable dynamic starting of
+# workers. When setting this to 1, all services from
+# this worker will be executed one after another.
+max-worker=20
+
+# Time after which an idling worker exists
+# This parameter controls how fast your waiting workers will
+# exit if there are no jobs waiting.
+idle-timeout=30
+
+# Controls the amount of jobs a worker will do before he exits
+# Use this to control how fast the amount of workers will go down
+# after high load times
+max-jobs=50
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/extras/gearmand-init
^
|
@@ -16,8 +16,8 @@
OPTIONS="-d -j 0"
PORT=4730
LISTEN=0.0.0.0
-PIDFILE=/tmp/gm/var/mod_gearman/gearmand.pid
-LOGFILE=/tmp/gm/var/mod_gearman/gearmand.log
+PIDFILE=/usr/local/var/mod_gearman/gearmand.pid
+LOGFILE=/usr/local/var/mod_gearman/gearmand.log
USER=nagios
GRACEFUL_SHUTDOWN_TIME=30
LIBEVENTMINVERSION=1.4
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/include/common.h
^
|
@@ -52,7 +52,7 @@
#define MOD_GM_COMMON_H
/* constants */
-#define GM_VERSION "1.0.7"
+#define GM_VERSION "1.0.8"
#define GM_ENABLED 1
#define GM_DISABLED 0
#define GM_BUFFERSIZE 98304
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/include/utils.h
^
|
@@ -334,11 +334,11 @@
*
* @param[in] exec_job - job structure
* @param[in] fork_exec - fork or not before exec
- * @param[in] hostname - current worker hostname
+ * @param[in] identifier - current worker identifier
*
* @return true on success
*/
-int execute_safe_command(gm_job_t * exec_job, int fork_exec, char * hostname);
+int execute_safe_command(gm_job_t * exec_job, int fork_exec, char * identifier);
/**
*
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/neb_module/mod_gearman.c
^
|
@@ -47,8 +47,7 @@
void *gearman_module_handle=NULL;
gearman_client_st client;
-int send_now = FALSE;
-int result_threads_running = 0;
+int send_now, result_threads_running;
pthread_t result_thr[GM_LISTSIZE];
char target_queue[GM_BUFFERSIZE];
char temp_buffer[GM_BUFFERSIZE];
@@ -72,6 +71,8 @@
int nebmodule_init( int flags, char *args, nebmodule *handle ) {
int i;
int broker_option_errors = 0;
+ send_now = FALSE;
+ result_threads_running = 0;
/* save our handle */
gearman_module_handle=handle;
@@ -88,12 +89,14 @@
set_default_options(mod_gm_opt);
/* parse arguments */
- read_arguments( args );
gm_log( GM_LOG_INFO, "Version %s\n", GM_VERSION );
gm_log( GM_LOG_TRACE, "args: %s\n", args );
gm_log( GM_LOG_TRACE, "nebmodule_init(%i, %i)\n", flags );
gm_log( GM_LOG_DEBUG, "running on libgearman %s\n", gearman_version() );
+ if( read_arguments( args ) == GM_ERROR )
+ return NEB_ERROR;
+
/* check for minimum eventbroker options */
if(!(event_broker_options & BROKER_PROGRAM_STATE)) {
gm_log( GM_LOG_ERROR, "mod_gearman needs BROKER_PROGRAM_STATE (%i) event_broker_options enabled to work\n", BROKER_PROGRAM_STATE );
@@ -159,6 +162,14 @@
neb_register_callback( i, gearman_module_handle, 0, handle_export );
}
+ /* log at least one line into the core logfile */
+ if ( mod_gm_opt->logmode != GM_LOG_MODE_CORE ) {
+ int logmode_saved = mod_gm_opt->logmode;
+ mod_gm_opt->logmode = GM_LOG_MODE_CORE;
+ gm_log( GM_LOG_INFO, "initialized version %s (libgearman %s)\n", GM_VERSION, gearman_version() );
+ mod_gm_opt->logmode = logmode_saved;
+ }
+
gm_log( GM_LOG_DEBUG, "finished initializing\n" );
return NEB_OK;
@@ -227,13 +238,14 @@
gm_log( GM_LOG_DEBUG, "deregistered callbacks\n" );
/* stop result threads */
- for(x = 0; x < mod_gm_opt->result_workers; x++) {
+ for(x = 0; x < result_threads_running; x++) {
pthread_cancel(result_thr[x]);
pthread_join(result_thr[x], NULL);
}
- /* cleanup client */
+ /* cleanup */
free_client(&client);
+ mod_gm_free_opt(mod_gm_opt);
return NEB_OK;
}
@@ -827,7 +839,7 @@
/* start our threads */
static void start_threads(void) {
- if ( !result_threads_running ) {
+ if ( result_threads_running < mod_gm_opt->result_workers ) {
/* create result worker */
int x;
for(x = 0; x < mod_gm_opt->result_workers; x++) {
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/support/mod_gearman.spec
^
|
@@ -10,8 +10,8 @@
Group: Applications/Monitoring
Requires: gearmand
BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(%{__id_u} -n)
-BuildRequires: autoconf, automake
-BuildRequires: libtool, libevent-devel, ncurses-devel
+BuildRequires: autoconf, automake, ncurses-devel
+BuildRequires: libtool, libtool-ltdl-devel, libevent-devel
Summary: Gearman module for Icinga/Nagios
Requires(pre,post): /sbin/ldconfig
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/t/01-utils.c
^
|
@@ -18,7 +18,7 @@
}
int main(void) {
- plan(44);
+ plan(48);
/* lowercase */
char test[100];
@@ -28,6 +28,14 @@
strcpy(test, "yeS"); like(lc(test), "yes", "lc(yeS)");
+ /* trim */
+ strcpy(test, " text "); like(ltrim(test), "text ", "ltrim()");
+ strcpy(test, " text "); like(rtrim(test), " text", "rtrim()");
+ strcpy(test, " text "); like(trim(test), "text", "trim()");
+ char *test2;
+ test2 = strdup(" text "); like(trim(test2), "text", "trim()");
+ free(test2);
+
/* parse_yes_or_no */
ok(parse_yes_or_no(NULL, GM_ENABLED) == GM_ENABLED, "parse_yes_or_no 1");
ok(parse_yes_or_no(NULL, GM_DISABLED) == GM_DISABLED, "parse_yes_or_no 2");
@@ -53,7 +61,7 @@
mod_gm_opt = malloc(sizeof(mod_gm_opt_t));
int rc = set_default_options(mod_gm_opt);
ok(rc == 0, "setting default options");
- mod_gm_opt->keyfile = "t/data/test1.key";
+ mod_gm_opt->keyfile = strdup("t/data/test1.key");
read_keyfile(mod_gm_opt);
//printf_hex(mod_gm_opt->crypt_key, 32);
test[0]='\x0';
@@ -66,12 +74,14 @@
}
like(test, "3131313131313131313131313131313131313131313131313131313131310000", "read keyfile t/data/test1.key");
- mod_gm_opt->keyfile = "t/data/test2.key";
+ free(mod_gm_opt->keyfile);
+ mod_gm_opt->keyfile = strdup("t/data/test2.key");
read_keyfile(mod_gm_opt);
like(mod_gm_opt->crypt_key, "abcdef", "reading keyfile t/data/test2.key");
- mod_gm_opt->keyfile = "t/data/test3.key";
+ free(mod_gm_opt->keyfile);
+ mod_gm_opt->keyfile = strdup("t/data/test3.key");
read_keyfile(mod_gm_opt);
//printf_hex(mod_gm_opt->crypt_key, 32);
like(mod_gm_opt->crypt_key, "11111111111111111111111111111111", "reading keyfile t/data/test3.key");
@@ -151,6 +161,8 @@
parse_args_line(mod_gm_opt, test, 0);
like(mod_gm_opt->server_list[1], "localhost:4730", "server=:4730");
+ mod_gm_free_opt(mod_gm_opt);
+
return exit_status();
}
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/t/02-full.c
^
|
@@ -10,6 +10,7 @@
#include <common.h>
#include <utils.h>
#include <gearman.h>
+#include "gearman_utils.h"
#define GEARMAND_TEST_PORT 54730
@@ -33,9 +34,11 @@
snprintf(port, 30, "--port=%d", GEARMAND_TEST_PORT);
/* for newer gearman versions */
if(atof(gearman_version()) > 0.14) {
- execlp("gearmand", "gearmand", "--threads=10", "--job-retries=0", port, "--verbose=5", (char *)NULL);
+ //diag("having gearmand > 0.14");
+ execlp("gearmand", "gearmand", "--threads=10", "--job-retries=0", port, "--verbose=999", "--log-file=/tmp/gearmand.log" , (char *)NULL);
} else {
/* for gearman 0.14 */
+ //diag("having gearmand <= 0.14");
execlp("gearmand", "gearmand", "-t 10", "-j 0", port, (char *)NULL);
}
perror("gearmand");
@@ -95,7 +98,7 @@
char temp_buffer[GM_BUFFERSIZE];
temp_buffer[0]='\x0';
snprintf( temp_buffer,sizeof( temp_buffer )-1,"type=service\nresult_queue=%s\nhost_name=%s\nservice_description=%s\nstart_time=%i.%i\ntimeout=%d\ncheck_options=%i\nscheduled_check=%i\nreschedule_check=%i\nlatency=%f\ncommand_line=%s\n\n\n",
- "result_queue",
+ GM_DEFAULT_RESULT_QUEUE,
"host1",
"service1",
( int )start_time.tv_sec,
@@ -123,42 +126,84 @@
}
-/* check logfile for errors */
-void check_logfile(void);
-void check_logfile() {
+/* check logfile for errors, set mode to 1 to display file by diag() */
+void check_logfile(char *logfile, int mode);
+void check_logfile(char *logfile, int mode) {
FILE * fp;
char *line;
int errors = 0;
- fp = fopen(worker_logfile, "r");
+ fp = fopen(logfile, "r");
if(fp == NULL) {
- perror(worker_logfile);
+ perror(logfile);
return;
}
line = malloc(GM_BUFFERSIZE);
while(fgets(line, GM_BUFFERSIZE, fp) != NULL) {
- trim(line);
if(strstr(line, "ERROR") != NULL) {
errors++;
- diag("logfile: %s", line);
}
}
fclose(fp);
+ /* output complete logfile */
+ if(errors > 0 || mode == 1) {
+ fp = fopen(logfile, "r");
+ while(fgets(line, GM_BUFFERSIZE, fp) != NULL) {
+ diag("logfile: %s", line);
+ }
+ fclose(fp);
+ }
+
ok(errors == 0, "errors in logfile: %d", errors);
/* cleanup logfile */
- ok(unlink(worker_logfile) == 0, "removed temporary logfile: %s", worker_logfile);
+ ok(unlink(logfile) == 0, "removed temporary logfile: %s", logfile);
free(line);
return;
}
+void wait_for_empty_queue(char *queue, int timeout);
+void wait_for_empty_queue(char *queue, int timeout) {
+ char * message = NULL;
+ char * version = NULL;
+ int rc, x;
+ mod_gm_server_status_t *stats;
+
+ int tries = 0;
+ int found = 0;
+ while(tries <= timeout && found == 0) {
+ tries++;
+ stats = malloc(sizeof(mod_gm_server_status_t));
+ stats->function_num = 0;
+ stats->worker_num = 0;
+ rc = get_gearman_server_data(stats, &message, &version, "localhost", GEARMAND_TEST_PORT);
+ if( rc == STATE_OK ) {
+ for(x=0; x<stats->function_num;x++) {
+ //diag("%s %d %d\n", stats->function[x]->queue, stats->function[x]->waiting, stats->function[x]->running);
+ if(stats->function[x]->waiting == 0 &&
+ stats->function[x]->running == 0 &&
+ !strcmp( stats->function[x]->queue, queue )
+ ) {
+ found = 1;
+ }
+ }
+ }
+ free(message);
+ free(version);
+ free_mod_gm_status_server(stats);
+ sleep(1);
+ }
+
+ ok(tries < timeout, "queue %s empty after %d seconds", queue, tries);
+ return;
+}
/* main tests */
int main(void) {
int status, chld;
- int tests = 40;
+ int tests = 53;
int rrc;
char cmd[150];
char * result;
@@ -188,7 +233,7 @@
diag( "waitpid() %d exited with %d\n", chld, status);
}
- if(!ok(gearmand_pid > 0, "'gearmand --threads=10 --job-retries=0 --port=%d --verbose=5' started with pid: %d", GEARMAND_TEST_PORT, gearmand_pid)) {
+ if(!ok(gearmand_pid > 0, "'gearmand --threads=10 --job-retries=0 --port=%d --verbose=5 --log-file=/tmp/gearmand.log' started with pid: %d", GEARMAND_TEST_PORT, gearmand_pid)) {
diag("make sure gearmand is in your PATH. Common locations are /usr/sbin or /usr/local/sbin");
exit( EXIT_FAILURE );
}
@@ -204,7 +249,6 @@
skip(gearmand_pid <= 0 || worker_pid <= 0,
tests-3, /* Number of tests to skip */
"Skipping all tests, no need to go on without gearmand or worker");
- sleep(2);
/* create server / worker / clients */
create_modules();
@@ -212,7 +256,13 @@
/* try to send some data with base64 only */
test_eventhandler(GM_ENCODE_ONLY);
test_servicecheck(GM_ENCODE_ONLY);
+ wait_for_empty_queue("eventhandler", 20);
+ wait_for_empty_queue("service", 5);
sleep(1);
+ kill(worker_pid, SIGTERM);
+ waitpid(worker_pid, &status, 0);
+ ok(status == 0, "worker exited with exit code %d", real_exit_code(status));
+ check_logfile(worker_logfile, 0);
char * test_keys[] = {
"12345",
@@ -226,19 +276,22 @@
int i;
for(i=0;i<4;i++) {
- kill(worker_pid, SIGTERM);
- waitpid(worker_pid, &status, 0);
- ok(status == 0, "worker exited with exit code %d", real_exit_code(status));
- check_logfile();
start_worker((void *)test_keys[i]);
- sleep(1);
mod_gm_crypt_init( test_keys[i] );
ok(1, "initialized with key: %s", test_keys[i]);
test_eventhandler(GM_ENCODE_AND_ENCRYPT);
test_servicecheck(GM_ENCODE_AND_ENCRYPT);
+
+ wait_for_empty_queue("eventhandler", 20);
+ wait_for_empty_queue("service", 5);
sleep(1);
+
+ kill(worker_pid, SIGTERM);
+ waitpid(worker_pid, &status, 0);
+ ok(status == 0, "worker exited with exit code %d", real_exit_code(status));
+ check_logfile(worker_logfile, 0);
}
/*****************************************
@@ -247,7 +300,8 @@
snprintf(cmd, 150, "./send_gearman --server=localhost:%d --key=testtest --host=test --service=test --message=test --returncode=0", GEARMAND_TEST_PORT);
rrc = real_exit_code(run_check(cmd, &result));
cmp_ok(rrc, "==", 0, "cmd '%s' returned rc %d", cmd, rrc);
- like(result, "^\s*$", "output from ./send_gearman");
+ like(result, "^\\s*$", "output from ./send_gearman");
+ free(result);
/*****************************************
* send_gearman
@@ -259,6 +313,7 @@
/* cleanup */
+ free(result);
mod_gm_free_opt(mod_gm_opt);
free_client(&client);
free_worker(&worker);
@@ -271,6 +326,8 @@
waitpid(worker_pid, &status, 0);
ok(status == 0, "worker exited with exit code %d", real_exit_code(status));
+ unlink("/tmp/gearmand.log");
+
endskip;
return exit_status();
}
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/t/03-exec_checks.c
^
|
@@ -50,6 +50,7 @@
rrc = real_exit_code(run_check(cmd, &result));
diag(result);
cmp_ok(rrc, "==", 1, "cmd '%s' returned rc %d", cmd, rrc);
+ free(result);
/*****************************************
* send_gearman
@@ -58,6 +59,7 @@
rrc = real_exit_code(run_check(cmd, &result));
diag(result);
cmp_ok(rrc, "==", 1, "cmd '%s' returned rc %d", cmd, rrc);
+ free(result);
/*****************************************
* simple test command 1
@@ -67,6 +69,7 @@
cmp_ok(rc, "==", 0, "pclose for cmd '%s' returned rc %d", cmd, rc);
rrc = real_exit_code(rc);
cmp_ok(rrc, "==", 0, "cmd '%s' returned rc %d", cmd, rrc);
+ free(result);
/*****************************************
* simple test command 2
@@ -76,6 +79,7 @@
cmp_ok(rc, "==", 0, "pclose for cmd '%s' returned rc %d", cmd, rc);
rrc = real_exit_code(rc);
cmp_ok(rrc, "==", 0, "cmd '%s' returned rc %d", cmd, rrc);
+ free(result);
/*****************************************
* simple test command 3
@@ -85,6 +89,7 @@
cmp_ok(rc, "==", 0, "pclose for cmd '%s' returned rc %d", cmd, rc);
rrc = real_exit_code(rc);
cmp_ok(rrc, "==", 0, "cmd '%s' returned rc %d", cmd, rrc);
+ free(result);
/*****************************************
* simple test command 4
@@ -94,6 +99,7 @@
rrc = real_exit_code(rc);
cmp_ok(rrc, "==", 2, "cmd '%s' returned rc %d", cmd, rrc);
like(result, "test", "returned result string");
+ free(result);
gm_job_t * exec_job;
exec_job = ( gm_job_t * )malloc( sizeof *exec_job );
@@ -112,105 +118,130 @@
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "CRITICAL: Return code of 127 is out of bounds. Make sure the plugin you're trying to run actually exists. \\(worker:", "returned result string");
+ free(exec_job->output);
fork_on_exec = 1;
lives_ok({execute_safe_command(exec_job, fork_on_exec, hostname);}, "executing command using fork on exec");
+ free(exec_job->output);
/* non existing command 2 */
+ free(exec_job->command_line);
exec_job->command_line = strdup("/bin/doesntexist 2>&1");
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "CRITICAL: Return code of 127 is out of bounds. Make sure the plugin you're trying to run actually exists. \\(worker:", "returned result string");
+ free(exec_job->output);
/*****************************************
* non executable command 1
*/
+ free(exec_job->command_line);
exec_job->command_line = strdup("./THANKS");
fork_on_exec = 0;
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "CRITICAL: Return code of 126 is out of bounds. Make sure the plugin you're trying to run is executable. \\(worker:", "returned result string");
+ free(exec_job->output);
/* non existing command 2 */
fork_on_exec = 1;
+ free(exec_job->command_line);
exec_job->command_line = strdup("./THANKS 2>&1");
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "CRITICAL: Return code of 126 is out of bounds. Make sure the plugin you're trying to run is executable. \\(worker:", "returned result string");
+ free(exec_job->output);
/*****************************************
* unknown exit code 1
*/
+ free(exec_job->command_line);
exec_job->command_line = strdup("./t/rc 5");
- fork_on_exec = 1;
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
- like(exec_job->output, "CRITICAL: Return code of 5 is out of bounds. \\(worker:", "returned result string");
+ like(exec_job->output, "CRITICAL: Return code of 5 is out of bounds. \\(worker:.*exiting with exit code 5", "returned result string");
+ free(exec_job->output);
+
/* unknown exit code 2 */
fork_on_exec = 0;
+ free(exec_job->command_line);
exec_job->command_line = strdup("./t/rc 5 2>&1");
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
- like(exec_job->output, "CRITICAL: Return code of 5 is out of bounds. \\(worker:", "returned result string");
+ like(exec_job->output, "CRITICAL: Return code of 5 is out of bounds. \\(worker:.*exiting with exit code 5", "returned result string");
+ free(exec_job->output);
/* unknown exit code 3 */
+ free(exec_job->command_line);
exec_job->command_line = strdup("./t/rc 128 2>&1");
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "CRITICAL: Return code of 128 is out of bounds. Plugin exited by signal signal 0. \\(worker:", "returned result string");
+ free(exec_job->output);
/* unknown exit code 4 */
+ free(exec_job->command_line);
exec_job->command_line = strdup("./t/rc 137 2>&1");
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "CRITICAL: Return code of 137 is out of bounds. Plugin exited by signal SIGKILL. \\(worker:", "returned result string");
+ free(exec_job->output);
/* unknown exit code 5 */
+ free(exec_job->command_line);
exec_job->command_line = strdup("./t/rc 255 2>&1");
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "CRITICAL: Return code of 255 is out of bounds. \\(worker:", "returned result string");
+ free(exec_job->output);
/*****************************************
* signaled exit code SIGINT
*/
+ free(exec_job->command_line);
exec_job->command_line = strdup("./t/killer INT");
fork_on_exec = 1;
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "CRITICAL: Return code of 130 is out of bounds. Plugin exited by signal SIGINT. \\(worker:", "returned result string");
+ free(exec_job->output);
/* signaled exit code SIGINT 2 */
fork_on_exec = 0;
+ free(exec_job->command_line);
exec_job->command_line = strdup("./t/killer INT 2>&1");
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "CRITICAL: Return code of 130 is out of bounds. Plugin exited by signal SIGINT. \\(worker:", "returned result string");
+ free(exec_job->output);
/*****************************************
* timed out check
*/
+ free(exec_job->command_line);
exec_job->command_line = strdup("./t/sleep 30");
- exec_job->timeout = 2;
+ exec_job->timeout = 1;
fork_on_exec = 1;
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
like(exec_job->output, "\\(Service Check Timed Out On Worker: ", "returned result string");
+ free(exec_job->output);
/* timed out check 2 */
fork_on_exec = 0;
+ free(exec_job->command_line);
exec_job->command_line = strdup("./t/sleep 30 2>&1");
execute_safe_command(exec_job, fork_on_exec, hostname);
cmp_ok(exec_job->return_code, "==", 2, "cmd '%s' returns rc 2", exec_job->command_line);
@@ -222,7 +253,7 @@
/* clean up */
free_job(exec_job);
-
+ mod_gm_free_opt(mod_gm_opt);
return exit_status();
}
|
[-]
[+]
|
Added |
mod_gearman-1.0.8.tar.bz2/t/05-neb.c
^
|
@@ -0,0 +1,95 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <t/tap.h>
+
+#include "nagios/nagios.h"
+#include "nagios/nebmodules.h"
+#include "nagios/nebstructs.h"
+#include "nagios/nebcallbacks.h"
+#include "nagios/broker.h"
+
+int service_check_timeout;
+int host_check_timeout;
+int currently_running_service_checks;
+int currently_running_host_checks;
+int event_broker_options;
+check_result *check_result_list;
+check_result check_result_info;
+int process_performance_data;
+
+int main(void) {
+ int (*initfunc)(int,char *,void *);
+ int (*deinitfunc)(int,int);
+ int (*callfunc)(int,void *);
+ int *module_version_ptr=NULL;
+ void* neb_handle;
+ lt_ptr init_func;
+ lt_ptr deinit_func;
+ lt_ptr call_func;
+ char * nebargs = "encryption=no server=localhost";
+
+ plan(7);
+
+ /* set some external variables */
+ service_check_timeout = 30;
+ host_check_timeout = 30;
+ currently_running_service_checks = 0;
+ currently_running_host_checks = 0;
+ event_broker_options = 1048575; /* BROKER_EVERYTHING */
+ check_result_list = NULL;
+ check_result_info.check_options = 1; /* CHECK_OPTION_FORCE_EXECUTION */
+ process_performance_data = 1;
+
+ /* load neb module */
+ neb_handle=(void *)dlopen("./mod_gearman.o",RTLD_LAZY|RTLD_GLOBAL);
+ ok(neb_handle != NULL, "neb module loaded") || BAIL_OUT("cannot load module: %s\n", dlerror());
+ module_version_ptr=(int *)dlsym(neb_handle,"__neb_api_version");
+ ok((*module_version_ptr) == CURRENT_NEB_API_VERSION, "got module api version %i", CURRENT_NEB_API_VERSION);
+
+ /* init neb module */
+ init_func=(void *)dlsym(neb_handle,"nebmodule_init");
+ ok(init_func != NULL, "located nebmodule_init()") || BAIL_OUT("cannot locate nebmodule_init() %s\n", dlerror());
+ initfunc = init_func;
+ int result=(*initfunc)(NEBMODULE_NORMAL_LOAD, nebargs, neb_handle);
+ ok(result == 0, "run nebmodule_init() -> %d", result) || BAIL_OUT("cannot run nebmodule_init(), got %d\n", result);
+
+ /* callback */
+ //call_func=(void *)dlsym(neb_handle,"handle_process_events");
+/*
+ call_func=(void *)dlsym(neb_handle,"handle_eventhandler");
+ ok(call_func != NULL, "located handle_process_events()") || BAIL_OUT("cannot locate handle_process_events() %s\n", dlerror());
+ callfunc=call_func;
+ nebstruct_process_data ps;
+ ps.type = NEBTYPE_PROCESS_EVENTLOOPSTART;
+ result=(*callfunc)(NEBCALLBACK_PROCESS_DATA,(void *)&ps);
+ ok(result == 0, "run handle_process_events() -> %d", result) || BAIL_OUT("cannot run handle_process_events(), got %d\n", result);
+*/
+
+ /* deinit neb module */
+ deinit_func=(void *)dlsym(neb_handle,"nebmodule_deinit");
+ ok(deinit_func != NULL, "located nebmodule_deinit()") || BAIL_OUT("cannot locate nebmodule_deinit() %s\n", dlerror());
+ deinitfunc=deinit_func;
+ result=(*deinitfunc)(NEBMODULE_FORCE_UNLOAD,NEBMODULE_NEB_SHUTDOWN);
+ ok(result == 0, "run nebmodule_deinit() -> %d", result) || BAIL_OUT("cannot run nebmodule_deinit(), got %d\n", result);
+
+
+ result=dlclose(neb_handle);
+ ok(result == 0, "dlclose() -> %d", result);
+
+ return exit_status();
+}
+
+/* core log wrapper */
+void write_core_log(char *data);
+void write_core_log(char *data) {
+ printf("logger: %s", data);
+ return;
+}
+
+/* fake some core functions */
+int neb_set_module_info(void *handle, int type, char *data) { return 0; }
+int neb_register_callback(int callback_type, void *mod_handle, int priority, int (*callback_func)(int,void *)) { return 0; }
+int neb_deregister_callback(int callback_type, int (*callback_func)(int,void *)) { return 0; }
\ No newline at end of file
|
[-]
[+]
|
Changed |
mod_gearman-1.0.8.tar.bz2/worker/worker_client.c
^
|
@@ -326,7 +326,7 @@
/* run the command */
gm_log( GM_LOG_TRACE, "command: %s\n", exec_job->command_line);
- execute_safe_command(exec_job, mod_gm_opt->fork_on_exec, hostname);
+ execute_safe_command(exec_job, mod_gm_opt->fork_on_exec, mod_gm_opt->identifier );
if ( !strcmp( exec_job->type, "service" ) || !strcmp( exec_job->type, "host" ) ) {
send_result_back();
|