Smarts SAM OI: How to parse oid from a trap's varbind
search cancel

Smarts SAM OI: How to parse oid from a trap's varbind

book

Article ID: 304242

calendar_today

Updated On:

Products

VMware

Environment

VMware Smart Assurance - SMARTS

Resolution

How to parse OID from a trap's varbind



To parse the OID from a trap's varbind, do the following:
  1. Open the trap_mgr.conf configuration file as follows:

    <BASEDIR>/SAM/smarts/bin/sm_edit conf/icoi/trap_mgr.conf

    # ciscoSlbRealStateChange
    BEGIN_TRAP .1.3.6.1.4.1.9.9.161.2 6 2
            ClassName:      SNMPTrap
            InstanceName:   $SYS$
            EventName:      ciscoSlbRealStateChange
            Severity:       3
            EventText:      The 1 Varibles are - slbRealState= $V1$
            Expiration:     100
            State:          NOTIFY
            ASL:  my_trap_rules.asl
            LogFile:        CSM_Trap.log


    END_TRAP


     
  2. Customize the my_trap_rules.asl file according to your requirements and put it into the following directory:

    <BASEDIR>/SAM/smarts/local/rules/icoi-trapd/

    See the Note statement for the contents of this file.

     
  3. Restart trap adapter for the changes to take effect. The Event Text for the example will be:
CSM Slot:6 SHAREPOINT IP:10.1.51.127 SlbRealServerState:probeFailed


Additional Information

Contents of the my_trap_rules.asl file
/*
 * my_trap_rules.asl - Hook adapter for any trap related customizations.
 *
 * Copyright (C) 2002, System Management ARTS (SMARTS)
 * All Rights Reserved
 *
 * RCS $Id: my_trap_rules.asl,v 1.9.10.1 2005/05/02 14:16:23 ku1 Exp $
 */
 

debug = TRUE;  
 
// Input/Output variables.
 
CLASSNAME = "";
INSTANCENAME = "";
EVENTNAME = "";
SEVERITY = "";
EVENTTEXT = "";
CATEGORY = "";
EXPIRATION = "";
STATE = "";
INMAINTENANCE = "";
CLEARONACKNOWLEDGE = "";
EVENTTYPE = "";
ELEMENTCLASSNAME = "";
ELEMENTNAME = "";
USERDEFINED1 = "";
USERDEFINED2 = "";
USERDEFINED3 = "";
USERDEFINED4 = "";
USERDEFINED5 = "";
USERDEFINED6 = "";
USERDEFINED7 = "";
USERDEFINED8 = "";
USERDEFINED9 = "";
USERDEFINED10 = "";
 
// Input Variables
 
TIMESTAMP = "0";
IPADDRESS = "";
SYSNAMEORADDR = "";
ENTERPRISE = "";
GENERIC = "9999";
SPECIFIC = "9999";
 
// Varbind and OID values
V1 = "";
V2 = "";
V3 = "";
V4 = "";
V5 = "";
V6 = "";
V7 = "";
V8 = "";
V9 = "";
V10 = "";
V11 = "";
V12 = "";
V13 = "";
V14 = "";
V15 = "";
V16 = "";
V17 = "";
V18 = "";
V19 = "";
V20 = "";
 
OID1 = "";
OID2 = "";
OID3 = "";
OID4 = "";
OID5 = "";
OID6 = "";
OID7 = "";
OID8 = "";
OID9 = "";
OID10 = "";
OID11 = "";
OID12 = "";
OID13 = "";
OID14 = "";
OID15 = "";
OID16 = "";
OID17 = "";
OID18 = "";
OID19 = "";
OID20 = "";
 
// Flag to discard the trap, when set to TRUE.
DISCARD_TRAP = "FALSE";
 
// Flag to update the UserDefined[1-10] fields and EventText, upon CLEAR
// when set to TRUE.
UPDATE_USERDEF_FIELDS = "FALSE";
 
// Set this to TRUE, if you want to overwrite the ElementClass and ElementName
// NOTE: i.e Modifying the 'OccurredOn' Object.
// The object(ELEMENTCLASSNAME, ELEMENTNAME) should exist, otherwise
//       the trap will default to having Agent's Name, if it exisits in toplogy.
// ----------------------------------------------------------------------------
FORCE_OCCURREDON = "FALSE";
 
if (debug) { print("Running my_trap_rules.asl "); }
 
