X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Ffilecount.c;h=7842aa610c786719f61762b11ca55ad6d9565941;hp=5b812b88ed3272f6039651b9b749fff294cb57b3;hb=7111bb6df7628edce3a8e538b386fbe27633a191;hpb=d5792bedfe62671f9f6f04b75506e39eaffde8c0 diff --git a/src/filecount.c b/src/filecount.c index 5b812b88..7842aa61 100644 --- a/src/filecount.c +++ b/src/filecount.c @@ -34,6 +34,7 @@ #define FC_RECURSIVE 1 #define FC_HIDDEN 2 +#define FC_REGULAR 4 struct fc_directory_conf_s { char *path; @@ -340,7 +341,7 @@ static int fc_config_add_dir(oconfig_item_t *ci) { return -1; } - dir->options = FC_RECURSIVE; + dir->options = FC_RECURSIVE | FC_REGULAR; dir->name = NULL; dir->plugin_name = strdup("filecount"); @@ -377,6 +378,8 @@ static int fc_config_add_dir(oconfig_item_t *ci) { status = fc_config_add_dir_option(dir, option, FC_RECURSIVE); else if (strcasecmp("IncludeHidden", option->key) == 0) status = fc_config_add_dir_option(dir, option, FC_HIDDEN); + else if (strcasecmp("RegularOnly", option->key) == 0) + status = fc_config_add_dir_option(dir, option, FC_REGULAR); else if (strcasecmp("FilesSizeType", option->key) == 0) status = cf_util_get_string(option, &dir->files_size_type); else if (strcasecmp("FilesCountType", option->key) == 0) @@ -488,7 +491,7 @@ static int fc_read_dir_callback(const char *dirname, const char *filename, abs_path, fc_read_dir_callback, dir, /* include hidden = */ (dir->options & FC_HIDDEN) ? 1 : 0); return status; - } else if (!S_ISREG(statbuf.st_mode)) { + } else if ((dir->options & FC_REGULAR) && !S_ISREG(statbuf.st_mode)) { return 0; } @@ -498,6 +501,11 @@ static int fc_read_dir_callback(const char *dirname, const char *filename, return 0; } + if (!S_ISREG(statbuf.st_mode)) { + dir->files_num++; + return 0; + } + if (dir->mtime != 0) { time_t mtime = dir->now;