Tom's Guide > Forum > Programmation > Informations sur script perl s'il-vous-plait, merci

Informations sur script perl s'il-vous-plait, merci

Forum Programmation : Informations sur script perl s'il-vous-plait, merci

TomsGuide.com : 800 000 inscrits répondent à toutes vos questions high-tech et informatique. Pour obtenir de l'aide, inscrivez-vous gratuitement !
Mot :    Pseudo :           
 

Bonjour,

Je suis novice en perl :( et j'aimerais, par le biais de vos connaissances :ange: , avoir un maximum d' informations sur le script suivant :??: :

(si je me trompe pas, ce script permet la surveillance d'une base de donnée oracle avec un logicel de supervison (que j'utilise) qui est Zabbix)


#!/usr/bin/perl

# script to monitor how much takes an oracle database to response
# original code from david eckelkamp


use strict;
use warnings;

use Parse::RecDescent;

use constant CONFIGFILE => "/home/zabbix/bin/chkora.cfg";

my $grammar = q {
file: section(s)
{
my %file;
for (@{$item[1]}) {
$file{$_->[0]} = $_->[1];
}
\%file;
}
section: header assign(s)
{
my %sec;
for (@{$item[2]}) {
push ( @{$sec{$_->[0]}}, $_->[1] );
}
[ lc($item[1]), \%sec ]
}
header: 'title' /[^\n]+/ { $item[2] }
assign: /(?!title)\w+/ /[^\n]+/
{ [lc($item[1]), $item[2]] }
};

my @hijos=();

my $parser=Parse::RecDescent->new($grammar);

my $text = "";
{
local $/ = undef;
open FICH, "<".CONFIGFILE or die "cant read input\n";
$text = <FICH>;
close(FICH);
}

my $tree = $parser->file($text);
for my $objeto (keys %$tree)
{
die "fork fail: $!" unless defined(my $kid = fork);

if ($kid) {
push @hijos, $kid;
while (my $crio = shift @hijos) { waitpid $crio, 0; }
} else {
my ($ldap, $entry, $mesg, $time1);
my $url=@{$tree->{$objeto}{'url'}}[0];
my $user=@{$tree->{$objeto}{'user'}}[0];
my $pass=@{$tree->{$objeto}{'pass'}}[0];
my $query=@{$tree->{$objeto}{'query'}}[0];
my $trap=@{$tree->{$objeto}{'zbxtrap'}}[0];

my ($host,$port,$sid)=$url=~m/(.+):(\d+):(\S+)/;

my $ora = qx{ /usr/bin/sqlplus $user/$pass@\\(DESCRIPTION=\\(ADDRESS=\\(PROTOCOL=TCP\\)\\(Host=$host\\)\\(Port=$port\\)\\)\\(CONNECT_DATA=\\(SID=$sid\\)\\)\\) <<EOF
set timing on;
set heading off;
set feedback off;
set trims on;
@{$tree->{$objeto}{'query'}};
exit
EOF };

my $valor="86400";
if ($ora=~m/Transcurrido:\s+(\S+):(\S+):(\S+)\.(\S+)/)
{
$valor=sprintf "%d.%d",($1*3600)+($2*60)+$3,$4;
$valor*=1;
}

my ($zbxserver,$zbxport,$zbxhost,$key)=$trap=~/^(.+):(\d+)@(.+)@(.+)$/;
system("/usr/local/sbin/zabbix_sender",("-z",$zbxserver,"-p",$zbxport,"-s",$zbxhost,"-k",$key,"-o",$valor));

exit 0;
}
}








En vous remerciant d'avance ;)

Liens sponsorisés
Inscrivez-vous ou connectez-vous pour masquer ceci.
Tom's Guide > Forum > Programmation > Informations sur script perl s'il-vous-plait, merci
Aller à :

Il y a 2359 utilisateurs connus et inconnus. Pour voir la liste des connectés connus, cliquez ici.

Attention

Vous allez répondre sur un sujet resté inactif pendant plus de 6 mois.
Assurez-vous d'apporter des éléments nouveaux à la discussion avant de poursuivre.

Répondre Annuler
Liens