From: Krzysztof Matczak Date: Fri, 23 Dec 2016 00:21:53 +0000 (+0000) Subject: PR comments addressed X-Git-Tag: collectd-5.8.0~257^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=36b8935eb1d642a7ce50799864901fbc0df6aba5;p=collectd.git PR comments addressed Change-Id: I0ddfd6dcd911ab46fcbc032081a2980b1f1f549b Signed-off-by: Krzysztof Matczak --- diff --git a/Makefile.am b/Makefile.am index 9f33cdc6..9f0506a7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1045,7 +1045,6 @@ if BUILD_PLUGIN_MCELOG pkglib_LTLIBRARIES += mcelog.la mcelog_la_SOURCES = mcelog.c mcelog_la_LDFLAGS = $(PLUGIN_LDFLAGS) -mcelog_la_LIBADD = endif if BUILD_PLUGIN_MD diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index e6f771e5..2f29713a 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -3324,23 +3324,23 @@ TCP-Port to connect to. Defaults to B<411>. =head2 Plugin C -The C uses mcelog to retrieve machine check exceptions, etc. +The C uses mcelog to retrieve machine check exceptions. By default the plugin connects to B<"/var/run/mcelog-client"> to check if the mcelog server is running. When the server is running, the plugin will tail the specified logfile to retrieve machine check exception information and send a notification with the details from the logfile. The plugin will use the mcelog -client protocol to retrieve memory errors. +client protocol to retrieve memory related machine check exceptions. =over 4 =item B I -Connect to mcelog client socket using the UNIX domain socket at I. +Connect to the mcelog client socket using the UNIX domain socket at I. Defaults to B<"/var/run/mcelog-client">. =item B I -mcelog file to parse. Defaults to B<"/var/log/mcelog">. +The mcelog file to parse. Defaults to B<"/var/log/mcelog">. =back diff --git a/src/mcelog.c b/src/mcelog.c index f1b4318a..9fad0be8 100644 --- a/src/mcelog.c +++ b/src/mcelog.c @@ -154,14 +154,13 @@ static int socket_write(socket_adapter_t *self, const char *msg, static int socket_reinit(socket_adapter_t *self) { char errbuff[MCELOG_BUFF_SIZE]; - int flags; int ret = -1; cdtime_t interval = plugin_get_interval(); struct timeval socket_timeout = CDTIME_T_TO_TIMEVAL(interval); /* synchronization via write lock since sock_fd may be changed here */ pthread_rwlock_wrlock(&self->lock); - self->sock_fd = socket(PF_UNIX, SOCK_STREAM, 0); + self->sock_fd = socket(PF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); if (self->sock_fd < 0) { ERROR("%s: Could not create a socket. %s", MCELOG_PLUGIN, sstrerror(errno, errbuff, sizeof(errbuff))); @@ -169,13 +168,9 @@ static int socket_reinit(socket_adapter_t *self) { return ret; } - flags = fcntl(self->sock_fd, F_GETFL, 0); - flags |= O_NONBLOCK; - fcntl(self->sock_fd, F_SETFL, flags); - /* Set socket timeout option */ if (setsockopt(self->sock_fd, SOL_SOCKET, SO_SNDTIMEO, - (char *)&socket_timeout, sizeof(socket_timeout)) < 0) + &socket_timeout, sizeof(socket_timeout)) < 0) ERROR("%s: Failed to set the socket timeout option.", MCELOG_PLUGIN); /* downgrading to read lock due to possible recursive read locks @@ -411,7 +406,7 @@ static int socket_receive(socket_adapter_t *self, FILE **pp_file) { static void *poll_worker(__attribute__((unused)) void *arg) { char errbuf[MCELOG_BUFF_SIZE]; mcelog_thread_running = 1; - FILE **pp_file = calloc(1, sizeof(FILE *)); + FILE **pp_file = calloc(1, sizeof(*pp_file)); if (pp_file == NULL) { ERROR("mcelog: memory allocation failed: %s", sstrerror(errno, errbuf, sizeof(errbuf))); @@ -439,8 +434,7 @@ static void *poll_worker(__attribute__((unused)) void *arg) { if (*pp_file == NULL) continue; - mcelog_memory_rec_t memory_record; - memset(&memory_record, 0, sizeof(memory_record)); + mcelog_memory_rec_t memory_record = {0}; while (parse_memory_info(*pp_file, &memory_record)) { notification_t n = {NOTIF_OKAY, cdtime(), "", "", MCELOG_PLUGIN, "", "", "", NULL};