Downtime value

I need to get a downtime value for a specific host. How can I do it with nagios? I need to use perl script.

Thanks,

Query the database, or grep the nagios.log file.