summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 98229d2)
raw | patch | inline | side by side (parent: 98229d2)
author | Florian Forster <sifnfors@informatik.stud.uni-erlangen.de> | |
Mon, 24 Nov 2008 11:05:24 +0000 (12:05 +0100) | ||
committer | Florian Forster <sifnfors@informatik.stud.uni-erlangen.de> | |
Mon, 24 Nov 2008 11:05:24 +0000 (12:05 +0100) |
The `stop' target now aborts all processing of the value completely, `return'
only stops the current chain and continues processing the parent chain.
The collectd.conf(5) manual page has been updated and the `FC_ACTION_*' defines
have been renamed to `FC_TARGET_*'.
only stops the current chain and continues processing the parent chain.
The collectd.conf(5) manual page has been updated and the `FC_ACTION_*' defines
have been renamed to `FC_TARGET_*'.
src/collectd.conf.pod | patch | blob | history | |
src/filter_chain.c | patch | blob | history | |
src/filter_chain.h | patch | blob | history | |
src/target_set.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index a1846003ae8a91e8bd741b6ed6edbef6bfd33e9c..87e86d46a928afd02e1ccd89c709d0d1315b4458 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=over 4
+=item B<return>
+
+Signals the "return" condition. This causes the current chain to stop
+processing the value and returns control to the calling chain. The calling
+chain will continue processing targets and rules just after the B<jump> target
+(see below). This is very similar to the B<RETURN> target of iptables, see
+L<iptables(8)>.
+
+This target does not have any options.
+
+Example:
+
+ Target "return"
+
=item B<stop>
-Does nothing except returning with the stop condition, causing processing of
-the current chain to be aborted.
+Signals the "stop" condition, causing processing of the value to be aborted
+immediately. This is similar to the B<DROP> target of iptables, see
+L<iptables(8)>.
+
+This target does not have any options.
+
+Example:
+
+ Target "stop"
=item B<write>
Name of the write plugin to which the data should be sent. This option may be
given multiple times to send the data to more than one write plugin.
-Example:
-
- Target "stop"
-
=back
If no plugin is explicitly specified, the values will be sent to all available
Starts processing the rules of another chain. If the end of that chain is
reached, or a stop condition is encountered, processing will continue right
after the B<jump> target, i.E<nbsp>e. with the next target or the next rule.
+This is similar to the B<-j> command line option of iptables, see
+L<iptables(8)>.
Available options:
=back
-=head2 Backwards compatibility
-
-If you use collectd with an old configuration, i.E<nbsp>e. one without a
-B<Chain> block, it will behave as it used to. This is equivalent to the
-following configuration:
-
- <Chain "main">
- Target "write"
- </Chain>
-
-If you specify a B<Chain> block anywhere, the B<write> target will not be added
-anywhere and you will have to make sure that it is called where appropriate. We
-suggest to add the above snippet as default target to your main chain.
-
-TODO: Notifications will be implemented using chains, too. Describe that here!
-
=head2 Available matches
=over 4
=back
+=head2 Backwards compatibility
+
+If you use collectd with an old configuration, i.E<nbsp>e. one without a
+B<Chain> block, it will behave as it used to. This is equivalent to the
+following configuration:
+
+ <Chain "main">
+ Target "write"
+ </Chain>
+
+If you specify a B<Chain> block anywhere, the B<write> target will not be added
+anywhere and you will have to make sure that it is called where appropriate. We
+suggest to add the above snippet as default target to your main chain.
+
+TODO: Notifications will be implemented using chains, too. Describe that here!
+
=head2 Examples
Ignore all values, where the hostname does not contain a dot, i.E<nbsp>e. can't
L<collectd-unixsock(5)>,
L<types.db(5)>,
L<hddtemp(8)>,
+L<iptables(8)>,
L<kstat(3KSTAT)>,
L<mbmon(1)>,
L<pcre(3)>,
diff --git a/src/filter_chain.c b/src/filter_chain.c
index 109a32a03c55e13b9f903abdd0abb97cb5113b25..01cd224cde5d430bb4fcf9fe7b949d32ed1cdbea 100644 (file)
--- a/src/filter_chain.c
+++ b/src/filter_chain.c
DEBUG ("fc_process_chain (chain = %s);", chain->name);
- status = FC_ACTION_CONTINUE;
-
+ status = FC_TARGET_CONTINUE;
for (rule = chain->rules; rule != NULL; rule = rule->next)
{
fc_match_t *match;
/* for-loop has been aborted: Either error or no match. */
if (match != NULL)
+ {
+ status = FC_TARGET_CONTINUE;
continue;
+ }
if (rule->name[0] != 0)
{
WARNING ("fc_process_chain (%s): A target failed.", chain->name);
continue;
}
- else if (status == FC_ACTION_CONTINUE)
+ else if (status == FC_TARGET_CONTINUE)
continue;
- else if (status == FC_ACTION_STOP)
+ else if (status == FC_TARGET_STOP)
+ break;
+ else if (status == FC_TARGET_RETURN)
break;
else
{
}
}
- if (status == FC_ACTION_STOP)
+ if ((status == FC_TARGET_STOP)
+ || (status == FC_TARGET_RETURN))
{
if (rule->name[0] != 0)
{
DEBUG ("fc_process_chain (%s): Rule `%s' signaled "
- "the stop condition.",
- chain->name, rule->name);
+ "the %s condition.",
+ chain->name, rule->name,
+ (status == FC_TARGET_STOP) ? "stop" : "return");
}
break;
}
+ else
+ {
+ status = FC_TARGET_CONTINUE;
+ }
} /* for (rule) */
- /* for-loop has been aborted: A target returned `FC_ACTION_STOP' */
+ if (status == FC_TARGET_STOP)
+ return (FC_TARGET_STOP);
+ else if (status == FC_TARGET_RETURN)
+ return (FC_TARGET_CONTINUE);
+
+ /* for-loop has been aborted: A target returned `FC_TARGET_STOP' */
if (rule != NULL)
- return (0);
+ return (FC_TARGET_CONTINUE);
DEBUG ("fc_process_chain (%s): Executing the default targets.",
chain->name);
+ status = FC_TARGET_CONTINUE;
for (target = chain->targets; target != NULL; target = target->next)
{
/* If we get here, all matches have matched the value. Execute the
WARNING ("fc_process_chain (%s): The default target failed.",
chain->name);
}
- else if (status == FC_ACTION_CONTINUE)
+ else if (status == FC_TARGET_CONTINUE)
continue;
- else if (status == FC_ACTION_STOP)
+ else if (status == FC_TARGET_STOP)
+ break;
+ else if (status == FC_TARGET_RETURN)
break;
else
{
}
}
- if (target != NULL)
+ if ((status == FC_TARGET_STOP)
+ || (status == FC_TARGET_RETURN))
{
+ assert (target != NULL);
DEBUG ("fc_process_chain (%s): Default target `%s' signaled "
- "the stop condition.",
- chain->name, target->name);
+ "the %s condition.",
+ chain->name, target->name,
+ (status == FC_TARGET_STOP) ? "stop" : "return");
+ if (status == FC_TARGET_STOP)
+ return (FC_TARGET_STOP);
+ else
+ return (FC_TARGET_CONTINUE);
}
- return (0);
+ DEBUG ("fc_process_chain (%s): Signaling `continue' at end of chain.",
+ chain->name);
+
+ return (FC_TARGET_CONTINUE);
} /* }}} int fc_process_chain */
/*
status = fc_process_chain (ds, vl, chain);
if (status < 0)
return (status);
-
- return (FC_ACTION_CONTINUE);
+ else if (status == FC_TARGET_STOP)
+ return (FC_TARGET_STOP);
+ else
+ return (FC_TARGET_CONTINUE);
} /* }}} int fc_bit_jump_invoke */
static int fc_bit_stop_invoke (const data_set_t *ds, /* {{{ */
value_list_t *vl, notification_meta_t **meta, void **user_data)
{
- return (FC_ACTION_STOP);
+ return (FC_TARGET_STOP);
} /* }}} int fc_bit_stop_invoke */
+static int fc_bit_return_invoke (const data_set_t *ds, /* {{{ */
+ value_list_t *vl, notification_meta_t **meta, void **user_data)
+{
+ return (FC_TARGET_RETURN);
+} /* }}} int fc_bit_return_invoke */
+
static int fc_bit_write_create (const oconfig_item_t *ci, /* {{{ */
void **user_data)
{
} /* for (i = 0; plugin_list[i] != NULL; i++) */
}
- return (FC_ACTION_CONTINUE);
+ return (FC_TARGET_CONTINUE);
} /* }}} int fc_bit_write_invoke */
static int fc_init_once (void) /* {{{ */
tproc.invoke = fc_bit_stop_invoke;
fc_register_target ("stop", tproc);
+ memset (&tproc, 0, sizeof (tproc));
+ tproc.create = NULL;
+ tproc.destroy = NULL;
+ tproc.invoke = fc_bit_return_invoke;
+ fc_register_target ("return", tproc);
+
memset (&tproc, 0, sizeof (tproc));
tproc.create = fc_bit_write_create;
tproc.destroy = fc_bit_write_destroy;
diff --git a/src/filter_chain.h b/src/filter_chain.h
index f2e22af2b36e8e0953734ccb17075191302c3782..2fd78d97038c54d79b5ae77b23a0f166ba4c2dbe 100644 (file)
--- a/src/filter_chain.h
+++ b/src/filter_chain.h
#define FC_MATCH_NO_MATCH 0
#define FC_MATCH_MATCHES 1
-#define FC_ACTION_CONTINUE 0
-#define FC_ACTION_STOP 1
+#define FC_TARGET_CONTINUE 0
+#define FC_TARGET_STOP 1
+#define FC_TARGET_RETURN 2
/*
* Match functions
diff --git a/src/target_set.c b/src/target_set.c
index e328da31a5327bd5541b2abcca1954744d38ca1f..70b0fdfc8c50164f294223336f06e40fa4c6e51f 100644 (file)
--- a/src/target_set.c
+++ b/src/target_set.c
/* SET_FIELD (type); */
SET_FIELD (type_instance);
- return (0);
+ return (FC_TARGET_CONTINUE);
} /* }}} int ts_invoke */
void module_register (void)