Anda di halaman 1dari 38

SNMP

Yi-Neng Lin

Copyright Reserved 2001

Simple Network Management Protocol (SNMP)


Background Architectural framework MIB SMI SNMP, SNMPv2, SNMPv3 Open source: NET-SNMP

Copyright Reserved 2001

Background

Remote control without attaching to managed entities of all physical networks Exchange management information between network devices Small tools: ping, traceroute, netstate..etc (base on ICMP) Short history

Copyright Reserved 2001

Architectural Framework

Management station Agent Managed device Managed object (specified in MIB) Management protocols

management station trap or response SNMP poll or request

agent & managed device in one machine

master agent

MIB

subagent (managed device ) MIB

Possible protocol to use SNMP proxy agent SMUX AgentX

MIB

MIB

Copyright Reserved 2001

SMUX or AgentX

Management Information Base (MIB)

A group of objects that describe an SNMP manageable entity Hierarchical object groups MIB-II (RFC 1213)

Copyright Reserved 2001

MIB-II

iso (1)

.
org (3)

. .
internet (1)
. mgmt (2)

dod. (6)

private (4)

experimental (3)

directory (1)

MIB-II within hierarchical object groups

mib-II (1)

snmp (11)

transmission (10) egp (8) udp (7) tcp (6)

icmp (5)

ip (4) at (3)

interface (2)

system (1)

OBJECT IDENTIFIER: 1.3.6.1.2.1.3

Copyright Reserved 2001

Structure of Management Information (SMI)

Define the structure of a particular MIB

Places restrictions on the types of the objects allowed in the MIB Exchange of information between application components in different systems

Abstract Syntax Notation one (ASN.1)

Encode the object values (by Basic Encoding Rule)

Define the way data is represented during transmission

Copyright Reserved 2001

SMI (part of the one defined in RFC1155)


RFC1155-SMI DEFINITIONS ::= BEGIN EXPORTS EVERYTHING internet, directory, mgmt, experimental, private, enterprises, OBJECT-TYPE, ObjectName, ObjectSyntax, SimpleSyntax, ApplicationSyntax, NetworkAddress, IpAddress, Counter, Gauge, TimeTicks, Opaque; -- the path to the root internet OBJECT IDENTIFIER ::= { iso org(3) dod(6) 1 } directory OBJECT IDENTIFIER ::= { internet 1 } mgmt OBJECT IDENTIFIER ::= { internet 2 } experimental OBJECT IDENTIFIER ::= { internet 3 } private OBJECT IDENTIFIER ::= { internet 4 } enterprises OBJECT IDENTIFIER ::= { private 1 } -- definition of object types OBJECT-TYPE MACRO ::= BEGIN TYPE NOTATION ::= "SYNTAX" type (TYPE ObjectSyntax) "ACCESS" Access "STATUS" Status VALUE NOTATION ::= value (VALUE ObjectName) Access ::= "read-only" | "read-write" | "write-only" | "not-accessible" Status ::= "mandatory" | "optional" | "obsolete" END -- names of objects in the MIB ObjectName ::= OBJECT IDENTIFIER -- syntax of objects in the MIB ObjectSyntax ::= CHOICE { simple SimpleSyntax, application-wide ApplicationSyntax } SimpleSyntax ::= CHOICE { number INTEGER, string OCTET STRING, object OBJECT IDENTIFIER, empty NULL }

Copyright Reserved 2001

SMIv2 (part of the one defined in RFC2578)


