1<?php 2 3/** 4 * Observium 5 * 6 * This file is part of Observium. 7 * 8 * @package observium 9 * @subpackage webui 10 * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited 11 * 12 */ 13 14include($config['install_dir'] . '/includes/polling/functions.inc.php'); 15include($config['install_dir'] . '/includes/discovery/functions.inc.php'); 16 17$ports_ignored_count = intval(get_entity_attrib('device', $device, 'ports_ignored_count')); // Cache last ports ignored count 18$ports_total_count = $ports_ignored_count + dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `deleted` = ?', array($device['device_id'], 0)); 19 20if ($vars['submit']) 21{ 22 if ($readonly) 23 { 24 print_error_permission('You have insufficient permissions to edit settings.'); 25 } else { 26 if ($vars['toggle_poller'] && isset($config['poller_modules'][$vars['toggle_poller']])) 27 { 28 $module = $vars['toggle_poller']; 29 if (isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] != $config['poller_modules'][$module]) 30 { 31 del_dev_attrib($device, 'poll_' . $module); 32 } elseif ($config['poller_modules'][$module] == 0) { 33 set_dev_attrib($device, 'poll_' . $module, "1"); 34 } else { 35 set_dev_attrib($device, 'poll_' . $module, "0"); 36 } 37 $attribs = get_dev_attribs($device['device_id']); 38 } 39 40 if ($vars['toggle_ports'] && isset($config[$vars['toggle_ports']]) && strpos($vars['toggle_ports'], 'enable_ports_') === 0) 41 { 42 $module = $vars['toggle_ports']; 43 if ($vars['submit'] === 'Disable' && $attribs[$module] !== '0') 44 { 45 set_dev_attrib($device, $module, "0"); 46 } 47 else if (isset($attribs[$module]) && $attribs[$module] != $config[$module]) 48 { 49 del_dev_attrib($device, $module); 50 } elseif ($config[$module] == 0) { 51 set_dev_attrib($device, $module, "1"); 52 } else { 53 set_dev_attrib($device, $module, "0"); 54 } 55 $attribs = get_dev_attribs($device['device_id']); 56 } 57 58 if ($vars['toggle_discovery'] && isset($config['discovery_modules'][$vars['toggle_discovery']])) 59 { 60 $module = $vars['toggle_discovery']; 61 if (isset($attribs['discover_'.$module]) && $attribs['discover_'.$module] != $config['discovery_modules'][$module]) 62 { 63 del_dev_attrib($device, 'discover_' . $module); 64 } elseif ($config['discovery_modules'][$module] == 0) { 65 set_dev_attrib($device, 'discover_' . $module, "1"); 66 } else { 67 set_dev_attrib($device, 'discover_' . $module, "0"); 68 } 69 $attribs = get_dev_attribs($device['device_id']); 70 } 71 } 72} 73 74//r($device_state); 75?> 76 77<div class="row"> <!-- begin row --> 78 79 <div class="col-md-6"> <!-- begin poller options --> 80 81 <div class="box box-solid"> 82 83 <div class="box-header with-border"> 84 <h3 class="box-title">Poller Modules</h3> 85 </div> 86 <div class="box-body no-padding"> 87 88<table class="table table-striped table-condensed"> 89 <thead> 90 <tr> 91 <th>Module</th> 92 <th style="width: 60px;">Last Poll</th> 93 <th style="width: 60px;">Global</th> 94 <th style="width: 60px;">Device</th> 95 <th style="width: 80px;"></th> 96 </tr> 97 </thead> 98 <tbody> 99 100<?php 101foreach (array_merge(array('os' => 1, 'system' => 1), $config['poller_modules']) as $module => $module_status) 102{ 103 $attrib_set = isset($attribs['poll_'.$module]); 104 105 // Last module poll time and row class 106 $module_row_class = ''; 107 if (!isset($device_state['poller_mod_perf'][$module])) 108 { 109 $module_time = '--'; 110 } 111 elseif ($device_state['poller_mod_perf'][$module] < 0.01) 112 { 113 $module_time = $device_state['poller_mod_perf'][$module] . 's'; 114 } else { 115 $module_time = format_value($device_state['poller_mod_perf'][$module]) . 's'; 116 117 if ($device_state['poller_mod_perf'][$module] > 10) 118 { 119 $module_row_class = 'error'; 120 } 121 else if ($device_state['poller_mod_perf'][$module] > 3) 122 { 123 $module_row_class = 'warning'; 124 } 125 } 126 127 echo('<tr class="'.$module_row_class.'"><td><strong>'.$module.'</strong></td>'); 128 echo('<td>'.$module_time.'</td><td>'); 129 echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>')); 130 echo('</td><td>'); 131 132 $attrib_status = '<span class="label label-important">disabled</span>'; 133 $toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok'; 134 $disabled = FALSE; 135 if ($module == 'os' || $module == 'system') 136 { 137 $attrib_status = '<span class="label label-default">locked</span>'; 138 $toggle = "Locked"; $btn_class = ''; $btn_icon = 'icon-lock'; 139 $disabled = TRUE; 140 } 141 else if (poller_module_excluded($device, $module)) 142 { 143 $attrib_status = '<span class="label label-default">excluded</span>'; 144 $toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock'; 145 $disabled = TRUE; 146 } 147 else if (($attrib_set && $attribs['poll_'.$module]) || (!$attrib_set && $module_status)) 148 { 149 $attrib_status = '<span class="label label-success">enabled</span>'; 150 $toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove'; 151 } 152 153 echo($attrib_status.'</td><td>'); 154 155 $form = array('type' => 'simple'); 156 // Elements 157 $form['row'][0]['toggle_poller'] = array('type' => 'hidden', 158 'value' => $module); 159 $form['row'][0]['submit'] = array('type' => 'submit', 160 'name' => $toggle, 161 'class' => 'btn-mini '.$btn_class, 162 'icon' => $btn_icon, 163 'right' => TRUE, 164 'readonly' => $readonly, 165 'disabled' => $disabled, 166 'value' => 'Toggle'); 167 print_form($form); unset($form); 168 169 echo('</td></tr>'); 170} 171?> 172 </tbody> 173</table> 174 175 </div> </div> 176</div> <!-- end poller options --> 177 178<div class="col-md-6"> <!-- begin ports options --> 179 180 <div class="box box-solid"> 181 182 <div class="box-header with-border"> 183 <h3 class="box-title">Ports polling options</h3> 184 </div> 185 <div class="box-body no-padding"> 186 187<table class="table table-striped table-condensed"> 188 <thead> 189 <tr> 190 <th>Module</th> 191 <th style="width: 60px;">Last Poll</th> 192 <th style="width: 60px;">Global</th> 193 <th style="width: 60px;">Device</th> 194 <th style="width: 80px;"></th> 195 </tr> 196 </thead> 197 <tbody> 198 199<?php 200foreach (array_keys($config) as $module) 201{ 202 if (strpos($module, 'enable_ports_') === FALSE) { continue; } 203 204 $module_status = $config[$module]; 205 $attrib_set = isset($attribs[$module]); 206 $module_name = str_replace('enable_ports_', '', $module); 207 208 // Last ports module poll time and row class 209 $module_row_class = ''; 210 if ($module_name == 'separate_walk') 211 { 212 $module_time = ''; // nothing to show for this pseudo-module 213 } 214 elseif (!isset($device_state['poller_ports_perf'][$module_name])) 215 { 216 $module_time = '--'; 217 } 218 elseif ($device_state['poller_ports_perf'][$module_name] < 0.01) 219 { 220 $module_time = $device_state['poller_ports_perf'][$module_name] . 's'; 221 } 222 else 223 { 224 $module_time = format_value($device_state['poller_ports_perf'][$module_name]) . 's'; 225 226 if ($device_state['poller_ports_perf'][$module_name] > 10) 227 { 228 $module_row_class = 'error'; 229 } 230 else if ($device_state['poller_ports_perf'][$module_name] > 3) 231 { 232 $module_row_class = 'warning'; 233 } 234 } 235 236 echo('<tr class="'.$module_row_class.'"><td><strong>'.$module_name.'</strong></td>'); 237 echo('<td>'.$module_time.'</td><td>'); 238 echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>')); 239 echo('</td><td>'); 240 241 $attrib_status = '<span class="label label-important">disabled</span>'; 242 $toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok'; 243 $value = 'Toggle'; 244 $disabled = FALSE; 245 if ($module == 'enable_ports_junoseatmvp' && $device['os'] != 'junose') /// FIXME. see here includes/discovery/junose-atm-vp.inc.php 246 { 247 $attrib_status = '<span class="label label-default">excluded</span>'; 248 $toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock'; 249 $disabled = TRUE; 250 } 251 // elseif (discovery_module_excluded($device, $module)) // What? This is ports options.. 252 // { 253 // $attrib_status = '<span class="label label-disabled">excluded</span>'; 254 // $toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock'; 255 // $disabled = TRUE; 256 // } 257 elseif (($attrib_set && $attribs[$module]) || (!$attrib_set && $module_status)) 258 { 259 $attrib_status = '<span class="label label-success">enabled</span>'; 260 $toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove'; 261 } 262 elseif ($module == 'enable_ports_separate_walk' && !$attrib_set) 263 { 264 if ($config['os'][$device['os']]['ports_separate_walk'] && $ports_total_count > 10) 265 { 266 $attrib_status = '<span class="label label-warning">FORCED</span>'; 267 $toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove'; 268 $value = 'Disable'; 269 } 270 elseif (intval($device['state']['poller_mod_perf']['ports']) < 20 && $ports_total_count <= 10) 271 { 272 $attrib_status = '<span class="label label-default">excluded</span>'; 273 $toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock'; 274 $disabled = TRUE; 275 } 276 } 277 278 echo($attrib_status . '</td><td>'); 279 280 $form = array('type' => 'simple'); 281 // Elements 282 $form['row'][0]['toggle_ports'] = array('type' => 'hidden', 283 'value' => $module); 284 $form['row'][0]['submit'] = array('type' => 'submit', 285 'name' => $toggle, 286 'class' => 'btn-mini '.$btn_class, 287 'icon' => $btn_icon, 288 'right' => TRUE, 289 'readonly' => $readonly, 290 'disabled' => $disabled, 291 'value' => $value); 292 print_form($form); unset($form); 293 294 echo('</td></tr>'); 295} 296?> 297 </tbody> 298</table> 299 300 </div> </div> 301</div> <!-- end ports options --> 302 303<div class="col-md-6"> <!-- begin discovery options --> 304 305 <div class="box box-solid"> 306 307 <div class="box-header with-border"> 308 <h3 class="box-title">Discovery Modules</h3> 309 </div> 310 <div class="box-body no-padding"> 311 312<table class="table table-striped table-condensed"> 313 <thead> 314 <tr> 315 <th>Module</th> 316 <th style="width: 60px;">Last</th> 317 <th style="width: 60px;">Global</th> 318 <th style="width: 60px;">Device</th> 319 <th style="width: 80px;"></th> 320 </tr> 321 </thead> 322 <tbody> 323 324<?php 325foreach ($config['discovery_modules'] as $module => $module_status) 326{ 327 $attrib_set = isset($attribs['discover_'.$module]); 328 329 // Last module discovery time and row class 330 $module_row_class = ''; 331 if (!isset($device_state['discovery_mod_perf'][$module])) 332 { 333 $module_time = '--'; 334 } 335 elseif ($device_state['discovery_mod_perf'][$module] < 0.01) 336 { 337 $module_time = $device_state['discovery_mod_perf'][$module] . 's'; 338 } else { 339 $module_time = format_value($device_state['discovery_mod_perf'][$module]) . 's'; 340 341 if ($device_state['discovery_mod_perf'][$module] > 10) 342 { 343 $module_row_class = 'error'; 344 } 345 elseif ($device_state['discovery_mod_perf'][$module] > 3) 346 { 347 $module_row_class = 'warning'; 348 } 349 } 350 351 echo('<tr class="'.$module_row_class.'"><td><strong>'.$module.'</strong></td>'); 352 echo('<td>'.$module_time.'</td><td>'); 353 echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>')); 354 echo('</td><td>'); 355 356 $attrib_status = '<span class="label label-important">disabled</span>'; 357 $toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok'; 358 $disabled = FALSE; 359 if (discovery_module_excluded($device,$module)) 360 { 361 $attrib_status = '<span class="label label-disabled">excluded</span>'; 362 $toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock'; 363 $disabled = TRUE; 364 } 365 else if (($attrib_set && $attribs['discover_'.$module]) || (!$attrib_set && $module_status)) 366 { 367 $attrib_status = '<span class="label label-success">enabled</span>'; 368 $toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove'; 369 } 370 371 echo($attrib_status . '</td><td>'); 372 373 $form = array('type' => 'simple'); 374 // Elements 375 $form['row'][0]['toggle_discovery'] = array('type' => 'hidden', 376 'value' => $module); 377 $form['row'][0]['submit'] = array('type' => 'submit', 378 'name' => $toggle, 379 'class' => 'btn-mini '.$btn_class, 380 'icon' => $btn_icon, 381 'right' => TRUE, 382 'readonly' => $readonly, 383 'disabled' => $disabled, 384 'value' => 'Toggle'); 385 print_form($form); unset($form); 386 387 echo('</td></tr>'); 388} 389?> 390 </tbody> 391</table> 392 393 </div> </div> 394</div> <!-- end discovery options --> 395 396 </div> <!-- end row --> 397<?php 398 399// EOF 400