Annotation of nagios/check_bioctl/utils.pm, Revision 1.1
1.1 ! andrew 1: # Utility drawer for Nagios plugins.
! 2: # $Id: utils.pm,v 1.1 2006/05/02 15:55:24 andrew Exp $
! 3: #
! 4: # $Log: utils.pm,v $
! 5: # Revision 1.1 2006/05/02 15:55:24 andrew
! 6: # This utils.pm is from the nagios plugins project, I just have it here for ease of development.
! 7: #
! 8: # Revision 1.7 2003/04/13 04:25:36 sghosh
! 9: # update for check_mailq - qmail support
! 10: #
! 11: # Revision 1.6 2003/02/03 20:29:55 sghosh
! 12: # change ntpdc to ntpq (Jonathan Rozes,Thomas Schimpke, bug-656237 )
! 13: #
! 14: # Revision 1.5 2002/10/30 05:07:29 sghosh
! 15: # monitor mailq
! 16: #
! 17: # Revision 1.4 2002/05/27 02:01:09 sghosh
! 18: # new var - smbclient
! 19: #
! 20: # Revision 1.3 2002/05/10 03:49:22 sghosh
! 21: # added programs to autoconf
! 22: #
! 23: # Revision 1.2 2002/05/08 05:10:35 sghosh
! 24: # is_hostname added, update CODES to POSIX
! 25: #
! 26: #
! 27: package utils;
! 28:
! 29: require Exporter;
! 30: @ISA = qw(Exporter);
! 31: @EXPORT_OK = qw($TIMEOUT %ERRORS &print_revision &support &usage);
! 32:
! 33: #use strict;
! 34: #use vars($TIMEOUT %ERRORS);
! 35: sub print_revision ($$);
! 36: sub usage;
! 37: sub support();
! 38: sub is_hostname;
! 39:
! 40: ## updated by autoconf
! 41: $PATH_TO_RPCINFO = "/usr/bin/rpcinfo" ;
! 42: $PATH_TO_NTPDATE = "/usr/local/sbin/ntpdate" ;
! 43: $PATH_TO_NTPDC = "/usr/local/sbin/ntpdc" ;
! 44: $PATH_TO_NTPQ = "/usr/local/sbin/ntpq" ;
! 45: $PATH_TO_LMSTAT = "" ;
! 46: $PATH_TO_SMBCLIENT = "/usr/local/bin/smbclient" ;
! 47: $PATH_TO_MAILQ = "/usr/bin/mailq";
! 48: $PATH_TO_QMAIL_QSTAT = "";
! 49:
! 50: ## common variables
! 51: $TIMEOUT = 15;
! 52: %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
! 53:
! 54: ## utility subroutines
! 55: sub print_revision ($$) {
! 56: my $commandName = shift;
! 57: my $pluginRevision = shift;
! 58: $pluginRevision =~ s/^\$Revision: //;
! 59: $pluginRevision =~ s/ \$\s*$//;
! 60: print "$commandName (nagios-plugins 1.4) $pluginRevision\n";
! 61: print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugins under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n";
! 62: }
! 63:
! 64: sub support () {
! 65: my $support='Send email to nagios-users@lists.sourceforge.net if you have questions\nregarding use of this software. To submit patches or suggest improvements,\nsend email to nagiosplug-devel@lists.sourceforge.net.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n';
! 66: $support =~ s/@/\@/g;
! 67: $support =~ s/\\n/\n/g;
! 68: print $support;
! 69: }
! 70:
! 71: sub usage {
! 72: my $format=shift;
! 73: printf($format,@_);
! 74: exit $ERRORS{'UNKNOWN'};
! 75: }
! 76:
! 77: sub is_hostname {
! 78: my $host1 = shift;
! 79: 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]+)*)$/) {
! 80: return 1;
! 81: }else{
! 82: return 0;
! 83: }
! 84: }
! 85:
! 86: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>