This works for me!
require ("library/html-alarms-lib")
recipient = "J@cem.com"
title = "Nimsoft - 24 Hour Alert Report"
buf = ""
buf = buf .. html_start (title)
buf = buf .. html_alarms (transactions)
buf = buf .. html_end ()
day = 60*60*24
past_day = timestamp.now() - day
past_week = timestamp.now() - 7*day
past_month = timestamp.now() - 30*day
database.open("transactionlog.db")
query = "select * from NAS_TRANSACTION_SUMMARY where created > \"" .. timestamp.format(past_day, "%Y-%m-%d %H:%M:%S") .. "\";"
data, rc = database.query(query);
email_msg = "\n"
email_msg = email_msg .. sprintf("%-25s%-25s%-20s%-40s%s\n", "created", "visibility", "origin", "host", "message")
for _, x in pairs(data) do
closed = "open"
if x.closed then
closed = x.closed
end
email_msg = email_msg .. sprintf("%-25s%-25s%-20s%-40s%s\n",x.created, x.visible, x.origin, x.hostname, x.message)
end
database.close()
action.email(recipient,title,buf)
--print (email_msg)