Commit dbf78846 authored by Olav Kvittem's avatar Olav Kvittem
Browse files

added varian-option

parent 0331f421
......@@ -12,18 +12,20 @@ use JSON;
my $debug=0;
my $index="uninett";
my $event_type="gapsum";
my $variant;
use Getopt::Long;
my ( $date, $opt_v, $opt_h);
my $usage="Usage\n$0
-index <index> (uninett)
-variant <variant> (mp-<index>)
-index <index> (uninett)
-date <yyyy-mm-dd> (yesterday)
-event_type <type> (jitter)
-v - print summary stats at end
-debug
";
GetOptions('index=s'=> \$index, 'date=s'=>\$date, 'event_type=s'=>\$event_type, 'v'=>\$opt_v, 'h'=>\$opt_h, 'debug=s'=>\$debug) or die "$usage : $!" ;
GetOptions( 'variant=s'=>\$variant, 'index=s'=> \$index, 'date=s'=>\$date, 'event_type=s'=>\$event_type, 'v'=>\$opt_v, 'h'=>\$opt_h, 'debug=s'=>\$debug) or die "$usage : $!" ;
die $usage if $opt_h;
if ( ! $date ){
......@@ -31,7 +33,8 @@ if ( ! $date ){
chomp $date;
}
my $config_dir="/var/lib/microdep/mp-$index";
$variant="mp-$index" if ! $variant;
my $config_dir="/var/lib/microdep/$variant";
my $mp_list="$config_dir/etc/mp-address.txt";
my $database="$config_dir/etc/microdep.db";
......@@ -49,11 +52,13 @@ my $end=`date --date ${date}T23:59:59 +%s`; chomp $end;
connect_db();
my @pairs = do_select( 'SELECT from_name, to_name FROM peers WHERE start < ' . $end . ' AND end > ' . $start . ' ORDER BY from_name, to_name LIMIT 10000;' );
$;=" - ";
my $es_txt=get_elastic();
my $es = decode_json $es_txt || die "Could not decode json : $!";
my %es_pair=();
my %cf_pair=();
my $yes=0, my $no=0;
printf "Check ES vs config for $index $event_type for $date\n\n";
printf "Check config vs ES for $index $event_type for $date\n\n";
if ( $es->{hits}{total}{value} > 0){
foreach my $hit ( @{$es->{hits}{hits}} ){
my $r=$hit->{_source};
......@@ -62,6 +67,7 @@ if ( $es->{hits}{total}{value} > 0){
for ( my $i=0; $i <= $#pairs; $i++){
my ( $a, $b ) = ( $pairs[$i][0], $pairs[$i][1] );
$cf_pair{$a,$b}++;
if ( ! $es_pair{ $a, $b } ){
printf "no data for: %s - %s \n", $a, $b;
$no++;
......@@ -70,9 +76,21 @@ if ( $es->{hits}{total}{value} > 0){
$yes++;
}
}
printf "\nTotal Ayes $yes, Nayes $no\n";
printf "\nTotal Ayes $yes, Nayes $no\n";
printf "\nChecking ES vs config\n";
my $es_no=0; my $es_yes=0;
foreach my $pair(keys %es_pair){
if ( !$cf_pair{ $pair } ){
printf "no config for: %s \n", $pair;
$es_no++;
} else {
$es_yes++;
}
}
printf "\nTotal Ayes $es_yes, Nayes $es_no\n";
} else {
printf "No data found is es for $index $event_type $date\n";
printf "No data found in ES for $index $event_type $date\n";
}
exit (0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment