Permalink
Browse files

pmdaroot: add check for config.v2.json docker files

docker 1.10+ now uses a different config file.  Add a check and support
that new file.  Add example to qa and update appropriate output
  • Loading branch information...
1 parent 35123e0 commit a1e2cae3a4d05fab522fef2207778be52ac76054 @lberk lberk committed Mar 29, 2016
Showing with 57 additions and 1 deletion.
  1. +30 −0 qa/761.out
  2. BIN qa/linux/containers-docker-1.10.3-root-004.tgz
  3. +27 −1 src/pmdas/root/docker.c
View
@@ -18,6 +18,36 @@ containers.cgroup
No value(s) available!
containers.engine
+ inst [N or "e137109040f53c67031325695ae541a3bf383c7b015af0fd718a412cc0f32da1"] value "docker"
+ inst [N or "e68c65472ffef4c1691c6c5d71327ce816231b2338753973550e7f5eda995fc9"] value "docker"
+
+containers.name
+ inst [N or "e137109040f53c67031325695ae541a3bf383c7b015af0fd718a412cc0f32da1"] value "tender_galileo"
+ inst [N or "e68c65472ffef4c1691c6c5d71327ce816231b2338753973550e7f5eda995fc9"] value "happy_hoover"
+
+containers.pid
+No value(s) available!
+
+containers.state.paused
+ inst [N or "e137109040f53c67031325695ae541a3bf383c7b015af0fd718a412cc0f32da1"] value 0
+ inst [N or "e68c65472ffef4c1691c6c5d71327ce816231b2338753973550e7f5eda995fc9"] value 0
+
+containers.state.restarting
+ inst [N or "e137109040f53c67031325695ae541a3bf383c7b015af0fd718a412cc0f32da1"] value 0
+ inst [N or "e68c65472ffef4c1691c6c5d71327ce816231b2338753973550e7f5eda995fc9"] value 0
+
+containers.state.running
+ inst [N or "e137109040f53c67031325695ae541a3bf383c7b015af0fd718a412cc0f32da1"] value 0
+ inst [N or "e68c65472ffef4c1691c6c5d71327ce816231b2338753973550e7f5eda995fc9"] value 0
+
+== done
+
+== Checking values for active containers
+
+containers.cgroup
+No value(s) available!
+
+containers.engine
inst [N or "781d21edbb014736f7fb4e1412ee55c5564c91ce0647be4879a7c547e6ebc1af"] value "docker"
inst [N or "d4999f7c6d639c837c03634ab2bc51daa5b35fce1bf1e9f56ee9f8342fafa2ec"] value "docker"
Binary file not shown.
View
@@ -351,6 +351,29 @@ docker_values_parse(FILE *fp, const char *name, container_t *values)
return sts;
}
+/* docker decided to not only change the config file json pointer layout, but
+ * also the filename in which the config resides. Check which version is being used.
+ */
+int determine_docker_version(container_engine_t *dp, const char *name, char *buf, size_t bufsize)
+{
+ FILE *fp;
+
+ /* we go with version two first, because v1 config files may not
+ * always be cleaned up after the upgrade to v2.
+ */
+ snprintf(buf, bufsize, "%s/%s/config.v2.json", dp->path, name);
+ if ((fp = fopen(buf, "r")) != NULL) {
+ fclose(fp);
+ return 2;
+ }
+ snprintf(buf, bufsize, "%s/%s/config.json", dp->path, name);
+ if ((fp = fopen(buf, "r")) != NULL) {
+ fclose(fp);
+ return 1;
+ }
+ return -oserror();
+}
+
/*
* Extract critical information (PID1, state) for a named container.
* Name here is the unique identifier we've chosen to use for Docker
@@ -364,7 +387,10 @@ docker_value_refresh(container_engine_t *dp,
FILE *fp;
char path[MAXPATHLEN];
- snprintf(path, sizeof(path), "%s/%s/config.json", dp->path, name);
+ sts = determine_docker_version(dp, name, path, sizeof(path));
+ if (sts < 0)
+ return sts;
+
if (!docker_values_changed(path, values))
return 0;
if (pmDebug & DBG_TRACE_ATTR)

0 comments on commit a1e2cae

Please sign in to comment.