Jeylox has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use DBI; #Activer le module DBD pour perl # Chargement du module use Monitoring::Plugin; # Definition de l'environnement BEGIN { $ENV{ORACLE_HOME} = "/home/oracle/oracle/product/11.2.0/dbhome_ +1"; } # Appel du module et règle de la commande my $oracle_connector = Monitoring::Plugin->new( shortname => 'File attente de datatable', usage => 'Usage : %s [ -c|--critical=<threshold> ] [ -w|--warning=<threshol +d> ]', ); # Définition de l'argument warning $oracle_connector->add_arg( spec => 'warning|w=f', + # Nous acceptons des nombres réels help => 'Exit with WARNING status if less than REQUEST', label => 'REQUEST', required => 1, ); # Définition de l'argument critical $oracle_connector->add_arg( spec => 'critical|c=f', help => 'Exit with CRITICAL status if less than REQUEST', label => 'REQUEST', required => 1, ); $oracle_connector->getopts; # Connection à la base my $db=DBI->connect("dbi:Oracle:AXIBASE", "AXINX","AXINX") or die( $DBI::errstr . "\n" ); # Requetes SQL my $sql = qq/SELECT COUNT (*) from schema.table1 UNION ALL SELECT COUNT (*) from schema.table2 UNION ALL SELECT COUNT (*) from schema.table3/; my $sth = $db->prepare($sql); $sth->execute(); my $data = $sth->fetchall_arrayref(); $sth->finish; foreach $data ( @$data) { (my $variable1,my $variable2,my $variable3) = @$data; # print "$variable1\n"; # print "$variable2\n"; my $code_retour = $oracle_connector->check_threshold( check => $data, warning => $oracle_connector->opts->warning, critical => $oracle_connector->opts->critical, ); $oracle_connector->plugin_exit( $code_retour, "File attente (@$data)" +); }
Edit: Finally i create a variable for my table and each time i have the return code of the plugin exit only for the table i asked. Thank you everyone for the help :)[root@BAC libexec]# ./check_oracle_connector -w 10 -c 20 File attente de datatable CRITICAL - File attente (170)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating a perl script for database monitoring
by hippo (Archbishop) on Apr 08, 2016 at 12:37 UTC | |
by Jeylox (Initiate) on Apr 08, 2016 at 13:09 UTC | |
by SimonPratt (Friar) on Apr 08, 2016 at 13:25 UTC | |
by poj (Abbot) on Apr 08, 2016 at 13:49 UTC | |
by Jeylox (Initiate) on Apr 08, 2016 at 15:23 UTC | |
by poj (Abbot) on Apr 08, 2016 at 15:41 UTC | |
|
Re: Creating a perl script for database monitoring
by Corion (Patriarch) on Apr 08, 2016 at 12:33 UTC |