Below query can be used to check SQL Agent failed jobs in last 24 hours. This query can be used in the monitoring script to find out failed job in SQL server agent.

SELECT sj.[name] AS "Failed Job Name", jh.run_date,jh.[message]
Read the rest