WIP: compatido

This commit is contained in:
Michael Friedrich 2012-09-15 12:51:40 +02:00
parent a6828f57d3
commit 7540cd82a6
12 changed files with 1324 additions and 1 deletions

View File

@ -4,6 +4,7 @@
SUBDIRS = \
checker \
compat \
compatido \
convenience \
delegation \
demo \

View File

@ -0,0 +1,34 @@
## Process this file with automake to produce Makefile.in
pkglib_LTLIBRARIES = \
compatido.la
compatido_la_SOURCES = \
compatidocomponent.cpp \
compatidocomponent.h \
i2-compatido.h
compatido_la_CPPFLAGS = \
$(BOOST_CPPFLAGS) \
-I${top_srcdir}/base \
-I${top_srcdir}/dyn \
-I${top_srcdir}/jsonrpc \
-I${top_srcdir}/icinga \
-I${top_srcdir}/cib
compatido_la_LDFLAGS = \
$(BOOST_LDFLAGS) \
-module \
-no-undefined \
@RELEASE_INFO@ \
@VERSION_INFO@
compatido_la_LIBADD = \
$(BOOST_SIGNALS_LIB) \
$(BOOST_THREAD_LIB) \
${top_builddir}/base/libbase.la \
${top_builddir}/dyn/libdyn.la \
${top_builddir}/jsonrpc/libjsonrpc.la \
${top_builddir}/icinga/libicinga.la \
${top_builddir}/cib/libcib.la

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7D0C062E-5199-4A5F-A31C-602275EBDF63}</ProjectGuid>
<RootNamespace>compatido</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(SolutionDir)\cib;$(SolutionDir)\dyn;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(SolutionDir)\cib;$(SolutionDir)\dyn;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;COMPATIDO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>base.lib;dyn.lib;jsonrpc.lib;icinga.lib;cib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;COMPATIDO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>base.lib;dyn.lib;jsonrpc.lib;icinga.lib;cib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="compatidocomponent.cpp" />
<ClCompile Include="idosocket.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="compatidocomponent.h" />
<ClInclude Include="i2-compatido.h" />
<ClInclude Include="idoprotoapi.h" />
<ClInclude Include="idosocket.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="compatidocomponent.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="idosocket.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="compatidocomponent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="i2-compatido.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="idosocket.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="idoprotoapi.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,484 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* 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. *
******************************************************************************/
#include "i2-compatido.h"
using namespace icinga;
/**
* Returns the name of the component.
*
* @returns The name.
*/
String CompatIdoComponent::GetName(void) const
{
return "compatido";
}
/**
* Starts the component.
*/
void CompatIdoComponent::Start(void)
{
/*
* TODO
* we should have configs for
* - socket (unix or tcp)
* - data_processing_options
* - config_output_options - 0..orig, 1..retained (fake one)
* - INSTANCE_NAME ?
*/
m_StatusTimer = boost::make_shared<Timer>();
m_StatusTimer->SetInterval(15);
m_StatusTimer->OnTimerExpired.connect(boost::bind(&CompatIdoComponent::StatusTimerHandler, this));
m_StatusTimer->Start();
m_StatusTimer->Reschedule(0);
/*
* open ido socket
*/
OpenSink("127.0.0.1", "5668");
SendHello("i2-default");
/*
* send the config on startup - FIXME dynamic config update handler
*/
DumpConfigObjects();
}
/**
* Stops the component.
*/
void CompatIdoComponent::Stop(void)
{
}
/* TODO
* subscribe to all status updates and checkresults and dump them
* should remove the periodic statusdata dump
*/
/**
* Periodically dumps status information
*
* @param - Event arguments for the timer.
*/
void CompatIdoComponent::StatusTimerHandler(void)
{
/*
* TODO
* - fetch config, dump it
* - fetch status data, dump it periodically
* - subscribe to check events and status updates, dump it
*/
/*
* HINTS
* - we don't have any implizit host commands, fake it
*/
}
/**
* Periodically dumps config information
*
* @param - Event arguments for the timer.
*/
void CompatIdoComponent::ConfigTimerHandler(void)
{
/*
* TODO
* - fetch config, dump it
* - fetch status data, dump it periodically
* - subscribe to check events and status updates, dump it
*/
/*
* HINTS
* - we don't have any implizit host commands, fake it
*/
}
/**
* opens a tcp connection to the socket
*/
void CompatIdoComponent::OpenSink(String node, String service)
{
m_IdoSocket = boost::make_shared<IdoSocket>(RoleOutbound);
m_IdoSocket->Connect(node, service);
m_IdoSocket->Start();
}
/**
* sends hello msg to ido
*/
void CompatIdoComponent::SendHello(String instancename)
{
time_t now;
time(&now);
/* IDO_API_CONNECTION is always TCP */
/* IDO_API_CONNECTTYPE is always initial */
stringstream message;
message << "\n\n"
<< IDO_API_HELLO << "\n"
<< IDO_API_PROTOCOL << ": " << IDO_API_PROTOVERSION << "\n"
<< IDO_API_AGENT << ": " << "I2 COMPAT-IDO" << "\n"
<< IDO_API_AGENTVERSION << ": " << "2.0" << "\n"
<< IDO_API_STARTTIME << ": " << now << "\n"
<< IDO_API_DISPOSITION << ": " << IDO_API_DISPOSITION_REALTIME << "\n"
<< IDO_API_CONNECTION << ": " << IDO_API_CONNECTION_TCPSOCKET << "\n"
<< IDO_API_INSTANCENAME << ": " << instancename << "\n"
<< IDO_API_STARTDATADUMP
<< "\n\n";
m_IdoSocket->SendMessage(message.str());
}
void CompatIdoComponent::StartConfigDump()
{
struct timeval now;
gettimeofday(&now, NULL);
/* IDOMOD_CONFIG_DUMP_ORIGINAL=1 is the default config type */
stringstream message;
message << "\n"
<< IDO_API_STARTCONFIGDUMP << ":" << "\n"
<< IDO_DATA_CONFIGDUMPTYPE << "=" << 1 << "\n"
<< IDO_DATA_TIMESTAMP << "=" << now.tv_sec << "." << now.tv_usec << "\n"
<< IDO_API_ENDDATA
<< "\n";
m_IdoSocket->SendMessage(message.str());
}
void CompatIdoComponent::EndConfigDump()
{
struct timeval now;
gettimeofday(&now, NULL);
stringstream message;
message << "\n"
<< IDO_API_ENDCONFIGDUMP << ":" << "\n"
<< IDO_DATA_TIMESTAMP << "=" << now.tv_sec << "." << now.tv_usec << "\n"
<< IDO_API_ENDDATA
<< "\n";
m_IdoSocket->SendMessage(message.str());
}
void CompatIdoComponent::DumpHostObject(const Host::Ptr& host)
{
struct timeval now;
gettimeofday(&now, NULL);
stringstream message;
message << "\n"
<< IDO_API_HOSTDEFINITION << ":" << "\n"
<< IDO_DATA_TIMESTAMP << "=" << now.tv_sec << "." << now.tv_usec << "\n"
<< IDO_DATA_HOSTNAME << "=" << host->GetName() << "\n"
<< IDO_DATA_DISPLAYNAME << "=" << host->GetAlias() << "\n"
<< IDO_DATA_HOSTALIAS << "=" << host->GetAlias() << "\n"
<< IDO_DATA_HOSTADDRESS << "=" << "" << "\n"
<< IDO_DATA_HOSTADDRESS6 << "=" << "" << "\n"
<< IDO_DATA_HOSTCHECKCOMMAND << "=" << "" << "\n"
<< IDO_DATA_HOSTEVENTHANDLER << "=" << "" << "\n"
<< IDO_DATA_HOSTNOTIFICATIONPERIOD << "=" << "" << "\n"
<< IDO_DATA_HOSTCHECKPERIOD << "=" << "" << "\n"
<< IDO_DATA_HOSTFAILUREPREDICTIONOPTIONS << "=" << "" << "\n"
<< IDO_DATA_HOSTCHECKINTERVAL << "=" << 1 << "\n"
<< IDO_DATA_HOSTRETRYINTERVAL << "=" << 1 << "\n"
<< IDO_DATA_HOSTMAXCHECKATTEMPTS << "=" << 1 << "\n"
<< IDO_DATA_FIRSTNOTIFICATIONDELAY << "=" << 0 << "\n"
<< IDO_DATA_HOSTNOTIFICATIONINTERVAL << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYHOSTDOWN << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYHOSTUNREACHABLE << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYHOSTRECOVERY << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYHOSTFLAPPING << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYHOSTDOWNTIME << "=" << 0 << "\n"
<< IDO_DATA_HOSTFLAPDETECTIONENABLED << "=" << 0 << "\n"
<< IDO_DATA_FLAPDETECTIONONUP << "=" << 0 << "\n"
<< IDO_DATA_FLAPDETECTIONOIDOWN << "=" << 0 << "\n"
<< IDO_DATA_FLAPDETECTIONONUNREACHABLE << "=" << 0 << "\n"
<< IDO_DATA_LOWHOSTFLAPTHRESHOLD << "=" << 0 << "\n"
<< IDO_DATA_HIGHHOSTFLAPTHRESHOLD << "=" << 0 << "\n"
<< IDO_DATA_STALKHOSTONUP << "=" << 0 << "\n"
<< IDO_DATA_STALKHOSTOIDOWN << "=" << 0 << "\n"
<< IDO_DATA_STALKHOSTONUNREACHABLE << "=" << 0 << "\n"
<< IDO_DATA_HOSTFRESHNESSCHECKSENABLED << "=" << 0 << "\n"
<< IDO_DATA_HOSTFRESHNESSTHRESHOLD << "=" << 0 << "\n"
<< IDO_DATA_PROCESSHOSTPERFORMANCEDATA << "=" << 1 << "\n"
<< IDO_DATA_ACTIVEHOSTCHECKSENABLED << "=" << 1 << "\n"
<< IDO_DATA_PASSIVEHOSTCHECKSENABLED << "=" << 1 << "\n"
<< IDO_DATA_HOSTEVENTHANDLERENABLED << "=" << 0 << "\n"
<< IDO_DATA_RETAINHOSTSTATUSINFORMATION << "=" << 1 << "\n"
<< IDO_DATA_RETAINHOSTNONSTATUSINFORMATION << "=" << 1 << "\n"
<< IDO_DATA_HOSTNOTIFICATIONSENABLED << "=" << 1 << "\n"
<< IDO_DATA_HOSTFAILUREPREDICTIONENABLED << "=" << 0 << "\n"
<< IDO_DATA_OBSESSOVERHOST << "=" << 0 << "\n"
<< IDO_DATA_NOTES << "=" << "i2_notes" << "\n"
<< IDO_DATA_NOTESURL << "=" << "" << "\n"
<< IDO_DATA_ACTIONURL << "=" << "" << "\n"
<< IDO_DATA_ICONIMAGE << "=" << "" << "\n"
<< IDO_DATA_ICONIMAGEALT << "=" << "" << "\n"
<< IDO_DATA_VRMLIMAGE << "=" << "" << "\n"
<< IDO_DATA_STATUSMAPIMAGE << "=" << "" << "\n"
<< IDO_DATA_HAVE2DCOORDS << "=" << 0 << "\n"
<< IDO_DATA_X2D << "=" << 0.0 << "\n"
<< IDO_DATA_Y2D << "=" << 0.0 << "\n"
<< IDO_DATA_HAVE3DCOORDS << "=" << 0 << "\n"
<< IDO_DATA_X3D << "=" << 0.0 << "\n"
<< IDO_DATA_Y3D << "=" << 0.0 << "\n"
<< IDO_DATA_Z3D<< "=" << 0.0 << "\n"
/* FIXME add more related config items
* parents, contactgroups, contacts, custom vars
* before sending the message
*/
<< IDO_API_ENDDATA << "\n\n";
m_IdoSocket->SendMessage(message.str());
}
void CompatIdoComponent::DumpHostStatus(const Host::Ptr& host)
{
}
void CompatIdoComponent::DumpServiceObject(const Service::Ptr& service)
{
struct timeval now;
gettimeofday(&now, NULL);
stringstream message;
message << "\n"
<< IDO_API_SERVICEDEFINITION << ":" << "\n"
<< IDO_DATA_TIMESTAMP << "=" << now.tv_sec << "." << now.tv_usec << "\n"
<< IDO_DATA_HOSTNAME << "=" << service->GetHost()->GetName() << "\n"
<< IDO_DATA_DISPLAYNAME << "=" << service->GetAlias() << "\n"
<< IDO_DATA_SERVICEDESCRIPTION << "=" << service->GetAlias() << "\n"
<< IDO_DATA_SERVICECHECKCOMMAND << "=" << "check_i2" << "\n"
<< IDO_DATA_SERVICEEVENTHANDLER << "=" << "" << "\n"
<< IDO_DATA_SERVICENOTIFICATIONPERIOD << "=" << "" << "\n"
<< IDO_DATA_SERVICECHECKPERIOD << "=" << "" << "\n"
<< IDO_DATA_SERVICEFAILUREPREDICTIONOPTIONS << "=" << "" << "\n"
<< IDO_DATA_SERVICECHECKINTERVAL << "=" << 1 << "\n"
<< IDO_DATA_SERVICERETRYINTERVAL << "=" << 1 << "\n"
<< IDO_DATA_MAXSERVICECHECKATTEMPTS << "=" << 1 << "\n"
<< IDO_DATA_FIRSTNOTIFICATIONDELAY << "=" << 0 << "\n"
<< IDO_DATA_SERVICENOTIFICATIONINTERVAL << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYSERVICEUNKNOWN << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYSERVICEWARNING << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYSERVICECRITICAL << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYSERVICERECOVERY << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYSERVICEFLAPPING << "=" << 0 << "\n"
<< IDO_DATA_NOTIFYSERVICEDOWNTIME << "=" << 0 << "\n"
<< IDO_DATA_STALKSERVICEONOK << "=" << 0 << "\n"
<< IDO_DATA_STALKSERVICEONWARNING << "=" << 0 << "\n"
<< IDO_DATA_STALKSERVICEONUNKNOWN << "=" << 0 << "\n"
<< IDO_DATA_STALKSERVICEONCRITICAL << "=" << 0 << "\n"
<< IDO_DATA_SERVICEISVOLATILE << "=" << 0 << "\n"
<< IDO_DATA_SERVICEFLAPDETECTIONENABLED << "=" << 0 << "\n"
<< IDO_DATA_FLAPDETECTIONONOK << "=" << 0 << "\n"
<< IDO_DATA_FLAPDETECTIONONWARNING << "=" << 0 << "\n"
<< IDO_DATA_FLAPDETECTIONONUNKNOWN << "=" << 0 << "\n"
<< IDO_DATA_FLAPDETECTIONONCRITICAL << "=" << 0 << "\n"
<< IDO_DATA_LOWSERVICEFLAPTHRESHOLD << "=" << 0 << "\n"
<< IDO_DATA_HIGHSERVICEFLAPTHRESHOLD << "=" << 0 << "\n"
<< IDO_DATA_PROCESSSERVICEPERFORMANCEDATA << "=" << 1 << "\n"
<< IDO_DATA_SERVICEFRESHNESSCHECKSENABLED << "=" << 0 << "\n"
<< IDO_DATA_SERVICEFRESHNESSTHRESHOLD << "=" << 0 << "\n"
<< IDO_DATA_PASSIVESERVICECHECKSENABLED << "=" << 1 << "\n"
<< IDO_DATA_SERVICEEVENTHANDLERENABLED << "=" << 0 << "\n"
<< IDO_DATA_ACTIVESERVICECHECKSENABLED << "=" << 1 << "\n"
<< IDO_DATA_RETAINSERVICESTATUSINFORMATION << "=" << 1 << "\n"
<< IDO_DATA_RETAINSERVICENONSTATUSINFORMATION << "=" << 1 << "\n"
<< IDO_DATA_SERVICENOTIFICATIONSENABLED << "=" << 0 << "\n"
<< IDO_DATA_OBSESSOVERSERVICE << "=" << 0 << "\n"
<< IDO_DATA_SERVICEFAILUREPREDICTIONENABLED << "=" << 0 << "\n"
<< IDO_DATA_NOTES << "=" << "i2_notes" << "\n"
<< IDO_DATA_NOTESURL << "=" << "" << "\n"
<< IDO_DATA_ACTIONURL << "=" << "" << "\n"
<< IDO_DATA_ICONIMAGE << "=" << "" << "\n"
<< IDO_DATA_ICONIMAGEALT << "=" << "" << "\n"
/* FIXME add more related config items
* contactgroups, contacts, custom vars
* before sending the message
*/
<< IDO_API_ENDDATA << "\n\n";
m_IdoSocket->SendMessage(message.str());
}
void CompatIdoComponent::DumpServiceStatus(const Service::Ptr& service)
{
}
/**
* process and dump all config objects
*/
void CompatIdoComponent::DumpConfigObjects(void)
{
/* TODO dump
* commands, timeperiods, contact*
* escalations, dependencies
* if needed/available.
*/
Logger::Write(LogInformation, "compatido", "Writing compat ido config information");
/* tell ido2db that we start now */
StartConfigDump();
/* hosts and hostgroups */
map<String, vector<String> > hostgroups;
DynamicObject::Ptr object;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicObject::GetObjects("Host")) {
const Host::Ptr& host = static_pointer_cast<Host>(object);
Dictionary::Ptr dict;
dict = host->GetGroups();
if (dict) {
Value hostgroup;
BOOST_FOREACH(tie(tuples::ignore, hostgroup), dict) {
hostgroups[hostgroup].push_back(host->GetName());
}
}
DumpHostObject(host);
}
pair<String, vector<String > > hgt;
BOOST_FOREACH(hgt, hostgroups) {
const String& name = hgt.first;
const vector<String>& hosts = hgt.second;
if(HostGroup::Exists(name)) {
HostGroup::Ptr hg = HostGroup::GetByName(name);
/* dump the hostgroup and its attributes/members to ido */
struct timeval now;
gettimeofday(&now, NULL);
stringstream message;
message << "\n"
<< IDO_API_HOSTGROUPDEFINITION << ":" << "\n"
<< IDO_DATA_TIMESTAMP << "=" << now.tv_sec << "." << now.tv_usec << "\n"
<< IDO_DATA_HOSTGROUPNAME << "=" << name << "\n"
<< IDO_DATA_HOSTGROUPALIAS << "=" << hg->GetAlias() << "\n";
CreateMessageList(message, hosts, IDO_DATA_HOSTGROUPMEMBER);
//vector<String>::iterator it;
//for (it = hosts.begin(); it != hosts.end(); it++) {
// message << IDO_DATA_HOSTGROUPMEMBER << "=" << *it << "\n";
//}
message << IDO_API_ENDDATA << "\n\n";
m_IdoSocket->SendMessage(message.str());
}
}
/* services and servicegroups */
map<String, vector<Service::Ptr> > servicegroups;
BOOST_FOREACH(tie(tuples::ignore, object), DynamicObject::GetObjects("Service")) {
Service::Ptr service = static_pointer_cast<Service>(object);
Dictionary::Ptr dict;
dict = service->GetGroups();
if (dict) {
Value servicegroup;
BOOST_FOREACH(tie(tuples::ignore, servicegroup), dict) {
servicegroups[servicegroup].push_back(service);
}
}
DumpServiceObject(service);
}
pair<String, vector<Service::Ptr> > sgt;
BOOST_FOREACH(sgt, servicegroups) {
const String& name = sgt.first;
const vector<Service::Ptr>& services = sgt.second;
if (ServiceGroup::Exists(name)) {
ServiceGroup::Ptr sg = ServiceGroup::GetByName(name);
/* dump the servicegroup and its attributes/members to ido */
struct timeval now;
gettimeofday(&now, NULL);
stringstream message;
message << "\n"
<< IDO_API_SERVICEGROUPDEFINITION << ":" << "\n"
<< IDO_DATA_TIMESTAMP << "=" << now.tv_sec << "." << now.tv_usec << "\n"
<< IDO_DATA_SERVICEGROUPNAME << "=" << name << "\n"
<< IDO_DATA_SERVICEGROUPALIAS << "=" << sg->GetAlias() << "\n";
vector<String> sglist;
vector<Service::Ptr>::iterator vt;
BOOST_FOREACH(const Service::Ptr& service, services) {
sglist.push_back(service->GetHost()->GetName());
sglist.push_back(service->GetAlias());
}
CreateMessageList(message, services, IDO_DATA_SERVICEGROUPMEMBER);
//for (vt = sglist.begin(); vt != sglist.end(); vt++) {
// message << IDO_DATA_SERVICEGROUPMEMBER << "=" << *vt << "\n";
//}
message << IDO_API_ENDDATA << "\n\n";
m_IdoSocket->SendMessage(message.str());
}
}
/* tell ido2db that we ended dumping the config */
EndConfigDump();
}
/**
* process and dump all status data
*/
void CompatIdoComponent::DumpStatusData(void)
{
Logger::Write(LogInformation, "compatido", "Writing compat ido status information");
stringstream message;
/* program status - should probably done more often */
message << "\n\n";
}
EXPORT_COMPONENT(compatido, CompatIdoComponent);

