SNMP work summary

xiaoxiao2021-03-06  97

SNMP work summary

2004-May to July

1. How to write a MIB file?

See Example: KSGBOX-ALARM-MIB.TXT

KsgBox-Alarm-MIB DEFINITIONS :: = BEGIN IMPORTS enterprises FROM RFC1155-SMI OBJECT-TYPE FROM RFC-1212 TRAP-TYPE FROM RFC-1215; cheyenne OBJECT IDENTIFIER :: = {enterprises 46} ca-jc OBJECT IDENTIFIER :: = { Cheyenne 880} - ************************************************************ ************************** - KSG BOX TRAP - *************** *********************************************************** ********* Ksgtrapemergent Trap-Type Enterprise CA-JC VARIABLES {KSGServerName, KsgtrapDesc} Description "KSGBOX EMERGENT TRAP." - # Type "Ksgbox EMERGENT" - # Summary "% s KSG:% s" - # arguments {0,1} - # severity critical - # State Operational :: = 1ksgtrap Normal Trap-Type Enterprise CA-JC VARIABLES {KSGServerName, Ksgtrapdesc} Description "KSGBOX NORMAL TRAP" - # type "ksgbox warning" - # Summary "% s ksg:% s" - # arguments {0,1} - - # severity minor - # TimeIndex 1 - # State OperationAl :: = 2END

2, how to write traphandler? Traphandler's format:

Traphandle Oid | Default Handler

Among them, Handler can only be a script. Under Linux, if you write a C program, you need to call with the shell script. And the shell script is specified, and there must be #! / Bin / bash in the file header, otherwise it is not recognized as a shell script; under Windows, you must use the batch script to call our Wen C program.

Recently carefully studied the running mechanism of SNMPTRAPD. Discover the situation as follows:

1) By specifying a parameter (-LF), the trap arrival can be output to a specified file. Its record format is as follows:

-------------------------------------------------- -----

2004-06-19 17:07:49 CA-96MB2UWXU21P [192.168.89.221] (VIA 192.168.89.205) Trap, SNMP V1, Community PUBLIC

SNMPv2-SMI :: Enterprises.46.879.0.1.0 link down trap (0) uptime: 0: 13: 26.69

-------------------------------------------------- -----

2) You can configure Trap Handler in the snmptrapd.conf file. The format is as follows:

---------------------------------------------- Traphandle OID | Default [TRAP HANDLER]

-----------------------------------------------

Where [Trap Handler] must be a script, not a program. For example, under Windows, write a program with the C language, build into an exe file, if you want to specify, when a specific TRAP comes to call this program, you must write a batch program, call the program in the batch. . For example, my C program is hello.exe, if you want to call it, my snmptrapd.conf file is as follows:

-----------------------

TrapHandle 1.3.6.1.6.3.1.1.5.1.0 E: / WWW

Traphandle Default E: / WWW

-----------------------

Among them, WWW is the batch I wrote, and www.bat is as follows:

----------------------

E: /Hello.exe

-------------------- 3) Specify a MIB library through -m.

转载请注明原文地址:https://www.9cbs.com/read-124903.html

New Post(0)