Merge branch 'maint/7.0'
[ninja.git] / modules / legacy / models / stats.php
blob5939ca439cea3323a7130c7694213335c5f972ce
1 <?php
3 /**
4 * A model for generating statistics from livestatus
5 */
6 class Stats_Model extends Model {
7 /**
8 * return statistics for given type
9 */
10 public function get_stats($type, $options = null, $last_program_start = null) {
11 try {
12 $ls = Livestatus::instance();
13 switch($type) {
14 case 'host_totals': return $ls->getHostTotals($options);
15 break;
16 case 'service_totals': return $ls->getServiceTotals($options);
17 break;
18 case 'host_performance': return $ls->getHostPerformance($last_program_start, $options);
19 break;
20 case 'service_performance': return $ls->getServicePerformance($last_program_start, $options);
21 break;
22 default: throw new Exception("unknown type: $type");
23 break;
25 } catch (LivestatusException $ex) {
26 return false;