SNMPv2-SMI DEFINITIONS ::= BEGIN -- the path to the root org OBJECT IDENTIFIER ::= { iso 3 } -- "iso" = 1 dod OBJECT IDENTIFIER ::= { org 6 } internet OBJECT IDENTIFIER ::= { dod 1 } directory OBJECT IDENTIFIER ::= { internet 1 } mgmt OBJECT IDENTIFIER ::= { internet 2 } mib-2 OBJECT IDENTIFIER ::= { mgmt 1 } transmission OBJECT IDENTIFIER ::= { mib-2 10 } experimental OBJECT IDENTIFIER ::= { internet 3 } private OBJECT IDENTIFIER ::= { internet 4 } enterprises OBJECT IDENTIFIER ::= { private 1 } security OBJECT IDENTIFIER ::= { internet 5 } snmpV2 OBJECT IDENTIFIER ::= { internet 6 } -- transport domains snmpDomains OBJECT IDENTIFIER ::= { snmpV2 1 } -- transport proxiessnmpProxys OBJECT IDENTIFIER ::= { snmpV2 2 } -- module identities snmpModules OBJECT IDENTIFIER ::= { snmpV2 3 } -- Extended UTCTime, to allow dates with four-digit years (Note that this definition of ExtUTCTime is not to be IMPORTed by MIB modules.) ExtUTCTime ::= OCTET STRING(SIZE(11 | 13)) -- format is YYMMDDHHMMZ or YYYYMMDDHHMMZMcCloghrie, et al. -- definitions for information modules MODULE-IDENTITY MACRO ::= BEGIN TYPE NOTATION ::= "LAST-UPDATED" value(Update ExtUTCTime) "ORGANIZATION" Text "CONTACT-INFO" Text "DESCRIPTION" Text RevisionPart

Copyright Reserved 2001

SMIv2 (part of the one defined in RFC2578)


VALUE NOTATION ::= value(VALUE OBJECT IDENTIFIER) RevisionPart ::= Revisions | empty Revisions ::= Revision | Revisions Revision Revision ::= "REVISION" value(Update ExtUTCTime) "DESCRIPTION" Text -- a character string as defined in section 3.1.1 Text ::= value(IA5String) END OBJECT-IDENTITY MACRO ::= BEGIN TYPE NOTATION ::= "STATUS" Status "DESCRIPTION" Text ReferPart VALUE NOTATION ::= value(VALUE OBJECT IDENTIFIER) Status ::= "current" | "deprecated" | "obsolete" ReferPart ::= "REFERENCE" Text | empty Text ::= value(IA5String) END -- names of objects (Note that these definitions of ObjectName and NotificationName are not to be IMPORTed by MIB modules.) ObjectName ::= OBJECT IDENTIFIER NotificationName ::= OBJECT IDENTIFIER -- syntax of objects the "base types" defined here are: 3 built-in ASN.1 types: INTEGER, OCTET STRING, OBJECT IDENTIFIER 8 application-defined types: Integer32, IpAddress, Counter32, Gauge32, Unsigned32, TimeTicks, Opaque, and Counter64 ObjectSyntax ::= CHOICE { simple SimpleSyntax, -- note that SEQUENCEs for conceptual tables and -rows are not mentioned here... application-wide ApplicationSyntax} -- built-in ASN.1 types SimpleSyntax ::= CHOICE { -- INTEGERs with a more restrictive range may also be used integer-value INTEGER (-2147483648..2147483647), string-value OCTET STRING (SIZE (0..65535)), objectID-value OBJECT IDENTIFIER} Integer32 ::= INTEGER (-2147483648..2147483647)

Copyright Reserved 2001

10

Address Translation Group (in MIB-II)


atTable OBJECT-TYPE SYNTAX SEQUENCE OF AtEntry ACCESS not-accessible STATUS deprecated DESCRIPTION ..." ::= { at 1 } atEntry OBJECT-TYPE SYNTAX AtEntry ACCESS not-accessible STATUS deprecated DESCRIPTION ..." INDEX { atIfIndex, atNetAddress } ::= { atTable 1 } AtEntry ::= SEQUENCE { atIfIndex INTEGER, atPhysAddress PhysAddress, atNetAddress NetworkAddress }

atIfIndex OBJECT-TYPE SYNTAX INTEGER ACCESS read-write STATUS deprecated DESCRIPTION ::= { atEntry 1 }
atPhysAddress OBJECT-TYPE SYNTAX PhysAddress ACCESS read-write STATUS deprecated DESCRIPTION " ::= { atEntry 2 }

