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