3 # Given one or more Lustre objects, create a mon configuration file
4 # naming the mon watches based on the Lustre object names
5 # For each Lustre object, the script will create two mon watches
6 # The first watch sets a trap, and the second watch clears the
7 # trap if Lustre is healthy.
9 # This may be more fun in Perl due to the need to support a list
12 # (plus we could use a Perl format for this goop)
14 MONBASEDIR=${MONBASEDIR:-/usr/local/lib/mon}
15 MONCFGDIR=${MONCFGDIR:-/etc/mon}
17 TMPMONCFG=${TD}-mon.cfg
18 # Determines how often we will check Lustre health
20 # Determines how quickly we must clear the trap
22 ALERTSCRIPT=${ALERTSCRIPT:-"fail_lustre.alert"}
23 TRAPSCRIPT=${TRAPSCRIPT:-"lustre.mon.trap"}
25 # We will assume all inputs are Lustre objects
26 # file locations and timeouts correct to taste
29 cat >> $TMPMONCFG <<-EOF
30 cfbasedir = $MONCFGDIR
31 alertdir = $MONBASEDIR/alert.d
32 mondir = $MONBASEDIR/mon.d
33 statedir = $MONBASEDIR/state.d
34 logdir = $MONBASEDIR/log.d
35 dtlogfile = $MONBASEDIR/log.d/downtime.log
43 # Tabs should be preserved in the config file
45 # we do not set a period, it is assumed monitor is always active
48 cat >> $TMPMONCFG <<EOF
52 description triggers heartbeat failure if trap springs on $1
53 traptimeout $TRAPINTERVAL
64 cat >> $TMPMONCFG <<EOF
68 description clears trap for $1
69 interval $CHECKINTERVAL
70 monitor $TRAPSCRIPT ${1}-obj ${1}_ser ${1}
79 echo "$0 -n <node> -n <node> -o <Lustre object> -o <Lustre object>...."
80 echo "Creates the /etc/mon/mon.cf file to monitor Lustre objects"
91 # This script should work for any number of hosts
99 while getopts "n:o:" opt; do
101 n) HOSTS[HOSTCNT]=$OPTARG
102 HOSTCNT=$(( HOSTCNT + 1 ))
104 o) OBJS[OBJCNT]=$OPTARG
105 OBJCNT=$(( OBJCNT + 1 ))
112 echo "Found $HOSTCNT hosts"
113 echo "Found $OBJCNT Lustre objects"
115 # First create the host groups
117 # each object will have two watches defined
118 # each object hostgroup will have all objects
120 # Create the file with the declared goop
123 for obj in ${OBJS[@]}
125 echo "hostgroup ${obj}-obj ${HOSTS[@]}" >> $TMPMONCFG
126 echo "hostgroup ${obj}-mon ${HOSTS[@]}" >> $TMPMONCFG
127 echo "#" >> $TMPMONCFG
130 # create the monitors
132 for obj in ${OBJS[@]}
138 echo "Mon config completed - new mon config is $TMPMONCFG"