Cyber-physical systems have emerged as a new engineering paradigm, which combine the cyber and physical world with comprehensive computational and analytical tools to solve complex tasks. In cyber-physical systems, components are developed to detect failures, prevent failures, or mitigate the failures of a system. Sensors gather real-time data as an input to the system for further processing. Therefore, the whole cyber-physical system depends on sensors to accomplish their tasks and the failure of one sensor may lead to the failure of the whole system. To address this issue, we present an approach that utilizes the Failure Modes, Effects, and Criticality Analysis, which is a prominent hazard analysis technique to increase the understanding of risk and failure prevention. In our approach, we transform the Failure Modes, Effects, and Criticality Analysis model into a UML(Unified Modeling Language) class diagram, and then a knowledge base is constructed based on the derived UML class diagram. Finally, the UML class diagram is used to build an ontology. The proposed approach employs a 5C architecture for smart industries for its systematic application. Lastly, we use a smart home case study to validate our approach.