This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Button for exporting alarms in CSV locally
#1
Hello,

is it possible to export all the alarms by pushing a button in the visualization locally on the machine as a CSV file without being logged in as administrator?
Reply
#2
Create alerts.lp file and upload it to user directory via FTP using apps login.
Code:
<?

require('apps')

setdlheader('text/csv; charset=utf-8', 'Alerts', 'csv')

rows = { '"Date/time","Script name","Message"' }
items = db:getall('SELECT * FROM alerts ORDER BY id DESC')

for _, item in ipairs(items) do
  datetime = os.date('%c', item.alerttime)
  rows[ #rows + 1 ] = string.format('%q,%q,%q',
    datetime, item.scriptname, item.alert)
end

csv = table.concat(rows, '\n')

write(csv)

Then in visualization create a link that points to /user/alerts.lp
Reply
#3
Thank you, it works perfectly
Reply


Forum Jump: