Copyright 2002-2020 Alex Burger
alex_b@users.sourceforge.net
4/3/2002
This program is free software; you can redistribute it and/or
modify
it under the terms of the GNU General Public License as published
by
the Free Software Foundation; either version 2 of the License,
or
(at your option) any later version.
This program is distributed in the hope that it will be
useful,
but WITHOUT ANY WARRANTY; without even the implied warranty
of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the
GNU General Public License for more details.
You should have received a copy of the GNU General Public
License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
SNMPTTCONVERTMIB is a Perl script which will read a MIB file and convert the TRAP-TYPE (v1) or NOTIFICATION-TYPE (v2) definitions into a configuration file readable by SNMPTT.
For example, if the file CPQHOST.mib (v1) contained:
CPQHOST-MIB DEFINITIONS ::= BEGINExecuting snmpttconvertmib CPQHOST.mib snmptt.conf would APPEND to the end of the snmptt.conf file (specified on the command line):IMPORTS
enterprises FROM RFC1155-SMI
.
.
. (lines removed)
.
.
cpqHo2NicSwitchoverOccurred2 TRAP-TYPE
ENTERPRISE compaq
VARIABLES { sysName, cpqHoTrapFlags, cpqHoIfPhysMapSlot,
cpqHoIfPhysMapPort, cpqHoIfPhysMapSlot,
cpqHoIfPhysMapPort }
DESCRIPTION
"This trap will be sent any time the configured redundant NIC
becomes the active NIC."--#TYPE "Status Trap"
--#SUMMARY "NIC switchover to slot %s, port %s from slot %s, port %s."
--#ARGUMENTS {2, 3, 4, 5}
--#SEVERITY MAJOR
--#TIMEINDEX 99
::= 11010
#
#
#
EVENT cpqHo2NicSwitchoverOccurred2 .1.3.6.1.4.1.232.0.11010 "Status Events" Normal
FORMAT Status Trap: NIC switchover to slot $3, port $4 from slot $5, port $6.
#EXEC qpage -f TRAP notifygroup1 "Status Trap: NIC switchover to slot $3, port $4 from slot $5, port $6."
SDESC
This trap will be sent any time the configured redundant NIC
becomes the active NIC.
EDESC
Notes:
To specifiy an EXEC statement, use the --exec= command line option.To prevent the --#TYPE text from being prepended to the --#SUMMARY line, change $prepend_type to 0 in the SNMPTTCONVERTMIB script.
See the help screen for more options (snmpttconvertmib --h).
Snmpttconvertmib converts a MIB file using the snmptranslate utility.
If the Net-SNMP Perl module is enabled using --net_snmp_perl on the command line, it can provide more detailed variable descriptions in the DESC sestion if available such as:
For example:
See the snmpttconvertmib help screen for all possible command line options (snmpttconvertmib --h) before converting a MIB file. Depending on what type of information is available in the MIB file, you may want to change how the FORMAT / EXEC lines are generated.
Before trying to convert MIB file, you should ensure that the MIB file can be parsed by Net-SNMP
Running
snmpttconvertmib:
snmpttconvertmib --in=/usr/share/snmp/mibs/CPQHOST.mib --out=/etc/snmp/snmptt.conf.compaqhost
snmpttconvertmib --in=/usr/share/snmp/mibs/CPQHOST.mib --out=/etc/snmp/snmptt.cong.compaq --net_snmp_perl
for i in CPQ*
> do
> /usr/local/sbin/snmpttconvertmib --in=$i --out=snmptt.conf.compaq
> done
for %i in (CPQ*) do perl snmpttconvertmib --in=%i --out=snmptt.conf.compaq
Some MIB files contain --#SUMMARY and --#ARGUMENTS
lines which are used by Novell's Network Management system.
These MIB files convert very well to SNMPTT as they contain
detailed information that can be used on the FORMAT and
EXEC lines. Compaq's MIBs usually have these
lines.
Other MIBS contain only a DESCRIPTION section where the first line contains the FORMAT string. In some MIBS, this line also contains variables similar to the --#SUMMARY lines.
The mib file is searched for the name of the MIB file. This should be at the top of the file and contain 'name DEFINITIONS ::=BEGIN'. This name will be used when looking up the TRAP / NOTIFICATION to ensure the correct MIB file is accessed.
The mib file is also searched for lines containing TRAP-TYPE or NOTIFICATION-TYPE. If it finds one that appears to be a valid trap definition, it reads in the following lines until a ::= is found while looking for the DESCRIPTION section. It then looks for the --#SUMMARY and --#ARGUMENTS line if enabled.
SNMPTRANSLATE is used with the following syntax to find the OID of the trap:
snmptranslate -IR -Ts mib-name::trapname -m mib-filename
Note: If Net-SNMP 5.0.2 or newer is detected, the command line also includes the -On switch. See the FAQ.
* If --#SUMMARY and --#ARGUMENTS are found, the %letter variables are replaced with $number variables based on the values lists in the --#ARGUMENTS section incremented by 1 (ARGUMENTS starts with 0, SNMPTT starts with 1). This will be used to define the FORMAT and EXEC lines.
* If there is no --#SUMMARY and --#ARGUMENTS lines, but the first line of the DESCRIPTION contains %letter variables, then that line will be used to define the FORMAT and EXEC lines. The %letter variables are replaced with $number variables starting at 1 and going up.
* If there is no --#SUMMARY and --#ARGUMENTS lines, and the first line of the DESCRIPTION does not contain %letter variables, then that line will be sed to define the FORMAT and EXEC lines followed by a $* which will dump all received variables.
* If the entry contains variables, the variables are listed in the DESC section. If --net_snmp_perl is specified, the syntax, description and enums for each variable is used.
* Note: This can be changed by specifying a --format=n command line option. See the snmpttconvertmib help screen for all possible command line options (snmpttconvertmib --h).