Source Code Cross Referenced for SnmpProtocol.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » server » snmp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server resin 3.1.5 » resin » com.caucho.server.snmp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Nam Nguyen
028:         */
029:
030:        package com.caucho.server.snmp;
031:
032:        import java.util.HashMap;
033:
034:        import com.caucho.server.connection.Connection;
035:        import com.caucho.server.port.Port;
036:        import com.caucho.server.port.Protocol;
037:        import com.caucho.server.port.ServerRequest;
038:
039:        import com.caucho.server.snmp.types.OctetStringValue;
040:        import com.caucho.server.snmp.types.SnmpValue;
041:
042:        /*
043:         * SNMP v1 protocol.
044:         */
045:        public class SnmpProtocol extends Protocol {
046:            private String _protocolName = "snmp";
047:
048:            //holds the mappings from SNMP oids to MBeans
049:            private HashMap<String, Oid> _mibMap = new HashMap<String, Oid>();
050:
051:            //specially reserved for Caucho by iana.org
052:            private final int PRIVATE_ENTERPRISE_NUMBER = 30350;
053:
054:            private String _community;
055:
056:            public SnmpProtocol() {
057:                addOid("1.3.6.1.2.1.1.1", "resin:type=Resin", "Version",
058:                        SnmpValue.OCTET_STRING);
059:
060:                addOid("1.3.6.1.2.1.1.3", "java.lang:type=Runtime", "UpTime",
061:                        SnmpValue.TIME_TICKS);
062:
063:                addOid("1.3.6.1.2.1.1.5", "resin:type=Host,name=default",
064:                        "URL", SnmpValue.OCTET_STRING);
065:
066:                String penPrefix = "1.3.6.1.4.1." + PRIVATE_ENTERPRISE_NUMBER
067:                        + ".";
068:
069:                addOid(penPrefix + "1.1", "resin:type=Server",
070:                        "KeepaliveCountTotal", SnmpValue.GAUGE);
071:
072:                addOid(penPrefix + "1.2", "resin:type=Server",
073:                        "RequestCountTotal", SnmpValue.GAUGE);
074:
075:                addOid(penPrefix + "1.3", "resin:type=Server", "RuntimeMemory",
076:                        SnmpValue.GAUGE);
077:
078:                addOid(penPrefix + "1.4", "resin:type=Server",
079:                        "RuntimeMemoryFree", SnmpValue.GAUGE);
080:
081:                addOid(penPrefix + "1.5", "resin:type=Server",
082:                        "ThreadActiveCount", SnmpValue.GAUGE);
083:
084:                addOid(penPrefix + "1.6", "resin:type=Server",
085:                        "ThreadKeepaliveCount", SnmpValue.GAUGE);
086:
087:                addOid(penPrefix + "2.1", "resin:type=ThreadPool",
088:                        "ThreadActiveCount", SnmpValue.GAUGE);
089:
090:                addOid(penPrefix + "2.2", "resin:type=ThreadPool",
091:                        "ThreadCount", SnmpValue.GAUGE);
092:
093:                addOid(penPrefix + "2.3", "resin:type=ThreadPool",
094:                        "ThreadIdleCount", SnmpValue.GAUGE);
095:
096:                addOid(penPrefix + "2.4", "resin:type=ThreadPool",
097:                        "ThreadIdleMax", SnmpValue.GAUGE);
098:
099:                addOid(penPrefix + "2.5", "resin:type=ThreadPool",
100:                        "ThreadIdleMin", SnmpValue.GAUGE);
101:
102:                addOid(penPrefix + "2.6", "resin:type=ThreadPool", "ThreadMax",
103:                        SnmpValue.GAUGE);
104:
105:                addOid(penPrefix + "3.1", "resin:type=ProxyCache",
106:                        "HitCountTotal", SnmpValue.GAUGE);
107:
108:                addOid(penPrefix + "3.2", "resin:type=ProxyCache",
109:                        "MissCountTotal", SnmpValue.GAUGE);
110:
111:                /* These return complex mbeans
112:                addOid(penPrefix + "4.1",
113:                       "java.lang:type=Memory",
114:                       "HeapMemoryUsage",
115:                       SnmpValue.GAUGE);
116:                
117:                addOid(penPrefix + "4.2",
118:                       "java.lang:type=Memory",
119:                       "NonHeapMemoryUsage",
120:                       SnmpValue.GAUGE);
121:                 */
122:            }
123:
124:            /**
125:             * Sets the containing port.
126:             */
127:            @Override
128:            public void setParent(Port port) {
129:                super .setParent(port);
130:            }
131:
132:            /**
133:             * Returns the protocol name.
134:             */
135:            public String getProtocolName() {
136:                return _protocolName;
137:            }
138:
139:            /**
140:             * Sets the protocol name.
141:             */
142:            public void setProtocolName(String name) {
143:                _protocolName = name;
144:            }
145:
146:            /*
147:             * Adds an SNMP-MBean mapping.
148:             */
149:            public void addOid(Oid oid) throws Exception {
150:                _mibMap.put(oid.getName(), oid);
151:            }
152:
153:            private void addOid(String name, String mbean, String attribute,
154:                    int type) {
155:                Oid oid = new Oid(name, mbean, attribute, type);
156:
157:                _mibMap.put(name, oid);
158:            }
159:
160:            public HashMap<String, Oid> getMib() {
161:                return _mibMap;
162:            }
163:
164:            public String getCommunity() {
165:                if (_community == null)
166:                    return "public";
167:                else
168:                    return _community;
169:            }
170:
171:            public void setCommunity(String s) {
172:                _community = s;
173:            }
174:
175:            public ServerRequest createRequest(Connection connection) {
176:                OctetStringValue community;
177:
178:                if (_community == null)
179:                    community = OctetStringValue.PUBLIC;
180:                else
181:                    community = new OctetStringValue(_community);
182:
183:                return new SnmpRequest(connection, _mibMap, community);
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.