This is functional specification for Integrating CS alerts via SNMP to external management system feature of Cloudstack.
https://issues.apache.org/jira/browse/CLOUDSTACK-680
These SNMP alerts can be used by SNMP managers (external running entities which can receive SNMP alerts) to find out the problems in Cloudstack and can act accordingly. This is similar to alerts that we see on dashboard of Cloudstack.
In this feature we are implementing partial SNMP Agent for Cloudstack. Partial SNMP Agent means we are just sending SNMP traps for alerts and not processing requests from SNMP Managers. In the current scenario we are writing alerts to database and are shown on Cloudstack dashboard. Now in addition to that we are sending an alert for SNMP managers also. For that purpose we will be defining MIB files. MIB files are written in ASN.1 language and contains the mapping of OID and variable mappings. MIB file acts like DNS server to identify the variable corresponding to OID.
SNMP version 2 will be supported with this feature.
There are two ways of getting OIDs for variable
Currently hardcoding OIDs in code of cloudstack since those are defined by us and code generation will require some processing. We have created MIB file for users.
The root OID for Apache CloudStack is 1.3.6.1.4.1.18060.15 .. we define the following traps
Each trap contains following information
currently sending all the alerts to administrator and he will filter alerts according to his needs.
For this feature, we will be using snmp4j library with Apache License
This feature will be implemented as plugin. This feature will use the log4j Appender to get the required alerts and will generate the SNMP trap from that. To do so following classes will be used.
We will add following classes
To configure multiple SNMP Managers one needs to add following appender in log4j-cloud.xml
<appender name="SNMP" class="org.apache.cloudstack.alert.snmp.SnmpTrapAppender">
<param name="Threshold" value="WARN"/>
<param name="SnmpManagerIpAddresses" value=""/>
<param name="SnmpManagerPorts" value=""/>
<param name="SnmpManagerCommunities" value=""/>
<layout class="org.apache.cloudstack.alert.snmp.SnmpEnhancedPatternLayout">
<param name="PairDelimeter" value="//"/>
<param name="KeyValueDelimeter" value="::"/>
</layout>
</appender>
To specify multiple SnmpManagerIpAddresses one has to modify as follows with each SNMP Manager separated by ,
<appender name="SNMP" class="org.apache.cloudstack.alert.snmp.SnmpTrapAppender">
<param name="Threshold" value="WARN"/>
<param name="SnmpManagerIpAddresses" value="10.1.1.1,10.1.1.2"/>
<param name="SnmpManagerPorts" value="162,162"/>
<param name="SnmpManagerCommunities" value="public,public"/>
<layout class="org.apache.cloudstack.alert.snmp.SnmpEnhancedPatternLayout">
<param name="PairDelimeter" value="//"/>
<param name="KeyValueDelimeter" value="::"/>
</layout>
</appender>
Following loggers will also be added
<logger name="org.apache.cloudstack.alerts" additivity="false">
<level value="WARN"/>
<appender-ref ref="SYSLOG"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
<appender-ref ref="SNMP"/>
</logger>