[Objective] Fire is a frequent security incident in computer laboratories; it might devastate internal equipment and stored data and seriously threaten the lives and properties of personnel. Therefore, an effective fire warning method must be adopted to recognize the potential fire status in computer laboratories and promptly transmit graded fire warning information. However, the existing fire warning methods based on the Euclidean, Lance--Williams, and cosine distances suffer from the problems of low warning accuracy and inability to recognize the potential fire status of computer laboratories in time. Then, a fire risk early warning method for computer laboratories is proposed based on the discrimination of Mahalanobis distance. [Methods] First, various sensors arranged in the computer laboratory are utilized to detect the relevant gas concentration, temperature, radiant light intensity, current magnetic field intensity, and smoke and dust concentrations in the computer laboratory. Subsequently, reference matrices of different states are established based on typical samples, and different elements in the vectors composed of the detected indicator contents are given different weights. Afterward, the fire to which the indicator content belongs is determined based on the weighted Mahalanobis distance. Subsequently, the fire hazard level to which the indicator content belongs is determined based on the weighted Martensitic distance (i.e., very-high-risk level, higher-risk level, medium-risk level, medium-to low-risk level, and low-risk level). Finally, different solutions are adopted according to different fire hazard levels to eliminate fire hazards in computer laboratories. In the experimental phase, first, the coverage area of each sensor and the minimum number of sensors required to implement the method by calculation based on the size of a real computer laboratory are obtained. Second, a certain class of sensors in computer laboratories is removed, and the remaining four environmental data on fire risk warnings in computer laboratories are used to determine the reasonable weights corresponding to the relevant gas concentration, temperature, radiant light intensity, current magnetic field intensity, and smoke and dust concentrations in the Mahalanobis distance discrimination. Afterward, the location of each sensor is changed according to different distribution rules to determine the optimal distribution of sensors in the computer laboratory. Finally, with the deployment of different numbers of sensors in the computer laboratory, the fire risk warning method based on weighted Mahalanobis distance discrimination in the computer laboratory is compared with the fire risk warning methods based on Euclidean, Lance--Williams, and cosine distances to further validate the effectiveness and accuracy of the proposed method. [Results] The experimental results show that, compared with other fire risk warning methods, the proposed method based on weighted Mahalanobis distance discrimination exhibits a high warning accuracy. Its overall fire warning accuracy is maintained at approximately 80% even when the minimum number of sensors are placed in the computer laboratory, and the average warning accuracy of the method is increased to 90% after increasing the number of sensors in the computer laboratory. [Conclusions] Therefore, the proposed method based on weighted martensitic distance discrimination is more accurate and effective. [ABSTRACT FROM AUTHOR]