{ "name": "Example Template", "template_text": "{\"attributes\": [{\"name\": \"Static Value\", \"value\": \"Static Text\"}, {\"name\": \"Dynamic Value\", \"value\": \"{{ get(\u0027rule.uuid\u0027) }}\"}]}" }
Configuring alarms for SNMP trap notification
This release allows users to configure alarm templates and rules to forward SNMP trap information to a specified destination IP address or hostname. For details about how Blue Planet manages system notifications, review the API documentation on notifications.
To create SNMP templates you use a method similar to email template creation, with the exception that the body of the template must be a JSON object that contains one or more name-value pairs.
To configure Blue Planet to send specific SNMP trap notifications to a specific IP address or hostname:
-
As with email notifications, to create notifications you must first create a template object. You can either send a JSON payload to the ntfconfig API endpoint for templates programmatically or use the command line.
A JSON payload that creates an SNMP template programmatically follows:
Note that attributes is a list of structures of the form:
{ "name": "FIELD_NAME", "value": "FIELD_VALUE" }
To post this template using Curl:
curl -X POST http://HAPROXY_IP/ntfconfig/api/v1/ templates -- header ′content-type: application/json′; -d'{"name": "Example Template", "template_text": "{\"attributes\": [{\"name\": \"Static Value\", \"value\": \"Static Text\"}, {\"name\": \"Dynamic Value\", \"value\": \"{{ get(\u0027rule.uuid\u0027) }}\"}]}"}'
-
To create an SNMP rule, you follow similar email rule creation steps, except that the notification_type field is set to snmp and the notification_params field has different requirements.
A JSON payload used to create an SNMP template programmatically follows:
{ "name": "SNMP Example Rule", "notification_type": "snmp", "topic": "bp.aeprocessor.v1.alarms", "trigger_type": "bp.v1.alarmRaised", "template": 1, "notification_params": "{\"targets\": [{\"hostname\": \"DESTINATION_IP\"}]}", "extra_compare": "{\"alarm.resource\": \"SPECIFIC_RESOURCE\"}" }
This rule listens on the alarm processor output topic and triggers on alarm -raised events on a specific resource. Ensure you associate SNMP rules with SNMP-compatible templates. If you associate a non-SNMP template with a SNMP rule, the rule does not function correctly.
To post this rule using Curl:
curl -X POST http://HAPROXY_IP/ntfconfig/api/v1/rules -- header 'content-type: application/json' -d '{"name": "Example SNMP Rule", notification_type": "snmp", "topic": "bp.aeprocessor.v1.alarms", "trigger_type": "bp.v1.alarmRaised", "template": 1, "notification_params": "{\"targets\": [{\"hostname\": \"DESTINATION_IP\"}]}", "extra_compare": "{\"alarm.resource\": \"SPECIFIC_RESOURCE\"}"}'
-
To create a MIB file to add to your SNMP trap receiver, perform a GET operation on the /api/vi1/rules/mib path from your browser or API command line. For example:
curl http://<server_IP>/ntfconfig/api/v1/rules/mib
In a browser, this operation prompts a file download. Ensure you choose to save the results if prompted. You must install this file in your SNMP trap receiver of choice, so that system can properly translate SNMP traps generated via Blue Planet notifications.
When Blue Planet generates the MIB, it excludes any rules where MIB generation failed. If you see log messages that contain warnings or notice that one of your SNMP rules is not included in the MIB file, your rule is not properly configured. In most cases, this means the template is not well formed.