« November 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
Today

Blog::Navigation

Blog::Editing

Bookmarks::Blogroll

Blog::Referers

Today's Page Hits: 153

Site notes

This page validates as XHTML 1.0, and will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device. It was created using techniques detailed at glish.com/css/.

Powered by Roller Weblogger.
« Ganesh Hiregoudar's... | Main | SMF troubleshooting... »
Tuesday Jun 14, 2005

SNMP in Solaris

SNMP in Solaris



SNMP in Solaris



Solaris has a rich set of products that support SNMP protocol.

Some of these products are part of Solaris and others can be installed on top of Solaris

* System Management Agent(SMA) 
* Solstice Enterprise Agent(SEA)
* Sun Management Center(SunMC) 
* Solstice Enterprise Manager(SEM)
* Mobile IP agent
* Platform specific SNMP agents such as Netra agent, Enchilida, JDMK agent and so on

Background

SNMP is widely used in enterprise networks to effectively manage systems, network devices, and networks. One of the benefits of SNMP is that solutions can be quickly created to support the increasing numbers of networking components and applications. Within SNMP networks, systems, components, and applications are described as entities. The number of entities that need to be managed is growing rapidly.

SNMP uses a manager and agent architecture. The SNMP manager is a program, also known as a network management station (NMS), that runs on a host on the network. The manager sends requests to one or more SNMP agents running on devices connected to the network. An agent, or daemon, is a program that listens for SNMP requests from the manager.

Agent hierarchy consists of a master agent and subagents. The master agent receives the SNMP-based management requests from the managers. The master agent sends responses to these management requests. Responses are sent after retrieving the appropriate values from respective subagents.

Subagents provide management of different components. Management is based on a Management Information Base (MIB) specifically designed for components or applications. A MIB is a specification containing definitions of management information. Through the use of a MIB: networks and networked systems can be remotely monitored, remotely configured, and remotely controlled.

An agent receives a request and looks up information in the MIB and returns information to the manager. Each object in the MIB represents a piece of data about the managed device, and each object is assigned a unique identifier in the MIB. The manager and agent must have access to the same MIB to be able to communicate about the managed device. The manager uses the MIB to specify identifiers for the information that the agent is to act upon. The agent uses the MIB to look up the identifiers that were passed in the SNMP request from the manager. The agent gets or sets values for the requested data.

The System Management Agent is designed to be a standalone agent. That means the SMA agent can run without having any external NMS to run, but can work with any external NMS using SNMP protocol. The SMA can be accessed by multiple management applications, provided that these management applications communicate with the SMA using SNMP protocols. The SMA can coexist with existing SNMP agents. The SMA replaces some legacy SNMP agents.

The SMA is a new SNMP agent offering from Sun, based on the Net-SNMP open source implementation and is available from solaris 10 onwards. This open source implementation is described at http://www.net-snmp.org/. This open source implementation was formerly known as UCD-SNMP. The System Management Agent is designed to support the latest SNMP standards.

In this Solaris release, the System Management Agent can co-exist with the Solstice Enterprise AgentsTM software. For more information about the Solstice Enterprise Agents software, see the Solstice Enterprise Agents 1.0 User Guide. From an SNMP manager view, the System Management Agent operates in the same way the Solstice Enterprise Agents software. Unlike the Solstice Enterprise Agents software, the System Management Agent supports SNMPv3. The System Management Agent supports more default MIBs than the Solstice Enterprise Agents software. Please refer user and developer guides from http://docs.sun.com

Sun contributions to open source in SNMP world are

  • IPv6 support

  • 64 bit binaries

  • Security best practices code enhancements

  • PKCS support

  • Documentation enhancements

  • Large number of bug fixes



SNMP traps



SNMP traps are often used by network devices to report conditions. Trap information will "automatically" go out when the condition for the trap is met.

For instance, if you have multiple network links and you lose one then the "linkDown" trap will go out to inform the Network Management Station (NMS) that your machine has lost a link. All you need to do is define the host names of any NMS that you wish to send traps to.

The following piece of code will be generated for TRAP-TYPE variables such as demoEntryString and demoEntryInteger in table column by using mibcodegen(mib compiler). This is fixed as part of 4519879

struct CallbackItem genCallItem[13]={
        {(Object *)&column_table[1],STRING,1},
        {(Object *)&column_table[2],INTEGER,2},
        {&object_table[2],OBJID,-1},
};
int genNumCallItem=3;
int genTrapTableMap[11]={
0,};
int genNumTrapElem = 1;
struct TrapHndlCxt genTrapBucket[11] = {
        {"demotrap1",1,6,1},
};
struct TrapAnyEnterpriseInfo genTrapAnyEnterpriseInfo[11]={
        {1, 3, 6, 1, 4, 1, 42, (uint32_t)-1},
};
struct _CallTrapIndx {
        char name[256];
        IndexType *pindex_obj;
};

struct _Indx {
        char name[256];
        int index;
};