View File

@ -0,0 +1,70 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* 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. *
******************************************************************************/
#ifndef COMPATIDOCOMPONENT_H
#define COMPATIDOCOMPONENT_H
namespace icinga
{
/**
* @ingroup compatido
*/
class CompatIdoComponent : public IComponent
{
public:
virtual String GetName(void) const;
virtual void Start(void);
virtual void Stop(void);
private:
Timer::Ptr m_StatusTimer;
IdoSocket::Ptr m_IdoSocket;
void OpenSink(String node, String service );
void SendHello(String instancename);
void StartConfigDump();
void EndConfigDump();
void DumpConfigObjects(void);
void DumpHostObject(const Host::Ptr& host);
void DumpServiceObject(const Service::Ptr& service);
void DumpStatusData(void);
void DumpHostStatus(const Host::Ptr& host);
void DumpServiceStatus(const Service::Ptr& service);
template<typename T>
void CreateMessageList(stringstream& msg, const T& list, int type)
{
typename T::const_iterator it;
for (it = list.begin(); it != list.end(); it++) {
msg << type << "=" << *it << "\n";
}
}
//void DemoTimerHandler(void);
//void HelloWorldRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
void ConfigTimerHandler(void);
void StatusTimerHandler(void);
};
}
#endif /* COMPATIDOCOMPONENT_H */

