A. On Thu, 2008-06-12 at 10:16 -0400, Matt Brozowski wrote:
> SnmpPeerFactory.getInstance().getAgentConfig

For reference here is the final diff I ended up with node.jsp to get
what we wanted. Obviously it's not suitable for the OpenNMS code base
but I provide it as an example of the sort of flexibility needed in our
application.

In the long run if there are changes that can be made to the code base
for a more generic solution I'd be open to looking at making a cleaner
more generic patch. This of course in my interests too so I don't have
to hold too many invasive patches into our "product fork" of the ONMS
code as well as benefiting the wider community.

Any constructive comments on my Java/JSP code also welcome as I'm sure
I've mentioned before I'm just getting up to speed with this stuff :-)

diff --git a/opennms-webapp/src/main/webapp/element/node.jsp 
b/opennms-webapp/src/main/webapp/element/node.jsp
index d963c3c..f485714 100644
--- a/opennms-webapp/src/main/webapp/element/node.jsp
+++ b/opennms-webapp/src/main/webapp/element/node.jsp
@@ -61,6 +61,8 @@
         org.opennms.web.svclayer.ResourceService,
         org.opennms.web.asset.Asset,
         org.opennms.web.asset.AssetModel,
+        org.opennms.netmgt.config.SnmpPeerFactory,
+        org.opennms.netmgt.snmp.SnmpAgentConfig,
         org.springframework.web.context.WebApplicationContext,
         org.springframework.web.context.support.WebApplicationContextUtils"
 %>
@@ -73,7 +75,32 @@
     private int m_dellServiceId;
     private int m_snmpServiceId;
     private ResourceService m_resourceService;
-       private AssetModel m_model = new AssetModel();
+    private AssetModel m_model = new AssetModel();
+
+
+    // CBNL: These sysobjid map to either BS and CPEs which we need to know 
when generating links
+    //       to our data graphs. These are defined in the 
CAMBRIDGE-BROADBAND-REG MIB
+
+public enum VNMSDevice { BS, CPE, NMS }
+
+    public static Map<String, VNMSDevice> vnmsSysObjIdToDevMap;
+    static
+    {
+        vnmsSysObjIdToDevMap = new HashMap<String, VNMSDevice>();
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.1", VNMSDevice.BS);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.2", VNMSDevice.BS);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.3", VNMSDevice.CPE);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.4", VNMSDevice.CPE);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.5", VNMSDevice.CPE);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.6", VNMSDevice.CPE);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.7", VNMSDevice.CPE);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.8", VNMSDevice.CPE);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.9", VNMSDevice.CPE);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.10", 
VNMSDevice.CPE);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.15", 
VNMSDevice.CPE);
+        vnmsSysObjIdToDevMap.put(".1.3.6.1.4.1.5419.1.3500.20", 
VNMSDevice.NMS);
+    };
+
 
     public void init() throws ServletException {
         try {
@@ -145,6 +172,15 @@
         map.put("url", linkPrefix + ip + linkSuffix);
         return Collections.singleton(map);
     }
+
+    // CBNL: Create a link to a VNMS graph
+    public static Collection<Map<String, String>> createLinkForVNMS(int 
nodeId, String linkText, String ip, String script, String argument) {
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("text", linkText);
+        map.put("url", "http://"; + ip + "/cgi-bin/" + script + "?" + argument 
+ "&onmsid=" + nodeId);
+        return Collections.singleton(map);
+    }
+
 %>
 
 <%
@@ -159,7 +195,8 @@
     links.addAll(createLinkForService(nodeId, m_telnetServiceId, "Telnet", 
"telnet://", ""));
     links.addAll(createLinkForService(nodeId, m_httpServiceId, "HTTP", 
"http://";, "/"));
     links.addAll(createLinkForService(nodeId, m_dellServiceId, "OpenManage", 
"https://";, ":1311"));
-    nodeModel.put("links", links);
+
+    // Don't add the links yet, we may have more to add later
 
     Asset asset = m_model.getAsset(nodeId);
     nodeModel.put("asset", asset);
@@ -183,9 +220,12 @@
     nodeModel.put("hasIfAliases", 
NetworkElementFactory.nodeHasIfAliases(nodeId));
     
     Service[] snmpServices = NetworkElementFactory.getServicesOnNode(nodeId, 
m_snmpServiceId);
+    Interface primarySnmpIntf = null;
+
     if (snmpServices != null && snmpServices.length > 0) {
         for (Interface intf : intfs) {
             if ("P".equals(intf.getIsSnmpPrimary())) {
+                primarySnmpIntf = intf;
                 nodeModel.put("snmpPrimaryIntf", intf);
                 break;
             }
@@ -197,7 +237,42 @@
     nodeModel.put("showBridge", NetworkElementFactory.isBridgeNode(nodeId));
     
     nodeModel.put("node", node_db);
-    
+
+    // CBNL: Check for VectaStar sysID's and add appropriate links
+    //       to the display for the links
+
+    String sysId = node_db.getNodeSysId();
+
+    if (vnmsSysObjIdToDevMap.containsKey(sysId))
+    {
+                VNMSDevice type = vnmsSysObjIdToDevMap.get(sysId);
+       String snmpIfAddr = primarySnmpIntf.getIpAddress();
+
+           if (type == VNMSDevice.BS)
+                {
+                        // This should always work
+                        String basestationArg = "bs="+snmpIfAddr;
+
+                        links.addAll(createLinkForVNMS(nodeId,  "Basestation 
Graphs", request.getLocalAddr(), "daygen.pl", basestationArg));
+                }
+                else if (type == VNMSDevice.CPE)
+                {
+           // First of all we need to find out the proxy for this CPE (which 
is it's parent basestation)
+           InetAddress proxyIP=InetAddress.getByName(snmpIfAddr);
+           SnmpAgentConfig agentConfig = 
SnmpPeerFactory.getInstance().getAgentConfig(proxyIP);
+           String agentIP=agentConfig.getAddress().toString();
+           
+           String cpeArg="bs="+agentIP+"&cpe="+snmpIfAddr;
+           links.addAll(createLinkForVNMS(nodeId,  "CPE Graphs", 
request.getLocalAddr(), "cpegen.pl", cpeArg));
+                }
+    }
+
+    // Add links to the model
+    nodeModel.put("links", links);
+
+    // We need the IPAddr for links to our cgi scripts
+    nodeModel.put("requestIp", request.getLocalAddr());
+
     pageContext.setAttribute("model", nodeModel);
 %>
 


-- 
Alex Bennee, Software Engineer
All science is either physics or stamp collecting. -- Ernest Rutherford


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
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