atNetAddress OBJECT-TYPE SYNTAX NetworkAddress ACCESS read-write STATUS deprecated DESCRIPTION " ::= { atEntry 3 }

Copyright Reserved 2001

11

SNMP, SNMPv2, SNMPv3


Basic operators in SNMP
PDU
GetRequest SetRequest GetResponse Trap

Descriptions
Retrieve the value of a leaf object Set (update) a leaf object with a value Response for GetRequest (value) or SetRequest (ACK) Issued by agent to notify the management station of some significant event asynchronously

*PDU: Basic data unit in SNMP operations

Copyright Reserved 2001

12

An SNMP entity and its component (RFC 2271)


SNMP entity SNMP engine

dispatcher

message processing subsystem

security subsystem

access control subsystem

Application(s) command generator command responder notification receiver notification originator proxy forwarder other

Copyright Reserved 2001

13

Comparisons between three SNMP Versions


Version
SNMPv1

Descriptions and improvements


1. Define the SMI (RFC1155) 2. A more concise MIB definition (RFC 1212) 3. SNMP framework and its related operations (RFC 1157) 4. Concept of security (authentication) is proposed 1. Improved SMI 2. Inclusion of GetBulkRequest to improve the efficiency for retrieving large blocks of data 3. InformRequest for communication between management stations 1. Security and administration add-ons (RFC2571) 2. Multi-version SNMP message processing and dispatch capability (RFC 2572) 3. The five type of applications within an SNMP engine (RFC 2573) 4. User-based security model (RFC 2575) 5. View-based access control (RFC 2575)

SNMPv2

SNMPv3

Copyright Reserved 2001

14

Net-SNMP

J. Won-Ki Hong Dept. of Computer Science and Engineering POSTECH Tel: 054-279-2244 Email: jwkhong@postech.ac.kr

15

Contents

Net-SNMP Package

History of Net-SNMP
Applications of Net-SNMP Trap Daemon

Architecture of Net-SNMP Agent


How to extend SNMP agents with Net-SNMP Net-SNMP URL: www.net-snmp.org

16

Net-SNMP Package (1/2)

Net-SNMP is a suite of applications used to implement SNMPv1, SNMPv2c and SNMPv3 using both IPv4 and IPv6 and includes Command-line applications to:

retrieve information from an SNMP-capable device, either using single requests (snmpget, snmpgetnext), or multiple requests (snmpwalk, snmptable, snmpdelta). manipulate configuration information on an SNMP-capable device (snmpset). retrieve a fixed collection of information from an SNMP-capable device (snmpdf, snmpnetstat, snmpstatus). convert between numerical and textual forms of MIB OIDs, and display MIB content and structure (snmptranslate).

17

Net-SNMP Package (2/2)

A graphical MIB browser (tkmib), using Tk/perl. A daemon application for receiving SNMP notifications (snmptrapd). An extensible agent for responding to SNMP queries for management information (snmpd). A library for developing new SNMP applications, with both C and perl APIs.

18

History of Net-SNMP

Originally based on the Carnegie Mellon University implementation (1992) University of California at Davis SNMP extends CMU-SNMP, calls UCD-SNMP (1995) UCD-SNMP moves to Net-SNMP in April, 2002 (Web sites also moves from www.ucdsnmp.net to www.net-snmp.net) Now, Net-SNMP 5.7 released More detailed history can be found at

http://www.net-snmp.org/about/history.html
19

Applications (1)

Common Options

-c community -v 1 | 2c | 3 -r retries -t timeout -p port

snmpget [COMMON OPTIONS] [-Cf] OID [OID]...

SNMP application that uses the SNMP GET request to query for information on a network entity e.g., snmpget -c public localhost system.sysDescr.0 Result) system.sysDescr.0 = Linux enterflex2.postech.ac.kr

