mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 09:58:54 +00:00
executing query monitor under killswitch (#5170)
This commit is contained in:
parent
f7213ef9b4
commit
c301e361ca
@ -2,12 +2,11 @@
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under both the Apache 2.0 license (found in the
|
||||
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||
* in the COPYING file in the root directory of this source tree).
|
||||
* You may select, at your option, one of the above-listed licenses.
|
||||
* This source code is licensed under both the Apache 2.0 license (found in
|
||||
* the LICENSE file in the root directory of this source tree) and the GPLv2
|
||||
* (found in the COPYING file in the root directory of this source tree). You
|
||||
* may select, at your option, one of the above-listed licenses.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
@ -32,6 +31,10 @@ class Killswitch : private boost::noncopyable {
|
||||
public:
|
||||
virtual ~Killswitch();
|
||||
|
||||
// Author: @guliashvili
|
||||
// Creation Time: 3/09/2018
|
||||
bool isExecutingQueryMonitorEnabled();
|
||||
|
||||
// Author: @guliashvili
|
||||
// Creation Time: 24/08/2018
|
||||
bool isConfigBackupEnabled();
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <osquery/core.h>
|
||||
#include <osquery/database.h>
|
||||
#include <osquery/flags.h>
|
||||
#include <osquery/killswitch.h>
|
||||
#include <osquery/logger.h>
|
||||
#include <osquery/numeric_monitoring.h>
|
||||
#include <osquery/query.h>
|
||||
@ -178,11 +179,14 @@ inline void launchQueryWithProfiling(const std::string& name,
|
||||
auto status = launchQuery(name, query);
|
||||
auto query_duration = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - start_time_point);
|
||||
auto monitoring_path = boost::format("scheduler.executing_query.%s.%s") %
|
||||
name % (status.ok() ? "success" : "failure");
|
||||
monitoring::record(monitoring_path.str(),
|
||||
query_duration.count(),
|
||||
monitoring::PreAggregationType::Min);
|
||||
if (Killswitch::get().isExecutingQueryMonitorEnabled()) {
|
||||
auto monitoring_path = boost::format("scheduler.executing_query.%s.%s") %
|
||||
name % (status.ok() ? "success" : "failure");
|
||||
|
||||
monitoring::record(monitoring_path.str(),
|
||||
query_duration.count(),
|
||||
monitoring::PreAggregationType::Min);
|
||||
}
|
||||
}
|
||||
|
||||
void SchedulerRunner::start() {
|
||||
|
@ -32,6 +32,10 @@ FLAG(string,
|
||||
Killswitch::Killswitch() {}
|
||||
Killswitch::~Killswitch() = default;
|
||||
|
||||
bool Killswitch::isExecutingQueryMonitorEnabled() {
|
||||
return isNewCodeEnabled("executingQueryMonitorSwitch");
|
||||
}
|
||||
|
||||
bool Killswitch::isConfigBackupEnabled() {
|
||||
return isNewCodeEnabled("configBackupSwitch");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user