Alarm Program Question
Posted in 2009
Topics: General Discussion
11.50FC3 question I am upgrading to the new alarmprogram.sh with 11.50FC3. I was looking at the script and I came across this LINE: ALARMTESTFILE= Yes it sets the variable to nothing and it isn't in the PUBLIC section to be set by us. It is only used in one other place. if ( `test x${MAILTO} != x` ) then printf "\\n" >> $MAILHEAD cat $MAILBODY >> $MAILHEAD if ( `test x${ALARMPROGRAMTEST} = x` ) then if ( `test x${MAILUTILITY} != x` ) then ## Do not send same alarm in less than 5 minute interval. if ( test `grep "$EVENT_MSG" $LASTALARMFILE|wc -l` -lt 1 ) then $MAILUTILITY $MAILTO < $MAILHEAD fi else echo "MAILUTILITY is not set, NO MAIL will be sent." fi else cat $MAILHEAD >> $ALARMTESTFILE fi else echo "SENDER IS NULL NO MAIL WILL BE SENT" fi So, basically I want to know WTF? Is this just crap that doesn't really work but doesn't hurt you because it isn't really used anymore. I am reticent to use the alarmprogram.sh because I find things like: if ( `test x${LTAPEDEV} == x/dev/null` ) then There is no such thing as == in the ksh test command (At least according to my old ksh O'Reily book). I looked it up to be sure. The rest of the test command use the proper "=" operator for string compare. Of course, because of some fluke it does seem to return what you would expect test xA == xA returns 0 test xA == xB returns 1 (in bash anyway I don't have a real version of ksh to try it on. Mistakes like these just worry me that someone spent very little time with this script. I could write a better script but I shouldn't have to.
bozon wrote: > 11.50FC3 question > > I am upgrading to the new alarmprogram.sh with 11.50FC3. I was looking > at the script and I came across this LINE: > > ALARMTESTFILE= > > Yes it sets the variable to nothing and it isn't in the PUBLIC section > to be set by us. > It is only used in one other place. > > if ( `test x${MAILTO} != x` ) then > printf "\\n" >> $MAILHEAD > cat $MAILBODY >> $MAILHEAD > if ( `test x${ALARMPROGRAMTEST} = x` ) then > if ( `test x${MAILUTILITY} != x` ) then > ## Do not send same alarm in less than 5 minute interval. > if ( test `grep "$EVENT_MSG" $LASTALARMFILE|wc -l` -lt 1 ) then > $MAILUTILITY $MAILTO < $MAILHEAD > fi > else > echo "MAILUTILITY is not set, NO MAIL will be sent." > fi > else > cat $MAILHEAD >> $ALARMTESTFILE > fi > else > echo "SENDER IS NULL NO MAIL WILL BE SENT" > fi > > So, basically I want to know WTF? Is this just crap that doesn't > really work but doesn't hurt you because it isn't really used anymore. > I am reticent to use the alarmprogram.sh because I find things like: > > if ( `test x${LTAPEDEV} == x/dev/null` ) then > > There is no such thing as == in the ksh test command (At least > according to my old ksh O'Reily book). I looked it up to be sure. The > rest of the test command use the proper "=" operator for string > compare. Of course, because of some fluke it does seem to return what > you would expect test xA == xA returns 0 test xA == xB returns 1 (in > bash anyway I don't have a real version of ksh to try it on. > > Mistakes like these just worry me that someone spent very little time > with this script. I could write a better script but I shouldn't have > to. > I would have to check this more carefully... In any case just a few thoughts: - Which platform? I would say the script should be the same for any platform, but the "==" may make sense in Linux/bash - If the idea of using the variable is to avoid repeated alarms it makes sense... of course it would have to work... In any case I have hit another issue with my custom alarm program: In really stressful situations we may break all the attempts we make in the alarm script to check for things like this... In more than one situation I have hit the maximum number of user processes, which makes any attempt in the script to handle this more or less useless... take this into consideration if you make your own script Regards