author | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Tue, 29 Jul 2014 09:33:46 +0000 (11:33 +0200) | ||
committer | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Tue, 29 Jul 2014 09:33:46 +0000 (11:33 +0200) |
PUTNOTIF: Add the ability to populate meta options
src/collectd-exec.pod | patch | blob | history | |
src/collectd-unixsock.pod | patch | blob | history | |
src/utils_cmd_putnotif.c | patch | blob | history | |
src/utils_parse_option.c | patch | blob | history |
diff --git a/src/collectd-exec.pod b/src/collectd-exec.pod
index 2c5963025a4269687307cf9e5c1f3d43cae70e47..41f967e90e4a1393830b1f8a710e3862f067fbe9 100644 (file)
--- a/src/collectd-exec.pod
+++ b/src/collectd-exec.pod
or B<type_instance> without B<type> doesn't make much sense and should be
avoided.
+=item B<type:key=>I<value>
+
+Sets user defined meta information. The B<type> key is a single character
+defining the type of the meta information.
+
+The current supported types are:
+
+=over 8
+
+=item B<s> A string passed as-is.
+
+=back
+
=back
=back
index 40626d3739db266d3f10043485cbf45fd1e7b27f..7cc6e704061647ac4724a1616190fa422e6d65f1 100644 (file)
or B<type_instance> without B<type> doesn't make much sense and should be
avoided.
-Please note that this is the same format as used in the B<exec plugin>, see
-L<collectd-exec(5)>.
+=item B<type:key=>I<value>
+
+Sets user defined meta information. The B<type> key is a single character
+defining the type of the meta information.
+
+The current supported types are:
+
+=over 8
+
+=item B<s> A string passed as-is.
=back
+=back
+
+Please note that this is the same format as used in the B<exec plugin>, see
+L<collectd-exec(5)>.
+
Example:
-> | PUTNOTIF type=temperature severity=warning time=1201094702 message=The roof is on fire!
<- | 0 Success
index d3cf3834dea42885ff6df3d4695b53bf38d64872..d14d6d1323871738f46e9d3da9421be89191c85f 100644 (file)
--- a/src/utils_cmd_putnotif.c
+++ b/src/utils_cmd_putnotif.c
DEBUG ("utils_cmd_putnotif: set_option (option = %s, value = %s);",
option, value);
+ /* Add a meta option in the form: <type>:<key> */
+ if (option[0] != '\0' && option[1] == ':') {
+ /* Refuse empty key */
+ if (option[2] == '\0')
+ return (1);
+
+ if (option[0] == 's')
+ return plugin_notification_meta_add_string (n, option + 2, value);
+ else
+ return (1);
+ }
+
if (strcasecmp ("severity", option) == 0)
return (set_option_severity (n, value));
else if (strcasecmp ("time", option) == 0)
index 820f14f58ef1da32cdfbe73c016c7fefdba4a0b0..8086d63fc0ee669419c943690c36474ccff926b6 100644 (file)
--- a/src/utils_parse_option.c
+++ b/src/utils_parse_option.c
/* Look for the equal sign */
buffer = key;
- while (isalnum ((int) *buffer) || *buffer == '_')
+ while (isalnum ((int) *buffer) || *buffer == '_' || *buffer == ':')
buffer++;
if ((*buffer != '=') || (buffer == key))
return (1);