X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnotify_nagios.c;h=68f6e2a7f43b151df37a2e9a0a8904ff940a175b;hb=0b7cd83a5e6bac068ea83a88a5ddcfb07c09fbec;hp=13516915d868842e64a4789ba58b9d6ef3890e70;hpb=eec0cd9ca51c5c132ed09fc4699c02f3bd12d748;p=collectd.git diff --git a/src/notify_nagios.c b/src/notify_nagios.c index 13516915..68f6e2a7 100644 --- a/src/notify_nagios.c +++ b/src/notify_nagios.c @@ -67,10 +67,8 @@ static int nagios_print(char const *buffer) /* {{{ */ fd = open(file, O_WRONLY | O_APPEND); if (fd < 0) { - char errbuf[1024]; status = errno; - ERROR("notify_nagios plugin: Opening \"%s\" failed: %s", file, - sstrerror(status, errbuf, sizeof(errbuf))); + ERROR("notify_nagios plugin: Opening \"%s\" failed: %s", file, STRERRNO); return status; } @@ -79,30 +77,26 @@ static int nagios_print(char const *buffer) /* {{{ */ status = fcntl(fd, F_GETLK, &lock); if (status != 0) { - char errbuf[1024]; status = errno; ERROR("notify_nagios plugin: Failed to acquire write lock on \"%s\": %s", - file, sstrerror(status, errbuf, sizeof(errbuf))); + file, STRERRNO); close(fd); return status; } status = (int)lseek(fd, 0, SEEK_END); if (status == -1) { - char errbuf[1024]; status = errno; ERROR("notify_nagios plugin: Seeking to end of \"%s\" failed: %s", file, - sstrerror(status, errbuf, sizeof(errbuf))); + STRERRNO); close(fd); return status; } status = (int)swrite(fd, buffer, strlen(buffer)); if (status != 0) { - char errbuf[1024]; status = errno; - ERROR("notify_nagios plugin: Writing to \"%s\" failed: %s", file, - sstrerror(status, errbuf, sizeof(errbuf))); + ERROR("notify_nagios plugin: Writing to \"%s\" failed: %s", file, STRERRNO); close(fd); return status; } @@ -141,10 +135,10 @@ static int nagios_notify(const notification_t *n, /* {{{ */ break; } - ssnprintf(buffer, sizeof(buffer), - "[%.0f] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n", - CDTIME_T_TO_DOUBLE(n->time), n->host, &svc_description[1], code, - n->message); + snprintf(buffer, sizeof(buffer), + "[%.0f] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n", + CDTIME_T_TO_DOUBLE(n->time), n->host, &svc_description[1], code, + n->message); return nagios_print(buffer); } /* }}} int nagios_notify */ @@ -153,5 +147,3 @@ void module_register(void) { plugin_register_complex_config("notify_nagios", nagios_config); plugin_register_notification("notify_nagios", nagios_notify, NULL); } /* void module_register (void) */ - -/* vim: set sw=2 sts=2 ts=8 et : */