diff options
author | Hui Li <herdingcat@yahoo.com> | 2024-01-01 00:52:27 -0500 |
---|---|---|
committer | Hui Li <herdingcat@yahoo.com> | 2024-01-01 13:37:45 -0500 |
commit | 2dcfcb82acbc4b8c6f4f20278bcdd798dc96fefa (patch) | |
tree | 6f548108156492548a6bbae45b36370001983f64 | |
parent | f6ec8aa064f16d03ca8a9278cf9b02031a493d70 (diff) | |
download | mcelog-2dcfcb82acbc4b8c6f4f20278bcdd798dc96fefa.tar.gz |
add --ping option to mcelog client
-rw-r--r-- | client.c | 6 | ||||
-rw-r--r-- | mcelog.c | 22 |
2 files changed, 24 insertions, 4 deletions
@@ -64,6 +64,12 @@ void ask_server(char *command) } fputs(buf, stdout); + + /* we want to show the string pong before exiting the loop */ + if (n >= 5 && !memcmp(buf + n - 5, "pong\n", 5)) { + fclose(fp); + return; + } } fclose(fp); } @@ -886,6 +886,7 @@ void usage(void) "--raw (with --ascii) Dump in raw ASCII format for machine processing\n" "--daemon Run in background waiting for events (needs newer kernel)\n" "--client Query a currently running mcelog daemon for errors\n" +"--ping Send ping command to the currently running mcelog daemon\n" "--ignorenodev Exit silently when the device cannot be opened\n" "--file filename With --ascii read machine check log from filename instead of stdin\n" "--logfile filename Log decoded machine checks in file filename\n" @@ -930,6 +931,7 @@ enum options { O_DAEMON, O_ASCII, O_CLIENT, + O_PING, O_VERSION, O_CONFIG_FILE, O_CPU, @@ -971,6 +973,7 @@ static struct option options[] = { { "cpu", 1, NULL, O_CPU }, { "foreground", 0, NULL, O_FOREGROUND }, { "client", 0, NULL, O_CLIENT }, + { "ping", 0, NULL, O_PING }, { "num-errors", 1, NULL, O_NUMERRORS }, { "pidfile", 1, NULL, O_PIDFILE }, { "debug-numerrors", 0, NULL, O_DEBUG_NUMERRORS }, /* undocumented: for testing */ @@ -1276,10 +1279,18 @@ static void client_command(int ac, char **av) argsleft(ac, av); no_syslog(); // XXX modifiers - ask_server("dump all bios\n"); + ask_server("dump all bios\n"); ask_server("pages\n"); } +static void ping_command(int ac, char **av) +{ + argsleft(ac, av); + no_syslog(); + // XXX modifiers + ask_server("ping\n"); +} + struct mcefd_data { unsigned loglen; unsigned recordlen; @@ -1312,13 +1323,16 @@ int main(int ac, char **av) exit(1); } else if (combined_modifier(opt) > 0) { continue; - } else if (opt == O_ASCII) { + } else if (opt == O_ASCII) { ascii_command(ac, av); exit(0); - } else if (opt == O_CLIENT) { + } else if (opt == O_CLIENT) { client_command(ac, av); exit(0); - } else if (opt == O_VERSION) { + } else if (opt == O_PING) { + ping_command(ac, av); + exit(0); + } else if (opt == O_VERSION) { noargs(ac, av); fprintf(stderr, "mcelog %s\n", MCELOG_VERSION); exit(0); |