1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
| #!/usr/bin/perl
###################################################################################
#
# Script d'agregation hebdo des compteurs + suppression de l'historique > 6 mois
#
###################################################################################
use DBI;
use POSIX qw(strftime mktime);
use POSIX qw(strftime mktime);
use Date::Calc qw(:all);
use Date::Format qw(time2str);
use Getopt::Std;
use strict;
use warnings;
use diagnostics;
###################################################
# #
# Fonctions #
# #
###################################################
#ATENTION un debug a 5 va afficher beaucoups d'information a utiliser seulement en cas de besoin!
my $debug = 1;
my $dbh = DBI->connect( "dbi:mysql:dbname=$baseQFVD;host=$hostQFVD;",$loginQFVD,$passwordQFVD);
#calcul date Lundi et Dimanche de $semaine $annee
my $annee;
my $semaine;
my $req;
my $firstDayOfYear = mktime (0, 0, 0, 1, 0, $annee-1900, 0, 0, -1);
my $firstDayOfYearNumber = strftime "%u", localtime($firstDayOfYear);
my $Sunday = ($firstDayOfYear + (86400*7*$semaine)) - ($firstDayOfYearNumber * 86400);
my $Monday = $Sunday - (6*86400);
my @tableResEricsson;
my @tableResCisco;
my @tableRouteurEricsson;
my @tableRouteurCisco;
my @interfaceRouteurEricsson;
my @interfaceRouteurCisco;
my @tableDateEricsson;
my @tableDateCisco;
my @tableIndCisco;
my @tableIndEricsson;
my @indicateursCisco;
my @indicateursEricsson;
my $base;
#####################################
####### SELECTION DES NODES #########
#####################################
#$reqNode = select_sql1('Nodes','Node,Constructeur','Node LIKE "SG%"');
my $reqNode = $dbh->prepare('Select Node,Constructeur FROM Nodes WHERE Node LIKE "SG%"');
my $res = $reqNode->execute();
ref $res;
while (my($Node, $Constructeur) = $res->fetchrow_array)
{
if ($Constructeur eq "ERICSSON")
{
push(@tableResEricsson, $Node);
}
else
{
push(@tableResCisco, $Node);
}
}
foreach (@tableResEricsson)
{
print 'tab $_ \n';
}
foreach (@tableResCisco)
{
print 'tab $_ \n';
}
print 'njnjnjnj';
###############################################################
########### SELECTION DU NOM DES DIFFERENTS ROUTEURS ##########
###############################################################
for (my $i = 0 ; $i < scalar(@tableResEricsson) ; $i++)
{
my $sql = $dbh->prepare('SELECT Routeur FROM CorrespondanceVLANSGSNGn WHERE SGSN="'.$tableResEricsson[$i].'"');
while ($tableRouteurEricsson = $req->fetchrow_hashref()) {} // ERREUR ICI
}
for (my $i = 0 ; $i < scalar(@tableResCisco) ; $i++)
{
my $sql = $dbh->prepare('SELECT Routeur FROM CorrespondanceVLANSGSNGn WHERE SGSN="'.$tableResCisco[$i].'"');
while ($tableRouteurCisco = $req->fetchrow_hashref()) {} // ERREUR ICI
}
######################################################################
########### SUPPRESSION DES VIDES DANS LES TABLES ##########
######################################################################
@tableRouteurEricsson = grep {$_>0} @tableRouteurEricsson;
@tableRouteurCisco = grep {$_>0} @tableRouteurCisco;
#################################################################
########### SELECTION DES INTERFACES I/0 DES ROUTEURS ###########
#################################################################
for (my $i = 0 ; $i < scalar(@tableResEricsson) ; $i++)
{
my $sql = $dbh->prepare('SELECT InGn1_cq, OutGn1_cq, InGn2_cq, OutGn2_cq FROM CorrespondanceVLANSGSNGn WHERE SGSN="'.$tableResEricsson[$i].'"');
while ($interfaceRouteurEricsson = $req->fetchrow_hashref()) {} // ERREUR ICI
}
for (my $i = 0 ; $i < scalar(@tableResCisco) ; $i++)
{
my $sql = $dbh->prepare('SELECT InGb1_cq, OutGb1_cq,InGb2_cq, OutGb2_cq FROM CorrespondanceVLANSGSNGn WHERE SGSN="'.$tableResCisco[$i].'"');
while ($interfaceRouteurCisco = $req->fetchrow_hashref()) {} // ERREUR ICI
}
######################################################################
########### SUPPRESSION DES VIDES DANS LES TABLES ##########
######################################################################
@interfaceRouteurEricsson = grep {$_>0} @interfaceRouteurEricsson;
@interfaceRouteurCisco = grep {$_>0} @interfaceRouteurCisco;
$dbh->disconnect();
$dbh = DBI->connect( "dbi:mysql:dbname=$baseVoix;host=$hostVoix;",$loginVoix,$passwordVoix) or die print_log("ERROR : Echec connexion $base:$! \n");
#################################################################
########### SELECTION DES TABLES INDICATEURS ##########
#################################################################
for (my $i = 0 ; $i < scalar(@tableRouteurEricsson) ; $i++)
{
$tableIndEricsson[$i] = 'indicateur_'.$tableRouteurEricsson[$i].'';
}
#################################################################
########### SELECTION DES TABLES INDICATEURS ##########
#################################################################
for (my $i = 0 ; $i < scalar(@tableRouteurCisco) ; $i++)
{
$tableIndCisco[$i] = 'indicateur_'.$tableRouteurCisco[$i].'';
}
####################################################################
########### RANGEMENT DES ID_INDICATEUR ERICSSON ##########
####################################################################
for (my $i = 0 ; $i < scalar(@tableIndEricsson) ; $i++)
{
for (my $j = 0 ; $j < scalar(@interfaceRouteurEricsson) ; $j++)
{
my $req2 = 'SELECT ID_indicateur FROM '.$tableIndEricsson[$i].' WHERE indicateur = "'.$interfaceRouteurEricsson[$j].'"';
my $req = mysql_query($req2);
$indicateursEricsson = mysql_result($req,0); // ERREUR ICI
}
}
#################################################################
########### RANGEMENT DES ID_INDICATEUR CISCO ##########
#################################################################
for (my $i = 0 ; $i < scalar(@tableIndCisco) ; $i++)
{
for (my $j = 0 ; $j < scalar(@interfaceRouteurCisco) ; $j++)
{
my $req2 = 'SELECT ID_indicateur FROM '.$tableIndCisco[$i].' WHERE indicateur = "'.$interfaceRouteurCisco[$j].'"';
my $req = mysql_query($req2);
$indicateursCisco = mysql_result($req,0); // ERREUR ICI
}
}
########################################################################################
########### CREATION DES TABLES QUI CONTIENNENT LES ID_INDICATEURS ###########
########################################################################################
for (my $i = 0 ; $i < scalar(@tableRouteurEricsson) ; $i++)
{
$tableDateEricsson[$i] = ''.$tableRouteurEricsson[$i].'_'.$semaine.'_'.$annee.'';
}
for (my $i = 0 ; $i < scalar(@tableRouteurCisco) ; $i++)
{
$tableDateCisco[$i] = ''.$tableRouteurCisco[$i].'_'.$semaine.'_'.$annee.'';
}
foreach (@tableDateCisco)
{
print '$_ \n';
}
exit; |
Partager