On Fri, 27 Apr 2007, Alan Robertson wrote:
> David Lee wrote:
> >
> > The principle of calling the system "ping" is clean and simple -- far more
> > so (isn't it?) than having to (re-)write a ping-like command to call the C
> > code in our base.
>
> I knew the context ;-). There is a bit of devil's advocate in my blood
> I confess ;-).
>
> My experience is that the autofoo commands work really well for C, and
> less well so for shell scripts. And, what's the big difference between
> calling a system binary we have no control over versus one of our own
> that we do have control over?
Writing and maintenance of C code vs. shell wrapper, itself influenced by
relative likely sizes (and by things such as falling down security holes:
buffer overflow within C; data cleaning ...) of those two entities.
>
> > The current problem is simply that the system "ping" in different OSes has
> > different options, and the current discussion is about how to handle that.
>
> And some OSes provide options that others don't. Not just that they
> need different flags.
This _would_ become an issue _if_ our desired use needed unavailable
options. Is that the case here?
>
> > So I'm wondering whether, in the case of script-based (not C) callers, we
> > could simply have a shell function (e.g. "pingfn") with a fixed interface
> > acting as a wrapper to the system-shell ping command and handling all the
> > relevant OS incompatibilities.
>
> One could certainly do that. It would have to detect at run time which
> thing to do. Or I suppose one could have something like this:
>
> if test "we are on solaris"; then
> ourping() {
> }
> else if test "we are on linux" then
> ourping() {
> }
The autofoo principles advise against such OS-based activity in general.
But I suspect that this particular case might be a suitable candidate for
deviancy.
We already have such code, and already have it duplicated (ouch!) in
"resources/OCF/IPaddr.in" and "resources/heartbeat/IPaddr.in". And
"pingd.sh" is in danger of making this triplicate.
> Or one could use autofoo to detect which options we need and pass them
> through all the autofoo stuff to the script.
In general, yes. But this adds quite a lot of configure-time overhead.
Is that worth it for this case, and this context?
And note that "-c" is valid on both Solaris and Linux, but with totally
different meanings; how might autofoo easily distinguish them? (Emphasis
on the "easily").
My personal order of preference (as I still try to duck this apparently
returning boomerang!) is:
1. simple shell-function "ourping" extracted from the "IPaddr.in"
instances with the simple, though non-ideal, "if on-solaris" logic;
2. similar to above, with added autofoo option detection as its logic;
3. C code.
--
: David Lee I.T. Service :
: Senior Systems Programmer Computer Centre :
: UNIX Team Leader Durham University :
: South Road :
: http://www.dur.ac.uk/t.d.lee/ Durham DH1 3LE :
: Phone: +44 191 334 2752 U.K. :
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems