[-]
[+]
|
Changed |
nagios-mod_gearman.changes
|
|
[-]
[+]
|
Changed |
nagios-mod_gearman.spec
^
|
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/Changes
^
|
@@ -1,5 +1,10 @@
This file documents the revision history for mod_gearman.
+1.0.10 Thu Aug 25 16:07:55 CEST 2011
+ - new option 'show_error_output' for worker
+ - fixed failed job when host+service > 64 chars
+ - fixed tests
+
1.0.9 Mon Aug 15 16:05:23 CEST 2011
- nicer error messages for send_multi when zero results transmitted
- fixed sigsegv when reloading core in combination with exports options
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/Makefile.am
^
|
@@ -25,7 +25,8 @@
common/rijndael.c \
common/gearman.c \
common/gearman_utils.c \
- common/utils.c
+ common/utils.c \
+ common/popenRWE.c
pkglib_LIBRARIES = mod_gearman.so
mod_gearman_so_SOURCES = $(common_SOURCES) \
@@ -56,7 +57,7 @@
gearman_top_LDADD = -lncurses
# tests
-check_PROGRAMS = 01_utils 02_full 03_exec 04_log 05_neb
+check_PROGRAMS = 01_utils 02_full 03_exec 04_log 05_neb 06_exec
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
@@ -64,6 +65,8 @@
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
+# only used for performance tests
+06_exec_SOURCES = $(common_SOURCES) t/06-execvp_vs_popen.c
TESTS = $(check_PROGRAMS)
@@ -195,6 +198,14 @@
@echo ""
@echo "################################################################"
+fulltest:
+ ./t/test_all.pl
+ @echo "################################################################"
+ @echo ""
+ @echo " Full tests completed successfully"
+ @echo ""
+ @echo "################################################################"
+
docs:
@if [ -z "$(DOS2UNIX)" ]; then \
printf "\n\n**** please install dos2unix or tofrodos package ****\n\n"; \
@@ -229,3 +240,12 @@
mrproper:
git clean -xfd
+
+version:
+ newversion=$$(dialog --stdout --inputbox "New Version:" 0 0 "$(VERSION)") ; \
+ if [ -n "$$newversion" ] && [ "$$newversion" != "$(VERSION)" ]; then \
+ sed -ri "s/$(VERSION)/$$newversion/" include/common.h configure.ac docs/QUICKSTART; \
+ fi ;
+ sed -i Changes -e "s/$(VERSION)/$$newversion $(shell date)\n - ...\n\n$(VERSION)/"
+ $(MAKE) docs
+
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.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) 05_neb$(EXEEXT)
+ 04_log$(EXEEXT) 05_neb$(EXEEXT) 06_exec$(EXEEXT)
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
@@ -92,7 +92,8 @@
am__dirstamp = $(am__leading_dot)dirstamp
am__objects_1 = common/base64.$(OBJEXT) common/crypt.$(OBJEXT) \
common/rijndael.$(OBJEXT) common/gearman.$(OBJEXT) \
- common/gearman_utils.$(OBJEXT) common/utils.$(OBJEXT)
+ common/gearman_utils.$(OBJEXT) common/utils.$(OBJEXT) \
+ common/popenRWE.$(OBJEXT)
am_mod_gearman_so_OBJECTS = $(am__objects_1) \
neb_module/result_thread.$(OBJEXT) \
neb_module/mod_gearman.$(OBJEXT)
@@ -120,6 +121,9 @@
05_neb_DEPENDENCIES =
05_neb_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(05_neb_LDFLAGS) \
$(LDFLAGS) -o $@
+am_06_exec_OBJECTS = $(am__objects_1) t/06-execvp_vs_popen.$(OBJEXT)
+06_exec_OBJECTS = $(am_06_exec_OBJECTS)
+06_exec_LDADD = $(LDADD)
am_check_gearman_OBJECTS = $(am__objects_1) \
tools/check_gearman.$(OBJEXT)
check_gearman_OBJECTS = $(am_check_gearman_OBJECTS)
@@ -148,12 +152,12 @@
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) \
- $(05_neb_SOURCES) $(check_gearman_SOURCES) \
+ $(05_neb_SOURCES) $(06_exec_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) \
- $(05_neb_SOURCES) $(check_gearman_SOURCES) \
+ $(05_neb_SOURCES) $(06_exec_SOURCES) $(check_gearman_SOURCES) \
$(gearman_top_SOURCES) $(mod_gearman_worker_SOURCES) \
$(send_gearman_SOURCES) $(send_multi_SOURCES)
ETAGS = etags
@@ -280,7 +284,8 @@
common/rijndael.c \
common/gearman.c \
common/gearman_utils.c \
- common/utils.c
+ common/utils.c \
+ common/popenRWE.c
pkglib_LIBRARIES = mod_gearman.so
mod_gearman_so_SOURCES = $(common_SOURCES) \
@@ -311,6 +316,8 @@
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
+# only used for performance tests
+06_exec_SOURCES = $(common_SOURCES) t/06-execvp_vs_popen.c
TESTS = $(check_PROGRAMS)
GEARMANDS = /usr/sbin/gearmand /opt/sbin/gearmand
replace_vars = sed -e 's:%CONFIG%:$(sysconfdir)/mod_gearman.conf:g' \
@@ -431,6 +438,8 @@
common/$(DEPDIR)/$(am__dirstamp)
common/utils.$(OBJEXT): common/$(am__dirstamp) \
common/$(DEPDIR)/$(am__dirstamp)
+common/popenRWE.$(OBJEXT): common/$(am__dirstamp) \
+ common/$(DEPDIR)/$(am__dirstamp)
neb_module/$(am__dirstamp):
@$(MKDIR_P) neb_module
@: > neb_module/$(am__dirstamp)
@@ -513,6 +522,11 @@
05_neb$(EXEEXT): $(05_neb_OBJECTS) $(05_neb_DEPENDENCIES)
@rm -f 05_neb$(EXEEXT)
$(05_neb_LINK) $(05_neb_OBJECTS) $(05_neb_LDADD) $(LIBS)
+t/06-execvp_vs_popen.$(OBJEXT): t/$(am__dirstamp) \
+ t/$(DEPDIR)/$(am__dirstamp)
+06_exec$(EXEEXT): $(06_exec_OBJECTS) $(06_exec_DEPENDENCIES)
+ @rm -f 06_exec$(EXEEXT)
+ $(LINK) $(06_exec_OBJECTS) $(06_exec_LDADD) $(LIBS)
tools/$(am__dirstamp):
@$(MKDIR_P) tools
@: > tools/$(am__dirstamp)
@@ -559,6 +573,7 @@
-rm -f common/crypt.$(OBJEXT)
-rm -f common/gearman.$(OBJEXT)
-rm -f common/gearman_utils.$(OBJEXT)
+ -rm -f common/popenRWE.$(OBJEXT)
-rm -f common/rijndael.$(OBJEXT)
-rm -f common/utils.$(OBJEXT)
-rm -f neb_module/mod_gearman.$(OBJEXT)
@@ -568,6 +583,7 @@
-rm -f t/03-exec_checks.$(OBJEXT)
-rm -f t/04-log.$(OBJEXT)
-rm -f t/05-neb.$(OBJEXT)
+ -rm -f t/06-execvp_vs_popen.$(OBJEXT)
-rm -f t/tap.$(OBJEXT)
-rm -f tools/check_gearman.$(OBJEXT)
-rm -f tools/gearman_top.$(OBJEXT)
@@ -583,6 +599,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/crypt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/gearman.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/gearman_utils.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/popenRWE.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/rijndael.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@neb_module/$(DEPDIR)/mod_gearman.Po@am__quote@
@@ -592,6 +609,7 @@
@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)/06-execvp_vs_popen.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@
@@ -1162,6 +1180,14 @@
@echo ""
@echo "################################################################"
+fulltest:
+ ./t/test_all.pl
+ @echo "################################################################"
+ @echo ""
+ @echo " Full tests completed successfully"
+ @echo ""
+ @echo "################################################################"
+
docs:
@if [ -z "$(DOS2UNIX)" ]; then \
printf "\n\n**** please install dos2unix or tofrodos package ****\n\n"; \
@@ -1197,6 +1223,14 @@
mrproper:
git clean -xfd
+version:
+ newversion=$$(dialog --stdout --inputbox "New Version:" 0 0 "$(VERSION)") ; \
+ if [ -n "$$newversion" ] && [ "$$newversion" != "$(VERSION)" ]; then \
+ sed -ri "s/$(VERSION)/$$newversion/" include/common.h configure.ac docs/QUICKSTART; \
+ fi ;
+ sed -i Changes -e "s/$(VERSION)/$$newversion $(shell date)\n - ...\n\n$(VERSION)/"
+ $(MAKE) docs
+
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/README
^
|
@@ -25,7 +25,7 @@
Download
--------
-* Latest stable release http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.9.tar.gz[version 1.0.9] from August 16 2011
+* Latest stable release http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.10.tar.gz[version 1.0.10] from August 28 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>>.
@@ -209,7 +209,7 @@
From Source
~~~~~~~~~~~
-Pre Requirements:
+Pre Requirements:
- gcc / g++
- autoconf / automake / autoheader
@@ -297,6 +297,7 @@
config::
include config from this file. Options are the same as described here.
+ 'include' is an alias for 'config'.
+
=====
config=/etc/nagios3/mod_gm_worker.conf
@@ -308,9 +309,9 @@
Possible values are:
+
--
- * `0` - only errors
- * `1` - debug messages
- * `2` - trace messages
+ * `0` - only errors
+ * `1-4` - debug verbosity
+ * `5` - trace and all gearman related logs are going to stdout
--
+
Default is 0.
@@ -504,7 +505,7 @@
+
Default is 1.
+
-====
+====
perfdata_mode=1
====
@@ -606,6 +607,17 @@
dupserver=logserver:4730,logserver2:4730
====
+
+show_error_output::
+Use this option to show stderr output of plugins too. When set to no,
+only stdout will be displayed.
+Default is yes.
++
+====
+ show_error_output=yes
+====
+
+
workaround_rc_25::
Duplicate jobs from gearmand result sometimes in exit code 25 of
plugins because they are executed twice and get killed because of
@@ -777,12 +789,12 @@
How to Submit check_multi Results
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-check_multi is a plugin which executes multiple child checks.
-See more details about the feed_passive mode at:
+check_multi is a plugin which executes multiple child checks.
+See more details about the feed_passive mode at:
http://www.my-plugin.de/wiki/projects/check_multi/feed_passive[www.my-plugin.de]
You can pass such child checks to Nagios via the mod_gearman
-neb module:
+neb module:
--------------------------------------
%> check_multi -f multi.cmd -r 256 | ./send_multi --server=<job server> --encryption=no --host="<hostname>" --service="<service>"
@@ -828,6 +840,7 @@
Archive
-------
+* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.10.tar.gz[version 1.0.10 - August 28 2011]
* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.9.tar.gz[version 1.0.9 - August 16 2011]
* 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]
@@ -844,4 +857,3 @@
* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-0.6.tar.gz[version 0.6 - October 13 2010]
* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-0.5.tar.gz[version 0.5 - October 01 2010]
* http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-0.4.tar.gz[version 0.4 - September 25 2010]
-
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/THANKS
^
|
@@ -16,3 +16,6 @@
https://github.com/zorgnax/libtap
for the libtap code.
+Thanks to
+www.jukie.net/bart/blog/popenRWE
+for the popenRWE code.
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/common/gearman.c
^
|
@@ -164,9 +164,22 @@
gearman_task_st *task = NULL;
gearman_return_t ret1, ret2;
char * crypted_data;
- int size;
+ int size, free_uniq;
struct timeval now;
+ /* check too long queue names */
+ if(strlen(queue) > 63) {
+ gm_log( GM_LOG_ERROR, "queue name too long: '%s'\n", queue );
+ return GM_ERROR;
+ }
+
+ /* cut off to long uniq ids */
+ free_uniq = 0;
+ if(uniq != NULL && strlen(uniq) > 63) {
+ uniq = strndup(uniq, 63);
+ free_uniq = 1;
+ }
+
signal(SIGPIPE, SIG_IGN);
gm_log( GM_LOG_TRACE, "add_job_to_queue(%s, %s, %d, %d, %d, %d)\n", queue, uniq, priority, retries, transport_mode, send_now );
@@ -253,6 +266,9 @@
/* reset error counter */
mod_gm_con_errors = 0;
+ if(free_uniq)
+ free(uniq);
+
gm_log( GM_LOG_TRACE, "add_job_to_queue() finished sucessfully: %d %d\n", ret1, ret2 );
return GM_OK;
}
|
[-]
[+]
|
Added |
mod_gearman-1.0.10.tar.bz2/common/popenRWE.c
^
|
@@ -0,0 +1,92 @@
+/**
+ * Copyright 2009-2010 Bart Trojanowski <bart@jukie.net>
+ * Licensed under GPLv2, or later, at your choosing.
+ *
+ * bidirectional popen() call
+ *
+ * @param rwepipe - int array of size three
+ * @param exe - program to run
+ * @param argv - argument list
+ * @return pid or -1 on error
+ *
+ * The caller passes in an array of three integers (rwepipe), on successful
+ * execution it can then write to element 0 (stdin of exe), and read from
+ * element 1 (stdout) and 2 (stderr).
+ */
+
+#include "popenRWE.h"
+
+int popenRWE(int *rwepipe, char *command) {
+ int in[2];
+ int out[2];
+ int err[2];
+ int pid;
+ int rc;
+
+ rc = pipe(in);
+ if (rc<0)
+ goto error_in;
+
+ rc = pipe(out);
+ if (rc<0)
+ goto error_out;
+
+ rc = pipe(err);
+ if (rc<0)
+ goto error_err;
+
+ pid = fork();
+ if (pid > 0) { // parent
+ close(in[0]);
+ close(out[1]);
+ close(err[1]);
+ rwepipe[0] = in[1];
+ rwepipe[1] = out[0];
+ rwepipe[2] = err[0];
+ return pid;
+ } else if (pid == 0) { // child
+ close(in[1]);
+ close(out[0]);
+ close(err[0]);
+ close(0);
+ if(!dup(in[0])) {
+ ;
+ }
+ close(1);
+ if(!dup(out[1])) {
+ ;
+ }
+ close(2);
+ if(!dup(err[1])) {
+ ;
+ }
+
+ execl( "/bin/sh", "sh", "-c", command, NULL );
+ exit(1);
+ } else
+ goto error_fork;
+
+ return pid;
+
+error_fork:
+ close(err[0]);
+ close(err[1]);
+error_err:
+ close(out[0]);
+ close(out[1]);
+error_out:
+ close(in[0]);
+ close(in[1]);
+error_in:
+ return -1;
+}
+
+int pcloseRWE(int pid, int *rwepipe)
+{
+ int rc, status;
+ close(rwepipe[0]);
+ close(rwepipe[1]);
+ close(rwepipe[2]);
+ rc = waitpid(pid, &status, 0);
+ return status;
+}
\ No newline at end of file
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/common/utils.c
^
|
@@ -25,42 +25,54 @@
#include "crypt.h"
#include "base64.h"
#include "gearman.h"
+#include "popenRWE.h"
pid_t current_child_pid = 0;
char temp_buffer1[GM_BUFFERSIZE];
char temp_buffer2[GM_BUFFERSIZE];
/* escapes newlines in a string */
-char *escape_newlines(char *rawbuf) {
+char *gm_escape_newlines(char *rawbuf, int trimmed) {
+ char *tmpbuf=NULL;
+ char *tmpbuf_dup=NULL;
char *newbuf=NULL;
register int x,y;
if(rawbuf==NULL)
return NULL;
+ tmpbuf = strdup(rawbuf);
+ tmpbuf_dup = tmpbuf;
+ if ( trimmed == GM_ENABLED ) {
+ tmpbuf = trim(tmpbuf);
+ }
+
/* allocate enough memory to escape all chars if necessary */
- if((newbuf=malloc((strlen(rawbuf)*2)+1))==NULL)
+ if((newbuf=malloc((strlen(tmpbuf)*2)+1))==NULL)
return NULL;
- for(x=0,y=0;rawbuf[x]!=(char)'\x0';x++){
+ for(x=0,y=0;tmpbuf[x]!=(char)'\x0';x++){
/* escape backslashes */
- if(rawbuf[x]=='\\'){
+ if(tmpbuf[x]=='\\'){
newbuf[y++]='\\';
newbuf[y++]='\\';
}
/* escape newlines */
- else if(rawbuf[x]=='\n'){
+ else if(tmpbuf[x]=='\n'){
newbuf[y++]='\\';
newbuf[y++]='n';
}
else
- newbuf[y++]=rawbuf[x];
+ newbuf[y++]=tmpbuf[x];
}
+
newbuf[y]='\x0';
+ free(tmpbuf_dup);
+
return newbuf;
}
@@ -164,6 +176,8 @@
char *back;
if(s == NULL)
return NULL;
+ if(strlen(s) == 0)
+ return s;
back = s + strlen(s);
while(isspace(*--back));
*(back+1) = '\0';
@@ -226,6 +240,7 @@
opt->max_jobs = GM_DEFAULT_MAX_JOBS;
opt->spawn_rate = GM_DEFAULT_SPAWN_RATE;
opt->identifier = NULL;
+ opt->show_error_output = GM_ENABLED;
opt->workaround_rc_25 = GM_DISABLED;
@@ -250,7 +265,7 @@
opt->local_servicegroups_num = 0;
for(i=0;i<=GM_LISTSIZE;i++)
opt->local_servicegroups_list[i] = NULL;
- for(i=0;i<=GM_NEBTYPESSIZE;i++) {
+ for(i=0;i<GM_NEBTYPESSIZE;i++) {
mod_gm_exp_t *mod_gm_exp;
mod_gm_exp = malloc(sizeof(mod_gm_exp_t));
mod_gm_exp->elem_number = 0;
@@ -371,13 +386,19 @@
}
/* active */
- else if ( !strcmp( key, "active" ) ) {
+ else if ( !strcmp( key, "active" ) ) {
opt->active = parse_yes_or_no(value, GM_ENABLED);
return(GM_OK);
}
+ /* show_error_output */
+ else if ( !strcmp( key, "show_error_output" ) ) {
+ opt->show_error_output = parse_yes_or_no(value, GM_ENABLED);
+ return(GM_OK);
+ }
+
/* workaround_rc_25 */
- else if ( !strcmp( key, "workaround_rc_25" ) ) {
+ else if ( !strcmp( key, "workaround_rc_25" ) ) {
opt->workaround_rc_25 = parse_yes_or_no(value, GM_ENABLED);
return(GM_OK);
}
@@ -472,9 +493,10 @@
string2timeval(value, &opt->finishtime);
}
- /* configfile */
+ /* configfile / includes */
else if ( !strcmp( key, "config" )
|| !strcmp( key, "configfile" )
+ || !strcmp( key, "include" )
) {
if(read_config_file(opt, value, ++recursion_level) != GM_OK) {
recursion_level--;
@@ -600,9 +622,13 @@
while ( (groupname = strsep( &value, "," )) != NULL ) {
groupname = trim(groupname);
if ( strcmp( groupname, "" ) ) {
- opt->servicegroups_list[opt->servicegroups_num] = strdup(groupname);
- opt->servicegroups_num++;
- opt->set_queues_by_hand++;
+ if(strlen(groupname) > 50) {
+ gm_log( GM_LOG_ERROR, "servicegroup name '%s' is too long, please use a maximum of 50 characters\n", groupname );
+ } else {
+ opt->servicegroups_list[opt->servicegroups_num] = strdup(groupname);
+ opt->servicegroups_num++;
+ opt->set_queues_by_hand++;
+ }
}
}
}
@@ -614,9 +640,13 @@
while ( (groupname = strsep( &value, "," )) != NULL ) {
groupname = trim(groupname);
if ( strcmp( groupname, "" ) ) {
- opt->hostgroups_list[opt->hostgroups_num] = strdup(groupname);
- opt->hostgroups_num++;
- opt->set_queues_by_hand++;
+ if(strlen(groupname) > 50) {
+ gm_log( GM_LOG_ERROR, "hostgroup name '%s' is too long, please use a maximum of 50 characters\n", groupname );
+ } else {
+ opt->hostgroups_list[opt->hostgroups_num] = strdup(groupname);
+ opt->hostgroups_num++;
+ opt->set_queues_by_hand++;
+ }
}
}
}
@@ -657,31 +687,35 @@
char *return_code = strsep( &value, ":" );
int return_code_num = atoi(return_code);
char *callbacks = strsep( &value, ":" );
- while ( (callback = strsep( &callbacks, "," )) != NULL ) {
- int callback_num = atoi(trim(callback));
- if(index(callback, 'N') != NULL) {
- callback_num = -1;
- /* get neb callback number by name */
- int i;
- for(i=0;i<=GM_NEBTYPESSIZE;i++) {
- char * type = nebcallback2str(i);
- if(!strcmp(type, callback)) {
- callback_num = i;
+ if(strlen(export_queue) > 50) {
+ gm_log( GM_LOG_ERROR, "export queue name '%s' is too long, please use a maximum of 50 characters\n", export_queue );
+ } else {
+ while ( (callback = strsep( &callbacks, "," )) != NULL ) {
+ int callback_num = atoi(trim(callback));
+ if(index(callback, 'N') != NULL) {
+ callback_num = -1;
+ /* get neb callback number by name */
+ int i;
+ for(i=0;i<GM_NEBTYPESSIZE;i++) {
+ char * type = nebcallback2str(i);
+ if(!strcmp(type, callback)) {
+ callback_num = i;
+ }
+ free(type);
+ }
+ if(callback_num == -1) {
+ gm_log( GM_LOG_ERROR, "unknown nebcallback : %s\n", callback);
+ continue;
}
- free(type);
- }
- if(callback_num == -1) {
- gm_log( GM_LOG_ERROR, "unknown nebcallback : %s\n", callback);
- continue;
}
- }
- int number = opt->exports[callback_num]->elem_number;
- opt->exports[callback_num]->name[number] = strdup(export_queue);
- opt->exports[callback_num]->return_code[number] = return_code_num;
- opt->exports[callback_num]->elem_number++;
+ int number = opt->exports[callback_num]->elem_number;
+ opt->exports[callback_num]->name[number] = strdup(export_queue);
+ opt->exports[callback_num]->return_code[number] = return_code_num;
+ opt->exports[callback_num]->elem_number++;
+ }
+ opt->exports_count++;
}
- opt->exports_count++;
}
else {
@@ -808,7 +842,7 @@
for(i=0;i<opt->local_servicegroups_num;i++)
gm_log( GM_LOG_DEBUG, "local_servicegroups: %s\n", opt->local_servicegroups_list[i]);
/* export queues*/
- for(i=0;i<=GM_NEBTYPESSIZE;i++) {
+ for(i=0;i<GM_NEBTYPESSIZE;i++) {
char * type = nebcallback2str(i);
for(j=0;j<opt->exports[i]->elem_number;j++)
gm_log( GM_LOG_DEBUG, "export: %-45s -> %s\n", type, opt->exports[i]->name[j]);
@@ -998,7 +1032,7 @@
/* extract check result */
-char *extract_check_result(FILE *fp) {
+char *extract_check_result(FILE *fp, int trimmed) {
int size;
char buffer[GM_BUFFERSIZE] = "";
char output[GM_BUFFERSIZE] = "";
@@ -1011,7 +1045,8 @@
strncat(output, buffer, size);
size -= strlen(buffer);
}
- return(escape_newlines(output));
+
+ return(gm_escape_newlines(output, trimmed));
}
@@ -1061,17 +1096,27 @@
/* run a check */
-int run_check(char *processed_command, char **ret) {
+int run_check(char *processed_command, char **ret, char **err) {
char *argv[MAX_CMD_ARGS];
FILE *fp;
pid_t pid;
- int pipefds[2];
+ int pipe_stdout[2], pipe_stderr[2], pipe_rwe[3];
int retval;
/* check for check execution method (shell or execvp) */
if(!strpbrk(processed_command,"!$^&*()~[]|{};<>?`\"'")) {
+ /* use the fast execvp when there are now shell characters */
gm_log( GM_LOG_TRACE, "using execvp\n" );
- if(pipe(pipefds)) {
+
+ parse_command_line(processed_command,argv);
+ if(!argv[0])
+ _exit(STATE_UNKNOWN);
+
+ if(pipe(pipe_stdout)) {
+ gm_log( GM_LOG_ERROR, "error creating pipe: %s\n", strerror(errno));
+ _exit(STATE_UNKNOWN);
+ }
+ if(pipe(pipe_stderr)) {
gm_log( GM_LOG_ERROR, "error creating pipe: %s\n", strerror(errno));
_exit(STATE_UNKNOWN);
}
@@ -1080,14 +1125,17 @@
_exit(STATE_UNKNOWN);
}
else if(!pid){
- if((dup2(pipefds[1],STDOUT_FILENO)<0)||(dup2(pipefds[1],STDERR_FILENO)<0)){
+ /* child process */
+ if((dup2(pipe_stdout[1],STDOUT_FILENO)<0)){
gm_log( GM_LOG_ERROR, "dup2 error\n");
_exit(STATE_UNKNOWN);
}
- close(pipefds[1]);
- parse_command_line(processed_command,argv);
- if(!argv[0])
+ if((dup2(pipe_stderr[1],STDERR_FILENO)<0)){
+ gm_log( GM_LOG_ERROR, "dup2 error\n");
_exit(STATE_UNKNOWN);
+ }
+ close(pipe_stdout[1]);
+ close(pipe_stderr[1]);
current_child_pid = getpid();
execvp(argv[0], argv);
if(errno == 2)
@@ -1097,37 +1145,59 @@
_exit(STATE_UNKNOWN);
}
- /* prepare pipe reading */
- close(pipefds[1]);
- fp=fdopen(pipefds[0],"r");
+ /* parent */
+ /* prepare stdout pipe reading */
+ close(pipe_stdout[1]);
+ fp=fdopen(pipe_stdout[0],"r");
if(!fp){
gm_log( GM_LOG_ERROR, "fdopen error\n");
_exit(STATE_UNKNOWN);
}
+ *ret = extract_check_result(fp, GM_DISABLED);
+ fclose(fp);
- /* extract check result */
- *ret = extract_check_result(fp);
-
- /* close the process */
+ /* prepare stderr pipe reading */
+ close(pipe_stderr[1]);
+ fp=fdopen(pipe_stderr[0],"r");
+ if(!fp){
+ gm_log( GM_LOG_ERROR, "fdopen error\n");
+ _exit(STATE_UNKNOWN);
+ }
+ *err = extract_check_result(fp, GM_ENABLED);
fclose(fp);
- close(pipefds[0]);
+
+ close(pipe_stdout[0]);
+ close(pipe_stderr[0]);
if(waitpid(pid,&retval,0)!=pid)
retval=-1;
}
else {
- current_child_pid = getpid();
+ /* use the slower popen when there were shell characters */
gm_log( GM_LOG_TRACE, "using popen\n" );
- fp=popen(processed_command,"r");
- if(fp==NULL)
- _exit(STATE_UNKNOWN);
+ current_child_pid = getpid();
+ pid = popenRWE(pipe_rwe, processed_command);
/* extract check result */
- *ret = extract_check_result(fp);
+ fp=fdopen(pipe_rwe[1],"r");
+ if(!fp){
+ gm_log( GM_LOG_ERROR, "fdopen error\n");
+ _exit(STATE_UNKNOWN);
+ }
+ *ret = extract_check_result(fp, GM_DISABLED);
+ fclose(fp);
+ /* extract check stderr */
+ fp=fdopen(pipe_rwe[2],"r");
+ if(!fp){
+ gm_log( GM_LOG_ERROR, "fdopen error\n");
+ _exit(STATE_UNKNOWN);
+ }
+ *err = extract_check_result(fp, GM_ENABLED);
+ fclose(fp);
/* close the process */
- retval=pclose(fp);
- }
+ retval=pcloseRWE(pid, pipe_rwe);
+ }
return retval;
}
@@ -1135,16 +1205,17 @@
/* execute this command with given timeout */
int execute_safe_command(gm_job_t * exec_job, int fork_exec, char * identifier) {
- int pdes[2];
+ int pipe_stdout[2] , pipe_stderr[2];
int return_code;
int pclose_result;
- char *plugin_output;
+ char *plugin_output, *plugin_error;
char *bufdup;
- char buffer[GM_BUFFERSIZE];
+ char buffer[GM_BUFFERSIZE], buf_error[GM_BUFFERSIZE];
sigset_t mask;
struct timeval start_time,end_time;
- pid_t pid = 0;
- buffer[0] = '\x0';
+ pid_t pid = 0;
+ buffer[0] = '\x0';
+ buf_error[0] = '\x0';
gm_log( GM_LOG_TRACE, "execute_safe_command()\n" );
@@ -1155,8 +1226,10 @@
/* fork a child process */
if(fork_exec == GM_ENABLED) {
- if(pipe(pdes) != 0)
- perror("pipe");
+ if(pipe(pipe_stdout) != 0)
+ perror("pipe stdout");
+ if(pipe(pipe_stderr) != 0)
+ perror("pipe stderr");
pid=fork();
@@ -1179,33 +1252,40 @@
sigfillset(&mask);
sigprocmask(SIG_UNBLOCK, &mask, NULL);
- if( fork_exec == GM_ENABLED )
- close(pdes[0]);
+ if( fork_exec == GM_ENABLED ) {
+ close(pipe_stdout[0]);
+ close(pipe_stderr[0]);
+ }
signal(SIGALRM, check_alarm_handler);
alarm(exec_job->timeout);
/* run the plugin check command */
- pclose_result = run_check(exec_job->command_line, &plugin_output);
+ pclose_result = run_check(exec_job->command_line, &plugin_output, &plugin_error);
return_code = pclose_result;
if(fork_exec == GM_ENABLED) {
- if(write(pdes[1], plugin_output, strlen(plugin_output)+1) <= 0)
+ if(write(pipe_stdout[1], plugin_output, strlen(plugin_output)+1) <= 0)
+ perror("write stdout");
+ if(write(pipe_stderr[1], plugin_error, strlen(plugin_error)+1) <= 0)
perror("write");
if(pclose_result == -1) {
char error[GM_BUFFERSIZE];
snprintf(error, sizeof(error), "error on %s: %s", identifier, strerror(errno));
- if(write(pdes[1], error, strlen(error)+1) <= 0)
+ if(write(pipe_stdout[1], error, strlen(error)+1) <= 0)
perror("write");
}
return_code = real_exit_code(pclose_result);
free(plugin_output);
+ free(plugin_error);
exit(return_code);
}
else {
- snprintf( buffer, sizeof( buffer )-1, "%s", plugin_output );
+ snprintf( buffer, sizeof( buffer )-1, "%s", plugin_output );
+ snprintf( buf_error, sizeof( buf_error )-1, "%s", plugin_error );
free(plugin_output);
+ free(plugin_error);
}
}
@@ -1215,12 +1295,15 @@
gm_log( GM_LOG_TRACE, "started check with pid: %d\n", pid);
if( fork_exec == GM_ENABLED) {
- close(pdes[1]);
+ close(pipe_stdout[1]);
+ close(pipe_stderr[1]);
waitpid(pid, &return_code, 0);
gm_log( GM_LOG_TRACE, "finished check from pid: %d with status: %d\n", pid, return_code);
/* get all lines of plugin output */
- if(read(pdes[0], buffer, sizeof(buffer)-1) < 0)
+ if(read(pipe_stdout[0], buffer, sizeof(buffer)-1) < 0)
+ perror("read");
+ if(read(pipe_stderr[0], buf_error, sizeof(buf_error)-1) < 0)
perror("read");
}
return_code = real_exit_code(return_code);
@@ -1239,7 +1322,11 @@
else if(return_code >= 128 && return_code < 144) {
char * signame = nr2signal((int)(return_code-128));
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);
+ snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of %d is out of bounds. Plugin exited by signal %s. (worker: %s)", (int)(return_code), signame, identifier);
+ if(strlen(bufdup) > 0) {
+ strncat(buffer, "\\n", (sizeof(buffer)-1));
+ strncat(buffer, bufdup, (sizeof(buffer)-1));
+ }
return_code = STATE_CRITICAL;
free(bufdup);
free(signame);
@@ -1249,7 +1336,7 @@
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);
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);
+ snprintf( buffer, sizeof( buffer )-1, "CRITICAL: Return code of %d is out of bounds. (worker: %s)\\n%s", (int)(return_code), identifier, bufdup);
free(bufdup);
if(return_code != 25 && mod_gm_opt->workaround_rc_25 == GM_DISABLED) {
return_code = STATE_CRITICAL;
@@ -1257,9 +1344,11 @@
}
exec_job->output = strdup(buffer);
+ exec_job->error = strdup(buf_error);
exec_job->return_code = return_code;
if( fork_exec == GM_ENABLED) {
- close(pdes[0]);
+ close(pipe_stdout[0]);
+ close(pipe_stderr[0]);
}
}
alarm(0);
@@ -1275,9 +1364,9 @@
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)\n", identifier);
+ snprintf( buffer, sizeof( buffer ) -1, "(Service Check Timed Out On Worker: %s)", identifier);
if ( !strcmp( exec_job->type, "host" ) )
- snprintf( buffer, sizeof( buffer ) -1, "(Host Check Timed Out On Worker: %s)\n", identifier);
+ snprintf( buffer, sizeof( buffer ) -1, "(Host Check Timed Out On Worker: %s)", identifier);
free(exec_job->output);
exec_job->output = strdup( buffer );
}
@@ -1295,6 +1384,7 @@
job->result_queue = NULL;
job->command_line = NULL;
job->output = NULL;
+ job->error = NULL;
job->exited_ok = TRUE;
job->scheduled_check = TRUE;
job->reschedule_check = TRUE;
@@ -1317,6 +1407,7 @@
free(job->result_queue);
free(job->command_line);
free(job->output);
+ free(job->error);
free(job);
return(GM_OK);
@@ -1933,6 +2024,13 @@
strncat(temp_buffer2, ") - ", (sizeof(temp_buffer2)-1));
}
strncat(temp_buffer2, exec_job->output, (sizeof(temp_buffer2)-1));
+ if(mod_gm_opt->show_error_output && strlen(exec_job->error) > 0) {
+ if(strlen(exec_job->output) > 0)
+ strncat(temp_buffer2, "\\n", (sizeof(temp_buffer2)-1));
+ strncat(temp_buffer2, "[", (sizeof(temp_buffer2)-1));
+ strncat(temp_buffer2, exec_job->error, (sizeof(temp_buffer2)-1));
+ strncat(temp_buffer2, "] ", (sizeof(temp_buffer2)-1));
+ }
strncat(temp_buffer2, "\n\n\n", (sizeof(temp_buffer2)-1));
strncat(temp_buffer1, temp_buffer2, (sizeof(temp_buffer1)-1));
}
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.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.9.
+# Generated by GNU Autoconf 2.65 for mod_gearman 1.0.10.
#
# 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.9'
-PACKAGE_STRING='mod_gearman 1.0.9'
+PACKAGE_VERSION='1.0.10'
+PACKAGE_STRING='mod_gearman 1.0.10'
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.9 to adapt to many kinds of systems.
+\`configure' configures mod_gearman 1.0.10 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.9:";;
+ short | recursive ) echo "Configuration of mod_gearman 1.0.10:";;
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.9
+mod_gearman configure 1.0.10
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.9, which was
+It was created by mod_gearman $as_me 1.0.10, 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.9'
+ VERSION='1.0.10'
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.9, which was
+This file was extended by mod_gearman $as_me 1.0.10, 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.9
+mod_gearman config.status 1.0.10
configured by $0, generated by GNU Autoconf 2.65,
with options \\"\$ac_cs_config\\"
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/configure.ac
^
|
@@ -3,7 +3,7 @@
##############################################
AC_PREREQ([2.59])
-AC_INIT([mod_gearman], [1.0.9], [sven.nierlein@consol.de])
+AC_INIT([mod_gearman], [1.0.10], [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.10.tar.bz2/docs/QUICKSTART
^
|
@@ -52,9 +52,9 @@
--------------------------------------
#> cd /tmp
-#> wget "http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.9.tar.gz"
-#> tar zxf mod_gearman-1.0.9.tar.gz
-#> cd mod_gearman-1.0.9
+#> wget "http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.10.tar.gz"
+#> tar zxf mod_gearman-1.0.10.tar.gz
+#> cd mod_gearman-1.0.10
#> ./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.9
+[1295003042] mod_gearman: Version 1.0.10
[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.9|worker=1 jobs=2c
+check_gearman OK - debian64 has 1 worker and is working on 0 jobs. Version: 1.0.10|worker=1 jobs=2c
--------------------------------------
The interesting number is the last one, '2c' in our case, which means there
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.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.9.tar.gz"
-#> tar zxf mod_gearman-1.0.9.tar.gz
-#> cd mod_gearman-1.0.9
+#> wget "http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.10.tar.gz"
+#> tar zxf mod_gearman-1.0.10.tar.gz
+#> cd mod_gearman-1.0.10
#> ./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.9
+[1295003042] mod_gearman: Version 1.0.10
[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.9|worker=1 jobs=2c</tt></pre>
+check_gearman OK - debian64 has 1 worker and is working on 0 jobs. Version: 1.0.10|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-08-16 09:50:33 CEST
+Last updated 2011-08-25 16:07:59 CEST
</div>
</div>
</body>
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/docs/README.html
^
|
@@ -593,7 +593,7 @@
<div class="ulist"><ul>
<li>
<p>
-Latest stable release <a href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.9.tar.gz">version 1.0.9</a> from August 16 2011
+Latest stable release <a href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.10.tar.gz">version 1.0.10</a> from August 28 2011
</p>
</li>
<li>
@@ -887,6 +887,7 @@
<dd>
<p>
include config from this file. Options are the same as described here.
+ <em>include</em> is an alias for <em>config</em>.
</p>
<div class="exampleblock">
<div class="exampleblock-content">
@@ -907,17 +908,17 @@
<div class="ulist"><ul>
<li>
<p>
-<tt>0</tt> - only errors
+<tt>0</tt> - only errors
</p>
</li>
<li>
<p>
-<tt>1</tt> - debug messages
+<tt>1-4</tt> - debug verbosity
</p>
</li>
<li>
<p>
-<tt>2</tt> - trace messages
+<tt>5</tt> - trace and all gearman related logs are going to stdout
</p>
</li>
</ul></div>
@@ -1442,6 +1443,23 @@
</div></div>
</dd>
<dt class="hdlist1">
+show_error_output
+</dt>
+<dd>
+<p>
+Use this option to show stderr output of plugins too. When set to no,
+only stdout will be displayed.
+Default is yes.
+</p>
+<div class="exampleblock">
+<div class="exampleblock-content">
+<div class="literalblock">
+<div class="content">
+<pre><tt>show_error_output=yes</tt></pre>
+</div></div>
+</div></div>
+</dd>
+<dt class="hdlist1">
workaround_rc_25
</dt>
<dd>
@@ -1720,6 +1738,11 @@
<div class="ulist"><ul>
<li>
<p>
+<a href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.10.tar.gz">version 1.0.10 - August 28 2011</a>
+</p>
+</li>
+<li>
+<p>
<a href="http://labs.consol.de/wp-content/uploads/2010/09/mod_gearman-1.0.9.tar.gz">version 1.0.9 - August 16 2011</a>
</p>
</li>
@@ -1804,7 +1827,7 @@
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Last updated 2011-08-16 09:46:51 CEST
+Last updated 2011-08-28 11:11:43 CEST
</div>
</div>
</body>
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/etc/mod_gearman.conf.in
^
|
@@ -168,9 +168,13 @@
# Use this option to disable an extra fork for each plugin execution. Disabling
# this option will reduce the load on the worker host but can lead to problems with
-# unclean plugin.
+# unclean plugin. Default: yes
fork_on_exec=yes
+# Use this option to show stderr output of plugins too.
+# Default: yes
+show_error_output=yes
+
# Workarounds
# workaround for rc 25 bug
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/extras/standalone_worker.conf
^
|
@@ -10,10 +10,9 @@
# 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.
+# 0 = only errors
+# 1-4 = debug verbosity
+# 5 = trace and all gearman related logs are going to stdout.
# Default is 0.
debug=0
@@ -118,6 +117,14 @@
# as there are jobs waiting
spawn-rate=1
+# Use this option to disable an extra fork for each plugin execution. Disabling
+# this option will reduce the load on the worker host but can lead to problems with
+# unclean plugin. Default: yes
+fork_on_exec=yes
+
+# Use this option to show stderr output of plugins too.
+# Default: yes
+show_error_output=yes
# Workarounds
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/include/common.h
^
|
@@ -52,13 +52,13 @@
#define MOD_GM_COMMON_H
/* constants */
-#define GM_VERSION "1.0.9"
+#define GM_VERSION "1.0.10"
#define GM_ENABLED 1
#define GM_DISABLED 0
#define GM_BUFFERSIZE 98304
#define GM_MAX_OUTPUT 65536 /* must be ~30% below GM_BUFFERSIZE for base64/encryption */
#define GM_LISTSIZE 512
-#define GM_NEBTYPESSIZE 32 /* maximum number of neb types */
+#define GM_NEBTYPESSIZE 33 /* maximum number of neb types */
#define GM_MIN_LIB_GEARMAN_VERSION 0.14
#define GM_SERVER_DEFAULT_PORT 4730
@@ -71,7 +71,9 @@
#define GM_LOG_INFO 0
#define GM_LOG_DEBUG 1
#define GM_LOG_TRACE 2
-#define GM_LOG_STDOUT 3
+#define GM_LOG_TRACE2 3
+#define GM_LOG_TRACE3 4
+#define GM_LOG_STDOUT 5
/* log modes */
#define GM_LOG_MODE_AUTO 0
@@ -201,6 +203,7 @@
int idle_timeout; /**< number of seconds till a idle worker exits */
int max_jobs; /**< maximum number of jobs done after a worker exits */
int spawn_rate; /**< number of spawned new worker */
+ int show_error_output; /**< optional display the stderr output of plugins */
int workaround_rc_25; /**< optional workaround for plugins returning exit code 25 */
/* send_gearman */
int timeout; /**< timeout for waiting reading on stdin */
@@ -222,7 +225,8 @@
char * command_line; /**< command line to execute */
char * type; /**< type of this job */
char * result_queue; /**< name of the result queue */
- char * output; /**< output from the executed command line */
+ char * output; /**< output from the executed command line (stdout) */
+ char * error; /**< errors from the executed command line (stderr) */
int return_code; /**< return code for this job */
int early_timeout; /**< did the check run into a timeout */
int check_options; /**< check_options given from the core */
|
[-]
[+]
|
Added |
mod_gearman-1.0.10.tar.bz2/include/popenRWE.h
^
|
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2009-2010 Bart Trojanowski <bart@jukie.net>
+ * Licensed under GPLv2, or later, at your choosing.
+ *
+ * bidirectional popen() call
+ *
+ * @param rwepipe - int array of size three
+ * @param exe - program to run
+ * @param argv - argument list
+ * @return pid or -1 on error
+ *
+ * The caller passes in an array of three integers (rwepipe), on successful
+ * execution it can then write to element 0 (stdin of exe), and read from
+ * element 1 (stdout) and 2 (stderr).
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int popenRWE(int *rwepipe, char *command);
+int pcloseRWE(int pid, int *rwepipe);
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/include/utils.h
^
|
@@ -40,16 +40,18 @@
#include <sys/wait.h>
#include <sys/stat.h>
+#include "popenRWE.h"
#include "common.h"
/**
* escpae newlines
*
- * @param[in] rawbuf - text to escape
+ * @param[in] rawbuf - text to escape
+ * @param[in] trimmed - trim string before escaping
*
* @return a text with all newlines escaped
*/
-char *escape_newlines(char *rawbuf);
+char *gm_escape_newlines(char *rawbuf, int trimmed);
/**
* real_exit_code
@@ -296,11 +298,12 @@
*
* get result from a file pointer
*
- * @param[in] fp - file pointer to executed command
+ * @param[in] fp - file pointer to executed command
+ * @param[in] trimmed - trim result
*
* @return check result
*/
-char *extract_check_result(FILE *fp);
+char *extract_check_result(FILE *fp, int trimmed);
/**
* parse_command_line
@@ -321,10 +324,11 @@
*
* @param[in] processed_command - command line
* @param[out] plugin_output - pointer to plugin output
+ * @param[out] plugin_error - pointer to plugin error output
*
* @return true on success
*/
-int run_check(char *processed_command, char **plugin_output);
+int run_check(char *processed_command, char **plugin_output, char **plugin_error);
/**
*
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/neb_module/mod_gearman.c
^
|
@@ -157,7 +157,7 @@
neb_register_callback( NEBCALLBACK_TIMED_EVENT_DATA, gearman_module_handle, 0, handle_timed_events );
/* register export callbacks */
- for(i=0;i<=GM_NEBTYPESSIZE;i++) {
+ for(i=0;i<GM_NEBTYPESSIZE;i++) {
if(mod_gm_opt->exports[i]->elem_number > 0)
neb_register_callback( i, gearman_module_handle, 0, handle_export );
}
@@ -228,7 +228,7 @@
}
/* register export callbacks */
- for(x=0;x<=GM_NEBTYPESSIZE;x++) {
+ for(x=0;x<GM_NEBTYPESSIZE;x++) {
if(mod_gm_opt->exports[x]->elem_number > 0)
neb_deregister_callback( x, gearman_module_handle );
}
@@ -401,8 +401,7 @@
gm_log( GM_LOG_TRACE, "got eventhandler event: %s\n", ds->command_line );
temp_buffer[0]='\x0';
- snprintf( temp_buffer,sizeof( temp_buffer )-1,"type=eventhandler\ncommand_line=%s\n\n\n",ds->command_line );
- temp_buffer[sizeof( temp_buffer )-1]='\x0';
+ snprintf( temp_buffer,GM_BUFFERSIZE-1,"type=eventhandler\ncommand_line=%s\n\n\n",ds->command_line );
if(add_job_to_queue( &client,
mod_gm_opt->server_list,
@@ -508,14 +507,13 @@
gm_log( GM_LOG_TRACE, "cmd_line: %s\n", processed_command );
temp_buffer[0]='\x0';
- snprintf( temp_buffer,sizeof( temp_buffer )-1,"type=host\nresult_queue=%s\nhost_name=%s\nstart_time=%i.0\ntimeout=%d\ncommand_line=%s\n\n\n",
+ snprintf( temp_buffer,GM_BUFFERSIZE-1,"type=host\nresult_queue=%s\nhost_name=%s\nstart_time=%i.0\ntimeout=%d\ncommand_line=%s\n\n\n",
mod_gm_opt->result_queue,
hst->name,
( int )hst->next_check,
host_check_timeout,
processed_command
);
- temp_buffer[sizeof( temp_buffer )-1]='\x0';
if(add_job_to_queue( &client,
mod_gm_opt->server_list,
@@ -634,7 +632,7 @@
gm_log( GM_LOG_TRACE, "cmd_line: %s\n", processed_command );
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.0\ntimeout=%d\ncommand_line=%s\n\n\n",
+ snprintf( temp_buffer,GM_BUFFERSIZE-1,"type=service\nresult_queue=%s\nhost_name=%s\nservice_description=%s\nstart_time=%i.0\ntimeout=%d\ncommand_line=%s\n\n\n",
mod_gm_opt->result_queue,
svcdata->host_name,
svcdata->service_description,
@@ -642,10 +640,9 @@
service_check_timeout,
processed_command
);
- temp_buffer[sizeof( temp_buffer )-1]='\x0';
uniq[0]='\x0';
- snprintf( uniq,sizeof( temp_buffer )-1,"%s-%s", svcdata->host_name, svcdata->service_description);
+ snprintf( uniq,GM_BUFFERSIZE-1,"%s-%s", svcdata->host_name, svcdata->service_description);
/* execute forced checks with high prio as they are propably user requested */
if(check_result_info.check_options & CHECK_OPTION_FORCE_EXECUTION)
@@ -796,8 +793,7 @@
servicegroup * temp_servicegroup = find_servicegroup( mod_gm_opt->servicegroups_list[x] );
if ( is_service_member_of_servicegroup( temp_servicegroup,svc )==TRUE ) {
gm_log( GM_LOG_TRACE, "service is member of servicegroup: %s\n", mod_gm_opt->servicegroups_list[x] );
- snprintf( target_queue, sizeof(target_queue)-1, "servicegroup_%s", mod_gm_opt->servicegroups_list[x] );
- target_queue[sizeof( target_queue )-1]='\x0';
+ snprintf( target_queue, GM_BUFFERSIZE-1, "servicegroup_%s", mod_gm_opt->servicegroups_list[x] );
return;
}
x++;
@@ -810,8 +806,7 @@
hostgroup * temp_hostgroup = find_hostgroup( mod_gm_opt->hostgroups_list[x] );
if ( is_host_member_of_hostgroup( temp_hostgroup,hst )==TRUE ) {
gm_log( GM_LOG_TRACE, "server is member of hostgroup: %s\n", mod_gm_opt->hostgroups_list[x] );
- snprintf( target_queue, sizeof(target_queue)-1, "hostgroup_%s", mod_gm_opt->hostgroups_list[x] );
- target_queue[sizeof( target_queue )-1]='\x0';
+ snprintf( target_queue, GM_BUFFERSIZE-1, "hostgroup_%s", mod_gm_opt->hostgroups_list[x] );
return;
}
x++;
@@ -820,16 +815,14 @@
if ( svc ) {
/* pass into the general service queue */
if ( mod_gm_opt->services == GM_ENABLED && svc ) {
- snprintf( target_queue, sizeof(target_queue)-1, "service" );
- target_queue[sizeof( target_queue )-1]='\x0';
+ snprintf( target_queue, GM_BUFFERSIZE-1, "service" );
return;
}
}
else {
/* pass into the general host queue */
if ( mod_gm_opt->hosts == GM_ENABLED ) {
- snprintf( target_queue, sizeof(target_queue)-1, "host" );
- target_queue[sizeof( target_queue )-1]='\x0';
+ snprintf( target_queue, GM_BUFFERSIZE-1, "host" );
return;
}
}
@@ -883,10 +876,10 @@
}
uniq[0]='\x0';
- snprintf( uniq,sizeof( temp_buffer )-1,"%s", hostchkdata->host_name);
+ snprintf( uniq,GM_BUFFERSIZE-1,"%s", hostchkdata->host_name);
temp_buffer[0]='\x0';
- snprintf( temp_buffer,sizeof( temp_buffer )-1,
+ snprintf( temp_buffer,GM_BUFFERSIZE-1,
"DATATYPE::HOSTPERFDATA\t"
"TIMET::%d\t"
"HOSTNAME::%s\t"
@@ -898,7 +891,6 @@
hostchkdata->host_name, hostchkdata->perf_data,
hostchkdata->command_name, hostchkdata->command_args,
hostchkdata->state, hostchkdata->state_type);
- temp_buffer[sizeof( temp_buffer )-1]='\x0';
has_perfdata = TRUE;
}
break;
@@ -919,10 +911,10 @@
}
uniq[0]='\x0';
- snprintf( uniq,sizeof( temp_buffer )-1,"%s-%s", srvchkdata->host_name, srvchkdata->service_description);
+ snprintf( uniq,GM_BUFFERSIZE-1,"%s-%s", srvchkdata->host_name, srvchkdata->service_description);
temp_buffer[0]='\x0';
- snprintf( temp_buffer,sizeof( temp_buffer )-1,
+ snprintf( temp_buffer,GM_BUFFERSIZE-1,
"DATATYPE::SERVICEPERFDATA\t"
"TIMET::%d\t"
"HOSTNAME::%s\t"
@@ -935,7 +927,7 @@
srvchkdata->host_name, srvchkdata->service_description,
srvchkdata->perf_data, svc->service_check_command,
srvchkdata->state, srvchkdata->state_type);
- temp_buffer[sizeof( temp_buffer )-1]='\x0';
+ temp_buffer[GM_BUFFERSIZE-1]='\x0';
has_perfdata = TRUE;
}
break;
@@ -1000,7 +992,7 @@
case NEBCALLBACK_PROCESS_DATA: /* 7 */
npd = (nebstruct_process_data *)data;
type = nebtype2str(npd->type);
- snprintf( temp_buffer,sizeof( temp_buffer )-1, "{\"callback_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d}",
+ snprintf( temp_buffer,GM_BUFFERSIZE-1, "{\"callback_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d}",
"NEBCALLBACK_PROCESS_DATA",
type,
npd->flags,
@@ -1013,7 +1005,7 @@
nted = (nebstruct_timed_event_data *)data;
event_type = eventtype2str(nted->event_type);
type = nebtype2str(nted->type);
- snprintf( temp_buffer,sizeof( temp_buffer )-1, "{\"callback_type\":\"%s\",\"event_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d,\"recurring\":%d,\"run_time\":%d}",
+ snprintf( temp_buffer,GM_BUFFERSIZE-1, "{\"callback_type\":\"%s\",\"event_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d,\"recurring\":%d,\"run_time\":%d}",
"NEBCALLBACK_TIMED_EVENT_DATA",
event_type,
type,
@@ -1030,7 +1022,7 @@
nld = (nebstruct_log_data *)data;
buffer = escapestring(nld->data);
type = nebtype2str(nld->type);
- snprintf( temp_buffer,sizeof( temp_buffer )-1, "{\"callback_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d,\"entry_time\":%d,\"data_type\":%d,\"data\":\"%s\"}",
+ snprintf( temp_buffer,GM_BUFFERSIZE-1, "{\"callback_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d,\"entry_time\":%d,\"data_type\":%d,\"data\":\"%s\"}",
"NEBCALLBACK_LOG_DATA",
type,
nld->flags,
@@ -1094,7 +1086,6 @@
return 0;
}
- temp_buffer[sizeof( temp_buffer )-1]='\x0';
if(temp_buffer[0] != '\x0') {
for(i=0;i<mod_gm_opt->exports[callback_type]->elem_number;i++) {
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/t/01-utils.c
^
|
@@ -28,7 +28,7 @@
}
int main(void) {
- plan(55);
+ plan(58);
/* lowercase */
char test[100];
@@ -64,11 +64,14 @@
/* trim */
ok(trim(NULL) == NULL, "trim(NULL)");
- strcpy(test, " test "); like(trim(test), "test", "trim(' test ')");
+ strcpy(test, " test "); like(trim(test), "^test$", "trim(' test ')");
+ strcpy(test, "\ntest\n"); like(trim(test), "^test$", "trim('\\ntest\\n')");
/* reading keys */
- mod_gm_opt_t *mod_gm_opt = renew_opts();
+ mod_gm_opt_t *mod_gm_opt;
+ 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 = strdup("t/data/test1.key");
read_keyfile(mod_gm_opt);
@@ -193,6 +196,14 @@
like(mod_gm_opt->server_list[1], "host:4730", "duplicate server");
ok(mod_gm_opt->server_num == 2, "server_number = %d", mod_gm_opt->server_num);
+ /* escape newlines */
+ char * escaped = gm_escape_newlines(" test\n", GM_DISABLED);
+ is(escaped, " test\\n", "untrimmed escape string");
+ free(escaped);
+ escaped = gm_escape_newlines(" test\n", GM_ENABLED);
+ is(escaped, "test", "trimmed escape string");
+ free(escaped);
+
mod_gm_free_opt(mod_gm_opt);
return exit_status();
@@ -203,4 +214,3 @@
printf("core logger is not available for tests: %s", data);
return;
}
-
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/t/02-full.c
^
|
@@ -116,6 +116,37 @@
return;
}
+/* test */
+void send_big_jobs(int transportmode);
+void send_big_jobs(int transportmode) {
+ struct timeval start_time;
+ gettimeofday(&start_time,NULL);
+ 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",
+ GM_DEFAULT_RESULT_QUEUE,
+ "host1",
+ "service1",
+ ( int )start_time.tv_sec,
+ ( int )start_time.tv_usec,
+ 60,
+ 0,
+ 1,
+ 1,
+ 0.0,
+ "/bin/hostname"
+ );
+ temp_buffer[sizeof( temp_buffer )-1]='\x0';
+ char * uniq = "something at least bigger than the 64 chars allowed by libgearman!";
+ int rt = add_job_to_queue( &client, mod_gm_opt->server_list, "service", uniq, temp_buffer, GM_JOB_PRIO_NORMAL, 1, transportmode, TRUE );
+ ok(rt == GM_OK, "big uniq id sent successfully in mode %s", transportmode == GM_ENCODE_ONLY ? "base64" : "aes256");
+
+ char * queue = "something at least bigger than the 64 chars allowed by libgearman!";
+ rt = add_job_to_queue( &client, mod_gm_opt->server_list, queue, uniq, temp_buffer, GM_JOB_PRIO_NORMAL, 1, transportmode, TRUE );
+ ok(rt == GM_ERROR, "big queue sent unsuccessfully in mode %s", transportmode == GM_ENCODE_ONLY ? "base64" : "aes256");
+
+ return;
+}
/* create server / worker / clients */
void create_modules(void);
@@ -203,10 +234,10 @@
/* main tests */
int main(void) {
int status, chld;
- int tests = 53;
+ int tests = 55;
int rrc;
char cmd[150];
- char * result;
+ char *result, *error;
plan(tests);
mod_gm_opt = malloc(sizeof(mod_gm_opt_t));
@@ -253,6 +284,9 @@
/* create server / worker / clients */
create_modules();
+ /* send big job */
+ send_big_jobs(GM_ENCODE_ONLY);
+
/* try to send some data with base64 only */
test_eventhandler(GM_ENCODE_ONLY);
test_servicecheck(GM_ENCODE_ONLY);
@@ -298,22 +332,24 @@
* send_gearman
*/
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));
+ rrc = real_exit_code(run_check(cmd, &result, &error));
cmp_ok(rrc, "==", 0, "cmd '%s' returned rc %d", cmd, rrc);
like(result, "^\\s*$", "output from ./send_gearman");
free(result);
+ free(error);
/*****************************************
* send_gearman
*/
snprintf(cmd, 150, "./send_multi --server=localhost:%d --host=blah < t/data/send_multi.txt", GEARMAND_TEST_PORT);
- rrc = real_exit_code(run_check(cmd, &result));
+ rrc = real_exit_code(run_check(cmd, &result, &error));
cmp_ok(rrc, "==", 0, "cmd '%s' returned rc %d", cmd, rrc);
like(result, "send_multi OK: 2 check_multi child checks submitted", "output from ./send_multi");
/* cleanup */
free(result);
+ free(error);
mod_gm_free_opt(mod_gm_opt);
free_client(&client);
free_worker(&worker);
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/t/03-exec_checks.c
^
|
@@ -11,11 +11,11 @@
int main(void) {
int rc, rrc;
- char * result;
+ char *result, *error;
char cmd[120];
char hostname[GM_BUFFERSIZE];
- plan(42);
+ plan(54);
/* set hostname */
gethostname(hostname, GM_BUFFERSIZE-1);
@@ -47,59 +47,66 @@
* send_gearman
*/
strcpy(cmd, "./send_gearman --server=blah --key=testtest --host=test --service=test --message=test --returncode=0");
- rrc = real_exit_code(run_check(cmd, &result));
+ rrc = real_exit_code(run_check(cmd, &result, &error));
diag(result);
cmp_ok(rrc, "==", 3, "cmd '%s' returned rc %d", cmd, rrc);
free(result);
+ free(error);
/*****************************************
* send_gearman
*/
+ //mod_gm_opt->debug_level = 4;
strcpy(cmd, "./send_multi --server=blah --host=blah < t/data/send_multi.txt");
- rrc = real_exit_code(run_check(cmd, &result));
+ rrc = real_exit_code(run_check(cmd, &result, &error));
diag(result);
cmp_ok(rrc, "==", 3, "cmd '%s' returned rc %d", cmd, rrc);
free(result);
+ free(error);
/*****************************************
* simple test command 1
*/
strcpy(cmd, "/bin/true");
- rc = run_check(cmd, &result);
+ rc = run_check(cmd, &result, &error);
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);
+ free(error);
/*****************************************
* simple test command 2
*/
strcpy(cmd, "/bin/true 2>&1");
- rc = run_check(cmd, &result);
+ rc = run_check(cmd, &result, &error);
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);
+ free(error);
/*****************************************
* simple test command 3
*/
strcpy(cmd, "/usr/lib/nagios/plugins/check_icmp -H 127.0.0.1");
- rc = run_check(cmd, &result);
+ rc = run_check(cmd, &result, &error);
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);
+ free(error);
/*****************************************
* simple test command 4
*/
strcpy(cmd, "echo -n 'test'; exit 2");
- rc = run_check(cmd, &result);
+ rc = run_check(cmd, &result, &error);
rrc = real_exit_code(rc);
cmp_ok(rrc, "==", 2, "cmd '%s' returned rc %d", cmd, rrc);
like(result, "test", "returned result string");
free(result);
+ free(error);
gm_job_t * exec_job;
exec_job = ( gm_job_t * )malloc( sizeof *exec_job );
@@ -119,10 +126,12 @@
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);
+ free(exec_job->error);
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);
+ free(exec_job->error);
/* non existing command 2 */
free(exec_job->command_line);
@@ -131,6 +140,7 @@
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);
+ free(exec_job->error);
@@ -145,6 +155,7 @@
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);
+ free(exec_job->error);
/* non existing command 2 */
fork_on_exec = 1;
@@ -154,6 +165,7 @@
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);
+ free(exec_job->error);
@@ -167,6 +179,7 @@
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:.*exiting with exit code 5", "returned result string");
free(exec_job->output);
+ free(exec_job->error);
/* unknown exit code 2 */
@@ -177,6 +190,7 @@
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:.*exiting with exit code 5", "returned result string");
free(exec_job->output);
+ free(exec_job->error);
/* unknown exit code 3 */
free(exec_job->command_line);
@@ -185,6 +199,7 @@
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);
+ free(exec_job->error);
/* unknown exit code 4 */
free(exec_job->command_line);
@@ -193,6 +208,7 @@
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);
+ free(exec_job->error);
/* unknown exit code 5 */
free(exec_job->command_line);
@@ -201,6 +217,7 @@
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);
+ free(exec_job->error);
/*****************************************
@@ -214,6 +231,7 @@
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);
+ free(exec_job->error);
/* signaled exit code SIGINT 2 */
fork_on_exec = 0;
@@ -223,6 +241,7 @@
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);
+ free(exec_job->error);
@@ -238,6 +257,7 @@
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);
+ free(exec_job->error);
/* timed out check 2 */
fork_on_exec = 0;
@@ -246,12 +266,55 @@
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);
+ free(exec_job->error);
/* reset timeout */
exec_job->timeout = 30;
- /* clean up */
+
+ /*****************************************
+ * capture stderr
+ */
+ free(exec_job->command_line);
+ exec_job->command_line = strdup("./t/both");
+ execute_safe_command(exec_job, fork_on_exec, hostname);
+ cmp_ok(exec_job->return_code, "==", 0, "cmd '%s' returns rc 0", exec_job->command_line);
+ like(exec_job->output, "out", "returned result string");
+ like(exec_job->error, "err", "returned error string");
+ free(exec_job->output);
+ free(exec_job->error);
+
+ free(exec_job->command_line);
+ exec_job->command_line = strdup("./t/both;");
+ execute_safe_command(exec_job, fork_on_exec, hostname);
+ cmp_ok(exec_job->return_code, "==", 0, "cmd '%s' returns rc 0", exec_job->command_line);
+ like(exec_job->output, "out", "returned result string");
+ like(exec_job->error, "err", "returned error string");
+ free(exec_job->output);
+ free(exec_job->error);
+
+ fork_on_exec = 1;
+ free(exec_job->command_line);
+ exec_job->command_line = strdup("./t/both");
+ execute_safe_command(exec_job, fork_on_exec, hostname);
+ cmp_ok(exec_job->return_code, "==", 0, "cmd '%s' returns rc 0", exec_job->command_line);
+ like(exec_job->output, "out", "returned result string");
+ like(exec_job->error, "err", "returned error string");
+ free(exec_job->output);
+ free(exec_job->error);
+
+ free(exec_job->command_line);
+ exec_job->command_line = strdup("./t/both;");
+ execute_safe_command(exec_job, fork_on_exec, hostname);
+ cmp_ok(exec_job->return_code, "==", 0, "cmd '%s' returns rc 0", exec_job->command_line);
+ like(exec_job->output, "out", "returned result string");
+ like(exec_job->error, "err", "returned error string");
+
+ /*****************************************
+ * clean up
+ */
free_job(exec_job);
mod_gm_free_opt(mod_gm_opt);
return exit_status();
|
[-]
[+]
|
Added |
mod_gearman-1.0.10.tar.bz2/t/06-execvp_vs_popen.c
^
|
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <common.h>
+#include <utils.h>
+
+mod_gm_opt_t *mod_gm_opt;
+
+int main(void) {
+ char *result, *error;
+ char cmd[120];
+ int x;
+
+ /* set hostname */
+ gethostname(hostname, GM_BUFFERSIZE-1);
+
+ /* create options structure and set debug level */
+ mod_gm_opt = malloc(sizeof(mod_gm_opt_t));
+ set_default_options(mod_gm_opt);
+ mod_gm_opt->debug_level = 4;
+
+ gm_job_t * exec_job;
+ exec_job = ( gm_job_t * )malloc( sizeof *exec_job );
+ set_default_job(exec_job, mod_gm_opt);
+ //strcpy(cmd, "/bin/true;");
+ strcpy(cmd, "/bin/true;");
+ //strcpy(cmd, "./t/both");
+
+ run_check(cmd, &result, &error);
+ mod_gm_opt->debug_level = 0;
+
+ for(x=0;x<100;x++) {
+ run_check(cmd, &result, &error);
+ }
+
+
+ free_job(exec_job);
+ mod_gm_free_opt(mod_gm_opt);
+ exit(0);
+}
+
+/* core log wrapper */
+void write_core_log(char *data) {
+ printf("core logger is not available for tests: %s", data);
+ return;
+}
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/tools/send_gearman.c
^
|
@@ -219,7 +219,7 @@
}
/* escape newline */
- buf = escape_newlines(mod_gm_opt->message);
+ buf = gm_escape_newlines(mod_gm_opt->message, GM_DISABLED);
free(mod_gm_opt->message);
mod_gm_opt->message = malloc(GM_BUFFERSIZE);
snprintf(mod_gm_opt->message, GM_BUFFERSIZE, "%s", buf);
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/tools/send_multi.c
^
|
@@ -208,7 +208,7 @@
}
/* escape newline */
- buf = escape_newlines(mod_gm_opt->message);
+ buf = gm_escape_newlines(mod_gm_opt->message, GM_DISABLED);
free(mod_gm_opt->message);
mod_gm_opt->message = malloc(GM_BUFFERSIZE);
snprintf(mod_gm_opt->message, GM_BUFFERSIZE, "%s", buf);
|
[-]
[+]
|
Changed |
mod_gearman-1.0.10.tar.bz2/worker/worker.c
^
|
@@ -168,8 +168,8 @@
void count_current_worker(int restart) {
int x;
- gm_log( GM_LOG_TRACE, "count_current_worker()\n");
- gm_log( GM_LOG_TRACE, "done jobs: shm[0] = %d\n", shm[0]);
+ gm_log( GM_LOG_TRACE3, "count_current_worker()\n");
+ gm_log( GM_LOG_TRACE3, "done jobs: shm[0] = %d\n", shm[0]);
/* shm states:
* 0 -> undefined
@@ -183,14 +183,14 @@
gm_log( GM_LOG_TRACE, "removed stale status worker, old pid: %d\n", shm[3] );
shm[3] = -1;
}
- gm_log( GM_LOG_TRACE, "status worker: shm[3] = %d\n", shm[3]);
+ gm_log( GM_LOG_TRACE3, "status worker: shm[3] = %d\n", shm[3]);
/* check all known worker */
current_number_of_workers = 0;
current_number_of_jobs = 0;
for(x=4; x < mod_gm_opt->max_worker+4; x++) {
/* verify worker is alive */
- gm_log( GM_LOG_TRACE, "worker slot: shm[%d] = %d\n", x, shm[x]);
+ gm_log( GM_LOG_TRACE3, "worker slot: shm[%d] = %d\n", x, shm[x]);
if( shm[x] != -1 && pid_alive(shm[x]) == FALSE ) {
gm_log( GM_LOG_TRACE, "removed stale worker %d, old pid: %d\n", x, shm[x]);
shm[x] = -1;
@@ -211,7 +211,7 @@
shm[1] = current_number_of_workers; /* total worker */
shm[2] = current_number_of_jobs; /* running worker */
- gm_log( GM_LOG_TRACE, "worker: %d - running: %d\n", current_number_of_workers, current_number_of_jobs);
+ gm_log( GM_LOG_TRACE3, "worker: %d - running: %d\n", current_number_of_workers, current_number_of_jobs);
return;
}
@@ -220,7 +220,7 @@
void check_worker_population() {
int x, now, target_number_of_workers;
- gm_log( GM_LOG_TRACE, "check_worker_population()\n");
+ gm_log( GM_LOG_TRACE3, "check_worker_population()\n");
/* set current worker number */
count_current_worker(GM_ENABLED);
@@ -504,14 +504,14 @@
int target = min;
if(cur_workers == 0) {
- gm_log( GM_LOG_TRACE, "adjust_number_of_worker(min %d, max %d, worker %d, jobs %d) -> %d\n", min, max, cur_workers, cur_jobs, mod_gm_opt->min_worker);
+ gm_log( GM_LOG_TRACE3, "adjust_number_of_worker(min %d, max %d, worker %d, jobs %d) -> %d\n", min, max, cur_workers, cur_jobs, mod_gm_opt->min_worker);
return mod_gm_opt->min_worker;
}
perc_running = (int)cur_jobs*100/cur_workers;
idle = (int)cur_workers - cur_jobs;
- gm_log( GM_LOG_TRACE, "adjust_number_of_worker(min %d, max %d, worker %d, jobs %d) = %d%% running\n", min, max, cur_workers, cur_jobs, perc_running);
+ gm_log( GM_LOG_TRACE3, "adjust_number_of_worker(min %d, max %d, worker %d, jobs %d) = %d%% running\n", min, max, cur_workers, cur_jobs, perc_running);
if(cur_workers == max)
return max;
@@ -527,7 +527,7 @@
if(target > max) { target = max; }
if(target != cur_workers)
- gm_log( GM_LOG_DEBUG, "adjust_number_of_worker(min %d, max %d, worker %d, jobs %d) = %d%% running -> %d\n", min, max, cur_workers, cur_jobs, perc_running, target);
+ gm_log( GM_LOG_TRACE3, "adjust_number_of_worker(min %d, max %d, worker %d, jobs %d) = %d%% running -> %d\n", min, max, cur_workers, cur_jobs, perc_running, target);
return target;
}
|