asciiTable = table();
asciiTable[32] = " ";
asciiTable[33] = "!";
asciiTable[34] = """;
asciiTable[35] = "#";
asciiTable[36] = "$";
asciiTable[37] = "%";
asciiTable[38] = "&";
asciiTable[39] = "'";
asciiTable[40] = "(";
asciiTable[41] = ")";
asciiTable[42] = "*";
asciiTable[43] = "+";
asciiTable[44] = ",";
asciiTable[45] = "-";
asciiTable[46] = ".";
asciiTable[47] = "/";
asciiTable[48] = "0";
asciiTable[49] = "1";
asciiTable[50] = "2";
asciiTable[51] = "3";
asciiTable[52] = "4";
asciiTable[53] = "5";
asciiTable[54] = "6";
asciiTable[55] = "7";
asciiTable[56] = "8";
asciiTable[57] = "9";
asciiTable[58] = ":";
asciiTable[59] = ";";
asciiTable[60] = "<";
asciiTable[61] = "=";
asciiTable[62] = ">";
asciiTable[63] = "?";
asciiTable[64] = "@";
asciiTable[65] = "A";
asciiTable[66] = "B";
asciiTable[67] = "C";
asciiTable[68] = "D";
asciiTable[69] = "E";
asciiTable[70] = "F";
asciiTable[71] = "G";
asciiTable[72] = "H";
asciiTable[73] = "I";
asciiTable[74] = "J";
asciiTable[75] = "K";
asciiTable[76] = "L";
asciiTable[77] = "M";
asciiTable[78] = "N";
asciiTable[79] = "O";
asciiTable[80] = "P";
asciiTable[81] = "Q";
asciiTable[82] = "R";
asciiTable[83] = "S";
asciiTable[84] = "T";
asciiTable[85] = "U";
asciiTable[86] = "V";
asciiTable[87] = "W";
asciiTable[88] = "X";
asciiTable[89] = "Y";
asciiTable[90] = "Z";
asciiTable[91] = "[";
asciiTable[92] = "";
asciiTable[93] = "]";
asciiTable[94] = "^";
asciiTable[95] = "_";
asciiTable[96] = "`";
asciiTable[97] = "a";
asciiTable[98] = "b";
asciiTable[99] = "c";
asciiTable[100] = "d";
asciiTable[101] = "e";
asciiTable[102] = "f";
asciiTable[103] = "g";
asciiTable[104] = "h";
asciiTable[105] = "i";
asciiTable[106] = "j";
asciiTable[107] = "k";
asciiTable[108] = "l";
asciiTable[109] = "m";
asciiTable[110] = "n";
asciiTable[111] = "o";
asciiTable[112] = "p";
asciiTable[113] = "q";
asciiTable[114] = "r";
asciiTable[115] = "s";
asciiTable[116] = "t";
asciiTable[117] = "u";
asciiTable[118] = "v";
asciiTable[119] = "w";
asciiTable[120] = "x";
asciiTable[121] = "y";
asciiTable[122] = "z";
asciiTable[123] = "{";
asciiTable[124] = """;
asciiTable[125] = "}";
asciiTable[126] = "~";
 
serverStateTable = table();
serverStateTable[1] = "outOfService";
serverStateTable[2] = "inService";
serverStateTable[3] = "failed";
serverStateTable[4] = "readyToTest";
serverStateTable[5] = "testing";
serverStateTable[6] = "maxConnsThrottle";
serverStateTable[7] = "maxClientsThrottle";
serverStateTable[8] = "dfpThrottle";
serverStateTable[9] = "probeFailed";
serverStateTable[10] = "probeTesting";
serverStateTable[11] = "operWait";
serverStateTable[12] = "testWait";
serverStateTable[13] = "inbandProbeFailed";
serverStateTable[14] = "returnCodeFailed";
 
intToChar(int)
do {
 return asciiTable[int]; 
}
 
intToServerState(oidval)
do {
 return serverStateTable[oidval];
}
 
START {
    .. eol
} do {
 
    // Default output is the same as input.
 
    // Set attributes in ICS_Notification.  Add any more customizations here ...
 
 PARSEOID(OID1);
 
    if (debug) { print("Done with my_trap_rules.asl ");}
    return;
}
 
PARSEOID(oid) {
 input=oid;
 trapOID: ".1.3.6.1.4.1.9.9.161.1.3.1.1.4."
 slot: integer "."
 serverNameInt: integer "."
 intserverName: {rep(integer ".",serverNameInt-1) integer} "."
 ipAddress: {rep(integer ".", 3) integer}
 .. eol
}
do {
 dserverNameIntOnly=list();
 PARSESERVERNAME(intserverName);
 serverName="";
 foreach alpha ( dserverNameIntOnly ) {
  serverName=serverName.intToChar(alpha);
 }
 if (debug) {
  print("slot:".slot);
  print("serverNameInt:".serverNameInt);
  print("serverName:".serverName);
  print("ipAddress:".ipAddress); 
 }
 EVENTTEXT="CSM Slot:".slot." ".serverName." IP:".ipAddress." SlbRealServerState:". intToServerState(V1);
 
}
 
PARSESERVERNAME(intoid){
 delim=".";
 input=intoid;
 rep(NUMBER) " eol
}
 
NUMBER {
 x:word
}
do {
 dserverNameIntOnly += x;
}
 
/*
 * These variables describe the formatting of this file.  If you don't like the
 * template defaults, feel free to change them here (not in your .emacs file).
 *
 * Local Variables:
 * mode: C++
 * End:
 */