]> granicus.if.org Git - icinga2/commitdiff
livestatus: add current_notification_number to host and service table
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 18 Jul 2013 15:24:14 +0000 (17:24 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 18 Jul 2013 15:32:09 +0000 (17:32 +0200)
refs #4372

components/livestatus/hoststable.cpp
components/livestatus/servicestable.cpp

index 27437617b96862cd39adbdc0588a133259b4b7f0..819802d67f27b2408b319fcc42b93e41c2f9c001 100644 (file)
@@ -681,8 +681,21 @@ Value HostsTable::HasBeenCheckedAccessor(const Value& row)
 
 Value HostsTable::CurrentNotificationNumberAccessor(const Value& row)
 {
-       /* TODO Host->Service->GetNotifications->(loop) new attribute */
-       return Empty;
+       /* use hostcheck service */
+       Service::Ptr hc = static_cast<Host::Ptr>(row)->GetHostCheckService();
+
+       if (!hc)
+               return Empty;
+
+        /* XXX Service -> Notifications, biggest wins */
+        int notification_number = 0;
+        BOOST_FOREACH(const Notification::Ptr& notification, hc->GetNotifications()) {
+                if (notification->GetNotificationNumber() > notification_number)
+                        notification_number = notification->GetNotificationNumber();
+        }
+
+        return notification_number;
+
 }
 
 Value HostsTable::PendingFlexDowntimeAccessor(const Value& row)
index 0b2d67d34ee509d42af752623ec87297a3e7445e..b914ad4e340d02ddf8abadbef15ca51faf553b62 100644 (file)
@@ -543,8 +543,16 @@ Value ServicesTable::NextNotificationAccessor(const Value& row)
 
 Value ServicesTable::CurrentNotificationNumberAccessor(const Value& row)
 {
-       /* TODO not implemented yet */
-       return Empty;
+       Service::Ptr service = static_cast<Service::Ptr>(row);
+
+       /* XXX Service -> Notifications, biggest wins */
+       int notification_number = 0;
+       BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
+               if (notification->GetNotificationNumber() > notification_number)
+                       notification_number = notification->GetNotificationNumber();
+       }
+
+       return notification_number;
 }
 
 Value ServicesTable::LastStateChangeAccessor(const Value& row)