RFC for Implement SNMP trap on openBMC.

Ratan Gupta ratagupt at linux.vnet.ibm.com
Tue Apr 17 19:37:48 AEST 2018

Hi All,

Further extending my last proposal.

Create a repo phosphor-snmp which would be exposing a lib named libsnmp.

Any process which wants to send the trap link that process with this lib
and call the following function to send the trap.

Prototype of sending trap function is below.

template<typename T, typename... ArgTypes>
void sendTrap(ArgTypes&&... tArgs)

T = Notification Type.

This Notification Type class needs to be defined and it would be defined
by the parser at build time by reading the mib file.

This parser would be custom written parser to generate these classes as 
we can not
use the mib2c for the same.

We would be using the netsnmp lib for sending the trap.

Configuration of SNMP Manager

    SNMP Manager Ip/port would be configured under the settings namespace.

How to add the new Notification
=> Define the intended notification object in the mib.
=> Write the specific notification class until parser is ready.

How to use the lib.

Suppose we want to send the Error Notification with some data.


Content in the error Notification Mib
1) ErrorId
2) Timestamp
3) Severity
4) ErrorMessage(should be small enough to be fit in single MTU.)

NOTE:-  Currently in error object through REST we send other properties 
like"additional data",
         but we can not send the same info through SNMP trap as it makes 
the trap heavy.
         seems to me that is not the intent of the trap to get all the 
info of the object.
         Fo such requirement we should support snmp agent SNMP-GET on 
that object.

Need opinion from the community members on this proposal as well as the
content of the Error Notification Mib.

Ratan Gupta

On Saturday 17 March 2018 05:17 PM, Ratan Gupta wrote:
> Hi All,
> I am working on the 
> issue(https://github.com/openbmc/openbmc/issues/3002) to Implement 
> SNMP trap notification support on openBMC.
> I would be explaining a rough idea of how we plan to go about.
> Please share your thoughts and feedback on this proposal.
> Requirement:- Enable support for SNMP trap notification on openbmc.
>               Currently the requirement is to send the SNMP trap in 
> the following cases
>               1) Whenever the error log gets created.
>               2) Whenever the BMC state changes to runtime.
> NOTE:- In future We would extend the support of sending trap in other 
> use cases.
>               1) Sending the sensor telemetry data.
>               2) Application specific use cases.
>                    eg:- Multiple Authentication failure.
> Configurable Trap Parameters
> ===================
> 1) Manager IP
> 2) Interested Trap types
>     Notice
>         Warning
>         Critical
> How to configure the SNMP Manager IP on bmc?
> - Through REST (and hence D-Bus) API
> We can define the MIB structure depending on the eventType
> eg
> ==>eventType = ErrorLog
> Structure for errorLog MIB
> ================
> AgentIP   :   BMC IP Address
> TimeStamp :   Time when the trap generated
> deviceName:-  DbusObjectPath
> alertLevel:-  Would be given by the config yaml
>     Following properties data would be fetched by making Dbus call on 
> that object.
> ErrorId:
> ErrorSeverity:
> ErrorMessage:
> ErrorAdditionalData{array of key value}:
> ErrorResolutionStatus:
> ===>eventType = Configuration
> AgentIP   :   BMC IP Address
> TimeStamp :   Time when the trap generated
> deviceName:-  DbusObjectPath
> alertLevel:-  Would be given by the config yaml
> eventMessage:- "BMC state changed"
> PropertyName:-
> PropertyValue:-
> Implement the snmp trap feature
> =====================
> Currently on openbmc the data is being modeled as D-bus Object so we 
> would be
> leveraging the capabilities given by the existing 
> app(phosphor-Dbus-Monitor) to get the
> triggers on following conditions to generate the snmp trap.
> 1) whenever the new object gets added
>       eg error object under /xyz/openbmc_project/Logging
> 2) There is some property change on the configured D-bus object
>       eg Network configuration change.
> 3) Some property reached a specific value/threshold value.
>       eg BMC state change to "poweron" or CPU temperature is > X
> NOTE:- There could be cases which is independent on the D-bus object
>        eg:- Generate a trap whenever there is multiple authentication 
> failure
>        We would expose a D-bus api to generate a trap to handle 
> application
>        specific use cases.
> Config YAML of Phosphor-Dbus-Monitor
> ========================
> - name: create property event
>   class: callback
>   callback: snmpEvent
>   paths: D-bus path group
>   properties: Group of interested Properties
>   eventSeverity: Notice/Warning/Critical
>   eventType: Error log / Sensor / State.
>   eventMessage: "User can give the message as per the eventType"
>          PropertyChange:- Normal property Change could be eventType as 
> Notice eg:- StateChange/Network Configuration change
>          PropertyChange would become Warning:- if we have met a 
> specific condition on a property
>                            eg Proc Temprature > some configured 
> temperature value.
> Opensource:- NetSnmp
>              Comes up with full suite of tools like snmp 
> agent,snmptrapd, mib2c, bunch of other tools
>              Currently the support is for trap so we need minimal of 
> above(libsnmp,mib2c).
> Regards
> Ratan Gupta

More information about the openbmc mailing list