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
| #!/usr/bin/perl -w
#
# bb-TEMPLATE - template for a Big Brother add-on
# cgoyard
use strict;
use Data::Dumper;
my $DEBUG = 0;
#------------------------------------------------------------------------------------------------------------
# VARIABLES MODIFIABLES
#--------------------------------------------------------------------------------------------------------
my $hostname = `hostname -f`;
chomp $hostname;
my $BB = $ENV{BB}; # full path to the bin/bb util
my $BBDISP = $ENV{BBDISP}; # IP of the BBDISPLAY server
#my $BB = "/usr/lib/hobbit/client/bin/bb";
#my $BBDISP = "10.3.254.1" ;
#my $BBTMP = "/var/lib/hobbit/tmp";
my $date = `date`; chomp $date;
my $test = "Import_kpi";
my $color = "green";
my $message = "Suivi des import dans Hybris\n";
my $status ;
my $tab_bgcolor = "#6E6E6E";
my $tab_width = "100%";
my $tab_header = "border=1 cellspacing='1' cellpadding='1' width=$tab_width align=center";
my $td_header = "style='background-color:\"#FF8000\";font-weight: bold;font-size:19;color:black;'";
my $image_green='<IMG SRC="/xymon/gifs/green.gif" ALT="green" HEIGHT="16" WIDTH="16" BORDER=0>';
my $image_red='<IMG SRC="/xymon/gifs/red.gif" ALT="red" HEIGHT="16" WIDTH="16" BORDER=0>';
my $image_yellow='<IMG SRC="/xymon/gifs/yellow.gif" ALT="yellow" HEIGHT="16" WIDTH="16" BORDER=0>';
my %test_names = ();
my %tableau = ();
my $i=0;
my %namembeans = (1,"BirdDeliveryMode",
2,"BirdDeliveryCalendar",
3,"ZoneDeliveryValue_piece",
4,"ZoneDeliveryValue_weight",
5,"ImageBrand",
6,"ImageBrandAssignment",
7,"ImagePictos",
8,"SupplyMode",
9,"ImagePictosAssignment",
10,"MainImageProducts",
11,"MainImageProductsAssignment",
12,"GalleryImageProducts",
13,"GalleryImageProductsAssignment",
14,"BirdBrand",
15,"ClassificationAttributeUnit",
16,"ClassificationClass",
17,"ClassificationAttribute",
18,"ClassificationAttributeAssignement",
19,"BirdProduct",
20,"BirdVariantProduct",
21,"BirdColorVariantDimension",
22,"BirdSizeVariantDimension",
23,"ArticleDefaultVariant",
24,"BirdBundle",
25,"BirdBundleComponent",
26,"BirdProductSet",
27,"ProductReference",
28,"Categoryattachement",
29,"CategoryProductRelation",
30,"ProductFeature",
31,"ProductFeatureFilter",
32,"PriceRow",
33,"BirdTaxParticipationRow",
34,"BirdPackage",
35,"BirdProductPackages",
36,"BirdProductSupplyModes",
37,"BirdProductDeliveryModes",
38,"ecat_stocklevel",
39,"Import MR",
41,"Proximité MR",
42,"Import Maxxing",
43,"Export Attribut Pertimm",
44,"Export Product Pertimm",
45,"Import Express",
46,"Proximité Express",
47,"Batch d'import des opérations commerciales",
48,"Batch d'import des relations produits <> offres",
49,"Batch d'import des relations catégories <> offres",
50,"Synchronisation Produits",
51,"Indexation SolR",
52,"Bazaarvoice Importer",
53,"Bazaarvoice Exporter",
54,"PaymentFacilityImport",
1000,"AutomatedProductRankingImport");
my $infos = `sudo -u hybris /usr/local/lib/jmx/launch.sh`;
my @values = split("\n", $infos);
$message = $message."<table $tab_header><td align=center $td_header ><center>Id</center></td>
<td align=center $td_header><center>Mbeans</enter></td>
<td align=center $td_header><center>Résultat d'intégration</center></td>
<td align=center $td_header><center>Pourcentage de lignes intégrées</center></td>
<td align=center $td_header><center>Nombre de lignes dans le fichie</center></td>
<td align=center $td_header><center>Temps d'intégration</center></td>
<td align=center $td_header><center>Date de démarrage d'intégration</center></td>
<td align=center $td_header><center>Date de fin d'intégration</center></td>
<td align=center $td_header<center>Statut d'intégration</center></td>";
foreach my $val (@values) {
if ($val =~ "Import_kpi") {
#print $val." test \n";
my @test_name_color_with_ncv_line = split("\\ ", $val, 2);
my $test_name = $test_name_color_with_ncv_line[0];
my $color_with_ncv_line = $test_name_color_with_ncv_line[1];
# print $color_with_ncv_line."\n";
if ( $color_with_ncv_line =~ /^(\d+\.?):(\D+):([A-Z].*)/ ) {push ( @{$tableau{$1}}, $3);}
# elsif ( $color_with_ncv_line =~ /^(\d+\.?):(\D+):(\d+)/ ) {$message=$message."<td>$1</td><td>$3</td>"}
elsif ( $color_with_ncv_line =~ /^(\d+\.?):(\D+):(\d+)/ ) {push ( @{$tableau{$1}}, $3);}
}
}
#print Dumper \%tableau;
foreach my $valt (sort {$a <=> $b} keys %tableau) {
#print "val => ".$valt."\n";
$status .= $namembeans{$valt}.": ";
$message=$message."<tr align=center><td> $valt </td><td> $namembeans{$valt} </td>";
while( my ($k,$v) = each($tableau{$valt}) ) {
if ($v eq "OK") {$v = "$image_green OK ";}
if ($v eq "WARNING") {$v = "$image_yellow WARNING ";}
if ($v eq "CRITICAL") {$v = "$image_red CRITICAL ";}
$message=$message."<td> $v </td>";
if ( $k ==3 ) {
$status .= $v."\n";
}
}
$message=$message."</tr>";
}
$message=$message."</tables>";
#$status .= "";
# Envoie au serveur
my $cmd = " $BB $BBDISP \"status $hostname.$test $color $date <HR> $message\n\n
<!--
$status-->
\n\"";
#print $cmd;
system($cmd); |
Partager