20

Applications (2)

snmpset [COMMON OPTIONS] OID TYPE VALUE

SNMP application that uses the SNMP SET request to set information on a network entity Type: i (INTEGER), u (UNSIGNED), s (STRING) e.g., snmpset -c private -v 1 localhost system.sysContact.0 s mjchoi@postech.ac.kr

snmpwalk [APPLICATION OPTIONS] [COMMON OPTIONS] [OID]

SNMP application that uses SNMP GETNEXT requests to query a network entity Retrieves lots of data, a part of MIB tree (subtree) at once e.g., snmpwalk -c public localhost system Result) system.sysDescr.0 =
system.sysObjectID.0 = system.sysUpTime.0 =

21

Applications (3)

snmpstatus [COMMON OPTIONS]

SNMP application that retrieves several important statistics from a network entity. The IP address of the entity. sysDescr.0 / sysUpTime.0 / e.g., snmpstatus -c public -v 1 localhost Result) [127.0.0.1] [Linux enterflex2 .postech . ac .kr 2.4.7-10 #1 Thu Sep 6 17 :27:27 EDT 2001 i386 ] Application that translates SNMP object identifier values from their symbolic (textual) forms into their numerical forms e.g., snmptranslate system.sysUpTime.0 Result) .1.3.6.1.2.1.1.3.0

snmptranslate [OPTIONS] OID [OID]...

22

Applications (4)

snmptrap [COMMON OPTIONS] [-Ci] enterprise-oid agent generic-trap specific-trap uptime [OID TYPE VALUE]

SNMP application that uses the SNMP TRAP operation to send information to a network manager
Definition)
TRAP-TEST-MIB DEFINITIONS ::= BEGIN IMPORTS ucdExperimental FROM UCD-SNMP-MIB; demotraps OBJECT IDENTIFIER ::= { ucdExperimental 990 } demo-trap TRAP-TYPE STATUS current ENTERPRISE demotraps VARIABLES { sysLocation } DESCRIPTION "This is just a demo" ::= 17 END

e.g., snmptrap v 1 -c public host TRAP-TEST-MIB::demotraps localhost 6 17 '' SNMPv2MIB::sysLocation.0 s "Just here"

23

Applications (5)

Other SNMP applications:


snmpgetnext: retrieving unknown indexed data. snmpbulkwalk: uses SNMP GETBULK requests to query a network entity snmptable: displaying table. snmpnetstat: symbolically displays the values of various network-related information retrieved from a remote system using the SNMP protocol

24

Trap Daemon

snmptrapd [OPTIONS][LISTENING ADDRESSES]

SNMP application that receives and logs SNMP TRAP the default is to listen on UDP port 162 snmptrapd is displayed as follows Result) 1999-11-12 23:26:07 localhost [127.0.0.1] TRAP-TEST-MIB::demotraps: Enterprise Specific Trap (demo-trap) Uptime: 1 day, 5:34:06 SNMPv2MIB::sysLocation.0 = "Just here"

25

Architecture of SNMP Agent


Managed System SNMP Agent S N M P Trap Monitor Operation Processor
Mgmt. Backend Interface

Embedded System Application

M A N A G E R

Message Generator

Message Parser

BER Decoder & Encoder Connection Listener

Response/ Trap

Request 26

How to Extend (1)


1.

Define a private MIB: Example of Cluster MIB

27

How to Extend (2)


2. 3.

4.

Download net-snmp-5.7.1.tar.gz Decompress the file in your home directory command: gtar xvfz net-snmp-5.7.1.tar.gz Compile default SNMP agent

cd net-snmp-5.7.1 ./configure --prefix=/usr/local/net-snmp make umask 022 make install

28

How to Extend (3)


6.

Install SNMP perl module for using mib2c


cd net-snmp-5.7.1 cd perl perl Makefile.PL -NET-SNMP-CONFIG=sh ../netsnmp-config -NET-SNMP-IN-SOURCE=true make make test make install

