diff --git a/man/redfishpower.8.in b/man/redfishpower.8.in index de4be5ac..9b651800 100644 --- a/man/redfishpower.8.in +++ b/man/redfishpower.8.in @@ -63,6 +63,10 @@ Set path and optional post data to turn off node. .I "settimeout " Set command timeout in seconds. .TP +.I "setstatuspollinginterval " +Set status polling interval in seconds. This is the polling interval +to determine an on/off command has completed. +.TP .I "stat [nodes]" Get power status of all nodes or specified subset of nodes. .TP diff --git a/src/redfishpower/redfishpower.c b/src/redfishpower/redfishpower.c index 972585e7..12f24d77 100644 --- a/src/redfishpower/redfishpower.c +++ b/src/redfishpower/redfishpower.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -64,11 +65,13 @@ static zhashx_t *test_power_status; /* in usec * - * status polling interval of 1 second may seem long, but testing - * shows wait ranges from a few seconds to 20 seconds + * status polling interval of 1 second may seem long, but testing shows wait ranges + * from a few seconds to almost a minute. Device files should adjust + * to longer times for really bad systems. */ -#define STATUS_POLLING_INTERVAL 1000000 +#define STATUS_POLLING_INTERVAL_DEFAULT 1000000 +#define USEC_IN_SEC 1000000 #define MS_IN_SEC 1000 #define CMD_STAT "stat" @@ -138,6 +141,10 @@ static struct option longopts[] = { }; static time_t cmd_timeout = CMD_TIMEOUT_DEFAULT; +/* typically is of type suseconds_t, but has questionable portability, + * so use 'long int' instead + */ +static long int status_polling_interval = STATUS_POLLING_INTERVAL_DEFAULT; void help(void) { @@ -148,6 +155,7 @@ void help(void) printf(" setonpath path [postdata]\n"); printf(" setoffpath path [postdata]\n"); printf(" settimeout seconds\n"); + printf(" setstatuspollinginterval seconds\n"); printf(" stat [nodes]\n"); printf(" on [nodes]\n"); printf(" off [nodes]\n"); @@ -569,7 +577,7 @@ static void send_status_poll(struct powermsg *pm) statpath, NULL, &pm->start, - STATUS_POLLING_INTERVAL, + status_polling_interval, STATE_WAIT_UNTIL_ON_OFF); if (!(nextpm->handle = zlistx_add_end(delayedcmds, nextpm))) err_exit(true, "zlistx_add_end"); @@ -749,6 +757,23 @@ static void settimeout(char **av) } } +static void setstatuspollinginterval(char **av) +{ + if (av[0]) { + char *endptr; + long tmp; + + errno = 0; + tmp = strtol (av[0], &endptr, 10); + if (errno + || endptr[0] != '\0' + || tmp <= 0 + || (tmp > (LONG_MAX / USEC_IN_SEC))) + printf("invalid status polling interval specified\n"); + status_polling_interval = tmp * USEC_IN_SEC; + } +} + static void process_cmd(CURLM *mh, char **av, int *exitflag) { if (av[0] != NULL) { @@ -768,6 +793,8 @@ static void process_cmd(CURLM *mh, char **av, int *exitflag) setpowerpath(av + 1, &offpath, &offpostdata); else if (strcmp(av[0], "settimeout") == 0) settimeout(av + 1); + else if (strcmp(av[0], "setstatuspollinginterval") == 0) + setstatuspollinginterval(av + 1); else if (strcmp(av[0], CMD_STAT) == 0) stat_cmd(mh, av + 1); else if (strcmp(av[0], CMD_ON) == 0)