[Pkg-nagios-changes] [SCM] Debian packaging for mod gearman. branch, master, updated. f5edd3e88aa2138dcf6d044c835fbd0ada944168

Sven Nierlein sven at nierlein.org
Fri Feb 11 11:17:58 UTC 2011


The following commit has been merged in the master branch:
commit 22cade7258e850e850061e338db9c15f1e67e453
Author: Sven Nierlein <sven at nierlein.org>
Date:   Thu Jan 20 15:45:04 2011 +0100

    added missing performance data to send_multi

diff --git a/Changes b/Changes
index 5589564..3c9d5ae 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 This file documents the revision history for mod_gearman.
 
+1.0    Sun...
+          - added missing performance data to send_multi
+
 0.9    Sun Jan 16 21:20:06 CET 2011
           - prepared debian packaging (thanks Stig Sandbeck Mathisen)
           - increased max output to 64k
diff --git a/configure.ac b/configure.ac
index 748a1ef..5f9eea4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
 
 ##############################################
 AC_PREREQ([2.59])
-AC_INIT([mod_gearman], [0.9], [sven.nierlein at consol.de])
+AC_INIT([mod_gearman], [1.0], [sven.nierlein at 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])
diff --git a/include/common.h b/include/common.h
index 4baae68..5840a6a 100644
--- a/include/common.h
+++ b/include/common.h
@@ -28,7 +28,7 @@
 #define MOD_GM_COMMON_H
 
 /* constants */
-#define GM_VERSION                  "0.9"
+#define GM_VERSION                  "1.0"
 #define GM_ENABLED                      1
 #define GM_DISABLED                     0
 #define GM_BUFFERSIZE               98304
diff --git a/mod_gearman.spec b/mod_gearman.spec
index 43b4a23..dbbb915 100644
--- a/mod_gearman.spec
+++ b/mod_gearman.spec
@@ -1,5 +1,5 @@
 Name:          mod_gearman
-Version:       0.9
+Version:       1.0
 Release:       3
 License:       GNU Public License version 2
 Packager:      Olivier Raginel <babar at cern.ch>
diff --git a/tools/send_multi.c b/tools/send_multi.c
index 9327ac6..011acaa 100644
--- a/tools/send_multi.c
+++ b/tools/send_multi.c
@@ -62,10 +62,10 @@ 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) {
-	    gm_log( GM_LOG_INFO, "%d check_multi child check%s submitted\n", rc, (rc>1)?"s":"" );
-       rc=0; /* OK */
+        gm_log( GM_LOG_INFO, "%d check_multi child check%s submitted\n", rc, (rc>1)?"s":"" );
+        rc=0; /* OK */
     } else {
-	    rc*=-1;
+        rc*=-1;
     }
 
     gearman_client_free( &client );
