ActionCustomReport
Syntax
Inside a callback action:
ActionCustomReport(<template>[, <params>][, title=<title>])
Description
Generates a multiple line report with customized content. The report content can be viewed in the Web UI from the alert details for the agent.
Parameters
<template>
- Specifies the report template to use when generating this report. This template must be defined elsewhere in the script.
<title>
Specifies the title to be displayed for this action. The definition of
<title>
must use theTitle
function.For example:
title=Title("Generate final MAC report")
Usage
This function can only be used inside a callback action.
The script must contain the template (code) that generates and formats the report.
You can create a custom title for this action. The title you create can help the user of the Web UI to determine what action was executed. The title is displayed in the Action Results section of the Alert Details dialog box.
Examples
Example of calling the custom report action with a parameter:
ActionCustomReport(my_template, [self.params["author"]])
Example of generating a custom report:
uri1 = '/rest/v1/system/vlans/{}/macs/?count'
self.m1 = Monitor(uri1, 'Mac address count', [self.params['vlan_id']])
self.r1 = Rule('MAC Address Learnt')
self.r1.condition(
'{} > 0 pause {} minutes',
[self.m1, self.params['alert_pause']])
self.r1.action(self.gen_custom_report)
def gen_custom_report(self, event):
vlan_id = self.params['vlan_id'].value
type_s = ["dynamic", "static", "mclag", "vrrp"]
mac_report = []
for m in type_s:
mac_all_dict = self.get_mac_result(vlan_id, m)
mac_report.append(mac_all_dict)
final_report = self.generate_htmlreport(mac_report)
ActionCustomReport(final_report, title=Title("Generate final MAC report"))
def get_mac_result(self, vlan_id, mac_type):
url = 'http://127.0.0.1:5577/rest/v1/system/vlans/' \
+ str(vlan_id) + '/macs?count=true&filter=from:' + \
mac_type
r1 = self.rest_get(url)
result = str(r1.json()["count"])
return result
def generate_htmlreport(self, mac_report):
html_prefix = '''<html>
<head>
<title>HPE-Aruba</title>
</head>
<body>
<table border="1">
<tr align="center">
<th><td colspan="4"><b>Summary</b></td></th>
</tr>
<tr align="center">
<th>
<td colspan="4">
<b>Number of MAC learnt on various types</b>
</td>
</th>
</tr>
<tr>
<th> DYNAMIC </th>
<th> STATIC </th>
<th> MCLAG </th>
<th> VRRP </th>
</tr>
''' + self.get_mac_htmlcontent(mac_report) + '''
</table>
</body>
</html>'''
return html_prefix
For another example of a custom report, see the
ospfv2_interface_state_flaps_impact_monitor
solution on the Aruba Solutions Exchange.