View File

@ -0,0 +1,44 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* 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. *
******************************************************************************/
#ifndef I2COMPATIDO_H
#define I2COMPATIDO_H
/**
* @defgroup compatido Compat IDO component
*
* The compat ido component dumps config, status, history
* to a socket where ido2db is listening
*/
#include <i2-base.h>
#include <i2-jsonrpc.h>
#include <i2-icinga.h>
#include <i2-cib.h>
using std::stringstream;
#include "idoprotoapi.h"
#include "idosocket.h"
#include "compatidocomponent.h"
#include <sstream>
#endif /* I2COMPATIDO_H */

View File

@ -0,0 +1,405 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* 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. *
******************************************************************************/
#ifndef COMPATIDOPROTOAPI_H
#define COMPATIDOPROTOAPI_H
/*
* PROTOCOL VERSION
*/
#define IDO_API_PROTOVERSION 2
/*
* CONTROL STRINGS
*/
#define IDO_API_NONE ""
#define IDO_API_HELLO "HELLO"
#define IDO_API_GOODBYE "GOODBYE"
#define IDO_API_PROTOCOL "PROTOCOL"
#define IDO_API_AGENT "AGENT"
#define IDO_API_AGENTVERSION "AGENTVERSION"
#define IDO_API_DISPOSITION "DISPOSITION" /* archived or realtime */
#define IDO_API_CONNECTION "CONNECTION" /* immediate or deferred */
#define IDO_API_CONNECTTYPE "CONNECTTYPE" /* initial or reconnection */
#define IDO_API_DISPOSITION_ARCHIVED "ARCHIVED"
#define IDO_API_DISPOSITION_REALTIME "REALTIME"
#define IDO_API_CONNECTION_FILE "FILE"
#define IDO_API_CONNECTION_UNIXSOCKET "UNIXSOCKET"
#define IDO_API_CONNECTION_TCPSOCKET "TCPSOCKET"
#define IDO_API_CONNECTTYPE_INITIAL "INITIAL"
#define IDO_API_CONNECTTYPE_RECONNECT "RECONNECT"
#define IDO_API_STARTDATADUMP "STARTDATADUMP"
#define IDO_API_STARTTIME "STARTTIME"
#define IDO_API_ENDTIME "ENDTIME"
#define IDO_API_CONFIGDUMP_ORIGINAL "ORIGINAL"
#define IDO_API_CONFIGDUMP_RETAINED "RETAINED"
#define IDO_API_INSTANCENAME "INSTANCENAME"
#define IDO_API_STARTCONFIGDUMP 900
#define IDO_API_ENDCONFIGDUMP 901
#define IDO_API_ENDDATA 999
#define IDO_API_ENDDATADUMP 1000
/*
* DATA TYPES
*/
#define IDO_API_LOGENTRY 100
#define IDO_API_PROCESSDATA 200
#define IDO_API_TIMEDEVENTDATA 201
#define IDO_API_LOGDATA 202
#define IDO_API_SYSTEMCOMMANDDATA 203
#define IDO_API_EVENTHANDLERDATA 204
#define IDO_API_NOTIFICATIONDATA 205
#define IDO_API_SERVICECHECKDATA 206
#define IDO_API_HOSTCHECKDATA 207
#define IDO_API_COMMENTDATA 208
#define IDO_API_DOWNTIMEDATA 209
#define IDO_API_FLAPPINGDATA 210
#define IDO_API_PROGRAMSTATUSDATA 211
#define IDO_API_HOSTSTATUSDATA 212
#define IDO_API_SERVICESTATUSDATA 213
#define IDO_API_ADAPTIVEPROGRAMDATA 214
#define IDO_API_ADAPTIVEHOSTDATA 215
#define IDO_API_ADAPTIVESERVICEDATA 216
#define IDO_API_EXTERNALCOMMANDDATA 217
#define IDO_API_AGGREGATEDSTATUSDATA 218
#define IDO_API_RETENTIONDATA 219
#define IDO_API_CONTACTNOTIFICATIONDATA 220
#define IDO_API_CONTACTNOTIFICATIONMETHODDATA 221
#define IDO_API_ACKNOWLEDGEMENTDATA 222
#define IDO_API_STATECHANGEDATA 223
#define IDO_API_CONTACTSTATUSDATA 224
#define IDO_API_ADAPTIVECONTACTDATA 225
#define IDO_API_MAINCONFIGFILEVARIABLES 300
#define IDO_API_RESOURCECONFIGFILEVARIABLES 301
#define IDO_API_CONFIGVARIABLES 302
#define IDO_API_RUNTIMEVARIABLES 303
#define IDO_API_HOSTDEFINITION 400
#define IDO_API_HOSTGROUPDEFINITION 401
#define IDO_API_SERVICEDEFINITION 402
#define IDO_API_SERVICEGROUPDEFINITION 403
#define IDO_API_HOSTDEPENDENCYDEFINITION 404
#define IDO_API_SERVICEDEPENDENCYDEFINITION 405
#define IDO_API_HOSTESCALATIONDEFINITION 406
#define IDO_API_SERVICEESCALATIONDEFINITION 407
#define IDO_API_COMMANDDEFINITION 408
#define IDO_API_TIMEPERIODDEFINITION 409
#define IDO_API_CONTACTDEFINITION 410
#define IDO_API_CONTACTGROUPDEFINITION 411
/*
* COMMON DATA ATTRIBUTES
*/
#define IDO_MAX_DATA_TYPES 270
#define IDO_DATA_NONE 0
#define IDO_DATA_TYPE 1
#define IDO_DATA_FLAGS 2
#define IDO_DATA_ATTRIBUTES 3
#define IDO_DATA_TIMESTAMP 4
/*
* LIVE DATA ATTRIBUTES
*/
#define IDO_DATA_ACKAUTHOR 5
#define IDO_DATA_ACKDATA 6
#define IDO_DATA_ACKNOWLEDGEMENTTYPE 7
#define IDO_DATA_ACTIVEHOSTCHECKSENABLED 8
#define IDO_DATA_ACTIVESERVICECHECKSENABLED 9
#define IDO_DATA_AUTHORNAME 10
#define IDO_DATA_CHECKCOMMAND 11
#define IDO_DATA_CHECKTYPE 12
#define IDO_DATA_COMMANDARGS 13
#define IDO_DATA_COMMANDLINE 14
#define IDO_DATA_COMMANDSTRING 15
#define IDO_DATA_COMMANDTYPE 16
#define IDO_DATA_COMMENT 17
#define IDO_DATA_COMMENTID 18
#define IDO_DATA_COMMENTTIME 19
#define IDO_DATA_COMMENTTYPE 20
#define IDO_DATA_CONFIGFILENAME 21
#define IDO_DATA_CONFIGFILEVARIABLE 22
#define IDO_DATA_CONFIGVARIABLE 23
#define IDO_DATA_CONTACTSNOTIFIED 24
#define IDO_DATA_CURRENTCHECKATTEMPT 25
#define IDO_DATA_CURRENTNOTIFICATIONNUMBER 26
#define IDO_DATA_CURRENTSTATE 27
#define IDO_DATA_DAEMONMODE 28
#define IDO_DATA_DOWNTIMEID 29
#define IDO_DATA_DOWNTIMETYPE 30
#define IDO_DATA_DURATION 31
#define IDO_DATA_EARLYTIMEOUT 32
#define IDO_DATA_ENDTIME 33
#define IDO_DATA_ENTRYTIME 34
#define IDO_DATA_ENTRYTYPE 35
#define IDO_DATA_ESCALATED 36
#define IDO_DATA_EVENTHANDLER 37
#define IDO_DATA_EVENTHANDLERENABLED 38
#define IDO_DATA_EVENTHANDLERSENABLED 39
#define IDO_DATA_EVENTHANDLERTYPE 40
#define IDO_DATA_EVENTTYPE 41
#define IDO_DATA_EXECUTIONTIME 42
#define IDO_DATA_EXPIRATIONTIME 43
#define IDO_DATA_EXPIRES 44
#define IDO_DATA_FAILUREPREDICTIONENABLED 45
#define IDO_DATA_FIXED 46
#define IDO_DATA_FLAPDETECTIONENABLED 47
#define IDO_DATA_FLAPPINGTYPE 48
#define IDO_DATA_GLOBALHOSTEVENTHANDLER 49
#define IDO_DATA_GLOBALSERVICEEVENTHANDLER 50
#define IDO_DATA_HASBEENCHECKED 51
#define IDO_DATA_HIGHTHRESHOLD 52
#define IDO_DATA_HOST 53
#define IDO_DATA_ISFLAPPING 54
#define IDO_DATA_LASTCOMMANDCHECK 55
#define IDO_DATA_LASTHARDSTATE 56
#define IDO_DATA_LASTHARDSTATECHANGE 57
#define IDO_DATA_LASTHOSTCHECK 58
#define IDO_DATA_LASTHOSTNOTIFICATION 59
#define IDO_DATA_LASTLOGROTATION 60
#define IDO_DATA_LASTSERVICECHECK 61
#define IDO_DATA_LASTSERVICENOTIFICATION 62
#define IDO_DATA_LASTSTATECHANGE 63
#define IDO_DATA_LASTTIMECRITICAL 64
#define IDO_DATA_LASTTIMEDOWN 65
#define IDO_DATA_LASTTIMEOK 66
#define IDO_DATA_LASTTIMEUNKNOWN 67
#define IDO_DATA_LASTTIMEUNREACHABLE 68
#define IDO_DATA_LASTTIMEUP 69
#define IDO_DATA_LASTTIMEWARNING 70
#define IDO_DATA_LATENCY 71
#define IDO_DATA_LOGENTRY 72
#define IDO_DATA_LOGENTRYTIME 73
#define IDO_DATA_LOGENTRYTYPE 74
#define IDO_DATA_LOWTHRESHOLD 75
#define IDO_DATA_MAXCHECKATTEMPTS 76
#define IDO_DATA_MODIFIEDHOSTATTRIBUTE 77
#define IDO_DATA_MODIFIEDHOSTATTRIBUTES 78
#define IDO_DATA_MODIFIEDSERVICEATTRIBUTE 79
#define IDO_DATA_MODIFIEDSERVICEATTRIBUTES 80
#define IDO_DATA_NEXTHOSTCHECK 81
#define IDO_DATA_NEXTHOSTNOTIFICATION 82
#define IDO_DATA_NEXTSERVICECHECK 83
#define IDO_DATA_NEXTSERVICENOTIFICATION 84
#define IDO_DATA_NOMORENOTIFICATIONS 85
#define IDO_DATA_NORMALCHECKINTERVAL 86
#define IDO_DATA_NOTIFICATIONREASON 87
#define IDO_DATA_NOTIFICATIONSENABLED 88
#define IDO_DATA_NOTIFICATIONTYPE 89
#define IDO_DATA_NOTIFYCONTACTS 90
#define IDO_DATA_OBSESSOVERHOST 91
#define IDO_DATA_OBSESSOVERHOSTS 92
#define IDO_DATA_OBSESSOVERSERVICE 93
#define IDO_DATA_OBSESSOVERSERVICES 94
#define IDO_DATA_OUTPUT 95
#define IDO_DATA_PASSIVEHOSTCHECKSENABLED 96
#define IDO_DATA_PASSIVESERVICECHECKSENABLED 97
#define IDO_DATA_PERCENTSTATECHANGE 98
#define IDO_DATA_PERFDATA 99
#define IDO_DATA_PERSISTENT 100
#define IDO_DATA_PROBLEMHASBEENACKNOWLEDGED 101
#define IDO_DATA_PROCESSID 102
#define IDO_DATA_PROCESSPERFORMANCEDATA 103
#define IDO_DATA_PROGRAMDATE 104
#define IDO_DATA_PROGRAMNAME 105
#define IDO_DATA_PROGRAMSTARTTIME 106
#define IDO_DATA_PROGRAMVERSION 107
#define IDO_DATA_RECURRING 108
#define IDO_DATA_RETRYCHECKINTERVAL 109
#define IDO_DATA_RETURNCODE 110
#define IDO_DATA_RUNTIME 111
#define IDO_DATA_RUNTIMEVARIABLE 112
#define IDO_DATA_SCHEDULEDDOWNTIMEDEPTH 113
#define IDO_DATA_SERVICE 114
#define IDO_DATA_SHOULDBESCHEDULED 115
#define IDO_DATA_SOURCE 116
#define IDO_DATA_STARTTIME 117
#define IDO_DATA_STATE 118
#define IDO_DATA_STATECHANGE 119
#define IDO_DATA_STATECHANGETYPE 120
#define IDO_DATA_STATETYPE 121
#define IDO_DATA_STICKY 122
#define IDO_DATA_TIMEOUT 123
#define IDO_DATA_TRIGGEREDBY 124
#define IDO_DATA_LONGOUTPUT 125
/*
* OBJECT CONFIG DATA ATTRIBUTES
*/
#define IDO_DATA_ACTIONURL 126
#define IDO_DATA_COMMANDNAME 127
#define IDO_DATA_CONTACTADDRESS 128
#define IDO_DATA_CONTACTALIAS 129
#define IDO_DATA_CONTACTGROUP 130
#define IDO_DATA_CONTACTGROUPALIAS 131
#define IDO_DATA_CONTACTGROUPMEMBER 132
#define IDO_DATA_CONTACTGROUPNAME 133
#define IDO_DATA_CONTACTNAME 134
#define IDO_DATA_DEPENDENCYTYPE 135
#define IDO_DATA_DEPENDENTHOSTNAME 136
#define IDO_DATA_DEPENDENTSERVICEDESCRIPTION 137
#define IDO_DATA_EMAILADDRESS 138
#define IDO_DATA_ESCALATEONCRITICAL 139
#define IDO_DATA_ESCALATEOIDOWN 140
#define IDO_DATA_ESCALATEONRECOVERY 141
#define IDO_DATA_ESCALATEONUNKNOWN 142
#define IDO_DATA_ESCALATEONUNREACHABLE 143
#define IDO_DATA_ESCALATEONWARNING 144
#define IDO_DATA_ESCALATIONPERIOD 145
#define IDO_DATA_FAILONCRITICAL 146
#define IDO_DATA_FAILOIDOWN 147
#define IDO_DATA_FAILONOK 148
#define IDO_DATA_FAILONUNKNOWN 149
#define IDO_DATA_FAILONUNREACHABLE 150
#define IDO_DATA_FAILONUP 151
#define IDO_DATA_FAILONWARNING 152
#define IDO_DATA_FIRSTNOTIFICATION 153
#define IDO_DATA_HAVE2DCOORDS 154
#define IDO_DATA_HAVE3DCOORDS 155
#define IDO_DATA_HIGHHOSTFLAPTHRESHOLD 156
#define IDO_DATA_HIGHSERVICEFLAPTHRESHOLD 157
#define IDO_DATA_HOSTADDRESS 158
#define IDO_DATA_HOSTALIAS 159
#define IDO_DATA_HOSTCHECKCOMMAND 160
#define IDO_DATA_HOSTCHECKINTERVAL 161
#define IDO_DATA_HOSTCHECKPERIOD 162
#define IDO_DATA_HOSTEVENTHANDLER 163
#define IDO_DATA_HOSTEVENTHANDLERENABLED 164
#define IDO_DATA_HOSTFAILUREPREDICTIONENABLED 165
#define IDO_DATA_HOSTFAILUREPREDICTIONOPTIONS 166
#define IDO_DATA_HOSTFLAPDETECTIONENABLED 167
#define IDO_DATA_HOSTFRESHNESSCHECKSENABLED 168
#define IDO_DATA_HOSTFRESHNESSTHRESHOLD 169
#define IDO_DATA_HOSTGROUPALIAS 170
#define IDO_DATA_HOSTGROUPMEMBER 171
#define IDO_DATA_HOSTGROUPNAME 172
#define IDO_DATA_HOSTMAXCHECKATTEMPTS 173
#define IDO_DATA_HOSTNAME 174
#define IDO_DATA_HOSTNOTIFICATIONCOMMAND 175
#define IDO_DATA_HOSTNOTIFICATIONINTERVAL 176
#define IDO_DATA_HOSTNOTIFICATIONPERIOD 177
#define IDO_DATA_HOSTNOTIFICATIONSENABLED 178
#define IDO_DATA_ICONIMAGE 179
#define IDO_DATA_ICONIMAGEALT 180
#define IDO_DATA_INHERITSPARENT 181
#define IDO_DATA_LASTNOTIFICATION 182
#define IDO_DATA_LOWHOSTFLAPTHRESHOLD 183
#define IDO_DATA_LOWSERVICEFLAPTHRESHOLD 184
#define IDO_DATA_MAXSERVICECHECKATTEMPTS 185
#define IDO_DATA_NOTES 186
#define IDO_DATA_NOTESURL 187
#define IDO_DATA_NOTIFICATIONINTERVAL 188
#define IDO_DATA_NOTIFYHOSTDOWN 189
#define IDO_DATA_NOTIFYHOSTFLAPPING 190
#define IDO_DATA_NOTIFYHOSTRECOVERY 191
#define IDO_DATA_NOTIFYHOSTUNREACHABLE 192
#define IDO_DATA_NOTIFYSERVICECRITICAL 193
#define IDO_DATA_NOTIFYSERVICEFLAPPING 194
#define IDO_DATA_NOTIFYSERVICERECOVERY 195
#define IDO_DATA_NOTIFYSERVICEUNKNOWN 196
#define IDO_DATA_NOTIFYSERVICEWARNING 197
#define IDO_DATA_PAGERADDRESS 198
#define IDO_DATA_PARENTHOST 200
#define IDO_DATA_PROCESSHOSTPERFORMANCEDATA 201
#define IDO_DATA_PROCESSSERVICEPERFORMANCEDATA 202
#define IDO_DATA_RETAINHOSTNONSTATUSINFORMATION 203
#define IDO_DATA_RETAINHOSTSTATUSINFORMATION 204
#define IDO_DATA_RETAINSERVICENONSTATUSINFORMATION 205
#define IDO_DATA_RETAINSERVICESTATUSINFORMATION 206
#define IDO_DATA_SERVICECHECKCOMMAND 207
#define IDO_DATA_SERVICECHECKINTERVAL 208
#define IDO_DATA_SERVICECHECKPERIOD 209
#define IDO_DATA_SERVICEDESCRIPTION 210
#define IDO_DATA_SERVICEEVENTHANDLER 211
#define IDO_DATA_SERVICEEVENTHANDLERENABLED 212
#define IDO_DATA_SERVICEFAILUREPREDICTIONENABLED 213
#define IDO_DATA_SERVICEFAILUREPREDICTIONOPTIONS 214
#define IDO_DATA_SERVICEFLAPDETECTIONENABLED 215
#define IDO_DATA_SERVICEFRESHNESSCHECKSENABLED 216
#define IDO_DATA_SERVICEFRESHNESSTHRESHOLD 217
#define IDO_DATA_SERVICEGROUPALIAS 218
#define IDO_DATA_SERVICEGROUPMEMBER 219
#define IDO_DATA_SERVICEGROUPNAME 220
#define IDO_DATA_SERVICEISVOLATILE 221
#define IDO_DATA_SERVICENOTIFICATIONCOMMAND 222
#define IDO_DATA_SERVICENOTIFICATIONINTERVAL 223
#define IDO_DATA_SERVICENOTIFICATIONPERIOD 224
#define IDO_DATA_SERVICENOTIFICATIONSENABLED 225
#define IDO_DATA_SERVICERETRYINTERVAL 226
#define IDO_DATA_STALKHOSTOIDOWN 228
#define IDO_DATA_STALKHOSTONUNREACHABLE 229
#define IDO_DATA_STALKHOSTONUP 230
#define IDO_DATA_STALKSERVICEONCRITICAL 231
#define IDO_DATA_STALKSERVICEONOK 232
#define IDO_DATA_STALKSERVICEONUNKNOWN 233
#define IDO_DATA_STALKSERVICEONWARNING 234
#define IDO_DATA_STATUSMAPIMAGE 235
#define IDO_DATA_TIMEPERIODALIAS 236
#define IDO_DATA_TIMEPERIODNAME 237
#define IDO_DATA_TIMERANGE 238
#define IDO_DATA_VRMLIMAGE 239
#define IDO_DATA_X2D 240
#define IDO_DATA_X3D 241
#define IDO_DATA_Y2D 242
#define IDO_DATA_Y3D 243
#define IDO_DATA_Z3D 244
#define IDO_DATA_CONFIGDUMPTYPE 245
#define IDO_DATA_FIRSTNOTIFICATIONDELAY 246
#define IDO_DATA_HOSTRETRYINTERVAL 247
#define IDO_DATA_NOTIFYHOSTDOWNTIME 248
#define IDO_DATA_NOTIFYSERVICEDOWNTIME 249
#define IDO_DATA_CANSUBMITCOMMANDS 250
#define IDO_DATA_FLAPDETECTIONONUP 251
#define IDO_DATA_FLAPDETECTIONOIDOWN 252
#define IDO_DATA_FLAPDETECTIONONUNREACHABLE 253
#define IDO_DATA_FLAPDETECTIONONOK 254
#define IDO_DATA_FLAPDETECTIONONWARNING 255
#define IDO_DATA_FLAPDETECTIONONUNKNOWN 256
#define IDO_DATA_FLAPDETECTIONONCRITICAL 257
#define IDO_DATA_DISPLAYNAME 258
#define IDO_DATA_DEPENDENCYPERIOD 259
#define IDO_DATA_MODIFIEDCONTACTATTRIBUTE 260 /* LIVE DATA */
#define IDO_DATA_MODIFIEDCONTACTATTRIBUTES 261 /* LIVE DATA */
#define IDO_DATA_CUSTOMVARIABLE 262
#define IDO_DATA_HASBEENMODIFIED 263
#define IDO_DATA_CONTACT 264
#define IDO_DATA_LASTSTATE 265
#define IDO_DATA_HOSTADDRESS6 266
#define IDO_DATA_END_TIME 267 /* ACKNOWLEDGEMENT DATA */
#define IDO_DATA_DOWNTIMEISINEFFECT 268
#define IDO_DATA_DOWNTIMETRIGGERTIME 269
#endif /* COMPATIDOPROTOAPI_H */

