Support standard deviation and json output for job stats

In the job stats, in addition to the max, min and average,
it will also display the standard deviation.

A new option --json is added to the rdci to output the results
in json format.

In the job stats, using the GMT time instead of timestamp
for start and end time.

Change-Id: If245c4fc4854a1dc867f97ff5aa9112af7962eca
This commit is contained in:
Bill(Shuzhou) Liu
2020-07-14 15:20:08 -04:00
committed by Chris Freehill
parent 9efb55b06f
commit e6d910f67a
17 changed files with 515 additions and 112 deletions
+15 -1
View File
@@ -33,13 +33,18 @@ RdciSubSystem::RdciSubSystem():
, use_auth_(true)
, root_ca_("/etc/rdc/client/certs/rdc_cacert.pem")
, client_cert_("/etc/rdc/client/certs/rdc_client_cert.pem")
, client_key_("/etc/rdc/client/private/rdc_client_cert.key") {
, client_key_("/etc/rdc/client/private/rdc_client_cert.key")
, is_json_output_(false) {
rdc_status_t status = rdc_init(0);
if (status != RDC_ST_OK) {
throw RdcException(status, "RDC initialize fail");
}
}
bool RdciSubSystem::is_json_output() const {
return is_json_output_;
}
bool RdciSubSystem::get_field_id_from_name(
const std::string& name, uint32_t& value) const {
const std::map<std::string, uint32_t> field_name_to_id = {
@@ -154,6 +159,11 @@ void RdciSubSystem::show_common_usage() const {
<< "information and exits.\n";
}
void RdciSubSystem::set_json_output(bool is_json) {
is_json_output_ = is_json;
std::cout << "{";
}
RdciSubSystem::~RdciSubSystem() {
if (rdc_handle_) {
rdc_disconnect(rdc_handle_);
@@ -161,6 +171,10 @@ RdciSubSystem::~RdciSubSystem() {
}
rdc_shutdown();
if (is_json_output_) {
std::cout << "}" << std::endl;
}
}
} // namespace rdc