[Pkg-nagios-changes] [SCM] Debian packaging for mod gearman. branch, upstream, updated. upstream/1.0.6-34-gd3fb2ec
Sven Nierlein
sven at nierlein.de
Wed Aug 24 09:21:57 UTC 2011
The following commit has been merged in the upstream branch:
commit 6a18609f8c4138576f60b9460160fcca1b66d1dd
Author: Sven Nierlein <sven at nierlein.de>
Date: Thu Jul 28 11:37:21 2011 +0200
reworked exit codes of send_multi and send_gearman
diff --git a/t/03-exec_checks.c b/t/03-exec_checks.c
index db8b9ea..da60c53 100644
--- a/t/03-exec_checks.c
+++ b/t/03-exec_checks.c
@@ -49,7 +49,7 @@ int main(void) {
strcpy(cmd, "./send_gearman --server=blah --key=testtest --host=test --service=test --message=test --returncode=0");
rrc = real_exit_code(run_check(cmd, &result));
diag(result);
- cmp_ok(rrc, "==", 1, "cmd '%s' returned rc %d", cmd, rrc);
+ cmp_ok(rrc, "==", 3, "cmd '%s' returned rc %d", cmd, rrc);
free(result);
/*****************************************
@@ -58,7 +58,7 @@ int main(void) {
strcpy(cmd, "./send_multi --server=blah --host=blah < t/data/send_multi.txt");
rrc = real_exit_code(run_check(cmd, &result));
diag(result);
- cmp_ok(rrc, "==", 1, "cmd '%s' returned rc %d", cmd, rrc);
+ cmp_ok(rrc, "==", 3, "cmd '%s' returned rc %d", cmd, rrc);
free(result);
/*****************************************
diff --git a/tools/send_gearman.c b/tools/send_gearman.c
index 6e96985..78901fe 100644
--- a/tools/send_gearman.c
+++ b/tools/send_gearman.c
@@ -39,7 +39,7 @@ int main (int argc, char **argv) {
*/
if(parse_arguments(argc, argv) != GM_OK) {
print_usage();
- exit( EXIT_FAILURE );
+ exit( STATE_UNKNOWN );
}
/* set logging */
@@ -55,14 +55,14 @@ int main (int argc, char **argv) {
/* create client */
if ( create_client( mod_gm_opt->server_list, &client ) != GM_OK ) {
- printf( "cannot start client\n" );
- exit( EXIT_FAILURE );
+ printf( "send_gearman UNKNOWN: cannot start client\n" );
+ exit( STATE_UNKNOWN );
}
/* create duplicate client */
if ( create_client_dup( mod_gm_opt->dupserver_list, &client_dup ) != GM_OK ) {
- gm_log( GM_LOG_ERROR, "cannot start client for duplicate server\n" );
- exit( EXIT_FAILURE );
+ printf( "send_gearman UNKNOWN: cannot start client for duplicate server\n" );
+ exit( STATE_UNKNOWN );
}
/* send result message */
@@ -175,7 +175,7 @@ void print_usage() {
printf("see README for a detailed explaination of all options.\n");
printf("\n");
- exit( EXIT_SUCCESS );
+ exit( STATE_UNKNOWN );
}
@@ -199,11 +199,11 @@ int send_result() {
if(mod_gm_opt->result_queue == NULL) {
printf( "got no result queue, please use --result_queue=...\n" );
- return(GM_ERROR);
+ return( STATE_UNKNOWN );
}
if(mod_gm_opt->host == NULL) {
printf("got no hostname, please use --host=...\n" );
- return(GM_ERROR);
+ return( STATE_UNKNOWN );
}
if(mod_gm_opt->message == NULL) {
/* get all lines from stdin, wait maximum of 5 seconds */
@@ -290,9 +290,9 @@ int send_result() {
}
else {
gm_log( GM_LOG_TRACE, "send_result_back() finished unsuccessfully\n" );
- return(GM_ERROR);
+ return( STATE_UNKNOWN );
}
- return(GM_OK);
+ return( STATE_OK );
}
@@ -302,7 +302,7 @@ void alarm_sighandler(int sig) {
printf("got no input! Either send plugin output to stdin or use --message=...\n");
- exit(EXIT_FAILURE);
+ exit( STATE_UNKNOWN );
}
diff --git a/tools/send_multi.c b/tools/send_multi.c
index a2eb952..9f4371e 100644
--- a/tools/send_multi.c
+++ b/tools/send_multi.c
@@ -40,7 +40,7 @@ int main (int argc, char **argv) {
*/
if(parse_arguments(argc, argv) != GM_OK) {
print_usage();
- exit( 3 );
+ exit( STATE_UNKNOWN );
}
/* set logging */
@@ -56,14 +56,14 @@ int main (int argc, char **argv) {
/* create client */
if ( create_client( mod_gm_opt->server_list, &client ) != GM_OK ) {
- printf( "send_multi CRITICAL: cannot start client\n" );
- exit(2);
+ printf( "send_multi UNKNOWN: cannot start client\n" );
+ exit( STATE_UNKNOWN );
}
/* create duplicate client */
if ( create_client_dup( mod_gm_opt->dupserver_list, &client_dup ) != GM_OK ) {
- gm_log( GM_LOG_ERROR, "cannot start client for duplicate server\n" );
- exit( EXIT_FAILURE );
+ printf( "send_multi UNKNOWN: cannot start client for duplicate server\n" );
+ exit( STATE_UNKNOWN );
}
/* send result message */
@@ -72,14 +72,14 @@ int main (int argc, char **argv) {
/* if rc > 0, it contains the number of checks being submitted,
otherwise its an error code (-1 - WARNING, -2 - CRITICAL, -3 - UNKNOWN) */
if (rc == 0) {
- printf( "send_multi WARNING: %d check_multi child checks submitted\n", rc );
- rc=1; /* WARNING */
+ printf( "send_multi UNKNOWN: %d check_multi child checks submitted\n", rc );
+ rc=STATE_UNKNOWN;
}
else if (rc > 0) {
printf( "send_multi OK: %d check_multi child check%s submitted\n", rc, (rc>1)?"s":"" );
- rc=0; /* OK */
+ rc=STATE_OK;
} else {
- rc*=-2;
+ rc*=-1;
}
gearman_client_free( &client );
@@ -190,7 +190,7 @@ void print_usage() {
printf("http://my-plugin.de/wiki/projects/check_multi/feed_passive\n");
printf("\n");
- exit(3);
+ exit( STATE_UNKNOWN );
}
@@ -288,7 +288,7 @@ void alarm_sighandler(int sig) {
printf("Timeout after %d seconds - got no input! Send plugin output to stdin.\n", mod_gm_opt->timeout);
- exit(EXIT_FAILURE);
+ exit( STATE_CRITICAL );
}
@@ -340,8 +340,8 @@ int read_multi_stream(FILE *stream) {
/* start <CHILD> tag found, but no closing tag </CHILD>, buffer too small? */
} else {
buflen=0L;
- gm_log( GM_LOG_ERROR, "Error: no closing tag </CHILD> within buffer, buffer size too small? discarding buffer, %ld bytes now\n", buflen);
- return -1;
+ printf("send_multi UNKNOWN: no closing tag </CHILD> within buffer, buffer size too small? discarding buffer, %ld bytes now\n", buflen);
+ return -STATE_UNKNOWN;
}
gm_log( GM_LOG_TRACE, "\tbuflen after XML chunk parsing:%ld\n", buflen);
@@ -356,7 +356,8 @@ int read_multi_stream(FILE *stream) {
;
/* ASCIIZ string? then print messages */
if (buffer[i] == '\0' && i) {
- printf("send_multi WARNING: error msg in input buffer: %s\n", buffer);
+ printf("send_multi UNKNOWN: error msg in input buffer: %s\n", buffer);
+ return -STATE_UNKNOWN;
}
}
@@ -374,7 +375,7 @@ int read_multi_stream(FILE *stream) {
/* break if zero read was caused by an error */
if (!feof(stream)) {
perror("fread");
- return -2;
+ return -STATE_CRITICAL;
}
} else {
--
Debian packaging for mod gearman.
More information about the Pkg-nagios-changes
mailing list