mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-16 18:24:31 +02:00
parent
6455ef6b0a
commit
41f7ec9c8e
@ -70,11 +70,13 @@ public:
|
|||||||
Log(sev, "troubleshoot", str);
|
Log(sev, "troubleshoot", str);
|
||||||
|
|
||||||
if (sev == LogCritical || sev == LogWarning) {
|
if (sev == LogCritical || sev == LogWarning) {
|
||||||
*m_Stream << std::string(24, '#') << '\n'
|
*m_Stream
|
||||||
|
<< std::string(24, '#') << '\n'
|
||||||
<< "# " << str << '\n'
|
<< "# " << str << '\n'
|
||||||
<< std::string(24, '#') << '\n';
|
<< std::string(24, '#') << '\n';
|
||||||
} else
|
} else
|
||||||
*m_Stream << str << '\n';
|
*m_Stream
|
||||||
|
<< str << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetStreamHealth(void) const
|
bool GetStreamHealth(void) const
|
||||||
@ -114,7 +116,8 @@ private:
|
|||||||
|
|
||||||
bool TroubleshootCollectCommand::GeneralInfo(InfoLog& log, const boost::program_options::variables_map& vm)
|
bool TroubleshootCollectCommand::GeneralInfo(InfoLog& log, const boost::program_options::variables_map& vm)
|
||||||
{
|
{
|
||||||
InfoLogLine(log) << '\n' << std::string(14, '=') << " GENERAL INFORMATION " << std::string(14, '=') << '\n';
|
InfoLogLine(log)
|
||||||
|
<< '\n' << std::string(14, '=') << " GENERAL INFORMATION " << std::string(14, '=') << '\n';
|
||||||
|
|
||||||
//Application::DisplayInfoMessage() but formatted
|
//Application::DisplayInfoMessage() but formatted
|
||||||
InfoLogLine(log)
|
InfoLogLine(log)
|
||||||
@ -142,13 +145,15 @@ bool TroubleshootCollectCommand::FeatureInfo(InfoLog& log, const boost::program_
|
|||||||
|
|
||||||
bool TroubleshootCollectCommand::ObjectInfo(InfoLog& log, const boost::program_options::variables_map& vm, Dictionary::Ptr& logs)
|
bool TroubleshootCollectCommand::ObjectInfo(InfoLog& log, const boost::program_options::variables_map& vm, Dictionary::Ptr& logs)
|
||||||
{
|
{
|
||||||
InfoLogLine(log) << '\n' << std::string(14, '=') << " OBJECT INFORMATION " << std::string(14, '=') << '\n';
|
InfoLogLine(log)
|
||||||
|
<< '\n' << std::string(14, '=') << " OBJECT INFORMATION " << std::string(14, '=') << '\n';
|
||||||
|
|
||||||
String objectfile = Application::GetObjectsPath();
|
String objectfile = Application::GetObjectsPath();
|
||||||
std::set<String> configs;
|
std::set<String> configs;
|
||||||
|
|
||||||
if (!Utility::PathExists(objectfile)) {
|
if (!Utility::PathExists(objectfile)) {
|
||||||
InfoLogLine(log, LogCritical) << "Cannot open object file '" << objectfile << "'.\n"
|
InfoLogLine(log, LogCritical)
|
||||||
|
<< "Cannot open object file '" << objectfile << "'.\n"
|
||||||
<< "FAILED: This probably means you have a fault configuration.";
|
<< "FAILED: This probably means you have a fault configuration.";
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
@ -159,7 +164,8 @@ bool TroubleshootCollectCommand::ObjectInfo(InfoLog& log, const boost::program_o
|
|||||||
|
|
||||||
bool TroubleshootCollectCommand::ReportInfo(InfoLog& log, const boost::program_options::variables_map& vm, Dictionary::Ptr& logs)
|
bool TroubleshootCollectCommand::ReportInfo(InfoLog& log, const boost::program_options::variables_map& vm, Dictionary::Ptr& logs)
|
||||||
{
|
{
|
||||||
InfoLogLine(log) << '\n' << std::string(14, '=') << " LOGS AND CRASH REPORTS " << std::string(14, '=') << '\n';
|
InfoLogLine(log)
|
||||||
|
<< '\n' << std::string(14, '=') << " LOGS AND CRASH REPORTS " << std::string(14, '=') << '\n';
|
||||||
PrintLoggers(log, logs);
|
PrintLoggers(log, logs);
|
||||||
PrintCrashReports(log);
|
PrintCrashReports(log);
|
||||||
|
|
||||||
@ -168,9 +174,12 @@ bool TroubleshootCollectCommand::ReportInfo(InfoLog& log, const boost::program_o
|
|||||||
|
|
||||||
bool TroubleshootCollectCommand::ConfigInfo(InfoLog& log, const boost::program_options::variables_map& vm)
|
bool TroubleshootCollectCommand::ConfigInfo(InfoLog& log, const boost::program_options::variables_map& vm)
|
||||||
{
|
{
|
||||||
InfoLogLine(log) << '\n' << std::string(14, '=') << " CONFIGURATION FILES " << std::string(14, '=') << '\n';
|
InfoLogLine(log)
|
||||||
|
<< '\n' << std::string(14, '=') << " CONFIGURATION FILES " << std::string(14, '=') << '\n';
|
||||||
|
|
||||||
|
InfoLogLine(log)
|
||||||
|
<< "A collection of important configuration files follows, please make sure to remove any sensitive data such as credentials, internal company names, etc";
|
||||||
|
|
||||||
InfoLogLine(log) << "A collection of important configuration files follows, please make sure to remove any sensitive data such as credentials, internal company names, etc";
|
|
||||||
if (!PrintConf(log, Application::GetSysconfDir() + "/icinga2/icinga2.conf")) {
|
if (!PrintConf(log, Application::GetSysconfDir() + "/icinga2/icinga2.conf")) {
|
||||||
InfoLogLine(log, LogWarning)
|
InfoLogLine(log, LogWarning)
|
||||||
<< "icinga2.conf not found, therefore skipping validation.\n"
|
<< "icinga2.conf not found, therefore skipping validation.\n"
|
||||||
@ -245,11 +254,14 @@ bool TroubleshootCollectCommand::CheckFeatures(InfoLog& log)
|
|||||||
<< "Disabled features:\n\t" << boost::algorithm::join(disabled_features, " ") << '\n';
|
<< "Disabled features:\n\t" << boost::algorithm::join(disabled_features, " ") << '\n';
|
||||||
|
|
||||||
if (!features->Get("checker").ToBool())
|
if (!features->Get("checker").ToBool())
|
||||||
InfoLogLine(log, LogWarning) << "checker is disabled, no checks can be run from this instance";
|
InfoLogLine(log, LogWarning)
|
||||||
|
<< "checker is disabled, no checks can be run from this instance";
|
||||||
if (!features->Get("mainlog").ToBool())
|
if (!features->Get("mainlog").ToBool())
|
||||||
InfoLogLine(log, LogWarning) << "mainlog is disabled, please activate it and rerun icinga2";
|
InfoLogLine(log, LogWarning)
|
||||||
|
<< "mainlog is disabled, please activate it and rerun icinga2";
|
||||||
if (!features->Get("debuglog").ToBool())
|
if (!features->Get("debuglog").ToBool())
|
||||||
InfoLogLine(log, LogWarning) << "debuglog is disabled, please activate it and rerun icinga2";
|
InfoLogLine(log, LogWarning)
|
||||||
|
<< "debuglog is disabled, please activate it and rerun icinga2";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -298,9 +310,8 @@ bool TroubleshootCollectCommand::PrintCrashReports(InfoLog& log)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
catch (...) {
|
catch (...) {
|
||||||
InfoLogLine(log, LogWarning)
|
InfoLogLine(log, LogWarning) << "Error printing crash reports.\n"
|
||||||
<< "Error printing crash reports.\nDoes "
|
<< "Does " << Application::GetLocalStateDir() << "/log/icinga2/crash/ exist?";
|
||||||
<< Application::GetLocalStateDir() << "/log/icinga2/crash/ exist?";
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -504,7 +515,8 @@ int TroubleshootCollectCommand::Run(const boost::program_options::variables_map&
|
|||||||
String appName = Utility::BaseName(Application::GetArgV()[0]);
|
String appName = Utility::BaseName(Application::GetArgV()[0]);
|
||||||
double goTime = Utility::GetTime();
|
double goTime = Utility::GetTime();
|
||||||
|
|
||||||
InfoLogLine(*log) << appName << " -- Troubleshooting help:\n"
|
InfoLogLine(*log)
|
||||||
|
<< appName << " -- Troubleshooting help:\n"
|
||||||
<< "Should you run into problems with Icinga please add this file to your help request\n"
|
<< "Should you run into problems with Icinga please add this file to your help request\n"
|
||||||
<< "Began procedure at timestamp " << Convert::ToString(goTime) << '\n';
|
<< "Began procedure at timestamp " << Convert::ToString(goTime) << '\n';
|
||||||
|
|
||||||
@ -532,7 +544,8 @@ int TroubleshootCollectCommand::Run(const boost::program_options::variables_map&
|
|||||||
<< "\nTook " << Convert::ToString(endTime - goTime) << " seconds\n";
|
<< "\nTook " << Convert::ToString(endTime - goTime) << " seconds\n";
|
||||||
|
|
||||||
if (!vm.count("console")) {
|
if (!vm.count("console")) {
|
||||||
std::cout << "\nFinished collection. See '" << path << "'\n";
|
std::cout
|
||||||
|
<< "\nFinished collection. See '" << path << "'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
delete log;
|
delete log;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user