Code

Fix translations when extra-opts aren't enabled
[nagiosplug.git] / plugins-scripts / utils.pm.in
index e245835924cc32a3a8aa374bec3eaaed51d2809a..37cd62c3b8210f3476f0f3964491eb3a35e3caf3 100644 (file)
@@ -1,5 +1,4 @@
 # Utility drawer for Nagios plugins.
-# $Id$
 #
 # This will be deprecated soon. Please use Nagios::Plugin from CPAN
 # for new plugins
@@ -32,9 +31,7 @@ $TIMEOUT = 15;
 sub print_revision ($$) {
        my $commandName = shift;
        my $pluginRevision = shift;
-       $pluginRevision =~ s/^\$Revision: //;
-       $pluginRevision =~ s/ \$\s*$//;
-       print "$commandName (@PACKAGE@ @VERSION@) $pluginRevision\n";
+       print "$commandName v$pluginRevision (@PACKAGE@ @VERSION@)\n";
        print "@WARRANTY@";
 }
 
@@ -53,9 +50,16 @@ sub usage {
 
 sub is_hostname {
        my $host1 = shift;
-       if ($host1 && $host1 =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z0-9][-a-zA-Z0-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*)$/) {
+       return 0 unless defined $host1;
+       if ($host1 =~ m/^[\d\.]+$/ && $host1 !~ /\.$/) {
+               if ($host1 =~ m/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
+                       return 1;
+               } else {
+                       return 0;
+               }
+       } elsif ($host1 =~ m/^[a-zA-Z0-9][-a-zA-Z0-9]*(\.[a-zA-Z0-9][-a-zA-Z0-9]*)*\.?$/) {
                return 1;
-       }else{
+       } else {
                return 0;
        }
 }