Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=72c6acd16... Commit: 72c6acd167fa7c4a8d19795957f73ee4aae17f60 Parent: 6e2ed26e4e82fac11f5c269b29b0f0c0bedefe6a Author: Marek 'marx' Grac mgrac@redhat.com AuthorDate: Wed Feb 25 09:49:21 2015 +0100 Committer: Marek 'marx' Grac mgrac@redhat.com CommitterDate: Wed Feb 25 09:49:21 2015 +0100
fence_kdump: Add 'monitor' action which tests possibility of doing kdump on local node
In case of fence_kdump we can not test if remote 'fencing device' is working because fence_kdump_send is started only after kernel crash. So, monitor action checks if LOCAL node can enter kdump. The test looks if crashkernel=.. occurs between boot arguments. --- fence/agents/kdump/fence_kdump.c | 35 ++++++++++++++++++++++++++++++++++- fence/agents/kdump/options.h | 2 ++ 2 files changed, 36 insertions(+), 1 deletions(-)
diff --git a/fence/agents/kdump/fence_kdump.c b/fence/agents/kdump/fence_kdump.c index cae9842..5cea11d 100644 --- a/fence/agents/kdump/fence_kdump.c +++ b/fence/agents/kdump/fence_kdump.c @@ -114,6 +114,34 @@ out: }
static int +do_action_monitor (void) +{ + const char cmdline_path[] = "/proc/cmdline"; + FILE *procFile; + size_t sz; + char *lines; + int result; + + procFile = fopen(cmdline_path, "r"); + sz = 0; + + while (!feof (procFile)) { + getline (&lines, &sz, procFile); + } + + if (strstr(lines, "crashkernel=") == NULL) { + result = 1; + } else { + result = 0; + } + + free (lines); + fclose (procFile); + + return result; +} + +static int do_action_off (const fence_kdump_opts_t *opts) { int error; @@ -205,6 +233,7 @@ do_action_metadata (const char *self)
fprintf (stdout, "\t<parameter name="action" unique="0" required="0">\n"); fprintf (stdout, "\t\t<getopt mixed="-o, --action" />\n"); + fprintf (stdout, "\t\t<content type="string" default="monitor" />\n"); fprintf (stdout, "\t\t<content type="string" default="off" />\n"); fprintf (stdout, "\t\t<shortdesc lang="en">%s</shortdesc>\n", "Fencing action"); @@ -242,6 +271,7 @@ do_action_metadata (const char *self)
fprintf (stdout, "<actions>\n"); fprintf (stdout, "\t<action name="off" />\n"); + fprintf (stdout, "\t<action name="monitor" />\n"); fprintf (stdout, "\t<action name="metadata" />\n"); fprintf (stdout, "</actions>\n");
@@ -264,7 +294,7 @@ print_usage (const char *self) fprintf (stdout, "%s\n", " -f, --family=FAMILY Network family: ([auto], ipv4, ipv6)"); fprintf (stdout, "%s\n", - " -o, --action=ACTION Fencing action: ([off], metadata)"); + " -o, --action=ACTION Fencing action: ([off], monitor, metadata)"); fprintf (stdout, "%s\n", " -t, --timeout=TIMEOUT Timeout in seconds (default: 60)"); fprintf (stdout, "%s\n", @@ -501,6 +531,9 @@ main (int argc, char **argv) case FENCE_KDUMP_ACTION_METADATA: error = do_action_metadata (argv[0]); break; + case FENCE_KDUMP_ACTION_MONITOR: + error = do_action_monitor (); + break; default: break; } diff --git a/fence/agents/kdump/options.h b/fence/agents/kdump/options.h index 10fa2a2..22731d7 100644 --- a/fence/agents/kdump/options.h +++ b/fence/agents/kdump/options.h @@ -189,6 +189,8 @@ set_option_action (fence_kdump_opts_t *opts, const char *arg) opts->action = FENCE_KDUMP_ACTION_OFF; } else if (!strcasecmp (arg, "metadata")) { opts->action = FENCE_KDUMP_ACTION_METADATA; + } else if (!strcasecmp (arg, "monitor")) { + opts->action = FENCE_KDUMP_ACTION_MONITOR; } else { fprintf (stderr, "[error]: unsupported action '%s'\n", arg); exit (1);