Exemplo n.º 1
0
 /**
  * Get the list of metric name by a service template id
  *
  * @param int $tmplId The service template id
  * @return array
  */
 public static function getMetricsNameByServiceTemplate($tmplId)
 {
     $services = ServicetemplateRepository::getServices($tmplId);
     if (count($services) == 0) {
         return array();
     }
     /* Check if all data are integer */
     array_map(function ($value) {
         if (false === is_numeric($value)) {
             throw new \Exception('The value is not numeric');
         }
     }, $services);
     $dbconn = \Centreon\Internal\Di::getDefault()->get('db_centreon');
     $query = "SELECT m.metric_name\n            FROM rt_metrics m, rt_index_data i\n            WHERE m.index_id = i.index_id\n                AND i.service_id IN (" . join(', ', $services) . ")";
     $stmt = $dbconn->query($query);
     $metrics = array();
     while ($row = $stmt->fetch()) {
         $metrics[] = $row['metric_name'];
     }
     return array_unique($metrics);
 }