// Register the FTDC system // Note: This must be run before the server parameters are parsed during startup // so that the FTDCController is initialized. // void startFTDC(boost::filesystem::path& path, FTDCStartMode startupMode, RegisterCollectorsFunction registerCollectors) { FTDCConfig config; config.period = Milliseconds(localPeriodMillis.load()); // Only enable FTDC if our caller says to enable FTDC, MongoS may not have a valid path to write // files to so update the diagnosticDataCollectionEnabled set parameter to reflect that. localEnabledFlag.store(startupMode == FTDCStartMode::kStart && localEnabledFlag.load()); config.enabled = localEnabledFlag.load(); config.maxFileSizeBytes = localMaxFileSizeMB.load() * 1024 * 1024; config.maxDirectorySizeBytes = localMaxDirectorySizeMB.load() * 1024 * 1024; config.maxSamplesPerArchiveMetricChunk = localMaxSamplesPerArchiveMetricChunk.load(); config.maxSamplesPerInterimMetricChunk = localMaxSamplesPerInterimMetricChunk.load(); auto controller = stdx::make_unique<FTDCController>(path, config); // Install periodic collectors // These are collected on the period interval in FTDCConfig. // NOTE: For each command here, there must be an equivalent privilege check in // GetDiagnosticDataCommand // CmdServerStatus // The "sharding" section is filtered out because at this time it only consists of strings in // migration status. This section triggers too many schema changes in the serverStatus which // hurt ftdc compression efficiency, because its output varies depending on the list of active // migrations. // TODO: do we need to enable "sharding" on MongoS? controller->addPeriodicCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "serverStatus", "serverStatus", "", BSON("serverStatus" << 1 << "tcMalloc" << true << "sharding" << false))); registerCollectors(controller.get()); // Install System Metric Collector as a periodic collector installSystemMetricsCollector(controller.get()); // Install file rotation collectors // These are collected on each file rotation. // CmdBuildInfo controller->addOnRotateCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "buildInfo", "buildInfo", "", BSON("buildInfo" << 1))); // CmdGetCmdLineOpts controller->addOnRotateCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "getCmdLineOpts", "getCmdLineOpts", "", BSON("getCmdLineOpts" << 1))); // HostInfoCmd controller->addOnRotateCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "hostInfo", "hostInfo", "", BSON("hostInfo" << 1))); // Install the new controller auto& staticFTDC = getFTDCController(getGlobalServiceContext()); staticFTDC = std::move(controller); staticFTDC->start(); }
// Register the FTDC system // Note: This must be run before the server parameters are parsed during startup // so that the FTDCController is initialized. // void startFTDC() { boost::filesystem::path dir(storageGlobalParams.dbpath); dir /= "diagnostic.data"; FTDCConfig config; config.period = Milliseconds(localPeriodMillis.load()); config.enabled = localEnabledFlag; config.maxFileSizeBytes = localMaxFileSizeMB * 1024 * 1024; config.maxDirectorySizeBytes = localMaxDirectorySizeMB * 1024 * 1024; config.maxSamplesPerArchiveMetricChunk = localMaxSamplesPerArchiveMetricChunk; config.maxSamplesPerInterimMetricChunk = localMaxSamplesPerInterimMetricChunk; auto controller = stdx::make_unique<FTDCController>(dir, config); // Install periodic collectors // These are collected on the period interval in FTDCConfig. // CmdServerStatus controller->addPeriodicCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "serverStatus", "serverStatus", "", BSON("tcMalloc" << true))); // These metrics are only collected if replication is enabled if (repl::getGlobalReplicationCoordinator()->getReplicationMode() != repl::ReplicationCoordinator::modeNone) { // CmdReplSetGetStatus controller->addPeriodicCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "replSetGetStatus", "replSetGetStatus", "", BSONObj())); // CollectionStats controller->addPeriodicCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "collStats", "local.oplog.rs.stats", "local.oplog.rs", BSONObj())); } // Install file rotation collectors // These are collected on each file rotation. // CmdBuildInfo controller->addOnRotateCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "buildInfo", "buildInfo", "", BSONObj())); // CmdGetCmdLineOpts controller->addOnRotateCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "getCmdLineOpts", "getCmdLineOpts", "", BSONObj())); // HostInfoCmd controller->addOnRotateCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "hostInfo", "hostInfo", "", BSONObj())); // Install the new controller auto& staticFTDC = getFTDCController(getGlobalServiceContext()); staticFTDC = std::move(controller); staticFTDC->start(); }
FTDCController* FTDCController::get(ServiceContext* serviceContext) { return getFTDCController(serviceContext).get(); }
// Register the FTDC system // Note: This must be run before the server parameters are parsed during startup // so that the FTDCController is initialized. // void startFTDC() { boost::filesystem::path dir(storageGlobalParams.dbpath); dir /= "diagnostic.data"; FTDCConfig config; config.period = Milliseconds(localPeriodMillis.load()); config.enabled = localEnabledFlag; config.maxFileSizeBytes = localMaxFileSizeMB * 1024 * 1024; config.maxDirectorySizeBytes = localMaxDirectorySizeMB * 1024 * 1024; config.maxSamplesPerArchiveMetricChunk = localMaxSamplesPerArchiveMetricChunk; config.maxSamplesPerInterimMetricChunk = localMaxSamplesPerInterimMetricChunk; auto controller = stdx::make_unique<FTDCController>(dir, config); // Install periodic collectors // These are collected on the period interval in FTDCConfig. // NOTE: For each command here, there must be an equivalent privilege check in // GetDiagnosticDataCommand // CmdServerStatus // The "sharding" section is filtered out because at this time it only consists of strings in // migration status. This section triggers too many schema changes in the serverStatus which // hurt ftdc compression efficiency, because its output varies depending on the list of active // migrations. controller->addPeriodicCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "serverStatus", "serverStatus", "", BSON("serverStatus" << 1 << "tcMalloc" << true << "sharding" << false))); // These metrics are only collected if replication is enabled if (repl::getGlobalReplicationCoordinator()->getReplicationMode() != repl::ReplicationCoordinator::modeNone) { // CmdReplSetGetStatus controller->addPeriodicCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "replSetGetStatus", "replSetGetStatus", "", BSON("replSetGetStatus" << 1))); // CollectionStats controller->addPeriodicCollector( stdx::make_unique<FTDCSimpleInternalCommandCollector>("collStats", "local.oplog.rs.stats", "local", BSON("collStats" << "oplog.rs"))); } // Install System Metric Collector as a periodic collector installSystemMetricsCollector(controller.get()); // Install file rotation collectors // These are collected on each file rotation. // CmdBuildInfo controller->addOnRotateCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "buildInfo", "buildInfo", "", BSON("buildInfo" << 1))); // CmdGetCmdLineOpts controller->addOnRotateCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "getCmdLineOpts", "getCmdLineOpts", "", BSON("getCmdLineOpts" << 1))); // HostInfoCmd controller->addOnRotateCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( "hostInfo", "hostInfo", "", BSON("hostInfo" << 1))); // Install the new controller auto& staticFTDC = getFTDCController(getGlobalServiceContext()); staticFTDC = std::move(controller); staticFTDC->start(); }