partitions are collected if a selection is made. If no selection is configured
at all, B<all> partitions are selected.
+=item B<LogOnce> B<false>|B<false>
+
+Only log stat() errors once.
+
=item B<ReportByDevice> B<true>|B<false>
Report using the device name rather than the mountpoint. i.e. with this I<false>,
#endif
static const char *config_keys[] = {
- "Device", "MountPoint", "FSType", "IgnoreSelected",
- "ReportByDevice", "ReportInodes", "ValuesAbsolute", "ValuesPercentage"};
+ "Device", "MountPoint", "FSType",
+ "IgnoreSelected", "ReportByDevice", "ReportInodes",
+ "ValuesAbsolute", "ValuesPercentage", "LogOnce"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
static ignorelist_t *il_device;
static ignorelist_t *il_mountpoint;
static ignorelist_t *il_fstype;
+static ignorelist_t *il_errors;
static bool by_device;
static bool report_inodes;
static bool values_absolute = true;
static bool values_percentage;
+static bool log_once;
static int df_init(void) {
if (il_device == NULL)
il_mountpoint = ignorelist_create(1);
if (il_fstype == NULL)
il_fstype = ignorelist_create(1);
+ if (il_errors == NULL)
+ il_errors = ignorelist_create(1);
return 0;
}
else
values_percentage = false;
+ return 0;
+ } else if (strcasecmp(key, "LogOnce") == 0) {
+ if (IS_TRUE(value))
+ log_once = true;
+ else
+ log_once = false;
+
return 0;
}
continue;
if (STATANYFS(mnt_ptr->dir, &statbuf) < 0) {
- ERROR(STATANYFS_STR "(%s) failed: %s", mnt_ptr->dir, STRERRNO);
+ if (log_once == false || ignorelist_match(il_errors, mnt_ptr->dir) == 0) {
+ if (log_once == true) {
+ ignorelist_add(il_errors, mnt_ptr->dir);
+ }
+ ERROR(STATANYFS_STR "(%s) failed: %s", mnt_ptr->dir, STRERRNO);
+ }
continue;
+ } else {
+ if (log_once == true) {
+ ignorelist_remove(il_errors, mnt_ptr->dir);
+ }
}
if (!statbuf.f_blocks)
return ignorelist_append_string(il, entry);
} /* int ignorelist_add (ignorelist_t *il, const char *entry) */
+/*
+ * remove entry from ignorelist_t
+ * return 0 for success
+ */
+int ignorelist_remove(ignorelist_t *il, const char *entry) {
+ /* if no entries, nothing to remove */
+ if ((il == NULL) || (il->head == NULL))
+ return (1);
+
+ if ((entry == NULL) || (strlen(entry) == 0))
+ return (1);
+
+ /* traverse list and check entries */
+ for (ignorelist_item_t *prev = NULL, *traverse = il->head; traverse != NULL;
+ prev = traverse, traverse = traverse->next) {
+ if (traverse->smatch != NULL && strcmp(traverse->smatch, entry) == 0) {
+ if (prev == NULL) {
+ il->head = traverse->next;
+ } else {
+ prev->next = traverse->next;
+ }
+ sfree(traverse->smatch);
+ traverse->smatch = NULL;
+ sfree(traverse);
+ return (0);
+ }
+ } /* for traverse */
+
+ return (1);
+} /* int ignorelist_remove (ignorelist_t *il, const char *entry) */
+
/*
* check list for entry
* return 1 for ignored entry