osquery-1/osquery/examples/example_module.cpp
Teddy Reed b28c4d8d0f Introduce table options (#2101)
Table options includes a change to the Registry::call API for TablePlugins.
When requesting route information or the 'columns' action, a new 'op' key is included.
2016-05-18 12:23:52 -07:00

48 lines
1.3 KiB
C++

/*
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#include <osquery/sdk.h>
using namespace osquery;
class ExampleTable : public TablePlugin {
private:
TableColumns columns() const override {
return {
std::make_tuple("example_text", TEXT_TYPE, DEFAULT),
std::make_tuple("example_integer", INTEGER_TYPE, DEFAULT),
};
}
QueryData generate(QueryContext& request) override {
QueryData results;
Row r;
r["example_text"] = "example";
r["example_integer"] = INTEGER(1);
results.push_back(r);
return results;
}
};
// Create the module if the environment variable TESTFAIL1 is not defined.
// This allows the integration tests to, at run time, test the module
// loading workflow.
CREATE_MODULE_IF(getenv("TESTFAIL1") == nullptr, "example", "0.0.1", "0.0.0");
void initModule(void) {
// Register a plugin from a module if the environment variable TESTFAIL2
// is not defined.
if (getenv("TESTFAIL2") == nullptr) {
REGISTER_MODULE(ExampleTable, "table", "example");
}
}