As we have discussed, Traps are like events. This is a way the SNMP agent pushes the information to client. Asynchronously, events can be fired to client from server (agent).
In Previous article, we have seen that how to create SNMP client in JAVA using SNMP4j.
To create the Agent for SNMP which listens for the request should extend the abstract class BaseAgent.
The BaseAgent abstract class defines a framework for writing SNMP agents using the SNMP4J-Agent API. To implement your own SNMP agent, extend this class and implement the abstract methods defined by BaseAgent. The hook methods do not need any specific implementation. They only provide a defined mechanism to customize your agent.
There are lots of open source library for SNMP is available, even java have library for the same, But in this article I will explain a simple example of using SNMP4j in JAVA to create a simple client which will display the hardware information.
Note : To run this program, SNMP service must be installed. Check this article to know that how to install SNMP in Windows XP.
Download libraries from http://www.snmp4j.org/html/download.html
Create Simple NMS (Network management station / Client) in JAVA using SNMP4j:
Enable SNMP services in Windows Xp:
- To open the Windows Components Wizard, click Start, click Control Panel, double-click Add or Remove Programs, and then click Add/Remove Windows Components.
- In Components, click Management and Monitoring Tools (but do not select or clear its check box), and then click Details.
- Select the Simple Network Management Protocol check box, and click OK.
- Click Next.
In Previous article, we have seen that what actually is SNMP. In this article we will discuss on different terminologies used in SNMP.
- Application-layer protocol for managing TCP/IP based networks.
- Runs over UDP, which runs over IP
(2) NMS (Network Management Station)
- Device that pools SNMP agent for info (Client)
(3) SNMP Agent
- Device (e.g. Router) running software that understands SNMP language. You can imagine like a Server.
- Database of info conforming to SMI.
(5) SMI (Structure of Management Information)
- Standard that defines how to create a MIB.
- Traps are like events. This is a way the SNMP agent pushes the information to client. Asynchronously, events can be fired to client from server (agent).
- The SNMP agent receives requests on UDP port 161. The manager may send requests from any available source port to port 161 in the agent. The agent response will be sent back to the source port on the manager. The manager receives notifications (Traps and InformRequests) on port 162. The agent may generate notifications from any available port.
SNMP defines both how to structure management information (data model exposed for management), and how to access it (protocol). According to SNMP, the management information is structured into MIBs (Management Information Bases). A MIB is defined using a formal language called Structure of Management Information (SMI) – whose syntax uses a subset of ASN.1 (Abstract Syntax Notation 1).