Pass through timestamps to external command handlers.

This commit is contained in:
Gunnar Beutner 2013-01-22 12:39:33 +01:00
parent e887ff0550
commit 61f2b5f0cf
3 changed files with 13 additions and 13 deletions

View File

@ -179,7 +179,7 @@ void CompatComponent::ProcessCommand(const String& command)
Logger::Write(LogInformation, "compat", msgbuf.str());
vector<String> argvExtra(argv.begin() + 1, argv.end());
ExternalCommand::Execute(argv[0], argvExtra);
ExternalCommand::Execute(ts, argv[0], argvExtra);
}
#endif /* _WIN32 */

View File

@ -24,7 +24,7 @@ using namespace icinga;
bool I2_EXPORT ExternalCommand::m_Initialized;
map<String, ExternalCommand::Callback> I2_EXPORT ExternalCommand::m_Commands;
int ExternalCommand::Execute(const String& command, const vector<String>& arguments)
int ExternalCommand::Execute(double time, const String& command, const vector<String>& arguments)
{
if (!m_Initialized) {
RegisterCommand("HELLO_WORLD", &ExternalCommand::HelloWorld);
@ -39,7 +39,7 @@ int ExternalCommand::Execute(const String& command, const vector<String>& argume
if (it == m_Commands.end())
return -1;
return it->second(arguments);
return it->second(time, arguments);
}
void ExternalCommand::RegisterCommand(const String& command, const ExternalCommand::Callback& callback)
@ -47,14 +47,14 @@ void ExternalCommand::RegisterCommand(const String& command, const ExternalComma
m_Commands[command] = callback;
}
int ExternalCommand::HelloWorld(const vector<String>& arguments)
int ExternalCommand::HelloWorld(double time, const vector<String>& arguments)
{
Logger::Write(LogInformation, "icinga", "HelloWorld external command called.");
return 0;
}
int ExternalCommand::ProcessServiceCheckResult(const vector<String>& arguments)
int ExternalCommand::ProcessServiceCheckResult(double time, const vector<String>& arguments)
{
if (arguments.size() < 4)
return -1;
@ -69,10 +69,10 @@ int ExternalCommand::ProcessServiceCheckResult(const vector<String>& arguments)
result->Set("state", PluginCheckTask::ExitStatusToState(exitStatus));
double now = Utility::GetTime();
result->Set("schedule_start", now);
result->Set("schedule_end", now);
result->Set("execution_start", now);
result->Set("execution_end", now);
result->Set("schedule_start", time);
result->Set("schedule_end", time);
result->Set("execution_start", time);
result->Set("execution_end", time);
service->ProcessCheckResult(result);

View File

@ -26,13 +26,13 @@ namespace icinga
class I2_ICINGA_API ExternalCommand {
public:
static int Execute(const String& command, const vector<String>& arguments);
static int Execute(double time, const String& command, const vector<String>& arguments);
static int HelloWorld(const vector<String>& arguments);
static int ProcessServiceCheckResult(const vector<String>& arguments);
static int HelloWorld(double time, const vector<String>& arguments);
static int ProcessServiceCheckResult(double time, const vector<String>& arguments);
private:
typedef function<int (const vector<String>& arguments)> Callback;
typedef function<int (double time, const vector<String>& arguments)> Callback;
static bool m_Initialized;
static map<String, Callback> m_Commands;