#!/usr/bin/perl
## -*- mode: perl; indent-tabs-mode: t; perl-indent-level: 4 -*-
## vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=perl

# Usage: pbench-get-primary-metric <elasticsearch-hostname-and-port> <iteration-id>
#
# You can get the iteraton-id with pbench-get-iterations.
# 
# This script will output the primary metric for the benchmark.
# For example, this is "iops" for Fio.

use strict;
use warnings;
use File::Basename;
use File::Find;
use REST::Client;
use Time::HiRes qw(gettimeofday);

use lib $ENV{'pbench_lib_dir'};
use JSON::MaybeXS;
use Data::Dumper;
use PbenchES qw(get_primary_metric);
use PbenchCDM qw(get_cdm_ver get_cdm_rel);
use PbenchBase qw(get_json_file put_json_file remove_element);

if (scalar @ARGV != 2) {
    print "Usage: pbench-get-metrics <elasticsearch-hostname-and-port> <iteration-id>\n";
    exit 1;
}
my $debug = 0;
my $script_name = basename($0);
my $es_host = shift(@ARGV);
my $iter_id = shift(@ARGV);
my $depth = shift;
my $coder = JSON::MaybeXS->new->ascii->canonical;
my $primary_metric = get_primary_metric($es_host, $iter_id);
printf "%s\n", $primary_metric;
