From 10a03d9299757a14525e1177ef34f68b316be1f0 Mon Sep 17 00:00:00 2001 From: Nathan Straz Date: Tue, 25 Feb 2014 09:38:58 -0500 Subject: Include host name in reboot and host down messages After a long running command or when multiple qarsh processes are running in parallel, it's hard to know which host is having trouble when a "Remote host rebooted" message shows up. Include the host name in these message to make them more informative. --- hbeat.c | 2 -- qarsh.c | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/hbeat.c b/hbeat.c index c62aeba..7b5b663 100644 --- a/hbeat.c +++ b/hbeat.c @@ -142,8 +142,6 @@ hbeat(hbeat_t hbh) hbeatp->last_rhost_btime = hbeat; retval = 1; } else if (abs(hbeat - hbeatp->last_rhost_btime) > 5) { - fprintf(stderr, "Host rebooted (%d, %d)\n", - hbeat, hbeatp->last_rhost_btime); hbeatp->rhost_state = HOST_REBOOT; retval = 0; } else { diff --git a/qarsh.c b/qarsh.c index b7814df..7a6adef 100644 --- a/qarsh.c +++ b/qarsh.c @@ -57,6 +57,7 @@ int signal_to_send = 0; int sigs_to_propogate[] = { SIGINT, SIGTERM, SIGHUP, SIGUSR1, SIGUSR2 }; sigset_t pselect_sigmask; int connection_timeout = 0; +char *host = NULL; void @@ -423,15 +424,15 @@ run_remote_cmd(char *cmdline) } } if (hbeat_getstate(qarsh_hb) == HOST_TIMEOUT) { - fprintf(stderr, "Didn't receive heartbeat for %d seconds\n", - hbeat_getmaxtimeout(qarsh_hb)); + fprintf(stderr, "Didn't receive heartbeat from %s for %d seconds\n", + host, hbeat_getmaxtimeout(qarsh_hb)); return W_EXITCODE(127, 0); } else if (hbeat_getstate(qarsh_hb) == HOST_REBOOT) { - fprintf(stderr, "Remote host rebooted\n"); + fprintf(stderr, "Remote host %s rebooted\n", host); return W_EXITCODE(127, 0); } if (!cmd_finished) { - fprintf(stderr, "Remote command exited with unknown state\n"); + fprintf(stderr, "Remote command on %s exited with unknown state\n", host); return W_EXITCODE(127, 0); } return rc; @@ -442,7 +443,6 @@ main(int argc, char *argv[]) { int c; int port = 5016; - char *host = NULL; char *remuser = NULL; char *remgroup = NULL; char *args; -- cgit