* [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* Re: [PATCH] mdadm: monitor event argument passing
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
0 siblings, 1 reply; 3+ messages in thread
From: Neil Brown @ 2006-04-03 0:16 UTC (permalink / raw)
To: Paul Clements; +Cc: linux-raid
On Friday March 31, paul.clements@steeleye.com wrote:
>
> 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.
I would recommend the use of environment variables for this:
md_event_context=<some_info> mdadm -F /dev/md0 -p md_event
It is true that this cannot be specified in mdadm.conf, but I don't
think you really need it at all in that context. The <some_info> can
be explicit in the script rather than in mdadm.conf.
Does that work for you?
NeilBrown
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mdadm: monitor event argument passing
2006-04-03 0:16 ` Neil Brown
@ 2006-04-03 19:55 ` Paul Clements
0 siblings, 0 replies; 3+ messages in thread
From: Paul Clements @ 2006-04-03 19:55 UTC (permalink / raw)
To: Neil Brown; +Cc: linux-raid
Neil Brown wrote:
> On Friday March 31, paul.clements@steeleye.com wrote:
>
>>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.
>
>
> I would recommend the use of environment variables for this:
>
> md_event_context=<some_info> mdadm -F /dev/md0 -p md_event
> Does that work for you?
Yes, that would work.
Thanks,
Paul
^ 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).