Hi,

This is something our customers have requested so I knocked this patch
up to see how easy it would be. I'd be interested in feedback from the
more "service" orientated network managers rather the "device"
orientated  people we seem to be in this field.

I suspect there is better wording for the title headings. This is
against the 1.6 stable series:

>From 685d93654bf67623ab37a66c71a446e7a982f12d Mon Sep 17 00:00:00 2001
From: Alex Bennee <a...@bennee.com>
Date: Thu, 28 May 2009 18:02:49 +0100
Subject: [PATCH] Add a node counter to the summary page

Some of our customers are familiar with seeing a summary off broken
nodes. At first glance
of the front page it's hard to tell if 4 disparate services on
different nodes are broken
or one node is down.
---
 .../java/org/opennms/web/category/Category.java    |   67 ++++++++++++++++++--
 .../src/main/webapp/includes/categories-box.jsp    |    7 ++
 2 files changed, 69 insertions(+), 5 deletions(-)

diff --git a/opennms-webapp/src/main/java/org/opennms/web/category/Category.java
b/opennms-webapp/src/main/java/org/opennms/web/category/Category.java
index 7a8704a..81e3a80 100644
--- a/opennms-webapp/src/main/java/org/opennms/web/category/Category.java
+++ b/opennms-webapp/src/main/java/org/opennms/web/category/Category.java
@@ -73,6 +73,16 @@ public class Category {
     protected Date m_lastUpdated;

     /**
+     * A cached value of the total number of nodes in a category
+     */
+    protected Long m_nodesCount;
+
+    /**
+     * A cached value of the total number of nodes affected by an outage
+     */
+    protected Long m_nodesAffectedCount;
+
+    /**
      * A cached value of the total number of services on nodes
belonging to this
      * category.
      */
@@ -117,6 +127,9 @@ public class Category {
         m_rtcCategory = rtcCategory;
         m_lastUpdated = lastUpdated;

+        m_nodesCount = null;
+        m_nodesAffectedCount = null;
+
         m_serviceCount = null;
         m_serviceDownCount = null;
     }
@@ -175,14 +188,18 @@ public class Category {
     public long getServiceCount() {
         if (m_serviceCount == null) {
             if (m_rtcCategory == null) {
+                m_nodesCount = new Long(0);
+                m_nodesAffectedCount = new Long(0);
                 m_serviceCount = new Long(0);
                 m_serviceDownCount = new Long(0);
                 m_servicePercentage = new Double(0);
             } else {
                 long[] counts = getServiceCounts(m_rtcCategory);

-                m_serviceCount = new Long(counts[0]);
-                m_serviceDownCount = new Long(counts[1]);
+                m_nodesCount = new Long(counts[0]);
+                m_nodesAffectedCount = new Long(counts[1]);
+                m_serviceCount = new Long(counts[2]);
+                m_serviceDownCount = new Long(counts[3]);

                 if (m_serviceCount.longValue() == 0) {
                     m_servicePercentage = new Double(100.0);
@@ -196,6 +213,28 @@ public class Category {
     }

     /**
+     * Return the number of nodes in the category
+     */
+    public long getNodesCount () {
+        if (m_nodesCount == null) {
+            getServiceCount();
+        }
+
+        return m_nodesCount.longValue();
+    }
+
+    /**
+     * Return the number of nodes that have affected services
+     */
+    public long getNodesAffectedCount () {
+        if (m_nodesAffectedCount == null) {
+            getServiceCount();
+        }
+
+        return m_nodesAffectedCount.longValue();
+    }
+
+    /**
      * Return the number of services that are currently down with
this category.
      */
     public long getServiceDownCount() {
@@ -257,6 +296,15 @@ public class Category {
     }

     /** Returns the outage text for this category ("X of Y" nodes down). */
+    public String getNodeOutageText() {
+        if (m_lastUpdated == null) {
+            return "Calculating...";
+        } else {
+            return getNodesAffectedCount() + " of " + getNodesCount();
+        }
+    }
+
+    /** Returns the outage text for this category ("X of Y" services down). */
     public String getOutageText() {
         if (m_lastUpdated == null) {
             return "Calculating...";
@@ -308,6 +356,9 @@ public class Category {
             throw new IllegalArgumentException("Cannot take null parameters.");
         }

+        long nodes = 0;
+        long affectedNodes = 0;
+
         long count = 0;
         long downCount = 0;

@@ -315,11 +366,17 @@ public class Category {

         while (nodeEnum.hasMoreElements()) {
             org.opennms.netmgt.xml.rtc.Node node =
(org.opennms.netmgt.xml.rtc.Node) nodeEnum.nextElement();
-
+            long affectedServices = node.getNodesvcdowncount();
+
+            nodes += 1;
             count += node.getNodesvccount();
-            downCount += node.getNodesvcdowncount();
+
+            if (affectedServices > 0) {
+                affectedNodes += 1;
+                downCount += affectedServices;
+            }
         }

-        return new long[] { count, downCount };
+        return new long[] { nodes, affectedNodes, count, downCount };
     }
 }
diff --git a/opennms-webapp/src/main/webapp/includes/categories-box.jsp
b/opennms-webapp/src/main/webapp/includes/categories-box.jsp
index 13416c7..9347ddd 100644
--- a/opennms-webapp/src/main/webapp/includes/categories-box.jsp
+++ b/opennms-webapp/src/main/webapp/includes/categories-box.jsp
@@ -95,6 +95,7 @@
        <thead>
                <tr>
                        <th><%= sectionName %></th>
+                       <th align="right">Nodes</th>
                        <th align="right">Outages</th>
                        <th align="right">Availability</th>
                </tr>
@@ -107,6 +108,7 @@
                String categoryName = category.getName();
 %>
        <tr class="CellStatus">
+
                <td>
           <% if (category.getLastUpdated() != null) { %>
                    <a href="<%= 
response.encodeURL("rtc/category.jsp?category=" +
Util.encode(categoryName)) %>"
@@ -117,6 +119,11 @@
             <%= categoryName %>
           <% } %>
                </td>
+                <td class="<%= (opennmsDisconnect ? "Indeterminate" :
category.getOutageClass()) %>"
+                   align="right"
+                   title="Updated: <%= category.getLastUpdated() %>">
+                  <%= category.getNodeOutageText() %>
+               </td>
                <td class="<%= (opennmsDisconnect ? "Indeterminate" :
category.getOutageClass()) %>"
                align="right"
                    title="Updated: <%= category.getLastUpdated() %>"><%=
category.getOutageText() %>
-- 
1.6.0.2.95.g72d40


-- 
Alex, homepage: http://www.bennee.com/~alex/
CV: http://www.bennee.com/~alex/cv.php

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-devel mailing list

To *unsubscribe* or change your subscription options, see the bottom of this 
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel

Reply via email to