diff options
author | Andi Kleen <github@halobates.de> | 2024-01-06 12:24:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-06 12:24:14 -0800 |
commit | a325ae1895634e990bed37a51f4190931cbd578c (patch) | |
tree | 973b203bb63250145cf96b3e9cec989468bad7d7 | |
parent | 20dc4373b7e04b00a6bd9f55446486df194b82ef (diff) | |
parent | 320a12809311b7ef135f3f11a9eaf1f71893496f (diff) | |
download | mcelog-a325ae1895634e990bed37a51f4190931cbd578c.tar.gz |
Merge pull request #120 from meow-watermelon/add_ping_option
add --ping option to mcelog client
-rw-r--r-- | client.c | 4 | ||||
-rw-r--r-- | mcelog.8 | 9 | ||||
-rw-r--r-- | mcelog.c | 22 |
3 files changed, 31 insertions, 4 deletions
@@ -64,6 +64,10 @@ void ask_server(char *command) } fputs(buf, stdout); + + if (n >= 5 && !memcmp(buf + n - 5, "pong\n", 5)) { + fflush(stdout); + } } fclose(fp); } @@ -18,6 +18,8 @@ mcelog [options] \-\-ascii .br mcelog [options] \-\-is\-cpu\-supported .br +mcelog \-\-ping +.br mcelog \-\-version .SH DESCRIPTION X86 CPUs report errors detected by the CPU as @@ -239,6 +241,13 @@ not to with the option. You might need this option when decoding old logs from a system where this mode was not enabled. +Users can utilize the +.B \-\-ping +option to check the availability of the mcelog server. If the mcelog server +is running, the command returns the string +.I pong +followed by a newline character. + .\".B \-\-database filename .\"specifies the memory module error database file. Default is .\"/var/lib/memory-errors. It is only used together with DMI decoding. @@ -891,6 +891,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" @@ -935,6 +936,7 @@ enum options { O_DAEMON, O_ASCII, O_CLIENT, + O_PING, O_VERSION, O_CONFIG_FILE, O_CPU, @@ -976,6 +978,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 */ @@ -1281,10 +1284,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; @@ -1317,13 +1328,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); |