[Nagiosplug-devel] Nagios plugin options -4 and -6

Jeremy T. Bouse jeremy+nagios at undergrid.net
Fri Jun 27 12:25:12 CEST 2003


	In looking how best to impliment the -4 and -6 options to the
plugins in order to explicitly use IPv6 or IPv4 hosts as opposed to
having the resolver return both and cycle through them till one succeeds
or the all fail I've come up with a few thoughts I'd like to get input
on...

	1) my_connect() in netutils.c seems to be the most ideal place
for this to take place as the hints.ai_family declaration can be coded
to specify AF_INET or AF_INET6 rather than AF_UNSPEC which returns
either. Note: Currently uses PF_UNSPEC which I will be changing to
AF_UNSPEC. It may require some inclusion into the verification functions
to make sure we don't try to verify a host as IPv4 only but try to
connect to IPv6 or vice versa but they should be trivial once
implimented in my_connect.

	2) I noticed check_by_ssh.c already has a -4 and -6 options (or
--use-ipv4 and --use-ipv6 long options) which do nothing but pass
through to the command line call to ssh... 

	3) Given that yes STD_LONG_OPTS could be extended to include the
long options for -4 and -6 it wouldn't make sense since utils.h is
included into plugins whether they use network calls or not... Also it
would still require modification to all network plugins to include the
options into their switch/case structure as there is no uniformed way to
change it in all plugins unilaterally...

	With that in mind my thought is to add a external int
declaration to netutils.h which we'll default to 0 (zero) then during
command line option parsing set it to the appropriate value of AF_INET
or AF_INET6 otherwise leave it as 0 which would be AF_UNSPEC then
hints.ai_family would be set to this value in my_connect.

	What this allows is the current operation is the default... But
once a plugin has been modified to set the value it would then allow it
to be able to include the -4 and -6 options correctly by insuring that
the extern variable was set accordingly... This would only be available
to those plugins which include netutils.h, of which I only count about a
dozen...

	If there were some way to have a standard #define that could be
used inline in the switch/case to include this option parsing it would
be great but I can't think of how to do so correctly and would welcome
some ideas... Also what should be make this extern variable called? I'd
opt for af_family but don't want it getting confused else where. Maybe
use_protocol?

	Regards,
	Jeremy




More information about the Devel mailing list