linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Clements <paul.clements@steeleye.com>
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org
Subject: [PATCH] mdadm: monitor event argument passing
Date: Fri, 31 Mar 2006 13:43:48 -0500	[thread overview]
Message-ID: <442D7864.9020901@steeleye.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 605 bytes --]


I've been looking at the mdadm monitor, and thought it might be useful 
if it allowed extra context information (in the form of command line 
arguments) to be sent to the event program, so instead of just:

# mdadm -F /dev/md0 -p "md_event"

you could do something like:

# mdadm -F /dev/md0 -p "md_event -i <some_info>"

And the "-i <some_info>" will be passed on the command line to the event 
program. Of course you can usually figure out what the extra context 
should be in the event program itself, but it may take more work.

Here's a short patch (against mdadm 2.4) that does this.

Thanks,
Paul

[-- Attachment #2: mdadm-2.4-event-args.diff --]
[-- Type: text/plain, Size: 1031 bytes --]


Signed-Off-By: Paul Clements <paul.clements@steeleye.com>

 Monitor.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletion(-)
--- mdadm-2.4/Monitor.c	2006-03-28 17:59:42.000000000 -0500
+++ mdadm-2.4-event-args/Monitor.c	2006-03-31 13:19:40.000000000 -0500
@@ -464,6 +464,27 @@ static void alert(char *event, char *dev
 		  int dosyslog)
 {
 	int priority;
+	int cnt = 0;
+	char path[PATH_MAX];
+	char *space, *ptr;
+	char *args[256];
+
+	if (cmd) {
+		strcpy(path, cmd);
+		ptr = path;
+		do {
+			space = strchr(ptr, ' ');
+			if (!space)
+				break;
+			args[cnt++] = ptr;
+			*space = 0;
+			ptr = space+1;
+		} while (1);
+		args[cnt++] = ptr;
+		args[cnt++] = event;
+		args[cnt++] = dev;
+		args[cnt++] = disc;
+	}
 
 	if (!cmd && !mailaddr) {
 		time_t now = time(0);
@@ -479,7 +500,7 @@ static void alert(char *event, char *dev
 		case -1:
 			break;
 		case 0:
-			execl(cmd, cmd, event, dev, disc, NULL);
+			execv(path, args); //execl(cmd,  cmd, event, dev, disc, NULL);
 			exit(2);
 		}
 	}

             reply	other threads:[~2006-03-31 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-31 18:43 Paul Clements [this message]
2006-04-03  0:16 ` [PATCH] mdadm: monitor event argument passing Neil Brown
2006-04-03 19:55   ` Paul Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=442D7864.9020901@steeleye.com \
    --to=paul.clements@steeleye.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).