コード例 #1
0
ファイル: scheduler.cpp プロジェクト: Centurion89/osquery
void SchedulerRunner::start() {
  // Start the counter at the second.
  auto i = osquery::getUnixTime();
  for (; (timeout_ == 0) || (i <= timeout_); ++i) {
    Config::get().scheduledQueries(
        ([&i](const std::string& name, const ScheduledQuery& query) {
          if (query.splayed_interval > 0 && i % query.splayed_interval == 0) {
            TablePlugin::kCacheInterval = query.splayed_interval;
            TablePlugin::kCacheStep = i;
            launchQuery(name, query);
          }
        }));
    // Configuration decorators run on 60 second intervals only.
    if ((i % 60) == 0) {
      runDecorators(DECORATE_INTERVAL, i);
    }
    if (FLAGS_schedule_reload > 0 && (i % FLAGS_schedule_reload) == 0) {
      if (FLAGS_schedule_reload_sql) {
        SQLiteDBManager::resetPrimary();
      }
      resetDatabase();
    }

    // GLog is not re-entrant, so logs must be flushed in a dedicated thread.
    if ((i % 3) == 0) {
      relayStatusLogs(true);
    }

    // Put the thread into an interruptible sleep without a config instance.
    pauseMilli(interval_ * 1000);
    if (interrupted()) {
      break;
    }
  }
}
コード例 #2
0
ファイル: dbpediaquery.cpp プロジェクト: KDE/bangarang
void DBPediaQuery::getMovieInfo(const QString & movieName)
{
    //Create query url
    QString query = m_queryPrefix +
                    QString("SELECT DISTINCT str(?label) AS  ?title ?description ?thumbnail ?duration ?releaseDate ?actor ?writer ?director ?producer "
                    "WHERE { "
                    "{ ?work rdf:type dbo:Film . } "
                    "?work rdfs:label ?label . "
                    "?label bif:contains \"%1\" . "
                    "?work rdfs:comment ?description . "
                    "OPTIONAL { ?work dbo:starring ?actorres . "
                    "?actorres foaf:name ?actor . } "
                    "OPTIONAL { ?work dbo:director ?directorres . "
                    "?directorres foaf:name ?director . } "
                    "OPTIONAL { ?work dbo:writer ?writerres . "
                    "?writerres foaf:name ?writer . } "
                    "OPTIONAL { ?work dbo:producer ?producerres . "
                    "?producerres foaf:name ?producer . } "
                    "OPTIONAL { ?work dbo:duration ?duration . } "
                    "OPTIONAL {?work foaf:depiction ?thumbnail . } "
                    "OPTIONAL {?work dbo:releaseDate ?releaseDate . } "
                    "FILTER (lang(?description) ='%2') } ")
                    .arg(movieName)
                    .arg(m_lang);

    //Create Request Key
    QString requestKey = QString("Movie:%1").arg(movieName);

    //Launch Query
    launchQuery(query, requestKey);
}
コード例 #3
0
ファイル: scheduler.cpp プロジェクト: readshaw/osquery
void SchedulerRunner::start() {
  // Start the counter at the second.
  auto i = osquery::getUnixTime();
  for (; (timeout_ == 0) || (i <= timeout_); ++i) {
    Config::getInstance().scheduledQueries(
        ([&i](const std::string& name, const ScheduledQuery& query) {
          if (query.splayed_interval > 0 && i % query.splayed_interval == 0) {
            TablePlugin::kCacheInterval = query.splayed_interval;
            TablePlugin::kCacheStep = i;
            launchQuery(name, query);
          }
        }));
    // Put the thread into an interruptible sleep without a config instance.
    osquery::interruptableSleep(interval_ * 1000);
  }
}
コード例 #4
0
ファイル: scheduler.cpp プロジェクト: aayn/osquery
void SchedulerRunner::start() {
  time_t t = std::time(nullptr);
  struct tm* local = std::localtime(&t);
  unsigned long int i = local->tm_sec;
  for (; (timeout_ == 0) || (i <= timeout_); ++i) {
    {
      ConfigDataInstance config;
      for (const auto& query : config.schedule()) {
        if (i % query.second.splayed_interval == 0) {
          launchQuery(query.first, query.second);
        }
      }
    }
    // Put the thread into an interruptible sleep without a config instance.
    osquery::interruptableSleep(interval_ * 1000);
  }
}
コード例 #5
0
ファイル: dbpediaquery.cpp プロジェクト: KDE/bangarang
void DBPediaQuery::getActorInfo(const QString & actorName)
{
    //Create query url
    QString query = m_queryPrefix +
                    QString("SELECT DISTINCT str(?label) AS  ?name ?description ?thumbnail "
                    "WHERE { "
                    "?person rdf:type dbo:Actor . "
                    "?person rdfs:label ?label . "
                    "?label bif:contains \"%1\" . "
                    "OPTIONAL {?person rdfs:comment ?description . "
                               "FILTER (lang(?description) ='%2') } "
                    "OPTIONAL {?person dbo:thumbnail ?thumbnail . } "
                    "} ")
                    .arg(actorName)
                    .arg(m_lang);

    //Create Request Key
    QString requestKey = QString("Actor:%1").arg(actorName);

    //Launch Query
    launchQuery(query, requestKey);
}
コード例 #6
0
ファイル: scheduler.cpp プロジェクト: friedbutter/osquery
void SchedulerRunner::start() {
  // Start the counter at the second.
  auto i = osquery::getUnixTime();
  for (; (timeout_ == 0) || (i <= timeout_); ++i) {
    Config::getInstance().scheduledQueries(
        ([&i](const std::string& name, const ScheduledQuery& query) {
          if (query.splayed_interval > 0 && i % query.splayed_interval == 0) {
            TablePlugin::kCacheInterval = query.splayed_interval;
            TablePlugin::kCacheStep = i;
            launchQuery(name, query);
          }
        }));
    // Configuration decorators run on 60 second intervals only.
    if (i % 60 == 0) {
      runDecorators(DECORATE_INTERVAL, i);
    }
    // Put the thread into an interruptible sleep without a config instance.
    pauseMilli(interval_ * 1000);
    if (interrupted()) {
      break;
    }
  }
}