osquery-1/tools/run.cpp

32 lines
749 B
C++
Raw Normal View History

// Copyright 2004-present Facebook. All Rights Reserved.
#include <gflags/gflags.h>
#include <glog/logging.h>
#include "osquery/core.h"
DEFINE_string(query, "", "query to execute");
DEFINE_int32(iterations, 1, "times to run the query in question");
int main(int argc, char* argv[]) {
2014-09-13 21:28:45 +00:00
osquery::initOsquery(argc, argv);
if (FLAGS_query != "") {
for (int i = 0; i < FLAGS_iterations; ++i) {
int err;
LOG(INFO) << "Executing: " << FLAGS_query;
2014-09-13 21:28:45 +00:00
osquery::aggregateQuery(FLAGS_query, err);
if (err != 0) {
LOG(ERROR) << "Query failed: " << err;
return 1;
}
LOG(INFO) << "Query succedded";
}
} else {
LOG(ERROR) << "Usage: run --query=\"<query>\"";
return 1;
}
return 0;
}