Blob Blame History Raw
diff -Naurp pcp-3.11.8-orig/configure pcp-3.11.8/configure
--- pcp-3.11.8-orig/configure	2017-02-14 07:37:52.000000000 +1100
+++ pcp-3.11.8/configure	2017-03-01 17:09:48.238622561 +1100
@@ -960,6 +960,7 @@ with_books_brand
 with_papi
 with_perfevent
 with_pmdajson
+with_pmdanutcracker
 with_pmdasnmp
 with_manager
 with_webapi
@@ -1675,6 +1676,7 @@ Optional Packages:
                           installation prefix, or a pkgconfig module name.
   --with-perfevent        enable perfevent pmda (default is on)
   --with-pmdajson         enable JSON pmda (default is on)
+  --with-pmdanutcracker   enable nutcracker pmda (default is on)
   --with-pmdasnmp         enable SNMP pmda (default is on)
   --with-manager          enable daemon manager (default is on)
   --with-webapi           enable REST API daemon (default is on)
@@ -2797,6 +2799,15 @@ fi
 
 
 
+# Check whether --with-pmdanutcracker was given.
+if test "${with_pmdanutcracker+set}" = set; then :
+  withval=$with_pmdanutcracker; do_pmdanutcracker=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdanutcracker=$withval"
+else
+  do_pmdanutcracker=check
+fi
+
+
+
 # Check whether --with-pmdasnmp was given.
 if test "${with_pmdasnmp+set}" = set; then :
   withval=$with_pmdasnmp; do_pmdasnmp=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdasnmp=$withval"
@@ -7560,15 +7571,22 @@ $as_echo "no" >&6; }; fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the nutcracker PMDA should be included" >&5
 $as_echo_n "checking if the nutcracker PMDA should be included... " >&6; }
 pmda_nutcracker=false
-if test "$have_perl" = true
-then
-        if $pcp_perl_prog -e "use YAML::XS" >/dev/null 2>&1
+if test "x$do_pmdanutcracker" = "xyes"; then :
+  pmda_nutcracker=true
+fi
+if test "x$do_pmdanutcracker" = "xcheck"; then :
+
+        if test "$have_perl" = true
     then
-	if $pcp_perl_prog -e "use JSON" >/dev/null 2>&1
+	if $pcp_perl_prog -e "use YAML::XS" >/dev/null 2>&1
 	then
-	    pmda_nutcracker=true
+	    if $pcp_perl_prog -e "use JSON" >/dev/null 2>&1
+	    then
+		pmda_nutcracker=true
+	    fi
 	fi
     fi
+
 fi
 PMDA_NUTCRACKER=$pmda_nutcracker
 
