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