Operating System - Linux
1826317 Members
4014 Online
109692 Solutions
New Discussion

Getting mdadm to run specified program

 
SOLVED
Go to solution
kenny chia
Regular Advisor

Getting mdadm to run specified program

Hi
I have a DL145G2 running software RAID. OS is Red Hat Enterprise Linux ES release 4 (Nahant Update 3)
I want mdadm to run a program whenever a disk event occurs.

This is my mdadm.conf settings
---------------------------
DEVICE partitions
MAILADDR root
PROGRAM /opt/mdmon/handle-mdadm-events
ARRAY /dev/md1 super-minor=1
ARRAY /dev/md0 super-minor=0
ARRAY /dev/md2 super-minor=2
ARRAY /dev/md3 super-minor=3
ARRAY /dev/md4 super-minor=4
-------------------------

I modified the following line in /etc/init.d/mdmonitor

"/bin/bash -c \"mdadm --monitor --scan -f > /var/run/mdadm/mdadm.pid\""

to

"/bin/bash -c \"mdadm --monitor --scan -f -t > /var/run/mdadm/mdadm.pid\""

Purpose is to generate test message at startup.
I restart mdadm using
# /etc/init.d/mdmonitor restart

As expected, an email message is sent to root but the program /opt/mdmon/handle-mdadm-events fails to execute.
Contents of program

/bin/echo "TEST" >> /opt/mdmon/test.log

The file /opt/mdmon/test.log is not generated at all. What could have gone wrong?

The execute bit of the program is already set.
All Your Bases Are Belong To Us!
2 REPLIES 2
Wouter Jagers
Honored Contributor
Solution

Re: Getting mdadm to run specified program

Can you run the script manually ?

I would anyway recommend some 'minimal' things in your script:

-----
#!/bin/bash

/bin/echo "TEST" >> /opt/mdmon/test.log
exit 0
-----

Kind of a safety net: the 1st line denotes how to interpret the script; the last one does a clean exit -and- prevents any control characters at the end of your file to mess things up.

(not at my linux machines right now so I can't recreate your situation for now, sorry)

Cheers,
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
kenny chia
Regular Advisor

Re: Getting mdadm to run specified program

Adding the line

#!/bin/bash

solved the problem. Thanks!
All Your Bases Are Belong To Us!