int numIndxElem = 2;
struct _Indx Indx[2] = {
        {"demoEntryString", 0},
        {"demoEntryInteger", 0},
};

int SSASetVarIndx(char* name, int index)
{
        int i;

        if (!name)
        return (-1);

        for (i = 0; i < numIndxElem; i++)
                if (!strcmp(name, Indx[i].name)) {
                        Indx[i].index = index;
                        return (0);
                }
        return (-1);
}
IndexType TrapIndx[3] = {
        {1,1,&Indx[0].index},
        {1,1,&Indx[1].index},
        {0,0,NULL},
};

struct _CallTrapIndx CallTrapIndx[1] = {
        {"demotrap1",&TrapIndx[0]},
};

int SSASendTrap(char* name)
{
        int i;

        if (!name)
        return (-1);

        numCallItem = genNumCallItem;
        numTrapElem = genNumTrapElem;
        callItem = genCallItem;
        trapTableMap = genTrapTableMap;
        trapBucket = genTrapBucket;
        trapAnyEnterpriseInfo = genTrapAnyEnterpriseInfo;
        for (i = 0; i < numTrapElem; i++)
        if (!strcmp(name, CallTrapIndx[i].name))
                return (_SSASendTrap4(name, CallTrapIndx[i].pindex_obj));
        return (-1);
}


In order to make snmdpx handle Traps from subagents during startup, the trap-port for communication between a subagent and snmpdx should be distinguished by using the function SSAGetTrapPort() from the SEA sdk/API. mibiisa mib-II subagent sends traps to snmpdx by send_traps(). send_traps() calls send_a_trap() per manager. This function, send_a_trap(), sends traps to port 162. This is fixed as part of 4889976.

/*
 * This function is used to develop the packet for getting the
 * master agent trap port. master agent trap port oid is 1.3.6.1.4.1.42.2.15.4.0 * master agent will assign the trap port to mibiisa for processing the
 * cold start and all generic traps. Master agent will intern forwards the
 * request to port 162.
 */

int
request_for_trap_port(int mibport)
{

        SNMP_PKT_T      *rp;
        VB_T *vbl;
        EBUFFER_T               ebuff;
        unsigned char   pktp[TBSIZE];
        int             pktl;
        int             got, p;
        int indx = 0;
        char            *community = "public";
        int             commleng;
        unsigned int    pktcom_length;

        struct sockaddr_in      pktsrc;
        struct sockaddr_in      pktdst;
        INT_32_T        request_id;
        int maport;
        int count = 0;
        struct timeval timeout;
        fd_set readfds, writefds, exceptfds;
        socklen_t       szfrom;
        timeout.tv_sec = 0;
        timeout.tv_usec = 0;

        if (mibport == 161 || (maport = get_port()) == 0)
                                /* maport = master agent  port */
                                /* mibport = mibiisa port */
                return (162);
        else {

        EBufferInitialize(&ebuff);

        (void) memset(&pktdst, 0, sizeof (pktdst));

        if ((rp = SNMP_Allocate()) == (SNMP_PKT_T *)0) {
                return (-1);
        }

        rp->snmp_version = 0;
        rp->pdu_type = GET_REQUEST_PDU;

        commleng = strlen(community);
        EBufferPreLoad(BFL_IS_STATIC, &(rp->community), community, commleng);

        rp->pdu.std_pdu.request_id = request_id;
        rp->pdu.std_pdu.error_status = 0;
        rp->pdu.std_pdu.error_index = 0;
        rp->pdu.std_pdu.std_vbl.vbl_count = 1;
        vbl = (VB_T *) malloc(sizeof (VB_T));
        rp->pdu.std_pdu.std_vbl.vblist = vbl;
        vbl->vb_obj_id = ra_trap_port_oid;

                if ((vbl = locate_vb(rp, indx)) == (VB_T *)0)
                        return (-1);

                if (build_object_id(snmp_product_id_count, snmp_product_id,
                        &(vbl->value_u.v_object)) == -1) {
                        Clean_Obj_ID(&(vbl->vb_obj_id));
                        return (-1);
                }

        vbl->vb_data_flags_n_type = VT_EMPTY;

                if (SNMP_Encode_Packet(rp, &ebuff) == -1) {
                        PRNTF0("Failure encoding startup trap\n");
                }

        pktsrc.sin_family = AF_INET;
        pktsrc.sin_port = htons(maport);
        pktsrc.sin_addr.s_addr = inet_addr("127.0.0.1");

        szfrom = (socklen_t)sizeof (pktsrc);

        while (count == 0) {

                FD_ZERO(&readfds);
                FD_ZERO(&writefds);
                FD_ZERO(&exceptfds);
                FD_SET(snmp_socket, &readfds);

                count = select(FD_SETSIZE, &readfds, &writefds, &exceptfds,
                                &timeout);
                switch (count) {

                        case 0:

                        if ((p = sendto(snmp_socket, (char *)ebuff.start_bp,
                                EBufferUsed(&ebuff),
                        0, (struct sockaddr *)&pktsrc, szfrom)) < 0) {
                                PERROR("sendto failed");
                        }
                        (void) gettimeofday(&timeout, (struct timezone *)0);
                        timeout.tv_sec = 0;
                        timeout.tv_usec = 100;
                        continue;

                        case -1:
                                if (errno == EINTR)
                                        continue;
                                else
                        PERROR("select failed");
                                break;

                        default :
                                break;
                        }
                }
        if ((got = recvfrom(snmp_socket, (char *)pktp, sizeof (pktp),
                        0, (struct sockaddr *)&pktsrc, &szfrom)) < 0) {
                PERROR("Recvfrom failed");
        }

        if ((rp = SNMP_Decode_Packet(pktp, got, (struct sockaddr_in *)&pktsrc,
                (struct sockaddr_in *)&pktdst))
                == (SNMP_PKT_T *)0) {
                return (-1);
        }

        vbl = rp->pdu.std_pdu.std_vbl.vblist;

        if (vbl->value_u.v_number)
                return (vbl->value_u.v_number);
        }
return (162);
}