View File

@ -0,0 +1,93 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* 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. *
******************************************************************************/
#include "i2-compatido.h"
using namespace icinga;
/**
* Constructor for the IdoSocket class.
*
* @param role The role of the underlying TCP client.
*/
IdoSocket::IdoSocket(TcpClientRole role)
: TcpClient(role)
{
/*
* we currently do not receive any data from the ido socket,
* this is just data output - so we do not need to bind
* a local instance of our datahandler in case of a new
* signal telling about new data
*/
//OnDataAvailable.connect(boost::bind(&IdoSocket::DataAvailableHandler, this));
}
/**
* Sends a message to the ido socket
*
* @param message The message.
*/
void IdoSocket::SendMessage(const String& message)
{
/*
* write our message to the send queue
* as we inherit all the functionality
* of the tcpclient class
*/
Write(message, message.size());
}
/**
* Processes inbound data.
* Currently not used, as we do not receive data from ido sockets
*/
void IdoSocket::DataAvailableHandler(void)
{
for (;;) {
string sString;
{
mutex::scoped_lock lock(GetMutex());
if (!Netstring::ReadStringFromFIFO(GetRecvQueue(), &sString))
return;
}
try {
//message = MessagePart(jsonString);
//OnNewMessage(GetSelf(), message);
} catch (const exception& ex) {
Logger::Write(LogCritical, "idosocket", "Exception while processing message from idosocket client: " + string(ex.what()));
}
}
}
/**
* Factory function for ido socket clients.
*
* @param fd The file descriptor.
* @param role The role of the underlying TCP client.
* @returns A new ido socket client.
*/
IdoSocket::Ptr icinga::IdoSocketFactory(SOCKET fd, TcpClientRole role)
{
IdoSocket::Ptr client = boost::make_shared<IdoSocket>(role);
client->SetFD(fd);
return client;
}

