David Lee wrote:
> On Thu, 19 Apr 2007, Xinwei Hu wrote:
>
>> [David Lee had earlier written:]
>>> 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.
>
> "ping" on Linux and Solaris (to name two of our OSes) seem incompatible in
> their options.
>
>> -q can be removed as we did ">/dev/null 2>&1" already.
>
> Yes. The ">/dev/null 2>&1" method is the way to go to suppress output
> across a range of OSes
>
>> -c is used so that ping won't last forever.
>
> On Solaris: "ping hostname [data_size ] [ count ]"
>
> In practice, it seems that "ping hostname number" also causes a swift
> return for non-replying hosts.
>
> See "resources/heartbeat/IPaddr.in" and "resources/OCF/IPaddr.in" which
> tryi to do the right thing according to which OS they are running on.
>
> So it might be worth us trying to develop our own "ping-wrapper" command
> with a fixed, portable, interface, whose contents are based on those in
> those other two files, and which they would then use, and which your new
> "pingd" could also use.
>
>
>>> 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
>
> Hmmm... that's absent from Solaris (and possibly from other traditional
> UNIX systems also).
>
> But I guess that what you want is a number of seconds since some arbitrary
> baseline, and that the "1970" value of the baseline is not important.
>
> So how about "date +%Y%m%d%H%M%S", which seems to be available on a range
> of systems? Here's its typical output:
>
> host% date; date +%Y%m%d%H%M%S
> Fri Apr 20 16:20:11 BST 2007
> 20070420162011
> host%
>
> It seems to meet the criteria and should be portable enough.
>
> I can see one failure condition: if this is running over the time interval
> that Daylight Savings comes into effect in some countries.
>
>
>> Yes, this script is written with only Linux in mind. I'll try to fix these
>> portability issues.
Of course, we already have portable ping code in C in our base. The
best way to do this portably is probably to use that code, which is
guaranteed not to change without us knowing about it...
--
Alan Robertson <[EMAIL PROTECTED]>
"Openness is the foundation and preservative of friendship... Let me
claim from you at all times your undisguised opinions." - William
Wilberforce
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems