In order to prevent potential failures due to lack of cooling systems, data centers are fitted with redundant air conditioning units. Even though such extra elements provide safety and could be turned off, they are typically on and underutilized, thus wasting energy. We propose a distributed and automatic control of air conditioning units based on dense environmental sensing and data center events handling system that prevent hot spots formation or server/device failures. The control is optimal in the sense of determining and controlling the operation of a set with the minimum number of active air conditioning units while preserving the specified data center cooling capacity. In addition, we present an implementation of such system for a discrete state (on/off) control of air conditioning units in a medium sized data center.