View File

@ -0,0 +1,55 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* 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. *
******************************************************************************/
#ifndef IDOSOCKET_H
#define IDOSOCKET_H
#include "i2-compatido.h"
namespace icinga
{
/**
* An IDO socket client.
*
* @ingroup compatido
*/
class IdoSocket : public TcpClient
{
public:
typedef shared_ptr<IdoSocket> Ptr;
typedef weak_ptr<IdoSocket> WeakPtr;
IdoSocket(TcpClientRole role);
void SendMessage(const String& message);
boost::signal<void (const IdoSocket::Ptr&, const stringstream&)> OnNewMessage;
private:
void DataAvailableHandler(void);
friend IdoSocket::Ptr IdoSocketFactory(SOCKET fd, TcpClientRole role);
};
IdoSocket::Ptr IdoSocketFactory(SOCKET fd, TcpClientRole role);
}
#endif /* JSONRPCCLIENT_H */

View File

@ -51,7 +51,7 @@ AM_PROG_LEX
AC_PROG_YACC
AC_PROG_LIBTOOL
AX_CXX_GCC_ABI_DEMANGLE
AX_BOOST_BASE([1.46], [], [AC_MSG_ERROR([You need the Boost headers and libraries in order to build this application])])
AX_BOOST_BASE([1.42], [], [AC_MSG_ERROR([You need the Boost headers and libraries in order to build this application])])
AX_BOOST_SIGNALS
AX_BOOST_THREAD
AX_BOOST_SYSTEM
@ -70,6 +70,7 @@ Makefile
components/Makefile
components/checker/Makefile
components/compat/Makefile
components/compatido/Makefile
components/convenience/Makefile
components/delegation/Makefile
components/demo/Makefile

