summaryrefslogtreecommitdiffstats
path: root/plugins-scripts/utils.pm.in
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts/utils.pm.in')
-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;