I have a runbook which has 2 Qapps and 1 Gapp, each of the Qapps generate Alerts based on the conditions and I can manually export the Alerts in csv format. Here, looking for a way to export the Alerts of Qapps/runbook using python or existing Netbrain APIs.
Hello RaviKishore,
There are multiple way to achieve this scenario.
- Use Qapp Scheduler to export csv output file into a shared folder or send an email with attachment.
- Use NetBrain API to send file as attachment in an email.
Approach 1 : Use Qapp Scheduler:
Below are the steps you can follow to export CSV output into a shared folder or send as an attachment to an email address:
Step 1: Click on start button, then search for “Schedule Qapp” and the open it.
Step 2: Click on + Add Task button, then follow the Edit Task dialogue box wizard to add basic info, add target devices, select Qapp, execution timings, then in the Output Section, Check the “Export Report File” option.
Step 3: Enter the shared network folder path for which NetBrain has access to export Qapp CSV output (or) specify the email address to which the report related attachment to be sent.
All Qapp output CSV files will be saved with filename containing the timestamp of execution time. This will help to filter the files with execution intervals.
Use NetBrain API to send file as attachment in an email:
You can below sample code to send a text file or a csv file as attachment upon execution of Qapp:
import netbrain.sysapi.datamodel as datamodel
mailContent = {
"subject":"From IE10.netbraintech.com",
"body":"<html><head>suggest</head><body>Hi all, <br>This is a test </body>",
"recipients":,"pradeep.gaddameedi@netbraintech.com"],
"Ccs":h"pradeep.gaddameedi@netbraintech.com"],
"attachments":<{"content":"place,location\ndalian_beach, dalian\nqingdao_beach,qingdao", "contenttype":"text/csv", "filename":"place.csv"},
{"content":"test, hello this is pradeep,\n this is a new line", "contenttype":"text/plain; charset=us-ascii","filename":"test.txt"}]
}
datamodel.SendEmail(mailContent)
Thanks,
Pradeep
Reply
Login to the community
No account yet? Create an account
Sign in with SSO
Login via NetBrain UniversityEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.