For my monitoring tool (Centreon), I need to create a script that will send me every day a report with my hosts / services that have been acknowledged for X days.
For this I need to get information in several tables which I can do with the following query
SELECT DISTINCT services.host_id,
hosts.name,
services.service_id,
services.description,
comments.author,
comments.DATA,from_unixtime(comments.entry_time),
comments.comment_id
FROM services,
hosts,
comments
WHERE services.host_id=hosts.host_id
AND hosts.host_id=comments.host_id
AND services.acknowledged='1'
AND services.enabled='1'
AND comments.DATA NOT LIKE '%downtime%'
What I'll need is to have as result only the highest comment_id per service_id
Is there a way to do this directly in a query or do I have to import my entire result into my python script and process the data afterwards?
Thanks in advance for your help.