Galactic Civilizations 3
Creation of a MIB

Creation of a MIB

Category: Administration.
Posted by on the 21/10/2013.
Last update on the 28/10/2013.

Description

This tutorial explains how to create a small MIB that allows to describe SNMP traps. It explains also how to define a module composed of integer, string and array objects.

Introduction

It is recommanded to have a enterprise OID (this can be obtained free of charge from the IANA).

MIB definition

Start of the MIB definition

TUTORIELSENFOLIE-MIB DEFINITIONS ::= BEGIN

Modules importation

Now we will add the imports in order to use the definitions.

IMPORTS
OBJECT-TYPE, MODULE-IDENTITY, enterprises, Integer32 ,TimeTicks
FROM SNMPv2-SMI
MODULE-COMPLIANCE,OBJECT-GROUP FROM SNMPv2-CONF;

Creation of a module

Then we will define our module and plug it to the enterprise module below the OID number 10388.

tutorielsenfolie MODULE-IDENTITY
LAST-UPDATED "201106270000Z"
ORGANIZATION " tutorielsenfolie "
CONTACT-INFO "
Author: tutorielsenfolie
www.tutorielsenfolie.com"

DESCRIPTION "MIB for the website Tutoriels en Folie."
REVISION "201106270000Z"
DESCRIPTION "MIB Tutoriels en Folie "
::={ enterprises 10388 }

Creation of the module's object

The following lines allow plugging two objects (object1 and object2) to our module.

objet1 OBJECT IDENTIFIER ::= { tutorielsenfolie 1}
objet2 OBJECT IDENTIFIER ::= { tutorielsenfolie 2}

Definition of an object

Now we will define sub objects: one of type integer and the other of type string.

sousObjet OBJECT-TYPE
SYNTAX Integer32 (0..150) -- The subobject will be an integer between 0 and 150
MAX-ACCESS read-write -- Read only access
STATUS current
DESCRIPTION
"Object 1 description."
DEFVAL{ 1 } -- default value
::= { objet1 1 }

nom OBJECT-TYPE
SYNTAX OCTET STRING -- name is a string
MAX-ACCESS read-only -- read only
STATUS current
DESCRIPTION
"Description of the object: name."
::={ objet1 2}

Definition of an array

Then we can define a two-dimensional array. First of all we define the object that represents the table:

maTable OBJECT-TYPE
SYNTAX SEQUENCE OF entree
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"Description of the table."
::={ objet2 1}

After, we describe the object that represents an entry in the table. We describe also the type of the entry.

entree OBJECT-TYPE
SYNTAX syntaxeEntree
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "entrey of the table"
INDEX {index}
::= { maTable 1}

An entry corresponds to a one-dimensional array. Our entries contain an integer that represents the index of the table and a string for the content of the cell.

syntaxeEntree ::=
SEQUENCE {
index Integer32,
colonne2 OCTET STRING,
}

Then, we define the different objects of the table.

index OBJECT-TYPE
SYNTAX Integer32 (0..100)
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION "Column index."
::= { entree 1}

colonne2 OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only -- read only
STATUS current
DESCRIPTION "Name of the column 2."
::= { entree 2}

MIB conformity

We will end the MIB definition by defining the conformity of the MIB.

tutorielsenfolieMIBConformance OBJECT IDENTIFIER ::= { tutorielsenfolie 3 }

tutorielsenfolieMIBCopliance MODULE-COMPLIANCE
STATUS current
DESCRIPTION "Conformity declaration of the web site Tutoriel en Folie."
MODULE
GROUP tutorielsenfolieMIBGroup
DESCRIPTION "tutorielsenfolieGroup contains all the objects."
::={ tutorielsenfolieMIBConformance 1}

tutorielsenfolieMIBGroup OBJECT-GROUP
OBJECTS {sousObjet, nom}
STATUS current
DESCRIPTION "Collection of all the objects of the mib."
::= { tutorielsenfolieMIBConformance 2}

End of the MIB definition

We end the MIB definition with the keyword « END ».

END

You can now check your MIB by sending SNMP request to your server.

You like this tutorial ?
Like this website in order to promote it on facebook !

You like this tutorial ? Share it with your friends !
Partager sur Facebook Partager sur Twitter Partager sur Myspace Partager sur Stumbleupon Soumettre sur Reddit Partager sur Digg Ajouter à vos favoris Technorati Ajouter à vos favoris Live Ajouter à vos favoris Google Ajouter sur vos favoris Yahoo