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 $group_type = strtolower($group_type);
79 $status = new Old_Status_Model();
80 if(empty($group_type)) {
81 list($hostfilter, $servicefilter, $hostgroupfilter, $servicegroupfilter) = $status->classic_filter('service', $name, false, false, $hoststatustypes, $hostprops, $servicestatustypes, $service_props);
83 if($group_type=='servicegroup') {
84 list($hostfilter, $servicefilter, $hostgroupfilter, $servicegroupfilter) = $status->classic_filter('service', false, false, $name, $hoststatustypes, $hostprops, $servicestatustypes, $service_props);
86 list($hostfilter, $servicefilter, $hostgroupfilter, $servicegroupfilter) = $status->classic_filter('service', false, $name, false, $hoststatustypes, $hostprops, $servicestatustypes, $service_props);
91 return $this->_redirect_to_query($servicefilter);
95 * Wrapper for Service problems link in menu
97 public function service_problems()
99 return $this->_redirect_to_query('[services] has_been_checked!=0 and state!=0');
103 * Wrapper for Host problems link in menu
105 public function host_problems()
107 return $this->_redirect_to_query('[hosts] has_been_checked!=0 and state!=0');
111 * Display a list of service groups
114 * @param $hoststatustypes
115 * @param $servicestatustypes
117 * @param $serviceprops
120 public function servicegroup($group='all', $hoststatustypes=false, $servicestatustypes=false, $style='overview', $serviceprops=false, $hostprops=false)
122 return $this->group('service', $group, $hoststatustypes, $servicestatustypes, $style, $serviceprops, $hostprops);
126 * Display a list of host groups
129 * @param $hoststatustypes
130 * @param $servicestatustypes
132 * @param $serviceprops
135 public function hostgroup($group='all', $hoststatustypes=false, $servicestatustypes=false, $style='overview', $serviceprops=false, $hostprops=false)
137 return $this->group('host', $group, $hoststatustypes, $servicestatustypes, $style, $serviceprops, $hostprops);
141 * Display a list of groups of some kind
145 * @param $hoststatustypes
146 * @param $servicestatustypes
148 * @param $serviceprops
151 public function group($grouptype='service', $group='all', $hoststatustypes=false, $servicestatustypes=false, $style='overview', $serviceprops=false, $hostprops=false)
153 $grouptype = $this->input
->get('grouptype', $grouptype);
154 $group = $this->input
->get('group', $group);
155 $hoststatustypes = $this->input
->get('hoststatustypes', $hoststatustypes);
156 $servicestatustypes = $this->input
->get('servicestatustypes', $servicestatustypes);
157 $serviceprops = $this->input
->get('serviceprops', $serviceprops);
158 $hostprops = $this->input
->get('hostprops', $hostprops);
159 $status = new Old_Status_Model();
160 list($hostfilter, $servicefilter) = $status->classic_filter($grouptype, false, ($grouptype=='host' ?
$group : false), ($grouptype=='service' ?
$group : false), $hoststatustypes, $hostprops, $servicestatustypes, $serviceprops);
161 return $this->_redirect_to_query($
{$grouptype.'filter'});
165 * Display servicegroup summary
167 public function servicegroup_summary()
169 return $this->_redirect_to_query('[servicegroups] all');
173 * Display hostgroups summary
175 public function hostgroup_summary()
177 return $this->_redirect_to_query('[hostgroups] all');
180 private function _redirect_to_query( $query ) {
181 /* Put the filter through the parser, so we simplify it */
182 $query = ObjectPool_Model
::get_by_query($query)->get_query();
183 return url
::redirect('listview?'.http_build_query(array('q'=>$query)));