diff options
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2002-05-08 05:10:35 (GMT) |
---|---|---|
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2002-05-08 05:10:35 (GMT) |
commit | 0976cd742c310675b771bf59ebc689864e70c107 (patch) | |
tree | e4a3e1f927dd30a0f171f3b22f5dede5f2c86079 /plugins-scripts/utils.pm.in | |
parent | 3f9ccbd2da5bd99967bac0efc7dfc5bb37e72b47 (diff) | |
download | monitoring-plugins-0976cd742c310675b771bf59ebc689864e70c107.tar.gz |
is_hostname added, update CODES to POSIX
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@26 f882894a-f735-0410-b71e-b25c423dba1c
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; |