linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mdadm: monitor event argument passing
@ 2006-03-31 18:43 Paul Clements
  2006-04-03  0:16 ` Neil Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Clements @ 2006-03-31 18:43 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid

[-- 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);
 		}
 	}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-04-03 19:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-31 18:43 [PATCH] mdadm: monitor event argument passing Paul Clements
2006-04-03  0:16 ` Neil Brown
2006-04-03 19:55   ` Paul Clements

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).