1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
4 * Model for generating trend graphs
6 class Trends_graph_Model
extends Model
10 * Fetch data to be used in the trends graph
12 * @param $data Data from get_sla_data
13 * @return $data_chart Formated data to fit trends graph
16 static public function format_graph_data ($data){
18 $data_chart = array();
19 $events = current($data);
21 // Group log entries by object type
22 foreach($data as $current_object => $events) {
23 foreach($events as $event) {
26 if (isset($event['output']))
27 $output = $event['output'];
29 $object_type = strpos($current_object, ';') !== false ?
'service' : 'host';
31 if(!isset($data_chart[$current_object])) {
32 $data_chart[$current_object] = array();
35 $data_chart[$current_object][] = array(
36 'duration' => $event['duration'],
37 'state' => $event['state'],
38 'object_type' => $object_type,