Here's one of possible solutions:
1) create a file (rwx permissions for root) containing this script:
SQL query |
---|
psql -d hyper9db -U h9pgsu -H -o /home/VM_Disk_latency_results_`date +"%Y_%m_%d"`.html -c " select date_trunc('day', a.time_stamp), count(a.guid) as Alert_raised from alert_recs a join workspace_file as w ON a.alert_guid = cast(w.id as varchar) where w.name = 'VM Disk Latency' -- alert name and a.time_stamp > now() - interval '100 days' -- days back and a.raised = true and a.statechange = true group by date_trunc" |
-this file creates an HTML file in /home folder named "VM_Disk_latency_results_YYYY_MM_DD.html". Example of output file is here:
2) run the file manually or copy it into /etc/cron.monthly folder to get results on monthly basis (or create your own schema in /etc/crontab).