The invention discloses an online analysis system for monitoring harmful gases in a livestock and poultry farm. The online analysis system comprises a sampling unit, a purifying unit and an analytic unit connected in turn. Steam with a constant pressure is introduced into the sampling unit, is sent into the purifying unit by an injection pump and then is passed into the gas analytic unit. Through multiple times of filtration and dehumidification treatments, the gasses exhausted by a ventilation opening of the livestock and poultry farm can be stably sampled under various working conditions, and the sampled gasses automatically undergo dust removal, dehumidification drying, pressure and flow stabilization, fine filtration, flow measurement and quantitative analysis. Besides, measurement range calibration and zero point calibration are performed on a gas analyzer through a standard gas connected with the analytic unit to realize online calibration of the analysis system. The invention also discloses an online analysis method for monitoring the harmful gasses in the livestock and poultry farm. Through the online analysis system and the online analysis method, hydrogen sulfide, ammonia gas, carbon dioxide, carbon monoxide and methane exhausted by the ventilation opening of the livestock and poultry farm can be accurately and reliably detected and analyzed online.