Announcement

Collapse
No announcement yet.

[REGLE] Hylafax

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [REGLE] Hylafax

    Le plug que j ai trouvé ne fonctionne pas !
    qui a une idée

    ./check_hylafax.pl -H 192.168.0.8 -w 5 -c 15
    Insecure dependency in connect while running with -T switch at /usr/lib/perl/5.8/IO/Socket.pm line 114.
    [email protected]:/usr/local/nagios/libexec$


    Code:
    #! /usr/bin/perl -wT
    
    use strict;
    use Getopt::Long;
    use vars qw($opt_V $opt_h $opt_H $opt_P $opt_w $opt_c $opt_l $opt_p $PROGNAME);
    use lib "/usr/lib/nagios/plugins" ;
    use utils qw(%ERRORS &print_revision &support &usage);
    use Net::FTP;
    
    $PROGNAME = "check_hylafax";
    
    sub print_help ();
    sub print_usage ();
    
    $ENV{'PATH'}='';
    $ENV{'BASH_ENV'}=''; 
    $ENV{'ENV'}='';
    
    Getopt::Long::Configure('bundling');
    GetOptions
    	("V"   => \$opt_V, "version"    => \$opt_V,
    	 "h"   => \$opt_h, "help"       => \$opt_h,
    	 "w=s" => \$opt_w, "warning=s"  => \$opt_w,
    	 "c=s" => \$opt_c, "critical=s" => \$opt_c,
    	 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
    	 "P=i" => \$opt_P, "port=i" => \$opt_P,
    	 "l=s" => \$opt_l, "login=s" => \$opt_l,
    	 "p=s" => \$opt_p, "password=s" => \$opt_p,
    );
    
    if ($opt_V) {
    	print_revision($PROGNAME,'$Revision: 1.0 $');
    	exit $ERRORS{'OK'};
    }
    
    if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
    
    my $host = ($opt_H ? $opt_H : "localhost");
    usage("Invalid host: $opt_H\n") unless $host =~ /^[-.A-Za-z0-9]+$/;
    
    my $port = ($opt_P ? $opt_P : "4559");
    usage("Invalid port: $opt_P\n") unless ($port > 1 and $port < 32767);
    
    usage("Warning threshold not specified\n") if not $opt_w;
    my $warning = $opt_w;
    usage("Invalid warning threshold: $opt_w\n") unless $warning =~ /^\d+$/;
    
    usage("Critical threshold not specified\n") if not $opt_c;
    my $critical = $opt_c;
    usage("Invalid critical threshold: $opt_c\n") unless $critical =~ /^\d+$/;
    
    #($opt_c) || usage("Critical threshold not specified\n");
    #my $critical = $1 if ($opt_c =~ /([0-9]{1,2}|100)/);
    #($critical) || usage("Invalid critical threshold: $opt_c\n");
    
    my $sig=0;
    my $ftp = Net::FTP->new($host, Port => $port);
    if (not $ftp) {
    	print "ERROR: Can't connect to $opt_h: [email protected]\n";
    	exit $ERRORS{'UNKNOWN'};
    }
    if (not $ftp->login($opt_l, $opt_p)) {
    	print "ERROR: Can't login to $opt_h: [email protected]\n";
    	exit $ERRORS{'UNKNOWN'};
    }
    my @jobs = $ftp->ls("sendq");
    $ftp->quit;
    $sig = scalar(@jobs);
    
    my $err = "OK";
    if ($sig >= $critical) {
    	$err = "CRITICAL";
    } elsif ($sig >= $warning) {
    	$err = "WARNING";
    }
    print "$err: $sig jobs in queue\n";
    exit $ERRORS{$err};
    
    sub print_usage () {
    	print "Usage: $PROGNAME [-H host] [-P port] [-l login] [-p password] -w <warn> -c <crit>\n";
    	print "\n";
    	print "Required Arguments:\n";
    	print "  -w, --warning==INTEGER\n";
    	print "     generate warning state if job count is greater than this number\n";
    	print "  -c, --critical==INTEGER\n";
    	print "     generate critical state if job count is greater than this number\n";
    	print "\nOptional Arguments:\n";
    	print "  -H, --hostname=STRING\n";
    	print "     connect to this host. Default is localhost.\n";
    	print "  -P, --port=INTEGER\n";
    	print "     connect to this port. Default is 4559.\n";
    	print "  -l, --login=STRING\n";
    	print "     connect using this login name.\n";
    	print "  -p, --password=STRING\n";
    	print "     connect using this password.\n";
    	print "\n";
    }
    
    sub print_help () {
    	print_revision($PROGNAME,'$Revision: 1.0 $');
    	print "Created by Adam Fox, November 2004
    
    This plugin reports how many jobs are in a HylaFAX fax queue.
    
    ";
    	print_usage();
    	support();
    Last edited by WAtt; 11 May 2007, 10:25.

  • #2
    une lettre de trop .... et c est le bordel ...

    Grace a Watt mon check hylafax fonctionne

    il fallait enlever le T sur la ligne
    #! /usr/bin/perl -wT

    (premiere ligne du script )

    MERI WATT

    Comment


    • #3
      Merci de votre aide!!! Ca a marché!!!!!

      Je tiens juste à ajouter qu'il faut autoriser la machine Nagios à accéder à Hylafax dans le fichier hosts.hfaxd qui se trouve dans /var/spool/hylafax/etc/.

      Comment

      Working...
      X