[Nagiosplug-devel] Nagios:Plugin feedback

Thomas Guyot-Sionnest dermoth at aei.ca
Fri Jan 19 03:40:45 CET 2007

On 18/01/07 09:12 PM, Andreas Ericsson wrote:
> Thomas Guyot-Sionnest wrote:
>> I just switched two of my checks (BigIP checks I put on NagiosExchange under
>> the name 'dermoth') to Nagios::Plugin. Since it's still brand new I though
>> you would like to hear some feedback :)
>> First of all it's awesome! Most of my functions and multi-line conditional
>> statements were replaced by one-liners. Makes the code much simpler thus
>> leaving more room for debug code and enhancements. The interface is simple
>> yet powerful.
>> Questions:
>> Is there a is_hostname function? is_ipaddr would be useful as well.
> This is a common misconception and thoroughly annoying when encountered.
> Resolver functions already recognize IP-addresses and return them
> immediately in case one is passed to them as a hostname, so detecting if
> something is a valid ip-address or not is not necessary.

That one actually isn't. In the particular script I was talking about
I'm embedding an IP address into an OID, so that would be a good check.

Same if you write a DNS check and when to match against an IP address.

But it's also true that Nagios::Plugins shouldn't drive ppl into bad
habits. I think I was too lazy to write something like
'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})' then check the range for
$1, $2, $3 and $4 :)

> Properly detecting if something is a valid hostname is an equally bogus
> activity, because people invariably make such functions overly strict.
> Again, the resolver will tell you if the name you chuck at it resolves
> to an IP-address or not, and that's really all you need to know.

True and false. While a resolver will chuck on any badly-formated
hostname, it's not bad practice when passing a hostname to a program to
make sure it doesn't contain any shell-interpretable character.

Ok, you make a point there. Can we have a is_shellclean function? :)


More information about the Devel mailing list