summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: db42a25)
raw | patch | inline | side by side (parent: db42a25)
author | alex2grad <alex2grad@users.noreply.github.com> | |
Wed, 18 Oct 2017 06:42:21 +0000 (02:42 -0400) | ||
committer | Florian Forster <ff@octo.it> | |
Wed, 18 Oct 2017 06:42:21 +0000 (08:42 +0200) |
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/filecount.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index ac0aa2d26f5d6f2bc2bdaaf85edb6914a30f7da6..c982e55499e52d0b0699819b59a2663093ea7427 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# Size "+10k"
# Recursive true
# IncludeHidden false
+# RegularOnly true
# #FilesSizeType "bytes"
# #FilesCountType "files"
# #TypeInstance "instance"
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 3739fe779733a09addcf97989955e23ceea9db1b..c92e3fdeb2a3bfd565d716cfd8ffd28c6d667123 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -2834,6 +2834,11 @@ Controls whether or not to include "hidden" files and directories in the count.
"Hidden" files and directories are those, whose name begins with a dot.
Defaults to I<false>, i.e. by default hidden files and directories are ignored.
+=item B<RegularOnly> I<true>|I<false>
+
+Controls whether or not to include only regular files in the count.
+Defaults to I<true>, i.e. by default non regular files are ignored.
+
=item B<FilesSizeType> I<Type>
Sets the type used to dispatch files combined size. Empty value ("") disables
diff --git a/src/filecount.c b/src/filecount.c
index 5b812b88ed3272f6039651b9b749fff294cb57b3..7842aa610c786719f61762b11ca55ad6d9565941 100644 (file)
--- a/src/filecount.c
+++ b/src/filecount.c
#define FC_RECURSIVE 1
#define FC_HIDDEN 2
+#define FC_REGULAR 4
struct fc_directory_conf_s {
char *path;
return -1;
}
- dir->options = FC_RECURSIVE;
+ dir->options = FC_RECURSIVE | FC_REGULAR;
dir->name = NULL;
dir->plugin_name = strdup("filecount");
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)
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;
}
return 0;
}
+ if (!S_ISREG(statbuf.st_mode)) {
+ dir->files_num++;
+ return 0;
+ }
+
if (dir->mtime != 0) {
time_t mtime = dir->now;