Hi -
Please see pcpfans.git fche/pmcd-autorestart for a patch of some dozen
lines that accomplishes pmda auto-restart entirely within pmcd. No
pmie, no pmsignal, nothing else needed.
RHBZ1323521: pmcd agent auto-restart
A few lines of code in pmcd's ClientLoop allow it to connect the
preexisting flags that detect recent agent malfunctions to the
preexisting code to trigger agent restarts. In this case, the
automatic restarting is limited once per minute.
diff --git a/src/pmcd/src/pmcd.c b/src/pmcd/src/pmcd.c
index 511944ccfc92..dccb1f95491c 100644
--- a/src/pmcd/src/pmcd.c
+++ b/src/pmcd/src/pmcd.c
@@ -29,6 +29,7 @@ static char *FdToString(int);
static void ResetBadHosts(void);
int AgentDied; /* for updating mapdom[] */
+int AgentPendingRestart; /* for automatic restart */
static int timeToDie; /* For SIGINT handling */
static int restart; /* For SIGHUP restart */
static int maxReqPortFd; /* Largest request port fd */
@@ -749,6 +750,19 @@ ClientLoop(void)
__pmNotifyErr(LOG_ERR, "ClientLoop select: %s\n", netstrerror());
break;
}
+ if (AgentDied) {
+ AgentPendingRestart = 1;
+ }
+ if (AgentPendingRestart) {
+ static time_t last_restart;
+ time_t now = time(NULL);
+ if ((now - last_restart) >= 60) {
+ AgentPendingRestart = 0;
+ last_restart = now;
+ __pmNotifyErr(LOG_INFO, "Auto-restarting agents.\n");
+ restart = 1;
+ }
+ }
if (restart) {
restart = 0;
reload_ns = 1;
|