在 星期四 19 四月 2007 22:00,David Lee 写道:
> On Thu, 19 Apr 2007, Xinwei Hu wrote:
> >   As I asked on the IRC channel last night, there's no real blocker if we
> > have a standalone pingd.sh (without ha.cf involved anymore).
> >
> >   So here attached my first bash version of pingd. It works well for a
> > day :)
> >
> >   The known issue is that I don't know how to daemonize in bash,
> > so the pingd RA needs a little tweak also.
> >
> >   Comments are welcome.
>
> OK.  Here are some portability considerations, based on a quick glance
> through the code.
>
> This might seem negative.  It is not intended that way!  Keep up the
> good work.
>
> But they are details that will need attention at some point as your
> project progresses.
>
> 1. Your email above says "bash".  Your file starts "#!/bin/sh", which is
> Bourne shell.  On a few systems, such as Linux, Bourne and bash might just
> happen to be equivalent, but in the world of portable programming they are
> not: bash ("Bourne Again SHell") is Bourne with extensions.
> Portability strongly urges true Bourne shell, rather than bash.  For
> portable software, such as heartbeat, it is necessary to keep to true
> Bourne (i.e. "sh"), avoiding the bash extensions.
>
> 2. "export LC_ALL=C" (and likewise "export LANG=C").  That's a bash-ism.
> In Bourne:
>     LC_ALL=C; export LC_ALL
>     LANG=C; export LANG=C
> 3. "attrd_updater=/usr/sbin/attrd_updater":  "attrd_updater" gets
> installed in different places in different systems.  The mechanism for
> handling this in autoconf projects (such as heartbeat) is routine.  When
> your "pingd.sh" is close to being ready for installing into the heartbeat
> source tree, it will need to be abstrated into a "pingd.sh.in" file (and a
> corresponding adjustment made to "configure.in").
>
> 4. "TEMP=`getopt ...`.  There is "getopt", and there is "getopts".  The
> heartbeat source currently includes one of each.  Their more obscure
> details can vary from system to system.  So keep it simple; don't try to
> do too much with the "getopt{,s}" call.  The "-l ..." and "-n ..." are
> not available on some systems.  At least on Solaris "getopts" (with the
> "s") is preferred.  Also this same "getopts" (with the "s") then makes
> argument parsing easier, with its "OPTARG" and "OPTIND".
>
> 5. "ping -q -c 1 $ping_host".  The options for "ping" are notoriously
> variable from system to system.  Keep it simple. (For example my system
> doesn't have a "-q" option; and it says that "-c <n>" is for a thing
> called "traffic class", only valid on IPv6.)  If they are not necessary,
> leave them out.  If they are necessary, then for those of us who come
> along later to maintain code, especially on other operating systems, it is
> worth adding comments about your intentions, such as:
>    # -q: to do foo
>    # -c <n> to do bar
Here on my system:
       -c count
              Stop  after  sending  count  ECHO_REQUEST packets. With deadline
              option, ping waits for count ECHO_REPLY packets, until the time‐
              out expires.
       -q     Quiet output.  Nothing is displayed except the summary lines  at
              startup time and when finished.

-q can be removed as we did ">/dev/null 2>&1" already.
-c is used so that ping won't last forever.
> 6. "date +%s":  My OS doesn't support the "+%s" option.  Could you clarify
> your intention?
"date +%s" outputs the seconds since 1970-01-01 00:00:00 UTC.
I try to make sure the interval of every ping is equal
.
> There are probably some others that I've missed on this quick glance.
>
> Another: 'pid_file="/tmp/pingd.pid':  I suspect that this file should
> probably be in one of the heartbeat runtime locations rather than /tmp.
> If someone can identify the best location, then the autoconfiscation of
> your code at the appropriate time will be able to handle this.

pid_file="/tmp/pingd.pid" is copied out from the original pingd.c.
this can be fixed.

Yes, this script is written with only Linux in mind. I'll try to fix these 
portability issues.

Thanks a lot for your review.  :)

_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to