master - lvmpolld: make lvpoll error messages visible
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7bbc128c3dd6e75524a4447c29ed7be2ace8e3b3 Commit: 7bbc128c3dd6e75524a4447c29ed7be2ace8e3b3 Parent: cb57f4f89b908ad3d7149ce18204b71448c9d259 Author: Ondrej Kozina <[email protected]> AuthorDate: Wed Sep 2 16:50:14 2015 +0200 Committer: Ondrej Kozina <[email protected]> CommitterDate: Wed Sep 2 17:24:26 2015 +0200
lvmpolld: make lvpoll error messages visible
Previously all stderr messages issued by spawned lvpoll command were reported as INFO only. This made all such messages invisible in syslog or lvmpolld log while running default configuration.
All lvpoll stderr messages are loged with WARN priority now and lvpoll command exiting with retcode != 0 is logged with ERROR priority in syslog and lvmpolld log
--- WHATS_NEW | 1 + daemons/lvmpolld/lvmpolld-core.c | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.130 - =================================== + Make lvpoll error messages visible in lvmpolld's stderr and in syslog. Add 'make install_full_man' to install all man pages regardless of config. Version 2.02.129 - 26th August 2015
daemons/lvmpolld/lvmpolld-core.c +15 -5
@@ -83,6 +83,12 @@ static int _init(struct daemon_state *s)struct lvmpolld_state *ls = s->private; ls->log = s->log; +/* +* log warnings to stderr by default. Otherwise we would miss any lvpoll +* error messages in default configuration +*/ +daemon_log_enable (ls->log,DAEMON_LOG_OUTLET_STDERR ,DAEMON_LOG_WARN ,1 ); +if (!daemon_log_parse (ls->log,DAEMON_LOG_OUTLET_STDERR , ls->log_config,1 ))return 0 ;
@@ -284,7 +290,7 @@ static int poll_for_output(struct lvmpolld_lv *pdlv, struct lvmpolld_thread_data "caught input data in STDERR");assert (read_single_line (data,1 ));/* may block indef. anyway */ -INFO (pdlv->ls,"%s: PID %d: %s: '%s'" ,LVM2_LOG_PREFIX , +WARN (pdlv->ls,"%s: PID %d: %s: '%s'" ,LVM2_LOG_PREFIX , pdlv->cmd_pid,"STDERR" , data->line); }else if (fds[1 ].revents) {if (fds[1 ].revents &POLLHUP )
@@ -327,15 +333,19 @@ static int poll_for_output(struct lvmpolld_lv *pdlv, struct lvmpolld_thread_dataif (fds[1 ].fd >=0 )while (read_single_line (data,1 )) {assert (r >0 ); -INFO (pdlv->ls,"%s: PID %d: %s: %s" ,LVM2_LOG_PREFIX , pdlv->cmd_pid,"STDERR" , data->line); +WARN (pdlv->ls,"%s: PID %d: %s: %s" ,LVM2_LOG_PREFIX , pdlv->cmd_pid,"STDERR" , data->line); }if (WIFEXITED (ch_stat)) { -INFO (pdlv->ls,"%s: %s (PID %d) %s (%d)" ,PD_LOG_PREFIX , -"lvm2 cmd" , pdlv->cmd_pid,"exited with" ,WEXITSTATUS (ch_stat)); cmd_state.retcode =WEXITSTATUS (ch_stat); +if (cmd_state.retcode) +ERROR (pdlv->ls,"%s: %s (PID %d) %s (retcode: %d)" ,PD_LOG_PREFIX , +"lvm2 cmd" , pdlv->cmd_pid,"failed" , cmd_state.retcode); +else +INFO (pdlv->ls,"%s: %s (PID %d) %s" ,PD_LOG_PREFIX , +"lvm2 cmd" , pdlv->cmd_pid,"finished successfully" ); }else if (WIFSIGNALED (ch_stat)) { -WARN (pdlv->ls,"%s: %s (PID %d) %s (%d)" ,PD_LOG_PREFIX , +ERROR (pdlv->ls,"%s: %s (PID %d) %s (%d)" ,PD_LOG_PREFIX ,"lvm2 cmd" , pdlv->cmd_pid,"got terminated by signal" ,WTERMSIG (ch_stat)); cmd_state.signal =WTERMSIG (ch_stat);