2015-01-22 12:10:32 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2017-01-10 15:54:22 +01:00
|
|
|
* Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) *
|
2015-01-22 12:10:32 +01:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2015-02-25 09:51:31 +01:00
|
|
|
#ifndef TROUBLESHOOTCOMMAND_H
|
|
|
|
#define TROUBLESHOOTCOMMAND_H
|
2015-01-22 12:10:32 +01:00
|
|
|
|
|
|
|
#include "cli/clicommand.hpp"
|
2015-02-19 17:12:32 +01:00
|
|
|
#include "base/i2-base.hpp"
|
|
|
|
#include "base/dictionary.hpp"
|
2015-01-22 12:10:32 +01:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2015-02-20 15:27:10 +01:00
|
|
|
/**
|
2015-02-25 09:51:31 +01:00
|
|
|
* The "troubleshoot" command.
|
2015-02-20 15:27:10 +01:00
|
|
|
*
|
|
|
|
* @ingroup cli
|
|
|
|
*/
|
2015-02-25 09:51:31 +01:00
|
|
|
class TroubleshootCommand : public CLICommand
|
2015-02-20 15:27:10 +01:00
|
|
|
{
|
|
|
|
public:
|
2015-02-25 09:51:31 +01:00
|
|
|
DECLARE_PTR_TYPEDEFS(TroubleshootCommand);
|
2015-02-20 15:27:10 +01:00
|
|
|
|
2015-08-18 09:12:49 +02:00
|
|
|
virtual String GetDescription(void) const override;
|
|
|
|
virtual String GetShortDescription(void) const override;
|
|
|
|
virtual int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
|
2015-02-20 15:27:10 +01:00
|
|
|
virtual void InitParameters(boost::program_options::options_description& visibleDesc,
|
2015-08-18 09:12:49 +02:00
|
|
|
boost::program_options::options_description& hiddenDesc) const override;
|
2015-02-20 15:27:10 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
class InfoLog;
|
|
|
|
class InfoLogLine;
|
|
|
|
static bool GeneralInfo(InfoLog& log, const boost::program_options::variables_map& vm);
|
|
|
|
static bool FeatureInfo(InfoLog& log, const boost::program_options::variables_map& vm);
|
|
|
|
static bool ObjectInfo(InfoLog& log, const boost::program_options::variables_map& vm,
|
2015-02-26 12:40:49 +01:00
|
|
|
Dictionary::Ptr& logs, const String& path);
|
2015-02-20 15:27:10 +01:00
|
|
|
static bool ReportInfo(InfoLog& log, const boost::program_options::variables_map& vm,
|
|
|
|
Dictionary::Ptr& logs);
|
|
|
|
static bool ConfigInfo(InfoLog& log, const boost::program_options::variables_map& vm);
|
|
|
|
|
|
|
|
static int Tail(const String& file, const int numLines, InfoLog& log);
|
|
|
|
static bool CheckFeatures(InfoLog& log);
|
|
|
|
static void GetLatestReport(const String& filename, time_t& bestTimestamp, String& bestFilename);
|
|
|
|
static bool PrintCrashReports(InfoLog& log);
|
2015-04-20 11:01:27 +02:00
|
|
|
static bool PrintFile(InfoLog& log, const String& path);
|
2015-02-20 15:27:10 +01:00
|
|
|
static bool CheckConfig(void);
|
2015-03-02 12:17:34 +01:00
|
|
|
static void CheckObjectFile(const String& objectfile, InfoLog& log, InfoLog *OFile, const bool objectConsole,
|
2015-02-20 15:27:10 +01:00
|
|
|
Dictionary::Ptr& logs, std::set<String>& configs);
|
2015-03-02 12:17:34 +01:00
|
|
|
static bool PrintVarsFile(const String& path, const bool console);
|
2015-02-20 15:27:10 +01:00
|
|
|
static void PrintLoggers(InfoLog& log, Dictionary::Ptr& logs);
|
2015-02-25 13:49:41 +01:00
|
|
|
static void PrintObjectOrigin(InfoLog& log, const std::set<String>& configSet);
|
2015-02-20 15:27:10 +01:00
|
|
|
};
|
2015-02-19 17:12:32 +01:00
|
|
|
|
2015-01-22 12:10:32 +01:00
|
|
|
}
|
2015-02-25 09:51:31 +01:00
|
|
|
#endif /* TROUBLESHOOTCOMMAND_H */
|