29

How to Extend (4)


7.

Compile the private MIB file using mib2c cd net-snmp-5.7.1 cd local mkdir cluster copy the private mib in the current directory ~mjchoi/cluster.my ./cluster.my export MIBS=ALL MIBS=./cluster.my mib2c -c mib2c.scalar.conf generalInfo mib2c -c mib2c.scalar.conf currentStatus mib2c -c mib2c.array-user.conf loadBalancer mv generalInfo.* cluster mv currentStatus.* cluster mv loadBalancer.* cluster cp r cluster ../agent/mibgroup/.

ex) cp

30

How to Extend (5)


8.

Code the extension agent


Header file: add necessary definitions C file


(1) Module definition: the code defining the contents of the MIB

e.g., static oid

clusterName_oid[] = { 1, 3, 6, 1, 3, 1, 1, 1, 0 };

(2) Module initialization: initialization before they can start providing the necessary information

e.g., netsnmp_register_instance(netsnmp_create_handler_registration ("clusterName", do_clusterName, clusterName_oid, OID_LENGTH(clusterName_oid), HANDLER_CAN_RWRITE));

31

How to Extend (6)


8.

Code the extension agent


(3) Variable handling: actually handles a request for a particular variable instance
e.g., char clusterName[NAME_LEN]; int *var_len;

(4) Non-table-based modules: the request handling routine is to retrieve any necessary scalar data
e.g., switch (reqinfo->mode) { case MODE_GET: snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR, (u_char *) clusterName, var_len); break; }
32

How to Extend (7)


8.

Code the extension agent


(5) Simple tables: process a simple table with limited table index

e.g., int serviceTable_handler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { switch (reqinfo->mode) { case MODE_GET: switch (table_info->colnum) { case COLUMN_SRINDEX: snmp_set_var_typed_value(var, ASN_INTEGER, ); break; } } }

33

How to Extend (8)


8.

Code the extension agent


(6) General tables: process a general table, which the maximum index is not determinable
e.g., Init_{Name}_Entry(); // Perform any necessary initialization while (( index = Get_Next_{Name}_Entry() ) != EndMarker ) { construct OID from vp->name and index compare new OID and request if valid { save current data if finished // exact match, or ordered table break; // so don't look at any more entries } }
34

How to Extend (9)


8.

Code the extension agent


(7) Set-able object: the handling of SNMPSET

e.g., switch (reqinfo->mode) { case MODE_SET_ACTION: // XXX: perform the value change here if ( /* XXX: error? */ ) { netsnmp_set_request_error(reqinfo, requests, error_msg.); } break; case MODE_SET_COMMIT: // XXX: delete temporary storage if ( /* XXX: error? */ ) { netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_COMMITFAILED); } break; }

35

How to Extend (10)


9.

Compile the MIB extension and generate SNMP daemon

./configure --with-mib-modules=cluster/generalInfo, cluster/currentStatus, cluster/loadBalancer cd agent make ./snmpd c config_file (ex) ./snmpd c /etc/snmp/snmpd.conf

snmpd [OPTIONS] [LISTENING ADDRESSES] SNMP agent which binds to a port and awaits requests from SNMP management software. collects the requested information and/or performs the requested operations and returns the information to the sender. By default, snmpd listens for SNMP requests on UDP port 161.

36

How to Extend (11)


10.

Modify snmpd.conf for SNMP community # First, map the community name # sec.name source community com2sec clusterUser default postech # Second, map the security name into a group name: # groupName securityModel securityName group clusterGroup v1 clusterUser # Third, create a view for us to let the group have rights to: # name incl/excl subtree mask(optional) view mibview included .iso.org.dod.internet # Finally, grant the group read-only access to the systemview view. # group context sec.model sec.level prefix read write notif access clusterGroup "" any noauth exact mibview mibview none

37

Good-Luck & Have Fun!

38

Anda mungkin juga menyukai