Annotation of nagios/check_pf_limits/utils.pm, Revision 1.1
1.1 ! andrew 1: # Utility drawer for Nagios plugins.
! 2: # $Id: utils.pm,v 1.1 2009/11/13 02:05:34 andrew Exp $
! 3: #
! 4: # $Log: utils.pm,v $
! 5: # Revision 1.1 2009/11/13 02:05:34 andrew
! 6: # support files, not actually needed.
! 7: #
! 8: # Revision 1.1 2006/05/02 15:55:24 andrew
! 9: # This utils.pm is from the nagios plugins project, I just have it here for ease of development.
! 10: #
! 11: # Revision 1.7 2003/04/13 04:25:36 sghosh
! 12: # update for check_mailq - qmail support
! 13: #
! 14: # Revision 1.6 2003/02/03 20:29:55 sghosh
! 15: # change ntpdc to ntpq (Jonathan Rozes,Thomas Schimpke, bug-656237 )
! 16: #
! 17: # Revision 1.5 2002/10/30 05:07:29 sghosh
! 18: # monitor mailq
! 19: #
! 20: # Revision 1.4 2002/05/27 02:01:09 sghosh
! 21: # new var - smbclient
! 22: #
! 23: # Revision 1.3 2002/05/10 03:49:22 sghosh
! 24: # added programs to autoconf
! 25: #
! 26: # Revision 1.2 2002/05/08 05:10:35 sghosh
! 27: # is_hostname added, update CODES to POSIX
! 28: #
! 29: #
! 30: package utils;
! 31:
! 32: require Exporter;
! 33: @ISA = qw(Exporter);
! 34: @EXPORT_OK = qw($TIMEOUT %ERRORS &print_revision &support &usage);
! 35:
! 36: #use strict;
! 37: #use vars($TIMEOUT %ERRORS);
! 38: sub print_revision ($$);
! 39: sub usage;
! 40: sub support();
! 41: sub is_hostname;
! 42:
! 43: ## updated by autoconf
! 44: $PATH_TO_RPCINFO = "/usr/bin/rpcinfo" ;
! 45: $PATH_TO_NTPDATE = "/usr/local/sbin/ntpdate" ;
! 46: $PATH_TO_NTPDC = "/usr/local/sbin/ntpdc" ;
! 47: $PATH_TO_NTPQ = "/usr/local/sbin/ntpq" ;
! 48: $PATH_TO_LMSTAT = "" ;
! 49: $PATH_TO_SMBCLIENT = "/usr/local/bin/smbclient" ;
! 50: $PATH_TO_MAILQ = "/usr/bin/mailq";
! 51: $PATH_TO_QMAIL_QSTAT = "";
! 52:
! 53: ## common variables
! 54: $TIMEOUT = 15;
! 55: %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
! 56:
! 57: ## utility subroutines
! 58: sub print_revision ($$) {
! 59: my $commandName = shift;
! 60: my $pluginRevision = shift;
! 61: $pluginRevision =~ s/^\$Revision: //;
! 62: $pluginRevision =~ s/ \$\s*$//;
! 63: print "$commandName (nagios-plugins 1.4) $pluginRevision\n";
! 64: 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";
! 65: }
! 66:
! 67: sub support () {
! 68: 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';
! 69: $support =~ s/@/\@/g;
! 70: $support =~ s/\\n/\n/g;
! 71: print $support;
! 72: }
! 73:
! 74: sub usage {
! 75: my $format=shift;
! 76: printf($format,@_);
! 77: exit $ERRORS{'UNKNOWN'};
! 78: }
! 79:
! 80: sub is_hostname {
! 81: my $host1 = shift;
! 82: 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]+)*)$/) {
! 83: return 1;
! 84: }else{
! 85: return 0;
! 86: }
! 87: }
! 88:
! 89: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>