Re: creating custom mib

Olivier Miakinen <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hello Áki Hermann,

Le 08/04/2014 01:45, Áki Hermann Barkarson a écrit :
> 
> [...]
> 
> To learn more about this I want to create my own MIB and I have an
> enterprise OID (1513) that I can use.
> 
> So I send traps with SNMPv2-SMI::enterprises.1513.... and passing
> along some variable and this is where I'm struggling with syntax and
> general lack of understanding. I want to format my mib in the correct
> way..

I wrote mibs a few years ago, and I think I can give you some advice,
but probably I will forget things, and maybe I will be wrong on some
points. I hope others would correct me if needed.

> maybe it should be split down into one mib defining objects and
> then I define the notifications in another mib..

I believe it is not necessary to write two separate mibs.

> and and.. so many
> questions :) I can see various examples out there but I'd love to
> have a conversation with someone who actually knows this stuff.
> 
> 
> This is what I have so far:
> 
> 
> Advania-Traps-MIB DEFINITIONS ::= BEGIN

Ok.

> 
> IMPORTS
>    enterprises                                  FROM RFC1155-SMI

This is the old deprecated SMIv1 version of the SNMP syntax. You
should import enterprises from SNMPv2-SMI instead, and don't forget
the ';' at the end of the IMPORTS clause.

But also, you need to import the OBJECT-TYPE, DisplayString and
NOTIFICATION-TYPE that you use, and the MODULE-IDENTITY macro that
you ought to use. ;-)

IMPORTS
   MODULE-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE,
   DisplayString, enterprises                   FROM SNMPv2-SMI;

> 
> advania                                OBJECT IDENTIFIER ::= { enterprises 1513 }

I think that advania could be defined to be the one and only
MODULE-IDENTITY of the mib, especially if this mib will be the
only one (or the main) mib under enterprises 1513.

Though, I prefer not taking the responsibility of this choice.
You may read the standard, and wait for other answers, before
deciding what to do.

<http://tools.ietf.org/html/rfc2578#section-5>
<http://tools.ietf.org/html/rfc2578#section-5.6>

> objects                 OBJECT IDENTIFIER ::= { advania 1 }
> notifications       OBJECT IDENTIFIER ::= { advania 2 }

Unless you are absolutely sure that the traps will never been generated
using SNMPv1 protocol but only SNMPv2c or SNMPv3 -- and even if you are
sure of that -- it would be highly desirable that you define a prefix
with a sub-id having the value zero for the notifications :

<http://tools.ietf.org/html/rfc2578#section-8.5>

Hence :

objects                 OBJECT IDENTIFIER ::= { advania 1 }
notifications           OBJECT IDENTIFIER ::= { advania 2 }
notificationsPrefix     OBJECT IDENTIFIER ::= { notifications 0 }


> 
> -- Objects
> 
> trapState OBJECT-TYPE
>     SYNTAX      DisplayString (SIZE (0..31))
>     MAX-ACCESS  read-write
>     STATUS      current
>     DESCRIPTION
>             "A brief description."
>     ::= { msg 1 }

  { objects 1 }  I suppose

> 
> shortMsg OBJECT-TYPE
>     SYNTAX      DisplayString (SIZE (0..31))
>     MAX-ACCESS  read-write
>     STATUS      current
>     DESCRIPTION
>             "A brief description."
>     ::= { msg 1 }

  { objects 2 }  I suppose

> 
> longMsg OBJECT-TYPE
>     SYNTAX      DisplayString (SIZE (0..1279))

I'm not sure whether it is allowed to redefine a DisplayString with
a maximum size greater than 255. What is the opinion of other readers
of this mailing list ?

>     MAX-ACCESS  read-write
>     STATUS      current
>     DESCRIPTION
>             "Detailed info."
>     ::= { msg 2 }

  { objects 3 }  I suppose

Also, if these objects are not actual objects than can be read
and written independently of traps, the MAX-ACCESS should
probably be accessible-for-notify and not read-write.

> 
> 
> -- Notifications
> 
> customTrap NOTIFICATION-TYPE
>        STATUS current
>        VARIABLES { trapState, shortMsg, longMsg }
>        DESCRIPTION "Custom trap alert."
>        ::= { notifications 1 }

  { notificationsPrefix 1 }

(see above, about the required zero subid)

> 
> END
> 
> Not sure if this is how it's meant to be formatted, any help would be appreciated..

I hope other answers will follow mine.

Best regards,
-- 
Olivier Miakinen


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.