diff -Naurp pcp-3.11.8-orig/configure.ac pcp-3.11.8/configure.ac
--- pcp-3.11.8-orig/configure.ac	2017-02-14 07:37:52.000000000 +1100
+++ pcp-3.11.8/configure.ac	2017-03-01 17:09:35.495740047 +1100
@@ -148,6 +148,12 @@ AC_ARG_WITH([pmdajson],
     [do_pmdajson=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdajson=$withval"],
     [do_pmdajson=check])
 
+AC_ARG_WITH([pmdanutcracker],
+    [AC_HELP_STRING([--with-pmdanutcracker],
+		   [enable nutcracker pmda (default is on)])],
+    [do_pmdanutcracker=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdanutcracker=$withval"],
+    [do_pmdanutcracker=check])
+
 AC_ARG_WITH([pmdasnmp],
     [AC_HELP_STRING([--with-pmdasnmp],
 		   [enable SNMP pmda (default is on)])],
@@ -1060,17 +1066,20 @@ if $pmda_bind2; then AC_MSG_RESULT(yes);
 
 AC_MSG_CHECKING([if the nutcracker PMDA should be included])
 pmda_nutcracker=false
-if test "$have_perl" = true
-then
-    dnl rpm build for nutcracker PMDA needs Perl JSON YAML::XS
-    if $pcp_perl_prog -e "use YAML::XS" >/dev/null 2>&1
+AS_IF([test "x$do_pmdanutcracker" = "xyes"], [pmda_nutcracker=true])
+AS_IF([test "x$do_pmdanutcracker" = "xcheck"], [
+    dnl build for nutcracker PMDA needs perl JSON & YAML::XS modules
+    if test "$have_perl" = true
     then
-	if $pcp_perl_prog -e "use JSON" >/dev/null 2>&1
+	if $pcp_perl_prog -e "use YAML::XS" >/dev/null 2>&1
 	then
-	    pmda_nutcracker=true
+	    if $pcp_perl_prog -e "use JSON" >/dev/null 2>&1
+	    then
+		pmda_nutcracker=true
+	    fi
 	fi
     fi
-fi
+])
 AC_SUBST(PMDA_NUTCRACKER, $pmda_nutcracker)
 if $pmda_nutcracker; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
 
diff -Naurp pcp-3.11.8-orig/src/libpcp/src/interp.c pcp-3.11.8/src/libpcp/src/interp.c
--- pcp-3.11.8-orig/src/libpcp/src/interp.c	2017-02-15 10:57:23.000000000 +1100
+++ pcp-3.11.8/src/libpcp/src/interp.c	2017-03-01 17:09:35.495740047 +1100
@@ -699,7 +699,7 @@ __pmLogFetchInterp(__pmContext *ctxp, in
     int		i;
     int		j;
     int		k;
-    int		sts, sts1;
+    int		sts;
     double	t_req;
     double	t_this;
     pmResult	*rp;
@@ -810,6 +810,8 @@ __pmLogFetchInterp(__pmContext *ctxp, in
 		/* enumerate all the instances from the domain underneath */
 		int		*instlist = NULL;
 		char		**namelist = NULL;
+		int		hsts = 0;
+
 		if (pcp->desc.indom == PM_INDOM_NULL) {
 		    sts = 1;
 		    if ((instlist = (int *)malloc(sizeof(int))) == NULL) {
@@ -821,10 +823,10 @@ __pmLogFetchInterp(__pmContext *ctxp, in
 		    sts = pmGetInDomArchive(pcp->desc.indom, &instlist, &namelist);
 		    if (sts > 0) {
 			/* Pre allocate enough space for the instance domain. */
-			sts1 = __pmHashPreAlloc(sts, &pcp->hc);
-			if (sts1 < 0) {
+			hsts = __pmHashPreAlloc(sts, &pcp->hc);
+			if (hsts < 0) {
 			    free(pcp);
-			    return sts1;
+			    goto done_icp;
 			}
 		    }
 		}
@@ -839,16 +841,19 @@ __pmLogFetchInterp(__pmContext *ctxp, in
 		    SET_UNDEFINED(icp->s_prior);
 		    SET_UNDEFINED(icp->s_next);
 		    icp->v_prior.pval = icp->v_next.pval = NULL;
-		    sts1 = __pmHashAdd((int)instlist[i], (void *)icp, &pcp->hc);
-		    if (sts1 < 0) {
+		    hsts = __pmHashAdd((int)instlist[i], (void *)icp, &pcp->hc);
+		    if (hsts < 0) {
 			free(icp);
-			return sts1;
+			goto done_icp;
 		    }
 		}
+	    done_icp:
 		if (instlist != NULL)
 		    free(instlist);
 		if (namelist != NULL)
 		    free(namelist);
+		if (hsts < 0)
+		    return hsts; /* hash allocation error */
 	    }
 	}
 	else
diff -Naurp pcp-3.11.8-orig/src/libpcp_web/src/http_client.c pcp-3.11.8/src/libpcp_web/src/http_client.c
--- pcp-3.11.8-orig/src/libpcp_web/src/http_client.c	2017-01-16 17:02:10.000000000 +1100
+++ pcp-3.11.8/src/libpcp_web/src/http_client.c	2017-03-01 17:09:02.208046949 +1100
@@ -283,7 +283,7 @@ http_client_connect(http_client *cp)
 	snprintf(path, sizeof(path), "/%.*s/%.*s",
 		up->field_data[UF_HOST].len, url + up->field_data[UF_HOST].off,
 		up->field_data[UF_PATH].len, url + up->field_data[UF_PATH].off);
-	path[length] = '\0';
+	path[length - 1] = '\0';
 	//	__pmNotifyErr(LOG_DEBUG, "host: %.*s\n", up->field_data[UF_HOST].len, url + up->field_data[UF_HOST].off);
 	//	__pmNotifyErr(LOG_DEBUG, "UF_path: %.*s\n", up->field_data[UF_PATH].len, url + up->field_data[UF_PATH].off);
 	//	__pmNotifyErr(LOG_DEBUG, "path: %s\n", path);
@@ -448,7 +448,7 @@ reset_url_location(const char *tourl, si
 	if (*suffix != '/')
 	    *str++ = '/';
 	strncat(str, suffix, length);
-	url[size] = '\0';
+	url[size - 1] = '\0';
 	http_parser_parse_url(url, size, 0, fromp);
 
 	if (pmDebug & DBG_TRACE_HTTP)
@@ -569,7 +569,7 @@ http_should_client_redirect(http_client
 static int
 http_client_response(http_client *cp)
 {
-    size_t		bytes, total;
+    size_t		bytes;
     char		buffer[BUFSIZ];
     int			sts;
     static int		setup;
@@ -599,7 +599,6 @@ http_client_response(http_client *cp)
 	    return sts ? sts : -EAGAIN;
 	}
 	bytes = http_parser_execute(&cp->parser, &settings, buffer, sts);
-	total += bytes;
 
     } while (bytes && !(cp->flags & F_MESSAGE_END));
 
diff -Naurp pcp-3.11.8-orig/src/libpcp_web/src/json_helpers.c pcp-3.11.8/src/libpcp_web/src/json_helpers.c
--- pcp-3.11.8-orig/src/libpcp_web/src/json_helpers.c	2017-01-17 07:34:15.000000000 +1100
+++ pcp-3.11.8/src/libpcp_web/src/json_helpers.c	2017-03-01 17:08:57.532090060 +1100
@@ -354,7 +354,8 @@ json_pointer_to_index(const char *json,
 	    pointer_final[j++] = strdup(json_pointer);
 	} else {
 	    pointer_final[j++] = strdup(pointer_part);
-	    while (pointer_part && j < sizeof(pointer_final)) {
+	    while (pointer_part &&
+		   j < sizeof(pointer_final)/sizeof(*pointer_final)) {
 		if ((pointer_part = strtok(NULL, "/")) != NULL)
 		    pointer_final[j++] = strdup(pointer_part);
 	    }
diff -Naurp pcp-3.11.8-orig/src/pmdas/docker/docker.c pcp-3.11.8/src/pmdas/docker/docker.c
--- pcp-3.11.8-orig/src/pmdas/docker/docker.c	2017-01-19 08:22:49.000000000 +1100
+++ pcp-3.11.8/src/pmdas/docker/docker.c	2017-03-01 17:08:57.532090060 +1100
@@ -69,6 +69,7 @@ static json_metric_desc version_metrics[
     { "GitCommit", 0, 1, {0}, ""},
     { "Arch", 0, 1, {0}, ""},
     { "ApiVersion", 0, 1, {0}, ""},
+    { "BuildVersion", 0, 1, {0}, ""}
 };
 #define version_metrics_size	ARRAY_SIZE(version_metrics)
 
diff -Naurp pcp-3.11.8-orig/src/pmdas/linux/ipc.c pcp-3.11.8/src/pmdas/linux/ipc.c
--- pcp-3.11.8-orig/src/pmdas/linux/ipc.c	2017-01-25 18:00:10.000000000 +1100
+++ pcp-3.11.8/src/pmdas/linux/ipc.c	2017-03-01 17:09:00.694060908 +1100
@@ -197,9 +197,6 @@ refresh_shm_stat(pmInDom shm_indom)
 	    if (sts < 0) {
 		fprintf(stderr, "Warning: %s: pmdaCacheStore(%s, %s): %s\n",
 			__FUNCTION__, shmid, shm_stat->shm_key, pmErrStr(sts));
-		free(shm_stat->shm_key);
-		free(shm_stat->shm_owner);
-		free(shm_stat->shm_status);
 		free(shm_stat);
 	    }	
 	}
@@ -266,8 +263,6 @@ refresh_msg_que(pmInDom msg_indom)
 	    if (sts < 0) {
 		fprintf(stderr, "Warning: %s: pmdaCacheStore(%s, %s): %s\n",
 			__FUNCTION__, msgid, msg_que->msg_key, pmErrStr(sts));
-		free(msg_que->msg_key);
-		free(msg_que->msg_owner);
 		free(msg_que);
 	    }	
 	}
@@ -336,8 +331,6 @@ refresh_sem_array(pmInDom sem_indom)
 	    if (sts < 0) {
 		fprintf(stderr, "Warning: %s: pmdaCacheStore(%s, %s): %s\n",
 			__FUNCTION__, semid, sem_arr->sem_key, pmErrStr(sts));
-		free(sem_arr->sem_key);
-		free(sem_arr->sem_owner);
 		free(sem_arr);
 	    }
 	}
diff -Naurp pcp-3.11.8-orig/src/pmdas/linux/proc_buddyinfo.c pcp-3.11.8/src/pmdas/linux/proc_buddyinfo.c
--- pcp-3.11.8-orig/src/pmdas/linux/proc_buddyinfo.c	2017-02-14 16:41:34.000000000 +1100
+++ pcp-3.11.8/src/pmdas/linux/proc_buddyinfo.c	2017-03-01 17:09:03.206037748 +1100
@@ -148,9 +148,13 @@ refresh_proc_buddyinfo(proc_buddyinfo_t
             proc_buddyinfo->buddys = (buddyinfo_t *)realloc(proc_buddyinfo->buddys, proc_buddyinfo->nbuddys * sizeof(buddyinfo_t));
             for (j=0; j < MAX_ORDER; j++) {
                 proc_buddyinfo->buddys[i+j].id = next_id++;
-                strcpy(proc_buddyinfo->buddys[i+j].node_name, node_name);
-                strcpy(proc_buddyinfo->buddys[i+j].zone_name, zone_name);
-                sprintf(proc_buddyinfo->buddys[i+j].id_name, "%s::order%u::%s", zone_name, j, node_name);
+                strncpy(proc_buddyinfo->buddys[i+j].node_name, node_name,
+			sizeof(proc_buddyinfo->buddys[i+j].node_name) - 1);
+                strncpy(proc_buddyinfo->buddys[i+j].zone_name, zone_name,
+			sizeof(proc_buddyinfo->buddys[i+j].zone_name) - 1);
+                snprintf(proc_buddyinfo->buddys[i+j].id_name,
+			 sizeof(proc_buddyinfo->buddys[i+j].id_name),
+			 "%s::order%u::%s", zone_name, j, node_name);
             }
         }
         /* update data */
diff -Naurp pcp-3.11.8-orig/src/pmdas/linux/sysfs_tapestats.c pcp-3.11.8/src/pmdas/linux/sysfs_tapestats.c
--- pcp-3.11.8-orig/src/pmdas/linux/sysfs_tapestats.c	2017-02-13 15:43:35.000000000 +1100
+++ pcp-3.11.8/src/pmdas/linux/sysfs_tapestats.c	2017-03-01 17:09:03.206037748 +1100
@@ -81,7 +81,7 @@ refresh_sysfs_tapestats(pmInDom tape_ind
 		return sts;
 	    }
 	    memset(device, 0, sizeof(tapedev_t));
-	    strncpy(device->devname, sysdev, sizeof(device->devname));
+	    strncpy(device->devname, sysdev, sizeof(device->devname) - 1);
 #if PCP_DEBUG
 	    if (pmDebug & DBG_TRACE_LIBPMDA)
 		fprintf(stderr, "refresh_sysfs_tapestats: added new tape device \"%s\"\n", sysdev);
diff -Naurp pcp-3.11.8-orig/src/pmdas/mmv/src/mmv.c pcp-3.11.8/src/pmdas/mmv/src/mmv.c
--- pcp-3.11.8-orig/src/pmdas/mmv/src/mmv.c	2017-01-27 09:16:52.000000000 +1100
+++ pcp-3.11.8/src/pmdas/mmv/src/mmv.c	2017-03-01 17:09:04.612024785 +1100
@@ -774,13 +774,11 @@ mmv_lookup_item1(int item, unsigned int
     mmv_disk_value_t *v = s->values;
     int mi, vi, sts = PM_ERR_PMID;
 
-    m1 = s->metrics1;
     for (mi = 0; mi < s->mcnt1; mi++) {
 	if (m1[mi].item != item)
 	    continue;
 
 	sts = PM_ERR_INST;
-	v = s->values;
 	for (vi = 0; vi < s->vcnt; vi++) {
 	    mmv_disk_metric_t *mt = (mmv_disk_metric_t *)
 			((char *)s->addr + v[vi].metric);
diff -Naurp pcp-3.11.8-orig/src/pmdas/nutcracker/GNUmakefile pcp-3.11.8/src/pmdas/nutcracker/GNUmakefile
--- pcp-3.11.8-orig/src/pmdas/nutcracker/GNUmakefile	2017-01-25 15:58:00.000000000 +1100
+++ pcp-3.11.8/src/pmdas/nutcracker/GNUmakefile	2017-03-01 17:09:35.495740047 +1100
@@ -26,20 +26,23 @@ MAN_SECTION = 1
 MAN_PAGES = pmda$(IAM).$(MAN_SECTION)
 MAN_DEST = $(PCP_MAN_DIR)/man$(MAN_SECTION)
 
-default: check_domain
+default_pcp default:	build-me $(MAN_PAGES)
 
 include $(BUILDRULES)
 
-install: default
+ifeq "$(PMDA_NUTCRACKER)" "true"
+build-me: check_domain
+install_pcp install: default
 	$(INSTALL) -m 755 -d $(PMDADIR)
 	$(INSTALL) -m 755 Install Remove $(PMDADIR)
 	$(INSTALL) -m 644 pmda$(IAM).pl $(PMDADIR)/pmda$(IAM).pl
 	$(INSTALL) -m 644 nutcracker.conf $(PMDADIR)/nutcracker.conf
 	@$(INSTALL_MAN)
-
-default_pcp : default
-
-install_pcp : install
+else
+build-me:
+install_pcp install: default
+	@$(INSTALL_MAN)
+endif
 
 check_domain:	../../pmns/stdpmid
 	$(DOMAIN_PERLRULE)