@@ -123,8 +123,8 @@ int verify_options(mod_gm_opt_t *opt) {
 
     /* no server specified? then default to localhost */
     if(opt->server_num == 0) {
-	opt->server_list[opt->server_num] = strdup("localhost");
-	opt->server_num++;
+        opt->server_list[opt->server_num] = strdup("localhost");
+        opt->server_num++;
     }
 
     /* host is mandatory */
@@ -267,183 +267,180 @@ void print_version() {
 }
 
 int read_multi_stream(FILE *stream) {
-	char buffer[GM_BUFFERSIZE+1];
-	unsigned long buflen=0L;
-	unsigned long bytes_read=0L;
-	char *bufstart=NULL;
-	char *bufend=NULL;
-	int count=0;
-
-	do {
-		/* opening tag <CHILD> found? read from buffer start with maximum buffer len */
-		if ((bufstart=(char *)memmem(buffer,buflen,"<CHILD>",strlen("<CHILD>"))) != NULL) {
-
-			/* closing tag </CHILD> found? read after <CHILD> with rest of buffer len */
-		    	if ((bufend=(char *)memmem(bufstart,buflen-(bufstart-buffer),"</CHILD>",strlen("</CHILD>"))) != NULL) {
-
-				gm_log( GM_LOG_TRACE, "\tXML chunk %d found: buffer position %3d-%3d length %d bytes\n", count, bufstart-buffer, bufend-buffer, bufend-bufstart);
-				/* count valid chunks */
-				count++;
-
-				/* identify CHILD chunk */
-				bufstart+=strlen("<CHILD>");
-
-				/* if valid check_multi chunk found, send the result*/
-				if (read_child_check(bufstart,bufend)) {
-					if (send_result() == GM_ERROR) {
-						count--;
-					}
-				} else {
-					count--;
-				}
-
-				/* shift input rest to buffer start, create space for subsequent reads */
-				memmove(buffer,bufend+strlen("</CHILD>"),buflen-(bufend+strlen("</CHILD>")-buffer));
-				buflen-=bufend+strlen("</CHILD>")-buffer;
-
-			/* 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;
-			}
-			gm_log( GM_LOG_TRACE, "\tbuflen after XML chunk parsing:%ld\n", buflen);
-
-		/* neither <CHILD> nor </CHILD> found, discard buffer */
-		} else {
-			/* discard whole buffer but continue */
-			buflen=0L;
-			gm_log( GM_LOG_TRACE, "Error: no starting tag <CHILD> within buffer - discarding buffer, buflen now %ld bytes\n", buflen);
-		}
-
-		gm_log( GM_LOG_TRACE, "\ttrying to fill up buffer with %ld bytes from offset %ld\n", GM_BUFFERSIZE-buflen, buflen);
-
-		/* read one block of data, or less bytes, if there is still data left */
-		alarm(mod_gm_opt->timeout);
-		if ((bytes_read=fread(buffer+buflen, 1, GM_BUFFERSIZE-buflen, stream)) == 0L) {
-
-			/* break if zero read was caused by an error */
-			if (!feof(stream)) {
-				perror("fread");
-				return -2;
-			}
-		} else {
-
-			/* adjust block len */
-			buflen+=bytes_read;
-		}
-		gm_log( GM_LOG_TRACE, "\tread %ld bytes, %ld bytes remaining in buffer\n", bytes_read, buflen);
-	} while (buflen > 0);
-	return count;
+    char buffer[GM_BUFFERSIZE+1];
+    unsigned long buflen=0L;
+    unsigned long bytes_read=0L;
+    char *bufstart=NULL;
+    char *bufend=NULL;
+    int count=0;
+
+    do {
+        /* opening tag <CHILD> found? read from buffer start with maximum buffer len */
+        if ((bufstart=(char *)memmem(buffer,buflen,"<CHILD>",strlen("<CHILD>"))) != NULL) {
+
+            /* closing tag </CHILD> found? read after <CHILD> with rest of buffer len */
+            if ((bufend=(char *)memmem(bufstart,buflen-(bufstart-buffer),"</CHILD>",strlen("</CHILD>"))) != NULL) {
+
+                gm_log( GM_LOG_TRACE, "\tXML chunk %d found: buffer position %3d-%3d length %d bytes\n", count, bufstart-buffer, bufend-buffer, bufend-bufstart);
+                /* count valid chunks */
+                count++;
+
+                /* identify CHILD chunk */
+                bufstart+=strlen("<CHILD>");
+
+                /* if valid check_multi chunk found, send the result*/
+                if (read_child_check(bufstart,bufend)) {
+                    if (send_result() == GM_ERROR) {
+                        count--;
+                    }
+                } else {
+                    count--;
+                }
+
+                /* shift input rest to buffer start, create space for subsequent reads */
+                memmove(buffer,bufend+strlen("</CHILD>"),buflen-(bufend+strlen("</CHILD>")-buffer));
+                buflen-=bufend+strlen("</CHILD>")-buffer;
+
+            /* 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;
+            }
+            gm_log( GM_LOG_TRACE, "\tbuflen after XML chunk parsing:%ld\n", buflen);
+
+        /* neither <CHILD> nor </CHILD> found, discard buffer */
+        } else {
+            /* discard whole buffer but continue */
+            buflen=0L;
+            gm_log( GM_LOG_TRACE, "Error: no starting tag <CHILD> within buffer - discarding buffer, buflen now %ld bytes\n", buflen);
+        }
+
+        gm_log( GM_LOG_TRACE, "\ttrying to fill up buffer with %ld bytes from offset %ld\n", GM_BUFFERSIZE-buflen, buflen);
+
+        /* read one block of data, or less bytes, if there is still data left */
+        alarm(mod_gm_opt->timeout);
+        if ((bytes_read=fread(buffer+buflen, 1, GM_BUFFERSIZE-buflen, stream)) == 0L) {
+
+            /* break if zero read was caused by an error */
+            if (!feof(stream)) {
+                perror("fread");
+                return -2;
+            }
+        } else {
+
+            /* adjust block len */
+            buflen+=bytes_read;
+        }
+        gm_log( GM_LOG_TRACE, "\tread %ld bytes, %ld bytes remaining in buffer\n", bytes_read, buflen);
+    } while (buflen > 0);
+    return count;
 }
 
 int read_child_check(char *bufstart, char *bufend) {
-	char *attribute=NULL;
-
-	/* child check number */
-	if ((attribute=read_multi_attribute(bufstart,bufend,"no")) == NULL) {
-		return 0;
-	} else {
-		/* skip parent check */
-		if (!strcmp(attribute,"0")) {
-			return 0;
-		}
-		gm_log( GM_LOG_TRACE, "child check: %d\n", atoi(attribute));
-	}
-
-	/* service description */
-	if ((attribute=read_multi_attribute(bufstart,bufend,"name")) == NULL) {
-		return 0;
-	} else {
-		mod_gm_opt->service=strdup(attribute);
-		gm_log( GM_LOG_TRACE, "service_description: %s\n", mod_gm_opt->service);
-	}
-
-	/* return code */
-	if ((attribute=read_multi_attribute(bufstart,bufend,"rc")) == NULL) {
-		return 0;
-	} else {
-		mod_gm_opt->return_code=atoi(attribute);
-		gm_log( GM_LOG_TRACE, "mod_gm_opt->return_code: %d\n", mod_gm_opt->return_code);
-	}
-
-	/* start time */
-	if ((attribute=read_multi_attribute(bufstart,bufend,"starttime")) == NULL) {
-		return 0;
-	} else {
-		if (strchr(attribute, '.') != NULL) {
-			mod_gm_opt->starttime.tv_sec=atoi(strtok(attribute, "."));
-			mod_gm_opt->starttime.tv_usec=atoi(strtok(NULL, "."));
-		} else {
-			mod_gm_opt->starttime.tv_sec=atoi(attribute);
-			mod_gm_opt->starttime.tv_usec=0;
-		}
-		gm_log( GM_LOG_TRACE, "starttime: %d.%d\n", mod_gm_opt->starttime.tv_sec, mod_gm_opt->starttime.tv_usec);
-	}
-
-	/* end time */
-	if ((attribute=read_multi_attribute(bufstart,bufend,"endtime")) == NULL) {
-		return 0;
-	} else {
-		if (strchr(attribute, '.') != NULL) {
-			mod_gm_opt->finishtime.tv_sec=atoi(strtok(attribute, "."));
-			mod_gm_opt->finishtime.tv_usec=atoi(strtok(NULL, "."));
-		} else {
-			mod_gm_opt->finishtime.tv_sec=atoi(attribute);
-			mod_gm_opt->finishtime.tv_usec=0;
-		}
-		gm_log( GM_LOG_TRACE, "endtime: %d.%d\n", mod_gm_opt->finishtime.tv_sec, mod_gm_opt->finishtime.tv_usec);
-	}
-
-	/* message */
-	if ((attribute=read_multi_attribute(bufstart,bufend,"output")) == NULL) {
-		return 0;
-	} else {
-		mod_gm_opt->message=strdup(decode_xml(attribute));
-		gm_log( GM_LOG_TRACE, "mod_gm_opt->message: %s\n", mod_gm_opt->message);
-	}
-	return 1;
+    char *attribute  = NULL;
+    char *attribute2 = NULL;
+    char temp_buffer[GM_BUFFERSIZE];
+
+    /* child check number */
+    if ((attribute=read_multi_attribute(bufstart,bufend,"no")) == NULL) {
+        return 0;
+    } else {
+        /* skip parent check */
+        if (!strcmp(attribute,"0")) {
+            return 0;
+        }
+        gm_log( GM_LOG_TRACE, "child check: %d\n", atoi(attribute));
+    }
+
+    /* service description */
+    if ((attribute=read_multi_attribute(bufstart,bufend,"name")) == NULL)
+        return 0;
+    mod_gm_opt->service=strdup(attribute);
+    gm_log( GM_LOG_TRACE, "service_description: %s\n", mod_gm_opt->service);
+
+    /* return code */
+    if ((attribute=read_multi_attribute(bufstart,bufend,"rc")) == NULL)
+        return 0;
+    mod_gm_opt->return_code=atoi(attribute);
+    gm_log( GM_LOG_TRACE, "mod_gm_opt->return_code: %d\n", mod_gm_opt->return_code);
+
+    /* start time */
+    if ((attribute=read_multi_attribute(bufstart,bufend,"starttime")) == NULL)
+        return 0;
+    if (strchr(attribute, '.') != NULL) {
+        mod_gm_opt->starttime.tv_sec=atoi(strtok(attribute, "."));
+        mod_gm_opt->starttime.tv_usec=atoi(strtok(NULL, "."));
+    } else {
+        mod_gm_opt->starttime.tv_sec=atoi(attribute);
+        mod_gm_opt->starttime.tv_usec=0;
+    }
+    gm_log( GM_LOG_TRACE, "starttime: %d.%d\n", mod_gm_opt->starttime.tv_sec, mod_gm_opt->starttime.tv_usec);
+
+    /* end time */
+    if ((attribute=read_multi_attribute(bufstart,bufend,"endtime")) == NULL)
+        return 0;
+    if (strchr(attribute, '.') != NULL) {
+        mod_gm_opt->finishtime.tv_sec=atoi(strtok(attribute, "."));
+        mod_gm_opt->finishtime.tv_usec=atoi(strtok(NULL, "."));
+    } else {
+        mod_gm_opt->finishtime.tv_sec=atoi(attribute);
+        mod_gm_opt->finishtime.tv_usec=0;
+    }
+    gm_log( GM_LOG_TRACE, "endtime: %d.%d\n", mod_gm_opt->finishtime.tv_sec, mod_gm_opt->finishtime.tv_usec);
+
+    /* message */
+    if ((attribute=read_multi_attribute(bufstart,bufend,"output")) == NULL)
+        return 0;
+    /* performance data */
+    if ((attribute2=read_multi_attribute(bufstart,bufend,"performance")) == NULL)
+        return 0;
+    snprintf( temp_buffer, sizeof( temp_buffer )-1, "%s|%s", decode_xml(attribute), decode_xml(attribute2));
+    mod_gm_opt->message=strdup(temp_buffer);
+    gm_log( GM_LOG_TRACE, "mod_gm_opt->message: %s\n", mod_gm_opt->message);
+
+    return 1;
 }
 
 char *read_multi_attribute(char *bufstart, char *bufend, char *element) {
-	char start_element[GM_BUFFERSIZE], end_element[GM_BUFFERSIZE];
-	sprintf(start_element, "<%s>", element);
-	sprintf(end_element, "</%s>", element);
-
-	if ((bufstart=(char *)memmem(bufstart,bufend-bufstart,start_element,strlen(start_element))) == NULL) {
-		gm_log( GM_LOG_TRACE, "\tread_multi_attribute: start element \'%s\' not found\n", start_element);
-		return NULL;
-	}
-	bufstart+=strlen(start_element);
-	if ((bufend=(char *)memmem(bufstart,bufend-bufstart,end_element,strlen(end_element))) == NULL) {
-		gm_log( GM_LOG_TRACE, "\tread_multi_attribute: end element \'%s\' not found\n", end_element);
-		return NULL;
-	}
-	*bufend='\0';
-	return bufstart;
+    char start_element[GM_BUFFERSIZE], end_element[GM_BUFFERSIZE];
+    sprintf(start_element, "<%s>", element);
+    sprintf(end_element, "</%s>", element);
+
+    if ((bufstart=(char *)memmem(bufstart,bufend-bufstart,start_element,strlen(start_element))) == NULL) {
+        gm_log( GM_LOG_TRACE, "\tread_multi_attribute: start element \'%s\' not found\n", start_element);
+        return NULL;
+    }
+    bufstart+=strlen(start_element);
+    if ((bufend=(char *)memmem(bufstart,bufend-bufstart,end_element,strlen(end_element))) == NULL) {
+        gm_log( GM_LOG_TRACE, "\tread_multi_attribute: end element \'%s\' not found\n", end_element);
+        return NULL;
+    }
+    *bufend='\0';
+    return bufstart;
 }
 
 char *decode_xml(char *string) {
-        struct decode{
-                char c;
-                char *enc_string;
-        } dtab[] = {
-                { '>', "&gt;"  },
-                { '<', "&lt;"  },
-                { '&', "&amp;" },
-        };
-        int i;
-        char *found;
-
-	/* foreach XML decode pair */
-        for (i=0; i<(int)(sizeof(dtab)/sizeof(struct decode)); i++) {
-		/* while XML encoding strings found */
-                while ((found=strstr(string, dtab[i].enc_string)) != NULL) {
-			/* replace string with character */
-                        *found=dtab[i].c;
-			/* shift rest of string after character */
-                        strcpy(found+1, found+strlen(dtab[i].enc_string));
-                }
+    struct decode{
+            char c;
+            char *enc_string;
+    } dtab[] = {
+            { '>', "&gt;"  },
+            { '<', "&lt;"  },
+            { '&', "&amp;" },
+    };
+    int i;
+    char *found;
+
+    /* foreach XML decode pair */
+    for (i=0; i<(int)(sizeof(dtab)/sizeof(struct decode)); i++) {
+    /* while XML encoding strings found */
+        while ((found=strstr(string, dtab[i].enc_string)) != NULL) {
+            /* replace string with character */
+            *found=dtab[i].c;
+            /* shift rest of string after character */
+            strcpy(found+1, found+strlen(dtab[i].enc_string));
         }
-        return string;
+    }
+    return string;
 }

-- 
Debian packaging for mod gearman.



More information about the Pkg-nagios-changes mailing list