diff options
Diffstat (limited to 'plugins-scripts/utils.pm.in')
-rw-r--r-- | plugins-scripts/utils.pm.in | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in index 361bfe9..ed105dd 100644 --- a/plugins-scripts/utils.pm.in +++ b/plugins-scripts/utils.pm.in | |||
@@ -1,3 +1,11 @@ | |||
1 | # Utility drawer for Nagios plugins. | ||
2 | # $Id$ | ||
3 | # | ||
4 | # $Log$ | ||
5 | # Revision 1.2 2002/05/08 05:10:35 sghosh | ||
6 | # is_hostname added, update CODES to POSIX | ||
7 | # | ||
8 | # | ||
1 | package utils; | 9 | package utils; |
2 | 10 | ||
3 | require Exporter; | 11 | require Exporter; |
@@ -9,9 +17,10 @@ require Exporter; | |||
9 | sub print_revision ($$); | 17 | sub print_revision ($$); |
10 | sub usage; | 18 | sub usage; |
11 | sub support(); | 19 | sub support(); |
20 | sub is_hostname; | ||
12 | 21 | ||
13 | $TIMEOUT = 15; | 22 | $TIMEOUT = 15; |
14 | %ERRORS=('UNKNOWN'=>-1,'OK'=>0,'WARNING'=>1,'CRITICAL'=>2); | 23 | %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); |
15 | 24 | ||
16 | sub print_revision ($$) { | 25 | sub print_revision ($$) { |
17 | my $commandName = shift; | 26 | my $commandName = shift; |
@@ -35,4 +44,13 @@ sub usage { | |||
35 | exit $ERRORS{'UNKNOWN'}; | 44 | exit $ERRORS{'UNKNOWN'}; |
36 | } | 45 | } |
37 | 46 | ||
47 | sub is_hostname { | ||
48 | my $host1 = shift; | ||
49 | if ($host1 && $host1 =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z][-a-zA-Z0-9]+)*)$/) { | ||
50 | return 1; | ||
51 | }else{ | ||
52 | return 0; | ||
53 | } | ||
54 | } | ||
55 | |||
38 | 1; | 56 | 1; |