X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fnotify_nagios.c;h=79926b52659b5e52796949382ad855991a87803d;hp=c95f7cb99bf1ab139670a85ccd1e2b51c603d5ff;hb=54619dc85fd308b21ed09a0271e5c7383c7921b9;hpb=c3d354c58d56c4b2bb4138a227f3546928bd84f2 diff --git a/src/notify_nagios.c b/src/notify_nagios.c index c95f7cb9..79926b52 100644 --- a/src/notify_nagios.c +++ b/src/notify_nagios.c @@ -26,8 +26,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #define NAGIOS_OK 0 #define NAGIOS_WARNING 1 @@ -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 */