X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_cmd_putnotif.c;h=530d153ea91437b0375b20eed65e85f426d5a5e8;hb=ca316d91e178412604ea8462dc60a8bc32cbfc87;hp=cee5327f2c148a46251cc6ef1fce29e739092430;hpb=633c3966f770e4d46651a2fe219a18d8a9907a9f;p=collectd.git diff --git a/src/utils_cmd_putnotif.c b/src/utils_cmd_putnotif.c index cee5327f..530d153e 100644 --- a/src/utils_cmd_putnotif.c +++ b/src/utils_cmd_putnotif.c @@ -31,12 +31,15 @@ #include "utils_parse_option.h" #define print_to_socket(fh, ...) \ - if (fprintf (fh, __VA_ARGS__) < 0) { \ - char errbuf[1024]; \ - WARNING ("handle_putnotif: failed to write to socket #%i: %s", \ - fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \ - return -1; \ - } + do { \ + if (fprintf (fh, __VA_ARGS__) < 0) { \ + char errbuf[1024]; \ + WARNING ("handle_putnotif: failed to write to socket #%i: %s", \ + fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \ + return -1; \ + } \ + fflush(fh); \ + } while (0) static int set_option_severity (notification_t *n, const char *value) { @@ -78,6 +81,18 @@ static int set_option (notification_t *n, const char *option, const char *value) DEBUG ("utils_cmd_putnotif: set_option (option = %s, value = %s);", option, value); + /* Add a meta option in the form: : */ + 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)