Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix /proc/mounts parsing & eliminate debug log noise #80

Merged
merged 1 commit into from
Sep 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/modules/zabbix_module_docker/zabbix_module_docker.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "module.h"
#include "sysinc.h"
#include "zbxjson.h"
#include "zbxregexp.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down Expand Up @@ -588,7 +589,7 @@ int zbx_docker_dir_detect()
""
}, **tdriver;
char path[512];
char *temp1, *temp2;
const char *mounts_regex = "^[^[:blank:]]+[[:blank:]]+(/[^[:blank:]]+/)[^[:blank:]]+[[:blank:]]+cgroup[[:blank:]]+.*$";
FILE *fp;
DIR *dir;

Expand All @@ -602,12 +603,11 @@ int zbx_docker_dir_detect()
{
if ((strstr(path, "cpuset cgroup")) != NULL)
{
temp1 = string_replace(path, "cgroup ", "");
temp2 = string_replace(temp1, strstr(temp1, " "), "");
free(temp1);
if (stat_dir != NULL) free(stat_dir);
stat_dir = string_replace(temp2, "cpuset", "");
free(temp2);
if (SUCCEED != zbx_regexp_sub(path, mounts_regex, "\\1", &stat_dir) || NULL == stat_dir)
{
zabbix_log(LOG_LEVEL_WARNING, "Cannot detect docker stat directory in /proc/mounts");
return SYSINFO_RET_FAIL;
}
zabbix_log(LOG_LEVEL_DEBUG, "Detected docker stat directory: %s", stat_dir);

pclose(fp);
Expand Down