1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
5 * op5, and the op5 logo are trademarks, servicemarks, registered servicemarks
6 * or registered trademarks of op5 AB.
7 * All other trademarks, servicemarks, registered trademarks, and registered
8 * servicemarks mentioned herein may be the property of their respective owner(s).
9 * The information contained herein is provided AS IS with NO WARRANTY OF ANY
10 * KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR A
13 class Status_Controller
extends Authenticated_Controller
{
16 * Display a list of hosts
19 * @param $hoststatustypes
22 * @param $show_services
24 * @param $serviceprops
27 public function host($host='all', $hoststatustypes=false, $sort_order='ASC', $sort_field='name', $show_services=false, $group_type=false, $serviceprops=false, $hostprops=false)
29 $host = $this->input
->get('host', $host);
30 $hoststatustypes = $this->input
->get('hoststatustypes', $hoststatustypes);
31 $sort_order = $this->input
->get('sort_order', $sort_order);
32 $sort_field = $this->input
->get('sort_field', $sort_field);
33 #$show_services = $this->input->get('show_services', $show_services);
34 $group_type = $this->input
->get('group_type', $group_type);
35 $group = $this->input
->get('group', false);
36 #$serviceprops = $this->input->get('serviceprops', $serviceprops);
37 $hostprops = $this->input
->get('hostprops', $hostprops);
38 $group_type = strtolower($group_type);
40 $status = new Old_Status_Model();
41 if( !empty($group_type) && $group_type=='hostgroup' ) {
42 list($hostfilter, $servicefilter) = $status->classic_filter('host', $host, $group, false, $hoststatustypes, $hostprops, false, $serviceprops);
44 else if( !empty($group_type) && $group_type=='servicegroup' ) {
45 list($hostfilter, $servicefilter) = $status->classic_filter('host', $host, false, $group, $hoststatustypes, $hostprops, false, $serviceprops);
48 list($hostfilter, $servicefilter) = $status->classic_filter('host', $host, false, false, $hoststatustypes, $hostprops, false, $serviceprops);
51 return $this->_redirect_to_query($hostfilter);
55 * Display a list of services
58 * @param $hoststatustypes
59 * @param $servicestatustypes
60 * @param $service_props
66 public function service($name='all', $hoststatustypes=false, $servicestatustypes=false, $service_props=false, $sort_order='ASC', $sort_field='host_name', $group_type=false, $hostprops=false)
68 $name = $this->input
->get('name', $name);
69 $hoststatustypes = $this->input
->get('hoststatustypes', $hoststatustypes);
70 $servicestatustypes = $this->input
->get('servicestatustypes', $servicestatustypes);
71 $service_props = $this->input
->get('serviceprops', $service_props);
72 $service_props = $this->input
->get('service_props', $service_props);
73 $hostprops = $this->input
->get('hostprops', $hostprops);
74 $sort_order = $this->input
->get('sort_order', $sort_order);
75 $sort_field = $this->input
->get('sort_field', $sort_field);
76 $group_type = $this->input
->get('group_type', $group_type);
77 $noheader = $this->input
->get('noheader', false);
78 $group_type = strtolower($group_type);
80 $status = new Old_Status_Model();
81 if(empty($group_type)) {
82 list($hostfilter, $servicefilter, $hostgroupfilter, $servicegroupfilter) = $status->classic_filter('service', $name, false, false, $hoststatustypes, $hostprops, $servicestatustypes, $service_props);
84 if($group_type=='servicegroup') {
85 list($hostfilter, $servicefilter, $hostgroupfilter, $servicegroupfilter) = $status->classic_filter('service', false, false, $name, $hoststatustypes, $hostprops, $servicestatustypes, $service_props);
87 list($hostfilter, $servicefilter, $hostgroupfilter, $servicegroupfilter) = $status->classic_filter('service', false, $name, false, $hoststatustypes, $hostprops, $servicestatustypes, $service_props);
92 return $this->_redirect_to_query($servicefilter);
96 * Wrapper for Service problems link in menu
98 public function service_problems()
100 return $this->_redirect_to_query('[services] has_been_checked!=0 and state!=0');
104 * Wrapper for Host problems link in menu
106 public function host_problems()
108 return $this->_redirect_to_query('[hosts] has_been_checked!=0 and state!=0');
112 * Display a list of service groups
115 * @param $hoststatustypes
116 * @param $servicestatustypes
118 * @param $serviceprops
121 public function servicegroup($group='all', $hoststatustypes=false, $servicestatustypes=false, $style='overview', $serviceprops=false, $hostprops=false)
123 return $this->group('service', $group, $hoststatustypes, $servicestatustypes, $style, $serviceprops, $hostprops);
127 * Display a list of host groups
130 * @param $hoststatustypes
131 * @param $servicestatustypes
133 * @param $serviceprops
136 public function hostgroup($group='all', $hoststatustypes=false, $servicestatustypes=false, $style='overview', $serviceprops=false, $hostprops=false)
138 return $this->group('host', $group, $hoststatustypes, $servicestatustypes, $style, $serviceprops, $hostprops);
142 * Display a list of groups of some kind
146 * @param $hoststatustypes
147 * @param $servicestatustypes
149 * @param $serviceprops
152 public function group($grouptype='service', $group='all', $hoststatustypes=false, $servicestatustypes=false, $style='overview', $serviceprops=false, $hostprops=false)
154 $grouptype = $this->input
->get('grouptype', $grouptype);
155 $group = $this->input
->get('group', $group);
156 $hoststatustypes = $this->input
->get('hoststatustypes', $hoststatustypes);
157 $servicestatustypes = $this->input
->get('servicestatustypes', $servicestatustypes);
158 $serviceprops = $this->input
->get('serviceprops', $serviceprops);
159 $hostprops = $this->input
->get('hostprops', $hostprops);
160 $status = new Old_Status_Model();
161 list($hostfilter, $servicefilter) = $status->classic_filter($grouptype, false, ($grouptype=='host' ?
$group : false), ($grouptype=='service' ?
$group : false), $hoststatustypes, $hostprops, $servicestatustypes, $serviceprops);
162 return $this->_redirect_to_query($
{$grouptype.'filter'});
166 * Display servicegroup summary
168 public function servicegroup_summary()
170 return $this->_redirect_to_query('[servicegroups] all');
174 * Display hostgroups summary
176 public function hostgroup_summary()
178 return $this->_redirect_to_query('[hostgroups] all');
181 private function _redirect_to_query( $query ) {
182 /* Put the filter through the parser, so we simplify it */
183 $query = ObjectPool_Model
::get_by_query($query)->get_query();
184 return url
::redirect('listview?'.http_build_query(array('q'=>$query)));