Debug messages

Trap debug messages are shown below. 
SEA currently supports four traps as outlined in rfc 1215 which are coldStart, linkUp, linkDown, and authenticationFailure.


<<debug message from mibiisa mib-II subagent>>


Trap packet sent to 127.0.0.1 at Mon May 30 11:22:03 2005
Packet Length=47, Version=0, Community: Length=9, Value=SNMP-trap
PDU Type=0x04 Length=31, Enterprise id:
OBJ_ID: 1.3.6.1.4.1.42.2.1.1
IP Address: 129.158.226.126
Generic trap=0 (0), specific trap=0 (0), Trap time=153396650 (924A5AA)
VBLlen=0, VBcount=0



<<debug message from snmpdx master agent>>


<< received 42 bytes from localhost.58657

PACKET:
-------
30 28 02 01 00 04 06 70 75 62 6C 69 63 A0 1B 02
01 00 02 01 00 02 01 00 30 10 30 0E 06 0A 2B 06
01 04 01 2A 02 0F 04 00 05 00

PDU:
----
version:      0
community:    public
type:         GET_REQ_MSG (0xa0)
request id:   0
error status: noError(0)
error index:  0
--------------------------------------------------
name:    1.3.6.1.4.1.42.2.15.4.0
type:    NULL (0x5)
length:  0
value:    ( )
--------------------------------------------------

## Open session 0

subtree_match() returned 1.3.6.1.4.1.42.2.15 supported by relay-agent

        address:        localhost.58657
        n_variables:    1
        o_flags:        0x0
        i_flags:        0x0
        request 0:
                session:     0
                subtree:     1.3.6.1.4.1.42.2.15
                visited agents:
                        relay-agent
                agent:       relay-agent (localhost.161)
                flags:       0x1
                state:       0
                variables:
                        1.3.6.1.4.1.42.2.15.4.0
                time:        0 sec 0 usec
                expire:      0 sec 0 usec

node_find() returned relayTrapPort with suffix 0

!! get(): processing the variable relayTrapPort
PDU:
----
version:      0
community:    public
type:         GET_RSP_MSG (0xa2)
request id:   0
error status: noError(0)
error index:  0
--------------------------------------------------
name:    1.3.6.1.4.1.42.2.15.4.0
type:    INTEGER (0x2)
length:  4
value:   58659
--------------------------------------------------

PACKET:
-------
30 2B 02 01 00 04 06 70 75 62 6C 69 63 A2 1E 02
01 00 02 01 00 02 01 00 30 13 30 11 06 0A 2B 06
01 04 01 2A 02 0F 04 00 02 03 00 E5 23

>> sent 45 bytes to localhost.58657

## Close session 0

SESSIONS:
---------
NUMBER OF SESSIONS: 0

<< received 49 bytes from localhost.58657

PACKET:
-------
30 2F 02 01 00 04 09 53 4E 4D 50 2D 74 72 61 70
A4 1F 06 09 2B 06 01 04 01 2A 02 01 01 40 04 81
9E E2 7E 02 01 00 02 01 00 43 04 09 24 A5 AA 30
00

PDU:
----
version:      0
community:    SNMP-trap
type:         TRP_MSG (0xa4)
enterprise:   1.3.6.1.4.1.42.2.1.1
IP agent addr: goudar
generic:      coldStart(0)
specific:     0
time stamp:   153396650
--------------------------------------------------

SESSIONS:
---------
NUMBER OF SESSIONS: 0




Technorati Tag: OpenSolaris
Technorati Tag: Solaris



Comments:

Hello, This information on this page helps me a lot. But I still have on eproblem regarding snmpdx.acl file. In trap { } part of it there is trap-num. I cannot find what those number 0, 1, 2-5, etc... means for e.g. enterprice = "sun". I just wondering maybe you knoew when I can find an answer on it. Thanks. Srdan

Posted by Srdan Foscarini on March 08, 2007 at 05:29 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
Copyright (C) 2003, G S Hiregoudar