mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 14:44:32 +02:00
compatido: general cleanup
This commit is contained in:
parent
ea9309096c
commit
e294afe7b4
@ -45,13 +45,6 @@ void CompatIdoComponent::Start(void)
|
|||||||
* - only icinga idoutils 1.8
|
* - only icinga idoutils 1.8
|
||||||
* - only "retained" config
|
* - only "retained" config
|
||||||
* - instance_name is i2-default
|
* - instance_name is i2-default
|
||||||
* TODO
|
|
||||||
* we should have configs for
|
|
||||||
* - data_processing_options
|
|
||||||
* - config_output_options - 0..orig, 1..retained (chose retained for icinga-web preferred)
|
|
||||||
* - INSTANCE_NAME ?
|
|
||||||
* - update interval ?
|
|
||||||
* - tcp socket+port
|
|
||||||
*/
|
*/
|
||||||
m_StatusTimer = boost::make_shared<Timer>();
|
m_StatusTimer = boost::make_shared<Timer>();
|
||||||
m_StatusTimer->SetInterval(StatusTimerInterval);
|
m_StatusTimer->SetInterval(StatusTimerInterval);
|
||||||
@ -72,7 +65,7 @@ void CompatIdoComponent::Start(void)
|
|||||||
m_ProgramStatusTimer->Reschedule(0);
|
m_ProgramStatusTimer->Reschedule(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* open ido socket once, send the updates via timer then
|
* open ido socket once
|
||||||
*/
|
*/
|
||||||
OpenSink("127.0.0.1", "5668");
|
OpenSink("127.0.0.1", "5668");
|
||||||
SendHello("i2-default");
|
SendHello("i2-default");
|
||||||
@ -83,8 +76,6 @@ void CompatIdoComponent::Start(void)
|
|||||||
*/
|
*/
|
||||||
void CompatIdoComponent::Stop(void)
|
void CompatIdoComponent::Stop(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
//FIXME cleanly close ido socket
|
|
||||||
GoodByeSink();
|
GoodByeSink();
|
||||||
CloseSink();
|
CloseSink();
|
||||||
}
|
}
|
||||||
@ -92,45 +83,31 @@ void CompatIdoComponent::Stop(void)
|
|||||||
/* TODO
|
/* TODO
|
||||||
* subscribe to all status updates and checkresults and dump them
|
* subscribe to all status updates and checkresults and dump them
|
||||||
* should remove the periodic statusdata dump
|
* should remove the periodic statusdata dump
|
||||||
|
* subscribe to config update events, and send insert/update/delete for configs to ido2db
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Periodically dumps status information
|
* Periodically dumps status information
|
||||||
*
|
|
||||||
* @param - Event arguments for the timer.
|
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::StatusTimerHandler(void)
|
void CompatIdoComponent::StatusTimerHandler(void)
|
||||||
{
|
{
|
||||||
Logger::Write(LogInformation, "compatido", "Writing compat ido status information");
|
Logger::Write(LogInformation, "compatido", "Writing compat ido status information");
|
||||||
/*
|
|
||||||
* TODO
|
|
||||||
* - fetch status data, dump it periodically
|
|
||||||
* - subscribe to check events and status updates, dump it
|
|
||||||
*/
|
|
||||||
DumpStatusData();
|
DumpStatusData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Periodically dumps config information
|
* Periodically dumps config information
|
||||||
*
|
|
||||||
* @param - Event arguments for the timer.
|
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::ConfigTimerHandler(void)
|
void CompatIdoComponent::ConfigTimerHandler(void)
|
||||||
{
|
{
|
||||||
Logger::Write(LogInformation, "compatido", "Writing compat ido config information");
|
Logger::Write(LogInformation, "compatido", "Writing compat ido config information");
|
||||||
/*
|
|
||||||
* TODO
|
|
||||||
* - fetch config, dump it
|
|
||||||
* - subscribe to config update events, and send insert/update/delete for configs to ido2db
|
|
||||||
*/
|
|
||||||
|
|
||||||
DumpConfigObjects();
|
DumpConfigObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Periodically dumps program status information
|
* Periodically dumps program status information
|
||||||
*
|
|
||||||
* @param - Event arguments for the timer.
|
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::ProgramStatusTimerHandler(void)
|
void CompatIdoComponent::ProgramStatusTimerHandler(void)
|
||||||
{
|
{
|
||||||
@ -140,9 +117,8 @@ void CompatIdoComponent::ProgramStatusTimerHandler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* opens a tcp connection to the socket
|
* opens a tcp connection to the ido socket
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::OpenSink(String node, String service)
|
void CompatIdoComponent::OpenSink(String node, String service)
|
||||||
{
|
{
|
||||||
@ -152,7 +128,7 @@ void CompatIdoComponent::OpenSink(String node, String service)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sends hello msg to ido
|
* sends hello msg to ido2b
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::SendHello(String instancename)
|
void CompatIdoComponent::SendHello(String instancename)
|
||||||
{
|
{
|
||||||
@ -180,7 +156,7 @@ void CompatIdoComponent::SendHello(String instancename)
|
|||||||
/**
|
/**
|
||||||
* sends goodbye msg to ido
|
* sends goodbye msg to ido
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::GoodByeSink()
|
void CompatIdoComponent::GoodByeSink(void)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
@ -196,9 +172,9 @@ void CompatIdoComponent::GoodByeSink()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* closes sink
|
* closes ido socket
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::CloseSink()
|
void CompatIdoComponent::CloseSink(void)
|
||||||
{
|
{
|
||||||
m_IdoSocket->Close();
|
m_IdoSocket->Close();
|
||||||
}
|
}
|
||||||
@ -206,7 +182,7 @@ void CompatIdoComponent::CloseSink()
|
|||||||
/**
|
/**
|
||||||
* sends config dump start signal to ido
|
* sends config dump start signal to ido
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::StartConfigDump()
|
void CompatIdoComponent::StartConfigDump(void)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
@ -226,7 +202,7 @@ void CompatIdoComponent::StartConfigDump()
|
|||||||
/**
|
/**
|
||||||
* sends config dump end signal to ido
|
* sends config dump end signal to ido
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::EndConfigDump()
|
void CompatIdoComponent::EndConfigDump(void)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
@ -243,6 +219,8 @@ void CompatIdoComponent::EndConfigDump()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* dump host config to ido
|
* dump host config to ido
|
||||||
|
*
|
||||||
|
* @param host Pointer to the Host object
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::DumpHostObject(const Host::Ptr& host)
|
void CompatIdoComponent::DumpHostObject(const Host::Ptr& host)
|
||||||
{
|
{
|
||||||
@ -317,13 +295,13 @@ void CompatIdoComponent::DumpHostObject(const Host::Ptr& host)
|
|||||||
<< 262 << "=" << "i2_customvar" << ":" << 1 << ":" << "i2_custom_var_mod" << "\n" /* customvariable */
|
<< 262 << "=" << "i2_customvar" << ":" << 1 << ":" << "i2_custom_var_mod" << "\n" /* customvariable */
|
||||||
<< 999 << "\n\n"; /* enddata */
|
<< 999 << "\n\n"; /* enddata */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_IdoSocket->SendMessage(message.str());
|
m_IdoSocket->SendMessage(message.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dump host status to ido
|
* dump host status to ido
|
||||||
|
*
|
||||||
|
* @param host Pointer to Host object
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::DumpHostStatus(const Host::Ptr& host)
|
void CompatIdoComponent::DumpHostStatus(const Host::Ptr& host)
|
||||||
{
|
{
|
||||||
@ -399,6 +377,8 @@ void CompatIdoComponent::DumpHostStatus(const Host::Ptr& host)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* dump service config to ido
|
* dump service config to ido
|
||||||
|
*
|
||||||
|
* @param service Pointer to Service object
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::DumpServiceObject(const Service::Ptr& service)
|
void CompatIdoComponent::DumpServiceObject(const Service::Ptr& service)
|
||||||
{
|
{
|
||||||
@ -470,6 +450,8 @@ void CompatIdoComponent::DumpServiceObject(const Service::Ptr& service)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* dump service status to ido
|
* dump service status to ido
|
||||||
|
*
|
||||||
|
* @param service Pointer to Service object
|
||||||
*/
|
*/
|
||||||
void CompatIdoComponent::DumpServiceStatus(const Service::Ptr& service)
|
void CompatIdoComponent::DumpServiceStatus(const Service::Ptr& service)
|
||||||
{
|
{
|
||||||
@ -479,6 +461,7 @@ void CompatIdoComponent::DumpServiceStatus(const Service::Ptr& service)
|
|||||||
double execution_start = -1, execution_end = -1;
|
double execution_start = -1, execution_end = -1;
|
||||||
|
|
||||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
Dictionary::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
output = cr->Get("output");
|
output = cr->Get("output");
|
||||||
schedule_start = cr->Get("schedule_start");
|
schedule_start = cr->Get("schedule_start");
|
||||||
|
@ -39,12 +39,16 @@ private:
|
|||||||
Timer::Ptr m_ProgramStatusTimer;
|
Timer::Ptr m_ProgramStatusTimer;
|
||||||
IdoSocket::Ptr m_IdoSocket;
|
IdoSocket::Ptr m_IdoSocket;
|
||||||
|
|
||||||
|
void ConfigTimerHandler(void);
|
||||||
|
void StatusTimerHandler(void);
|
||||||
|
void ProgramStatusTimerHandler(void);
|
||||||
|
|
||||||
void OpenSink(String node, String service );
|
void OpenSink(String node, String service );
|
||||||
void SendHello(String instancename);
|
void SendHello(String instancename);
|
||||||
void GoodByeSink();
|
void GoodByeSink(void);
|
||||||
void CloseSink();
|
void CloseSink(void);
|
||||||
void StartConfigDump();
|
void StartConfigDump(void);
|
||||||
void EndConfigDump();
|
void EndConfigDump(void);
|
||||||
|
|
||||||
void DumpConfigObjects(void);
|
void DumpConfigObjects(void);
|
||||||
void DumpHostObject(const Host::Ptr& host);
|
void DumpHostObject(const Host::Ptr& host);
|
||||||
@ -62,13 +66,6 @@ private:
|
|||||||
msg << type << "=" << *it << "\n";
|
msg << type << "=" << *it << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void DemoTimerHandler(void);
|
|
||||||
//void HelloWorldRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
|
|
||||||
|
|
||||||
void ConfigTimerHandler(void);
|
|
||||||
void StatusTimerHandler(void);
|
|
||||||
void ProgramStatusTimerHandler(void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,24 +60,6 @@ void IdoSocket::SendMessage(const String& message)
|
|||||||
void IdoSocket::DataAvailableHandler(void)
|
void IdoSocket::DataAvailableHandler(void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
/*
|
|
||||||
String sString;
|
|
||||||
|
|
||||||
while (NetString::ReadStringFromIOQueue(this, &sString)) {
|
|
||||||
//std::cerr << "<< " << jsonString << std::endl;
|
|
||||||
|
|
||||||
try {
|
|
||||||
Value value = Value::Deserialize(jsonString);
|
|
||||||
|
|
||||||
if (!value.IsObjectType<Dictionary>())
|
|
||||||
throw_exception(invalid_argument("JSON-RPC message must be a dictionary."));
|
|
||||||
|
|
||||||
OnNewMessage(GetSelf(), MessagePart(value));
|
|
||||||
} catch (const exception& ex) {
|
|
||||||
Logger::Write(LogCritical, "jsonrpc", "Exception while processing message from JSON-RPC client: " + String(ex.what()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user