osquery-1/osquery/main/daemon.cpp

60 lines
1.5 KiB
C++
Raw Normal View History

2014-07-31 00:35:19 +00:00
// Copyright 2004-present Facebook. All Rights Reserved.
#include <boost/thread.hpp>
#include <glog/logging.h>
#include "osquery/config.h"
#include "osquery/config/plugin.h"
#include "osquery/core.h"
#include "osquery/database.h"
#include "osquery/events.h"
#include "osquery/logger/plugin.h"
2014-07-31 00:35:19 +00:00
#include "osquery/scheduler.h"
2014-08-30 11:06:21 +00:00
int main(int argc, char* argv[]) {
2014-09-13 21:28:45 +00:00
osquery::initOsquery(argc, argv);
2014-07-31 00:35:19 +00:00
try {
osquery::DBHandle::getInstance();
} catch (std::exception& e) {
LOG(ERROR) << "osqueryd failed to start: " << e.what();
::exit(1);
}
LOG(INFO) << "Listing all plugins";
LOG(INFO) << "Logger plugins:";
for (const auto& it : REGISTERED_LOGGER_PLUGINS) {
LOG(INFO) << " - " << it.first;
}
LOG(INFO) << "Config plugins:";
for (const auto& it : REGISTERED_CONFIG_PLUGINS) {
LOG(INFO) << " - " << it.first;
}
2014-09-24 18:25:05 +00:00
LOG(INFO) << "Event Types:";
for (const auto& it : REGISTERED_EVENTPUBLISHERS) {
2014-09-24 18:25:05 +00:00
LOG(INFO) << " - " << it.first;
}
LOG(INFO) << "Event Modules:";
for (const auto& it : REGISTERED_EVENTSUBSCRIBERS) {
2014-09-24 18:25:05 +00:00
LOG(INFO) << " - " << it.first;
}
// Start a thread for each appropriate event type
osquery::registries::faucet(REGISTERED_EVENTPUBLISHERS,
2014-10-28 00:37:36 +00:00
REGISTERED_EVENTSUBSCRIBERS);
osquery::EventFactory::delay();
2014-07-31 00:35:19 +00:00
boost::thread scheduler_thread(osquery::initializeScheduler);
2014-07-31 00:35:19 +00:00
scheduler_thread.join();
// End any event type run loops.
osquery::EventFactory::end();
2014-07-31 00:35:19 +00:00
return 0;
}