entry_type | int | .
expires | int | .
expire_time | string | Seconds.
- service_ | join | Prefix for attributes from implicit join with services table (and implicit host table).
+ service_ | join | Prefix for attributes from implicit join with services table.
+ host_ | join | Prefix for attributes from implicit join with hosts table.
#### <a id="schema-livestatus-downtimes-table-attributes"></a> Livestatus Downtimes Table Attributes
comment | string | .
id | int | legacy_id.
entry_time | string | Seconds.
- type | int | 1=host, 2=service.
+ type | int | 1=active, 0=pending.
is_service | int | .
start_time | string | Seconds.
end_time | string | Seconds.
triggered_by | int | legacy_id.
triggers | int | NEW in Icinga 2.
trigger_time | string | NEW in Icinga 2.
- service_ | join | Prefix for attributes from implicit join with services table (and implicit host table).
+ service_ | join | Prefix for attributes from implicit join with services table.
+ host_ | join | Prefix for attributes from implicit join with hosts table.
#### <a id="schema-livestatus-timeperiod-table-attributes"></a> Livestatus Timeperiod Table Attributes
******************************************************************************/
#include "livestatus/commentstable.hpp"
+#include "livestatus/hoststable.hpp"
#include "livestatus/servicestable.hpp"
#include "icinga/service.hpp"
#include "base/dynamictype.hpp"
table->AddColumn(prefix + "expires", Column(&CommentsTable::ExpiresAccessor, objectAccessor));
table->AddColumn(prefix + "expire_time", Column(&CommentsTable::ExpireTimeAccessor, objectAccessor));
+ /* order is important - host w/o services must not be empty */
ServicesTable::AddColumns(table, "service_", boost::bind(&CommentsTable::ServiceAccessor, _1, objectAccessor));
+ HostsTable::AddColumns(table, "host_", boost::bind(&CommentsTable::HostAccessor, _1, objectAccessor));
}
String CommentsTable::GetName(void) const
String id;
Comment::Ptr comment;
BOOST_FOREACH(tie(id, comment), comments) {
- addRowFn(comment);
+ if (Host::GetOwnerByCommentID(id) == host)
+ addRowFn(comment);
}
}
String id;
Comment::Ptr comment;
BOOST_FOREACH(tie(id, comment), comments) {
- addRowFn(comment);
+ if (Service::GetOwnerByCommentID(id) == service)
+ addRowFn(comment);
}
}
}
+Object::Ptr CommentsTable::HostAccessor(const Value& row, const Column::ObjectAccessor&)
+{
+ Comment::Ptr comment = static_cast<Comment::Ptr>(row);
+
+ Checkable::Ptr checkable = Checkable::GetOwnerByCommentID(comment->GetId());
+
+ Host::Ptr host;
+ Service::Ptr service;
+ tie(host, service) = GetHostService(checkable);
+
+ return host;
+}
+
Object::Ptr CommentsTable::ServiceAccessor(const Value& row, const Column::ObjectAccessor&)
{
Comment::Ptr comment = static_cast<Comment::Ptr>(row);
- return Checkable::GetOwnerByCommentID(comment->GetId()); // XXX: this might return a Host object
+
+ Checkable::Ptr checkable = Checkable::GetOwnerByCommentID(comment->GetId());
+
+ Host::Ptr host;
+ Service::Ptr service;
+ tie(host, service) = GetHostService(checkable);
+
+ return service;
}
Value CommentsTable::AuthorAccessor(const Value& row)
virtual void FetchRows(const AddRowFunction& addRowFn);
private:
+ static Object::Ptr HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
static Object::Ptr ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
static Value AuthorAccessor(const Value& row);
******************************************************************************/
#include "livestatus/downtimestable.hpp"
+#include "livestatus/hoststable.hpp"
#include "livestatus/servicestable.hpp"
#include "icinga/service.hpp"
#include "base/dynamictype.hpp"
table->AddColumn(prefix + "duration", Column(&DowntimesTable::DurationAccessor, objectAccessor));
table->AddColumn(prefix + "triggered_by", Column(&DowntimesTable::TriggeredByAccessor, objectAccessor));
+ /* order is important - host w/o services must not be empty */
ServicesTable::AddColumns(table, "service_", boost::bind(&DowntimesTable::ServiceAccessor, _1, objectAccessor));
+ HostsTable::AddColumns(table, "host_", boost::bind(&DowntimesTable::HostAccessor, _1, objectAccessor));
}
String DowntimesTable::GetName(void) const
void DowntimesTable::FetchRows(const AddRowFunction& addRowFn)
{
+ BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
+ Dictionary::Ptr downtimes = host->GetDowntimes();
+
+ ObjectLock olock(downtimes);
+
+ String id;
+ Downtime::Ptr downtime;
+ BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
+ if (Host::GetOwnerByDowntimeID(id) == host)
+ addRowFn(downtime);
+ }
+ }
+
BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjectsByType<Service>()) {
Dictionary::Ptr downtimes = service->GetDowntimes();
}
}
+Object::Ptr DowntimesTable::HostAccessor(const Value& row, const Column::ObjectAccessor&)
+{
+ Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
+
+ Checkable::Ptr checkable = Checkable::GetOwnerByDowntimeID(downtime->GetId());
+
+ Host::Ptr host;
+ Service::Ptr service;
+ tie(host, service) = GetHostService(checkable);
+
+ return host;
+}
+
Object::Ptr DowntimesTable::ServiceAccessor(const Value& row, const Column::ObjectAccessor&)
{
Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
- return Service::GetOwnerByDowntimeID(downtime->GetId());
+
+ Checkable::Ptr checkable = Checkable::GetOwnerByDowntimeID(downtime->GetId());
+
+ Host::Ptr host;
+ Service::Ptr service;
+ tie(host, service) = GetHostService(checkable);
+
+ return service;
}
Value DowntimesTable::AuthorAccessor(const Value& row)
virtual void FetchRows(const AddRowFunction& addRowFn);
private:
+ static Object::Ptr HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
static Object::Ptr ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
static Value AuthorAccessor(const Value& row);
--- /dev/null
+GET comments
+Columns: id type is_service host_name service_description author comment
+ResponseHeader: fixed16
+
--- /dev/null
+GET downtimes
+Columns: id type is_service host_name service_description author comment start_time end_time
+ResponseHeader: fixed16
+