コード例 #1
0
 public function detailAction()
 {
     if (isset($_REQUEST["resource_id"]) && isset($_REQUEST["service_id"]) && isset($_REQUEST["time"])) {
         $resource_id = (int) $_REQUEST["resource_id"];
         $service_id = (int) $_REQUEST["service_id"];
         $time = (int) $_REQUEST["time"];
         $this->view->detail_service_id = $service_id;
         $this->view->detail_time = $time;
         //get service information
         $model = new ResourceServices();
         $params = array("resource_id" => $resource_id, "service_id" => $service_id);
         $this->view->detail_service = $model->get($params);
         //get statuses at specified timestamp
         $metricdata_model = new MetricData();
         $params = array("resource_id" => $resource_id, "time" => $time);
         $latest_metrics = $metricdata_model->get($params);
         //pull metric info
         $model = new Metric();
         $this->view->metric_details = $model->getindex();
         //pull all metric for this service
         $model = new MetricService();
         $this->view->detail_critical_metrics = array();
         $this->view->detail_noncritical_metrics = array();
         foreach ($model->get(array("service_id" => $service_id)) as $metric) {
             $info = array();
             $info["metric_id"] = $metric->metric_id;
             //find the reported detail (if not, leave it empty)
             foreach ($latest_metrics as $latest_metric) {
                 if ($latest_metric->metric_id == $metric->metric_id) {
                     $info["detail_id"] = $latest_metric->id;
                     $info["detail"] = $this->fetchMetricDetail($latest_metric->id);
                     $info["status"] = Status::getStatus($latest_metric->metric_status_id);
                     $info["timestamp"] = $latest_metric->timestamp;
                     break;
                 }
             }
             if ($metric->critical == 1) {
                 $this->view->detail_critical_metrics[] = $info;
             } else {
                 $this->view->detail_noncritical_metrics[] = $info;
             }
         }
         //load service status
         $service_status_model = new ServiceStatusChange();
         $params = array();
         $params["resource_id"] = $resource_id;
         $params["service_id"] = $service_id;
         $params["start_time"] = $time;
         $params["end_time"] = $time;
         $service_statuses = $service_status_model->get($params);
         $this->view->detail_service_status = null;
         if (isset($service_statuses[0])) {
             $this->view->detail_service_status = $service_statuses[0];
         }
         //load downtime
         $downtime_model = new Downtime();
         $params = array("resource_id" => $resource_id, "start_time" => $time, "end_time" => $time);
         $downtimes = $downtime_model->get($params);
         $downtimes_forservice = $this->getDowntimesForService($downtimes, $service_id);
         if (count($downtimes_forservice) > 0) {
             $this->view->downtime = $downtimes_forservice[0];
             //grab first one for this service
         }
     }
 }
コード例 #2
0
 public function loadStatusChanges()
 {
     /////////////////////////////////////////////////////////////////////////////////
     //get paramters
     if (!isset($_REQUEST["resource_id"])) {
         echo "resource_id missing";
         exit;
     }
     $dirty_resource_id = $_REQUEST["resource_id"];
     if (Zend_Validate::is($dirty_resource_id, 'Int')) {
         $resource_id = $dirty_resource_id;
     }
     list($start_time, $end_time) = getLastNDayRange(7);
     //this default shouldn't be used..
     if (isset($_REQUEST["start"]) && isset($_REQUEST["end"])) {
         $dirty_start_time = $_REQUEST["start"];
         if (Zend_Validate::is($dirty_start_time, 'Int')) {
             $start_time = $dirty_start_time;
         }
         $dirty_end_time = $_REQUEST["end"];
         if (Zend_Validate::is($dirty_end_time, 'Int')) {
             $end_time = $dirty_end_time;
         }
     }
     $service_id = null;
     if (isset($_REQUEST["service_id"])) {
         $service_id = (int) $_REQUEST["service_id"];
     }
     /////////////////////////////////////////////////////////////////////////////////
     //pull status changes
     if ($service_id === null) {
         //resource status
         $resource_statuschange_model = new ResourceStatusChange();
         $params = array();
         $params["resource_id"] = $resource_id;
         $params["start_time"] = $start_time;
         $params["end_time"] = $end_time;
         $status_changes = $resource_statuschange_model->get($params);
     } else {
         $service_statuschange_model = new ServiceStatusChange();
         $params = array();
         $params["service_id"] = $service_id;
         $params["resource_id"] = $resource_id;
         $params["start_time"] = $start_time;
         $params["end_time"] = $end_time;
         $status_changes = $service_statuschange_model->get($params);
     }
     /////////////////////////////////////////////////////////////////////////////////
     //pull downtime info
     $downtime_model = new Downtime();
     $params = array("resource_id" => $resource_id, "start_time" => $start_time, "end_time" => $end_time);
     $downtimes = $downtime_model->get($params);
     $downtimes_forservice = $this->getDowntimesForService($downtimes, $service_id);
     return array($status_changes, $start_time, $end_time, $downtimes_forservice);
 }