summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubhendu Ghosh <sghosh@users.sourceforge.net>2002-05-08 05:10:35 (GMT)
committerSubhendu Ghosh <sghosh@users.sourceforge.net>2002-05-08 05:10:35 (GMT)
commit0976cd742c310675b771bf59ebc689864e70c107 (patch)
treee4a3e1f927dd30a0f171f3b22f5dede5f2c86079
parent3f9ccbd2da5bd99967bac0efc7dfc5bb37e72b47 (diff)
downloadmonitoring-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
-rw-r--r--plugins-scripts/utils.pm.in20
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#
1package utils; 9package utils;
2 10
3require Exporter; 11require Exporter;
@@ -9,9 +17,10 @@ require Exporter;
9sub print_revision ($$); 17sub print_revision ($$);
10sub usage; 18sub usage;
11sub support(); 19sub support();
20sub 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
16sub print_revision ($$) { 25sub 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
47sub 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
381; 561;