DX Infrastructure Manager

Expand all | Collapse all

Lua extensions

Jump to Best Answer
  • 1.  Lua extensions

    Posted 05-23-2018 06:12 AM

    Can someone confirm the exact format of action.email() command.
    I see it is not taking up the html template for notifying the email but some report.txt file
    and the message details also are not populating.



  • 2.  Re: Lua extensions

    Posted 05-23-2018 07:26 AM

    This is my script for emailing from an alarm triggered lua script

    I notice it doesn't use the html template either so I will try to investigate

    But is does produce a message contents

     

    a = alarm.get()

    if a ~= nil then

    otime = timestamp.format (a.nimts,"%d/%m/%Y-%H:%M:%S")

    atime = timestamp.format (a.arrival,"%d/%m/%Y-%H:%M:%S")

    recipient = "xxxxx@ca.com"

    subject = a.severity.." Alarm for host "..a.hostname.." at "..otime

     

    buff = "The following alarm was recieved at "..atime.." from host "..a.hostname.." originating at "..otime..".\n"

    buff = buff..a.message

     

         action.email (recipient,subject,buff)

     

    end



  • 3.  Re: Lua extensions

    Posted 05-23-2018 08:28 AM

    Thanks for inputs Rowan,
    I figured that out and now I can see emails but as plain-text only.
    But, would definitely like to test the possibility of it using the html template. 

     

    Regards

    Abhishek



  • 4.  Re: Lua extensions
    Best Answer

    Posted 05-23-2018 11:13 AM

    Just force the body to be html. I use something like:

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.2.0">
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
    <title>Title stuff</title>

    <style type="text/css">
    td.c1 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 26px}
    </style>
    </head>

    <body>

    this will be HTML

    </body>

    </html>

     

    And then depending on the email client, the content will be rendered appropriately.

     

    -Garin