View File

@ -46,6 +46,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "convenience", "components\c
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compatido", "components\compatido\compatido.vcxproj", "{7D0C062E-5199-4A5F-A31C-602275EBDF63}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "components", "components", "{4A1773FD-DDED-4952-8700-C898E890554A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libraries", "libraries", "{BC82DE9C-42E2-4880-92DA-C2269D2F6416}"
@ -118,6 +120,10 @@ Global
{D02A349B-BAF7-41FB-86FF-B05BA05FE578}.Debug|Win32.Build.0 = Debug|Win32
{D02A349B-BAF7-41FB-86FF-B05BA05FE578}.Release|Win32.ActiveCfg = Release|Win32
{D02A349B-BAF7-41FB-86FF-B05BA05FE578}.Release|Win32.Build.0 = Release|Win32
{7D0C062E-5199-4A5F-A31C-602275EBDF63}.Debug|Win32.ActiveCfg = Debug|Win32
{7D0C062E-5199-4A5F-A31C-602275EBDF63}.Debug|Win32.Build.0 = Debug|Win32
{7D0C062E-5199-4A5F-A31C-602275EBDF63}.Release|Win32.ActiveCfg = Release|Win32
{7D0C062E-5199-4A5F-A31C-602275EBDF63}.Release|Win32.Build.0 = Release|Win32
{9C92DA90-FD53-43A9-A244-90F2E8AF9677}.Debug|Win32.ActiveCfg = Debug|Win32
{9C92DA90-FD53-43A9-A244-90F2E8AF9677}.Debug|Win32.Build.0 = Debug|Win32
{9C92DA90-FD53-43A9-A244-90F2E8AF9677}.Release|Win32.ActiveCfg = Release|Win32
@ -145,6 +151,7 @@ Global
{2BD1C70C-43DB-4F44-B66B-67CF5C7044AA} = {4A1773FD-DDED-4952-8700-C898E890554A}
{D02A349B-BAF7-41FB-86FF-B05BA05FE578} = {4A1773FD-DDED-4952-8700-C898E890554A}
{2E6C1133-730F-4875-A72C-B455B1DD4C5C} = {4A1773FD-DDED-4952-8700-C898E890554A}
{7D0C062E-5199-4A5F-A31C-602275EBDF63} = {4A1773FD-DDED-4952-8700-C898E890554A}
{19CBCE06-3F5C-479A-BD75-E2AB6215D345} = {3BE47C55-D74A-46E6-8F8B-470B3FD29FB7}
{66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {3BE47C55-D74A-46E6-8F8B-470B3FD29FB7}
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {BC82DE9C-42E2-4880-92DA-C2269D2F6416}