[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/usr/share/se3/scripts-alertes/ -> utils.pm (source)

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


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1