summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 49b303b)
raw | patch | inline | side by side (parent: 49b303b)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 30 Oct 2008 18:15:41 +0000 (19:15 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 2 Nov 2008 13:22:56 +0000 (14:22 +0100) |
This option controls whether or not to recurse into subdirectories. It's
enabled by default, so backward-compatibility is retained.
enabled by default, so backward-compatibility is retained.
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 4963a0604750c0e342921d88caf69709d9e520be..ae4cde6b9bb48770fe0854927a2a7e21c2023e0b 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# Name "*.conf"
# MTime "-5m"
# Size "+10k"
+# Recursive true
# </Directory>
#</Plugin>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 624f74d3ef7a7426e7de79ff59b703acbdf46d12..d2656eea757efecb519ec3f5deaf7ec7f8833c92 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -646,6 +646,10 @@ description see above. Valid multipliers here are C<b> (byte), C<k> (kilobyte),
C<m> (megabyte), C<g> (gigabyte), C<t> (terabyte), and C<p> (petabyte). Please
note that there are 1000 bytes in a kilobyte, not 1024.
+=item B<Recursive> I<true>|I<false>
+
+Controls whether or not to recurse into subdirectories. Enabled by default.
+
=back
=head2 Plugin C<filter_pcre>
diff --git a/src/filecount.c b/src/filecount.c
index 55b3655ebaccd877b1a3c844839d1fbcd4e60e79..3e6e64658e51842c5a0ce6742c885cad0b5821b6 100644 (file)
--- a/src/filecount.c
+++ b/src/filecount.c
#include <dirent.h>
#include <fnmatch.h>
+#define FC_RECURSIVE 1
+
struct fc_directory_conf_s
{
char *path;
char *instance;
+ int options;
+
/* Data counters */
uint64_t files_num;
uint64_t files_size;
return (0);
} /* int fc_config_add_dir_size */
+static int fc_config_add_dir_recursive (fc_directory_conf_t *dir,
+ oconfig_item_t *ci)
+{
+ if ((ci->values_num != 1)
+ || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
+ {
+ WARNING ("filecount plugin: The `Recursive' config options needs exactly "
+ "one boolean argument.");
+ return (-1);
+ }
+
+ if (ci->values[0].value.boolean)
+ dir->options |= FC_RECURSIVE;
+ else
+ dir->options &= ~FC_RECURSIVE;
+
+ return (0);
+} /* int fc_config_add_dir_recursive */
+
static int fc_config_add_dir (oconfig_item_t *ci)
{
fc_directory_conf_t *dir;
fc_config_set_instance (dir, dir->path);
+ dir->options = FC_RECURSIVE;
+
dir->name = NULL;
dir->mtime = 0;
dir->size = 0;
status = fc_config_add_dir_mtime (dir, option);
else if (strcasecmp ("Size", option->key) == 0)
status = fc_config_add_dir_size (dir, option);
+ else if (strcasecmp ("Recursive", option->key) == 0)
+ status = fc_config_add_dir_recursive (dir, option);
else
{
WARNING ("filecount plugin: fc_config_add_dir: "
return (-1);
}
- if (S_ISDIR (statbuf.st_mode))
+ if (S_ISDIR (statbuf.st_mode) && (dir->options & FC_RECURSIVE))
{
status = walk_directory (abs_path, fc_read_dir_callback, dir);
return (status);