mirror of https://github.com/Icinga/icinga2.git
Change commandline and performancedata
This commit is contained in:
parent
3439ea755f
commit
553f6f6ba9
|
@ -33,6 +33,7 @@
|
||||||
#include "icinga/eventcommand.hpp"
|
#include "icinga/eventcommand.hpp"
|
||||||
#include "icinga/notificationcommand.hpp"
|
#include "icinga/notificationcommand.hpp"
|
||||||
#include "icinga/timeperiod.hpp"
|
#include "icinga/timeperiod.hpp"
|
||||||
|
#include "icinga/pluginutility.hpp"
|
||||||
#include "remote/zone.hpp"
|
#include "remote/zone.hpp"
|
||||||
#include "base/json.hpp"
|
#include "base/json.hpp"
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
|
@ -664,8 +665,10 @@ Dictionary::Ptr RedisWriter::SerializeState(const Checkable::Ptr& checkable)
|
||||||
if (cr) {
|
if (cr) {
|
||||||
attrs->Set("output", CompatUtility::GetCheckResultOutput(cr));
|
attrs->Set("output", CompatUtility::GetCheckResultOutput(cr));
|
||||||
attrs->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
|
attrs->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
|
||||||
attrs->Set("performance_data", JsonEncode(cr->GetPerformanceData()));
|
if (cr->GetPerformanceData())
|
||||||
attrs->Set("command", JsonEncode(cr->GetCommand()));
|
attrs->Set("performance_data", PluginUtility::FormatPerfdata(cr->GetPerformanceData()));
|
||||||
|
if (!cr->GetCommand().IsEmpty())
|
||||||
|
attrs->Set("commandline", FormatCommandLine(cr->GetCommand()));
|
||||||
attrs->Set("execution_time", cr->CalculateExecutionTime());
|
attrs->Set("execution_time", cr->CalculateExecutionTime());
|
||||||
attrs->Set("latency", cr->CalculateLatency());
|
attrs->Set("latency", cr->CalculateLatency());
|
||||||
}
|
}
|
||||||
|
@ -707,7 +710,6 @@ Dictionary::Ptr RedisWriter::SerializeState(const Checkable::Ptr& checkable)
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<String>
|
std::vector<String>
|
||||||
RedisWriter::UpdateObjectAttrs(const ConfigObject::Ptr& object, int fieldType,
|
RedisWriter::UpdateObjectAttrs(const ConfigObject::Ptr& object, int fieldType,
|
||||||
const String& typeNameOverride)
|
const String& typeNameOverride)
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -48,6 +50,33 @@ String RedisWriter::FormatCheckSumBinary(const String& str)
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String RedisWriter::FormatCommandLine(const Value& commandLine)
|
||||||
|
{
|
||||||
|
String result;
|
||||||
|
if (commandLine.IsObjectType<Array>()) {
|
||||||
|
Array::Ptr args = commandLine;
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
|
ObjectLock olock(args);
|
||||||
|
for (const Value& arg : args) {
|
||||||
|
String token = "'" + Convert::ToString(arg) + "'";
|
||||||
|
|
||||||
|
if (first)
|
||||||
|
first = false;
|
||||||
|
else
|
||||||
|
result += String(1, ' ');
|
||||||
|
|
||||||
|
result += token;
|
||||||
|
}
|
||||||
|
} else if (!commandLine.IsEmpty()) {
|
||||||
|
result = commandLine;
|
||||||
|
boost::algorithm::replace_all(result, "\'", "\\'");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static Value l_DefaultEnv = "production";
|
static Value l_DefaultEnv = "production";
|
||||||
|
|
||||||
String RedisWriter::GetEnvironment()
|
String RedisWriter::GetEnvironment()
|
||||||
|
|
|
@ -83,6 +83,7 @@ private:
|
||||||
|
|
||||||
/* utilities */
|
/* utilities */
|
||||||
static String FormatCheckSumBinary(const String& str);
|
static String FormatCheckSumBinary(const String& str);
|
||||||
|
static String FormatCommandLine(const Value& commandLine);
|
||||||
|
|
||||||
static String GetObjectIdentifier(const ConfigObject::Ptr& object);
|
static String GetObjectIdentifier(const ConfigObject::Ptr& object);
|
||||||
static String GetEnvironment();
|
static String GetEnvironment();
|
||||||
|
@ -99,7 +100,6 @@ private:
|
||||||
static String GetLowerCaseTypeNameDB(const ConfigObject::Ptr& obj);
|
static String GetLowerCaseTypeNameDB(const ConfigObject::Ptr& obj);
|
||||||
static void MakeTypeChecksums(const ConfigObject::Ptr& object, std::set<String>& propertiesBlacklist, Dictionary::Ptr& checkSums);
|
static void MakeTypeChecksums(const ConfigObject::Ptr& object, std::set<String>& propertiesBlacklist, Dictionary::Ptr& checkSums);
|
||||||
|
|
||||||
|
|
||||||
static void StateChangeHandler(const ConfigObject::Ptr &object);
|
static void StateChangeHandler(const ConfigObject::Ptr &object);
|
||||||
static void VersionChangedHandler(const ConfigObject::Ptr& object);
|
static void VersionChangedHandler(const ConfigObject::Ptr& object);
|
||||||
static void DowntimeChangedHandler(const Downtime::Ptr& downtime);
|
static void DowntimeChangedHandler(const Downtime::Ptr& downtime);
|
||||||
|
|
Loading…
Reference in New Issue