#include "icinga/notification.h"
#include "icinga/macroprocessor.h"
#include "icinga/externalcommandprocessor.h"
+#include "icinga/compatutility.h"
#include "config/configcompilercontext.h"
#include "base/dynamictype.h"
#include "base/objectlock.h"
return; /* Nothing changed, ignore this checkresult. */
}
- String raw_output;
- String output;
-
- if (cr) {
- raw_output = cr->Get("output");
- size_t line_end = raw_output.Find("\n");
-
- output = raw_output.SubStr(0, line_end);
-
- boost::algorithm::replace_all(output, "\n", "\\n");
- }
+ String output;
+ if (cr) {
+ Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
+ output = output_bag->Get("output");
+ }
std::ostringstream msgbuf;
msgbuf << "SERVICE ALERT: "
return;
String output;
- String raw_output;
-
- if (cr) {
- raw_output = cr->Get("output");
- size_t line_end = raw_output.Find("\n");
-
- output = raw_output.SubStr(0, line_end);
- }
+ if (cr) {
+ Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
+ output = output_bag->Get("output");
+ }
std::ostringstream msgbuf;
msgbuf << "SERVICE NOTIFICATION: "
ObjectLock olock(hc);
+ String output;
+ Dictionary::Ptr cr = hc->GetLastCheckResult();
+
+ if (cr) {
+ Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
+ output = output_bag->Get("output");
+ }
+
std::ostringstream msgbuf;
msgbuf << "CURRENT HOST STATE: "
<< host->GetName() << ";"
<< Host::StateToString(Host::CalculateState(hc->GetState(), reachable)) << ";"
<< Service::StateTypeToString(hc->GetStateType()) << ";"
<< hc->GetCheckAttempt() << ";"
- << hc->GetLastCheckOutput() << "";
+ << output << "";
WriteLine(msgbuf.str());
}
if (!host)
continue;
+ String output;
+ Dictionary::Ptr cr = service->GetLastCheckResult();
+
+ if (cr) {
+ Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
+ output = output_bag->Get("output");
+ }
+
std::ostringstream msgbuf;
msgbuf << "CURRENT SERVICE STATE: "
<< host->GetName() << ";"
<< Service::StateToString(service->GetState()) << ";"
<< Service::StateTypeToString(service->GetStateType()) << ";"
<< service->GetCheckAttempt() << ";"
- << service->GetLastCheckOutput() << "";
+ << output << "";
WriteLine(msgbuf.str());
}
Value HostsTable::NameAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::DisplayNameAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::AddressAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::Address6Accessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NotesAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NotesUrlExpandedAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::ActionUrlExpandedAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Service::Ptr hc = host->GetCheckService();
String output;
- if(hc)
- output = hc->GetLastCheckOutput();
+ if(hc) {
+ String output;
+ Dictionary::Ptr cr = hc->GetLastCheckResult();
+
+ if (cr) {
+ Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
+ output = output_bag->Get("output");
+ }
+ }
return output;
}
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Service::Ptr hc = host->GetCheckService();
String perfdata;
- if (hc)
- perfdata = hc->GetLastCheckPerfData();
+ if (hc) {
+ Dictionary::Ptr cr = hc->GetLastCheckResult();
+
+ if (cr)
+ perfdata = CompatUtility::GetCheckResultPerfdata(cr);
+ }
return perfdata;
}
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::IconImageExpandedAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::IconImageAltAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::StatusmapImageAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Service::Ptr hc = host->GetCheckService();
String long_output;
- if (hc)
- long_output = hc->GetLastCheckLongOutput();
+ if (hc) {
+ String long_output;
+ Dictionary::Ptr cr = hc->GetLastCheckResult();
+
+ if (cr) {
+ Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
+ long_output = output_bag->Get("long_output");
+ }
+ }
return long_output;
}
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::LastStateAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::LastHardStateAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::TotalServicesAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
/* duplicate of ChecksEnableAccessor */
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::X2dAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::Y2dAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::CustomVariableNamesAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
- Dictionary::Ptr custom = host->GetCustom();
+ Dictionary::Ptr customvars;
- if (!custom)
+ {
+ ObjectLock olock(host);
+ customvars = CompatUtility::GetCustomVariableConfig(host);
+ }
+
+ if (!customvars)
return Empty;
Array::Ptr cv = boost::make_shared<Array>();
- ObjectLock olock(custom);
-
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), custom) {
- if (key == "notes" ||
- key == "action_url" ||
- key == "notes_url" ||
- key == "icon_image" ||
- key == "icon_image_alt" ||
- key == "statusmap_image" ||
- key == "2d_coords")
- continue;
-
+ BOOST_FOREACH(boost::tie(key, value), customvars) {
cv->Add(key);
}
Value HostsTable::CustomVariableValuesAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
- Dictionary::Ptr custom = host->GetCustom();
+ Dictionary::Ptr customvars;
- if (!custom)
+ {
+ ObjectLock olock(host);
+ customvars = CompatUtility::GetCustomVariableConfig(host);
+ }
+
+ if (!customvars)
return Empty;
Array::Ptr cv = boost::make_shared<Array>();
- ObjectLock olock(custom);
-
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), custom) {
- if (key == "notes" ||
- key == "action_url" ||
- key == "notes_url" ||
- key == "icon_image" ||
- key == "icon_image_alt" ||
- key == "statusmap_image" ||
- key == "2d_coords")
- continue;
-
+ BOOST_FOREACH(boost::tie(key, value), customvars) {
cv->Add(value);
}
Value HostsTable::CustomVariablesAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
- Dictionary::Ptr custom = host->GetCustom();
+ Dictionary::Ptr customvars;
- if (!custom)
+ {
+ ObjectLock olock(host);
+ customvars = CompatUtility::GetCustomVariableConfig(host);
+ }
+
+ if (!customvars)
return Empty;
Array::Ptr cv = boost::make_shared<Array>();
- ObjectLock olock(custom);
-
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), custom) {
- if (key == "notes" ||
- key == "action_url" ||
- key == "notes_url" ||
- key == "icon_image" ||
- key == "icon_image_alt" ||
- key == "statusmap_image" ||
- key == "2d_coords")
- continue;
-
+ BOOST_FOREACH(boost::tie(key, value), customvars) {
Array::Ptr key_val = boost::make_shared<Array>();
key_val->Add(key);
key_val->Add(value);
Value HostsTable::ParentsAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::ChildsAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* duplicate of TotalServices */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::WorstServiceStateAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NumServicesOkAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NumServicesWarnAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NumServicesCritAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NumServicesUnknownAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NumServicesPendingAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::WorstServiceHardStateAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NumServicesHardOkAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NumServicesHardWarnAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NumServicesHardCritAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::NumServicesHardUnknownAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::GroupsAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
{
/* use hostcheck service */
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::ServicesAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::ServicesWithStateAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
Value HostsTable::ServicesWithInfoAccessor(const Value& row)
{
Host::Ptr host = static_cast<Host::Ptr>(row);
-
+
if (!host)
return Empty;
svc_add->Add(service->GetShortName());
svc_add->Add(service->GetState());
svc_add->Add(service->HasBeenChecked() ? 1 : 0);
- svc_add->Add(service->GetLastCheckOutput());
+
+ String output;
+ Dictionary::Ptr cr = service->GetLastCheckResult();
+
+ if (cr) {
+ Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
+ output = output_bag->Get("output");
+ }
+
+ svc_add->Add(output);
services->Add(svc_add);
}
service = parentObjectAccessor(row);
else
service = row;
-
+
Service::Ptr svc = static_cast<Service::Ptr>(service);
-
+
if (!svc)
return Object::Ptr();
Value ServicesTable::CheckCommandExpandedAccessor(const Value& row)
{
Service::Ptr service = static_cast<Service::Ptr>(row);
-
+
if (!service)
return Empty;
Value ServicesTable::EventHandlerAccessor(const Value& row)
{
Service::Ptr service = static_cast<Service::Ptr>(row);
-
+
if (!service)
return Empty;
if (!service)
return Empty;
- return service->GetLastCheckOutput();
+ String output;
+ Dictionary::Ptr cr = service->GetLastCheckResult();
+
+ if (cr) {
+ Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
+ output = output_bag->Get("output");
+ }
+
+ return output;
}
Value ServicesTable::LongPluginOutputAccessor(const Value& row)
if (!service)
return Empty;
- return service->GetLastCheckLongOutput();
+ String long_output;
+ Dictionary::Ptr cr = service->GetLastCheckResult();
+
+ if (cr) {
+ Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
+ long_output = output_bag->Get("long_output");
+ }
+
+ return long_output;
}
Value ServicesTable::PerfDataAccessor(const Value& row)
if (!service)
return Empty;
- return service->GetLastCheckPerfData();
+ String perfdata;
+ Dictionary::Ptr cr = service->GetLastCheckResult();
+
+ if (cr)
+ perfdata = CompatUtility::GetCheckResultPerfdata(cr);
+
+ return perfdata;
}
Value ServicesTable::NotificationPeriodAccessor(const Value& row)
Value ServicesTable::NotesExpandedAccessor(const Value& row)
{
Service::Ptr service = static_cast<Service::Ptr>(row);
-
+
if (!service)
return Empty;
Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
{
Service::Ptr service = static_cast<Service::Ptr>(row);
-
+
if (!service)
return Empty;
Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
{
Service::Ptr service = static_cast<Service::Ptr>(row);
-
+
if (!service)
return Empty;
Value ServicesTable::IconImageExpandedAccessor(const Value& row)
{
Service::Ptr service = static_cast<Service::Ptr>(row);
-
+
if (!service)
return Empty;
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
+ Dictionary::Ptr customvars;
- if (!custom)
+ {
+ ObjectLock olock(service);
+ customvars = CompatUtility::GetCustomVariableConfig(service);
+ }
+
+ if (!customvars)
return Empty;
Array::Ptr cv = boost::make_shared<Array>();
- ObjectLock olock(custom);
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), custom) {
- if (key == "notes" ||
- key == "action_url" ||
- key == "notes_url" ||
- key == "icon_image" ||
- key == "icon_image_alt" ||
- key == "statusmap_image" ||
- key == "2d_coords")
- continue;
-
+ BOOST_FOREACH(boost::tie(key, value), customvars) {
cv->Add(key);
}
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
+ Dictionary::Ptr customvars;
- if (!custom)
+ {
+ ObjectLock olock(service);
+ customvars = CompatUtility::GetCustomVariableConfig(service);
+ }
+
+ if (!customvars)
return Empty;
Array::Ptr cv = boost::make_shared<Array>();
- ObjectLock olock(custom);
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), custom) {
- if (key == "notes" ||
- key == "action_url" ||
- key == "notes_url" ||
- key == "icon_image" ||
- key == "icon_image_alt" ||
- key == "statusmap_image" ||
- key == "2d_coords")
- continue;
-
+ BOOST_FOREACH(boost::tie(key, value), customvars) {
cv->Add(value);
}
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
+ Dictionary::Ptr customvars;
- if (!custom)
+ {
+ ObjectLock olock(service);
+ customvars = CompatUtility::GetCustomVariableConfig(service);
+ }
+
+ if (!customvars)
return Empty;
Array::Ptr cv = boost::make_shared<Array>();
- ObjectLock olock(custom);
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), custom) {
- if (key == "notes" ||
- key == "action_url" ||
- key == "notes_url" ||
- key == "icon_image" ||
- key == "icon_image_alt" ||
- key == "statusmap_image" ||
- key == "2d_coords")
- continue;
-
+ BOOST_FOREACH(boost::tie(key, value), customvars) {
Array::Ptr key_val = boost::make_shared<Array>();
key_val->Add(key);
key_val->Add(value);
status updates in a regular interval.
# icinga2-enable-feature statusdata
-
+
Icinga 1.x Classic UI requires this data set as part of its backend.
-
+
> **Note**
>
> If you are not using any web interface or addon requiring this output
> do not enable this feature.
+
+> **Note**
+>
+> Semi-colons in the check result output are replaced with colons because
+> they are used as attribute separators.
The `CompatLogger` object can be enabled with
# icinga2-enable-feature compatlog
-
+
By default, the Icinga 1.x log file called `icinga.log` is located
in `/var/log/icinga2/compat`. Rotated log files are moved into
`var/log/icinga2/compat/archives`.
[1382115731] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;localhost;ping6;2;critical test|
[1382115731] SERVICE ALERT: localhost;ping6;CRITICAL;SOFT;2;critical test
+> **Note**
+>
+> Semi-colons in the check result output are replaced with colons because
+> they are used as attribute separators.
/* History - update deletion time for service (and host in case) */
unsigned long entry_time = static_cast<long>(comment->Get("entry_time"));
+
double now = Utility::GetTime();
- unsigned long deletion_time = static_cast<long>(now);
- unsigned long deletion_time_usec = (now - deletion_time) * 1000 * 1000;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
DbQuery query2;
query2.Table = "commenthistory";
query2.Category = DbCatComment;
Dictionary::Ptr fields2 = boost::make_shared<Dictionary>();
- fields2->Set("deletion_time", DbValue::FromTimestamp(deletion_time));
- fields2->Set("deletion_time_usec", deletion_time_usec);
+ fields2->Set("deletion_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields2->Set("deletion_time_usec", time_bag->Get("time_usec"));
query2.Fields = fields2;
query2.WhereCriteria = boost::make_shared<Dictionary>();
/* History - update actual_end_time, was_cancelled for service (and host in case) */
double now = Utility::GetTime();
- unsigned long actual_end_time = static_cast<long>(now);
- unsigned long actual_end_time_usec = (now - actual_end_time) * 1000 * 1000;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
DbQuery query3;
query3.Table = "downtimehistory";
Dictionary::Ptr fields3 = boost::make_shared<Dictionary>();
fields3->Set("was_cancelled", downtime->Get("was_cancelled") ? 1 : 0);
- fields3->Set("actual_end_time", DbValue::FromTimestamp(actual_end_time));
- fields3->Set("actual_end_time_usec", actual_end_time_usec);
+ fields3->Set("actual_end_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields3->Set("actual_end_time_usec", time_bag->Get("time_usec"));
query3.Fields = fields3;
query3.WhereCriteria = boost::make_shared<Dictionary>();
Log(LogDebug, "db_ido", "updating triggered service downtime (id = " + downtime->Get("legacy_id") + ") for '" + service->GetName() + "'");
double now = Utility::GetTime();
- unsigned long actual_start_time = static_cast<long>(now);
- unsigned long actual_start_time_usec = static_cast<long>((now - actual_start_time) * 1000 * 1000);
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
/* Status */
DbQuery query1;
Dictionary::Ptr fields1 = boost::make_shared<Dictionary>();
fields1->Set("was_started", 1);
- fields1->Set("actual_start_time", DbValue::FromTimestamp(actual_start_time));
- fields1->Set("actual_start_time_usec", actual_start_time_usec);
+ fields1->Set("actual_start_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("actual_start_time_usec", time_bag->Get("time_usec"));
fields1->Set("is_in_effect", 1);
fields1->Set("trigger_time", DbValue::FromTimestamp(downtime->Get("trigger_time")));
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
Dictionary::Ptr fields3 = boost::make_shared<Dictionary>();
fields3->Set("was_started", 1);
fields3->Set("is_in_effect", 1);
- fields3->Set("actual_start_time", DbValue::FromTimestamp(actual_start_time));
- fields3->Set("actual_start_time_usec", actual_start_time_usec);
+ fields3->Set("actual_start_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields3->Set("actual_start_time_usec", time_bag->Get("time_usec"));
fields3->Set("trigger_time", DbValue::FromTimestamp(downtime->Get("trigger_time")));
query3.Fields = fields3;
Log(LogDebug, "db_ido", "add acknowledgement history for '" + service->GetName() + "'");
double now = Utility::GetTime();
- unsigned long entry_time = static_cast<long>(now);
- unsigned long entry_time_usec = (now - entry_time) * 1000 * 1000;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
+
unsigned long end_time = static_cast<long>(expiry);
DbQuery query1;
query1.Category = DbCatAcknowledgement;
Dictionary::Ptr fields1 = boost::make_shared<Dictionary>();
- fields1->Set("entry_time", DbValue::FromTimestamp(entry_time));
- fields1->Set("entry_time_usec", entry_time_usec);
+ fields1->Set("entry_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("entry_time_usec", time_bag->Get("time_usec"));
fields1->Set("acknowledgement_type", type);
fields1->Set("object_id", service);
fields1->Set("state", service->GetState());
/* start and end happen at the same time */
double now = Utility::GetTime();
- unsigned long start_time = static_cast<long>(now);
- unsigned long end_time = start_time;
- unsigned long start_time_usec = (now - start_time) * 1000 * 1000;
- unsigned long end_time_usec = start_time_usec;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
DbQuery query1;
query1.Table = "contactnotifications";
Dictionary::Ptr fields1 = boost::make_shared<Dictionary>();
fields1->Set("contact_object_id", user);
- fields1->Set("start_time", DbValue::FromTimestamp(start_time));
- fields1->Set("start_time_usec", start_time_usec);
- fields1->Set("end_time", DbValue::FromTimestamp(end_time));
- fields1->Set("end_time_usec", end_time_usec);
+ fields1->Set("start_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("start_time_usec", time_bag->Get("time_usec"));
+ fields1->Set("end_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("end_time_usec", time_bag->Get("time_usec"));
fields1->Set("notification_id", 0); /* DbConnection class fills in real ID */
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
/* start and end happen at the same time */
double now = Utility::GetTime();
- unsigned long start_time = static_cast<long>(now);
- unsigned long end_time = start_time;
- unsigned long start_time_usec = (now - start_time) * 1000 * 1000;
- unsigned long end_time_usec = start_time_usec;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
DbQuery query1;
query1.Table = "notifications";
fields1->Set("notification_type", 1); /* service */
fields1->Set("notification_reason", CompatUtility::MapNotificationReasonType(type));
fields1->Set("object_id", service);
- fields1->Set("start_time", DbValue::FromTimestamp(start_time));
- fields1->Set("start_time_usec", start_time_usec);
- fields1->Set("end_time", DbValue::FromTimestamp(end_time));
- fields1->Set("end_time_usec", end_time_usec);
+ fields1->Set("start_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("start_time_usec", time_bag->Get("time_usec"));
+ fields1->Set("end_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("end_time_usec", time_bag->Get("time_usec"));
fields1->Set("state", service->GetState());
if (cr) {
Log(LogDebug, "db_ido", "add state change history for '" + service->GetName() + "'");
double now = Utility::GetTime();
- unsigned long state_time = static_cast<long>(now);
- unsigned long state_time_usec = (now - state_time) * 1000 * 1000;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
DbQuery query1;
query1.Table = "statehistory";
query1.Category = DbCatStateHistory;
Dictionary::Ptr fields1 = boost::make_shared<Dictionary>();
- fields1->Set("state_time", DbValue::FromTimestamp(state_time));
- fields1->Set("state_time_usec", state_time_usec);
+ fields1->Set("state_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("state_time_usec", time_bag->Get("time_usec"));
fields1->Set("object_id", service);
fields1->Set("state_change", 1); /* service */
fields1->Set("state", service->GetState());
Log(LogDebug, "db_ido", "add log entry history for '" + service->GetName() + "'");
double now = Utility::GetTime();
- unsigned long entry_time = static_cast<long>(now);
- unsigned long entry_time_usec = (now - entry_time) * 1000 * 1000;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
DbQuery query1;
query1.Table = "logentries";
query1.Category = DbCatLog;
Dictionary::Ptr fields1 = boost::make_shared<Dictionary>();
- fields1->Set("logentry_time", DbValue::FromTimestamp(entry_time));
- fields1->Set("entry_time", DbValue::FromTimestamp(entry_time));
- fields1->Set("entry_time_usec", entry_time_usec);
+ fields1->Set("logentry_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("entry_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("entry_time_usec", time_bag->Get("time_usec"));
fields1->Set("object_id", service); // added in 1.10 see #4754
fields1->Set("logentry_type", type);
fields1->Set("logentry_data", buffer);
Log(LogDebug, "db_ido", "add flapping history for '" + service->GetName() + "'");
double now = Utility::GetTime();
- unsigned long event_time = static_cast<long>(now);
- unsigned long event_time_usec = (now - event_time) * 1000 * 1000;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
DbQuery query1;
query1.Table = "flappinghistory";
Dictionary::Ptr fields1 = boost::make_shared<Dictionary>();
- fields1->Set("event_time", DbValue::FromTimestamp(event_time));
- fields1->Set("event_time_usec", event_time_usec);
+ fields1->Set("event_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("event_time_usec", time_bag->Get("time_usec"));
switch (flapping_state) {
case FlappingStarted:
fields1->Set("state_type", attrs->Get("state_type"));
double now = Utility::GetTime();
- unsigned long start_time = static_cast<long>(now);
- unsigned long start_time_usec = (now - start_time) * 1000 * 1000;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
double end = now + attrs->Get("check_execution_time");
- unsigned long end_time = static_cast<long>(end);
- unsigned long end_time_usec = (end - end_time) * 1000 * 1000;
+ Dictionary::Ptr time_bag_end = CompatUtility::ConvertTimestamp(end);
- fields1->Set("start_time", DbValue::FromTimestamp(start_time));
- fields1->Set("start_time_usec", start_time_usec);
- fields1->Set("end_time", DbValue::FromTimestamp(end_time));
- fields1->Set("end_time_usec", end_time_usec);
+ fields1->Set("start_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("start_time_usec", time_bag->Get("time_usec"));
+ fields1->Set("end_time", DbValue::FromTimestamp(time_bag_end->Get("time_sec")));
+ fields1->Set("end_time_usec", time_bag_end->Get("time_usec"));
fields1->Set("command_object_id", service->GetCheckCommand());
fields1->Set("command_args", Empty);
fields1->Set("command_line", cr->Get("command"));
Log(LogDebug, "db_ido", "add eventhandler history for '" + service->GetName() + "'");
double now = Utility::GetTime();
- unsigned long event_time = static_cast<long>(now);
- unsigned long event_time_usec = (now - event_time) * 1000 * 1000;
+ Dictionary::Ptr time_bag = CompatUtility::ConvertTimestamp(now);
DbQuery query1;
query1.Table = "eventhandlers";
fields1->Set("state", service->GetState());
fields1->Set("state_type", service->GetStateType());
- fields1->Set("start_time", DbValue::FromTimestamp(event_time));
- fields1->Set("start_time_usec", event_time_usec);
- fields1->Set("end_time", DbValue::FromTimestamp(event_time));
- fields1->Set("end_time_usec", event_time_usec);
+ fields1->Set("start_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("start_time_usec", time_bag->Get("time_usec"));
+ fields1->Set("end_time", DbValue::FromTimestamp(time_bag->Get("time_sec")));
+ fields1->Set("end_time_usec", time_bag->Get("time_usec"));
fields1->Set("command_object_id", service->GetEventCommand());
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
Dictionary::Ptr bag = boost::make_shared<Dictionary>();
String raw_output = cr->Get("output");
+
+ /*
+ * replace semi-colons with colons in output
+ * semi-colon is used as delimiter in various interfaces
+ */
+ boost::algorithm::replace_all(raw_output, ";", ":");
+
size_t line_end = raw_output.Find("\n");
output = raw_output.SubStr(0, line_end);
return result;
}
+Dictionary::Ptr CompatUtility::ConvertTimestamp(double time)
+{
+ Dictionary::Ptr time_bag = boost::make_shared<Dictionary>();
+
+ unsigned long time_sec = static_cast<long>(time);
+ unsigned long time_usec = (time - time_sec) * 1000 * 1000;
+
+ time_bag->Set("time_sec", time_sec);
+ time_bag->Set("time_usec", time_usec);
+
+ return time_bag;
+}
+
int CompatUtility::MapNotificationReasonType(NotificationType type)
{
switch (type) {
static Dictionary::Ptr GetCheckResultOutput(const Dictionary::Ptr& cr);
static String GetCheckResultPerfdata(const Dictionary::Ptr& cr);
+ static Dictionary::Ptr ConvertTimestamp(double time);
+
static int MapNotificationReasonType(NotificationType type);
static int MapExternalCommandType(const String& name);
return schedule_end;
}
-String Service::GetLastCheckOutput(void) const
-{
- Dictionary::Ptr cr = GetLastCheckResult();
- String output;
-
- if (cr) {
- String raw_output = cr->Get("output");
- size_t line_end = raw_output.Find("\n");
- output = raw_output.SubStr(0, line_end);
- }
-
- return output;
-}
-
-String Service::GetLastCheckLongOutput(void) const
-{
- Dictionary::Ptr cr = GetLastCheckResult();
- String long_output;
-
- if (cr) {
- String raw_output = cr->Get("output");
- size_t line_end = raw_output.Find("\n");
-
- if (line_end > 0 && line_end != String::NPos) {
- long_output = raw_output.SubStr(line_end + 1, raw_output.GetLength());
- boost::algorithm::replace_all(long_output, "\n", "\\n");
- }
- }
-
- return long_output;
-}
-
-String Service::GetLastCheckPerfData(void) const
-{
- Dictionary::Ptr cr = GetLastCheckResult();
- String perfdata;
-
- if (cr) {
- perfdata = cr->Get("performance_data_raw");
-
- boost::algorithm::replace_all(perfdata, "\n", "\\n");
- }
-
- return perfdata;
-}
-
bool Service::GetEnableActiveChecks(void) const
{
if (!GetOverrideEnableActiveChecks().IsEmpty())
double GetLastCheck(void) const;
- String GetLastCheckOutput(void) const;
- String GetLastCheckLongOutput(void) const;
- String GetLastCheckPerfData(void) const;
-
bool GetEnableActiveChecks(void) const;
void SetEnableActiveChecks(bool enabled, const String& authority = String());