Commit version 24.12.13800

This commit is contained in:
2025-01-06 17:35:06 -05:00
parent b7f6a79c2c
commit 55d9218816
6133 changed files with 4239740 additions and 1374287 deletions

View File

@ -4,26 +4,30 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$ap = dbFetchRow("SELECT * FROM `accesspoints` LEFT JOIN `accesspoints-state` USING (`accesspoint_id`) WHERE `device_id` = ? AND accesspoints.`accesspoint_id` = ? AND `deleted` = '0' ORDER BY `name`,`radio_number` ASC", array($device['device_id'],$vars['ap']));
$sql = "SELECT * FROM `accesspoints` LEFT JOIN `accesspoints-state` USING (`accesspoint_id`)
WHERE `device_id` = ? AND accesspoints.`accesspoint_id` = ? AND `deleted` = '0'
ORDER BY `name`,`radio_number` ASC";
$ap = dbFetchRow($sql, [$device['device_id'], $vars['ap']]);
if (safe_empty($ap)) {
print_error("No Access Point Found");
return;
print_error("No Access Point Found");
return;
}
echo generate_box_open();
echo '<table class="table table-striped">';
include($config['html_dir'].'/includes/print-accesspoint.inc.php');
include($config['html_dir'] . '/includes/print-accesspoint.inc.php');
echo '</table>' ;
echo '</table>';
echo generate_box_close();

View File

@ -4,37 +4,35 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$i = "1";
$aps = dbFetchRows("SELECT * FROM `accesspoints` LEFT JOIN `accesspoints-state` USING (`accesspoint_id`) WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `name`,`radio_number` ASC", array($device['device_id']));
$aps = dbFetchRows("SELECT * FROM `accesspoints` LEFT JOIN `accesspoints-state` USING (`accesspoint_id`) WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `name`,`radio_number` ASC", [$device['device_id']]);
if(count($aps))
{
if (count($aps)) {
echo generate_box_open();
echo generate_box_open();
echo('<table class="table table-striped table-hover">');
echo('<table class="table table-striped table-hover">');
foreach ($aps as $ap)
{
include($config['html_dir'].'/includes/print-accesspoint.inc.php');
foreach ($aps as $ap) {
include($config['html_dir'] . '/includes/print-accesspoint.inc.php');
$i++;
}
echo('</table>');
$i++;
}
echo('</table>');
echo generate_box_close();
echo generate_box_close();
} else {
print_message('No access points found.', 'warning');
print_message('No access points found.', 'warning');
}

View File

@ -4,231 +4,269 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
// User level 7-9 only can see config
$readonly = $_SESSION['userlevel'] < 8;
if ($entry = get_alert_entry_by_id($vars['alert_entry']))
{
if ($entry['device_id'] != $device['device_id'])
{
print_error("This alert entry id does not match this device.");
} else {
// Run actions
if ($vars['submit'] === 'update-alert-entry' && !$readonly)
{
if (isset($vars['ignore_until_ok']) && ($vars['ignore_until_ok'] == '1' || $entry['ignore_until_ok'] == '1'))
{
$update_state['ignore_until_ok'] = '1';
if ($entry['alert_status'] == 0) { $update_state['alert_status'] = '3'; }
} else {
$update_state['ignore_until_ok'] = '0';
if ($entry = get_alert_entry_by_id($vars['alert_entry'])) {
if ($entry['device_id'] != $device['device_id']) {
print_error("This alert entry id does not match this device.");
return;
}
// 2019-12-05 23:30:00
// Run actions
if ($vars['submit'] === 'update-alert-entry' && !$readonly) {
if (isset($vars['ignore_until']) && $vars['ignore_until_enable'])
{
$vars['ignore_unixtime'] = strtotime($vars['ignore_until']);
$update_state['ignore_until'] = $vars['ignore_until'];
if ($entry['alert_status'] == 0 && $vars['ignore_unixtime'] > time()) { $update_state['alert_status'] = '3'; }
} else {
$update_state['ignore_until'] = array('NULL');
if (isset($vars['ignore_until_ok']) && ($vars['ignore_until_ok'] == '1' || $entry['ignore_until_ok'] == '1')) {
$update_state['ignore_until_ok'] = '1';
if ($entry['alert_status'] == 0) {
$update_state['alert_status'] = '3';
}
} else {
$update_state['ignore_until_ok'] = '0';
}
// 2019-12-05 23:30:00
if (isset($vars['ignore_until']) && $vars['ignore_until_enable']) {
$vars['ignore_unixtime'] = strtotime($vars['ignore_until']);
$update_state['ignore_until'] = $vars['ignore_until'];
if ($entry['alert_status'] == 0 && $vars['ignore_unixtime'] > time()) {
$update_state['alert_status'] = '3';
}
} else {
$update_state['ignore_until'] = ['NULL'];
}
if (is_array($update_state)) {
$up_s = dbUpdate($update_state, 'alert_table', '`alert_table_id` = ?', [$vars['alert_entry']]);
}
// Refresh array because we've changed the database.
$entry = get_alert_entry_by_id($vars['alert_entry']);
}
if (is_array($update_state))
{
$up_s = dbUpdate($update_state, 'alert_table', '`alert_table_id` = ?', array($vars['alert_entry']));
}
// End actions
// Refresh array because we've changed the database.
$entry = get_alert_entry_by_id($vars['alert_entry']);
}
humanize_alert_entry($entry);
// End actions
humanize_alert_entry($entry);
$alert_rules = cache_alert_rules();
$alert = $alert_rules[$entry['alert_test_id']];
$state = safe_json_decode($entry['state']);
$conditions = safe_json_decode($alert['conditions']);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
$alert_rules = cache_alert_rules();
$alert = $alert_rules[$entry['alert_test_id']];
$state = safe_json_decode($entry['state']);
$conditions = safe_json_decode($alert['conditions']);
$entity = get_entity_by_id_cache($entry['entity_type'], $entry['entity_id']);
// r($entry);
// r($alert);
?>
?>
<div class="row">
<div class="col-md-3">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Alert Details</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed table-striped ">
<tbody>
<tr><th>Type</th><td><?php echo '<i class="' . $config['entities'][$alert['entity_type']]['icon'] . '"></i> ' . nicecase($entry['entity_type']); ?></td></tr>
<tr><th>Entity</th><td><?php echo generate_entity_link($entry['entity_type'], $entry['entity_id'], $entity['entity_name']); ?></td></tr>
<tr><th>Checker</th><td><a href="<?php echo generate_url(array('page' => 'alert_check', 'alert_test_id' => $alert['alert_test_id'])); ?>"><?php echo escape_html($alert['alert_name']); ?></a></td></tr>
<tr><th>Fail Msg</th><td><?php echo escape_html($alert['alert_message']); ?></td></tr>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-3">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Alert Details</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed table-striped ">
<tbody>
<tr>
<th>Type</th>
<td><?php echo get_icon($config['entities'][$alert['entity_type']]['icon']) . nicecase($entry['entity_type']); ?></td>
</tr>
<tr>
<th>Entity</th>
<td><?php echo generate_entity_link($entry['entity_type'], $entry['entity_id'], $entity['entity_name']); ?></td>
</tr>
<tr>
<th>Checker</th>
<td><a
href="<?php echo generate_url(['page' => 'alert_check', 'alert_test_id' => $alert['alert_test_id']]); ?>"><?php echo escape_html($alert['alert_name']); ?></a>
</td>
</tr>
<tr>
<th>Fail Msg</th>
<td><?php echo escape_html($alert['alert_message']); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Status</h3>
</div>
<div class="box-body no-padding">
<div class="col-md-4">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Status</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed">
<tr><th>Status</th><td><span class="<?php echo $entry['class']; ?>"><?php echo $entry['last_message']; ?></span></td></tr>
<tr><th>Last Changed</th><td><?php echo $entry['changed']; ?></td></tr>
<tr><td colspan=2>
<?php
<table class="table table-condensed">
<tr>
<th>Status</th>
<td><span class="<?php echo $entry['class']; ?>"><?php echo $entry['last_message']; ?></span></td>
</tr>
<tr>
<th>Last Changed</th>
<td><?php echo $entry['changed']; ?></td>
</tr>
<tr>
<td colspan=2>
<?php
$state = safe_json_decode($entry['state']);
$state = safe_json_decode($entry['state']);
$alert['state_popup'] = '';
$alert['state_popup'] = '';
// FIXME - rewrite this, it's shit
// FIXME - rewrite this, it's shit
if ($alert['alert_status'] != '1' && safe_count($state['failed']))
{
$alert['state_popup'] .= '<table class="table table-striped table-condensed">';
$alert['state_popup'] .= '<thead><tr><th>Metric</th><th>Cond</th><th>Value</th><th>Measured</th></tr></thead>';
if ($alert['alert_status'] != '1' && safe_count($state['failed'])) {
$alert['state_popup'] .= '<table class="table table-striped table-condensed">';
$alert['state_popup'] .= '<thead><tr><th>Metric</th><th>Cond</th><th>Value</th><th>Measured</th></tr></thead>';
foreach($state['failed'] as $test)
{
$alert['state_popup'] .= '<tr><td><strong>'.$test['metric'].'</strong></td><td>'.$test['condition'].'</td><td>'.format_value($test['value']).'</td><td><i class="red">'.format_value($state['metrics'][$test['metric']]).'</i></td></tr>';
}
$alert['state_popup'] .= '</table>';
foreach ($state['failed'] as $test) {
$metric_def = $config['entities'][$alert['entity_type']]['metrics'][$test['metric']];
} elseif (safe_count($state['metrics'])) {
$alert['state_popup'] .= '<table class="table table-striped table-condensed">';
$alert['state_popup'] .= '<thead><tr><th>Metric</th><th>Value</th></tr></thead>';
foreach($state['metrics'] as $metric => $value)
{
$alert['state_popup'] .= '<tr><td><strong>'.$metric.'</strong></td><td>'.format_value($value).'</td></tr>';
}
$alert['state_popup'] .= '</table>';
$format = NULL;
$symbol = '';
if (!safe_empty($test['value'])) {
if (isset($metric_def['format'])) {
$format = isset($entity[$metric_def['format']]) ? $entity[$metric_def['format']] : $metric_def['format'];
}
if (isset($metric_def['symbol'])) {
$symbol = isset($entity[$metric_def['symbol']]) ? $entity[$metric_def['symbol']] : $metric_def['symbol'];
}
}
}
$alert['state_popup'] .= '<tr><td><strong>' . $test['metric'] . '</strong></td><td>' . $test['condition'] . '</td><td>' .
format_value($test['value'], $entity['entity_format']) . $entity['entity_symbol'] . '</td><td><i class="red">' .
format_value($state['metrics'][$test['metric']], $entity['entity_format']) . $entity['entity_symbol'] . '</i></td></tr>';
}
$alert['state_popup'] .= '</table>';
echo $alert['state_popup'];
} elseif (safe_count($state['metrics'])) {
$alert['state_popup'] .= '<table class="table table-striped table-condensed">';
$alert['state_popup'] .= '<thead><tr><th>Metric</th><th>Value</th></tr></thead>';
foreach ($state['metrics'] as $metric => $value) {
$alert['state_popup'] .= '<tr><td><strong>' . $metric . '</strong></td><td>' . format_value($value, $entity['entity_format']) . $entity['entity_symbol'] . '</td></tr>';
}
$alert['state_popup'] .= '</table>';
?>
</td></tr>
}
<!-- <tr><th>Last Checked</th><td><?php echo $entry['checked']; ?></td></tr>
echo $alert['state_popup'];
?>
</td>
</tr>
<!-- <tr><th>Last Checked</th><td><?php echo $entry['checked']; ?></td></tr>
<tr><th>Last Changed</th><td><?php echo $entry['changed']; ?></td></tr>
<tr><th>Last Alerted</th><td><?php echo $entry['alerted']; ?></td></tr>
<tr><th>Last Recovered</th><td><?php echo $entry['recovered']; ?></td></tr> -->
</table>
</div>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-5">
<?php
<div class="col-md-5">
<?php
$form = array('type' => 'horizontal',
'id' => 'update_alert_entry',
'title' => 'Alert Settings',
//'icon' => 'oicon-gear',
'fieldset' => array('edit' => ''),
);
$form = [
'type' => 'horizontal',
'id' => 'update_alert_entry',
'title' => 'Alert Settings',
//'icon' => 'oicon-gear',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['ignore_until'] = array(
'type' => 'datetime',
//'fieldset' => 'edit',
'name' => 'Ignore Until',
'placeholder' => '',
//'width' => '250px',
'readonly' => $readonly,
'disabled' => empty($entry['ignore_until']),
'min' => 'current',
'value' => ($entry['ignore_until'] ? $entry['ignore_until'] : ''));
$form['row'][1]['ignore_until_enable'] = array(
'type' => 'toggle',
'view' => 'toggle',
'size' => 'big',
'palette' => 'blue',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'ignore_until')",
'value' => !empty($entry['ignore_until']));
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
];
$form['row'][1]['ignore_until'] = [
'type' => 'datetime',
//'fieldset' => 'edit',
'name' => 'Ignore Until',
'placeholder' => '',
//'width' => '250px',
'readonly' => $readonly,
'disabled' => empty($entry['ignore_until']),
'min' => 'current',
'value' => $entry['ignore_until'] ?: ''
];
$form['row'][1]['ignore_until_enable'] = [
'type' => 'toggle',
'view' => 'toggle',
'size' => 'big',
'palette' => 'blue',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'ignore_until')",
'value' => !empty($entry['ignore_until'])
];
$form['row'][2]['ignore_until_ok'] = [
'type' => 'toggle',
'name' => 'Ignore Until OK',
//'fieldset' => 'edit',
'view' => 'toggle',
'size' => 'big',
'palette' => 'blue',
'readonly' => $readonly,
'value' => $entry['ignore_until_ok']
];
$form['row'][2]['ignore_until_ok'] = array(
'type' => 'toggle',
'name' => 'Ignore Until OK',
//'fieldset' => 'edit',
'view' => 'toggle',
'size' => 'big',
'palette' => 'blue',
'readonly' => $readonly,
'value' => $entry['ignore_until_ok']);
if (!$readonly) { // Hide button for readonly
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'div_style' => 'padding-top: 10px; padding-bottom: 10px;',
'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'update-alert-entry'
];
}
if (!$readonly) // Hide button for readonly
{
$form['row'][7]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'div_style' => 'padding-top: 10px; padding-bottom: 10px;',
'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'update-alert-entry');
}
print_form($form);
unset($form);
?>
</div>
print_form($form);
unset($form);
?>
</div>
<div class="col-md-12">
<?php echo generate_box_open(['title' => 'Historical Availability']); ?>
<div class="col-md-12">
<?php echo generate_box_open(array('title' => 'Historical Availability')); ?>
<table class="table table-condensed table-striped">
<table class="table table-condensed table-striped">
<tr>
<td>
<?php
$graph_array['id'] = $entry['alert_table_id'];
$graph_array['type'] = 'alert_status';
print_graph_row($graph_array);
?>
</td>
</tr>
</table>
<?php
<tr><td>
<?php
$graph_array['id'] = $entry['alert_table_id'];
$graph_array['type'] = 'alert_status';
print_graph_row($graph_array);
?>
</td></tr>
</table>
<?php
echo generate_box_close();
echo("</div></div>"); // end row
echo generate_box_close();
echo("</div></div>"); // end row
}
$vars['entity_type'] = $entry['entity_type'];
$vars['entity_id'] = $entry['entity_id'];
$vars['entity_type'] = $entry['entity_type'];
$vars['entity_id'] = $entry['entity_id'];
print_alert_log($vars);
print_alert_log($vars);
} else {
print_error("Unfortunately, this alert entry id does not seem to exist in the database!");
print_error("Unfortunately, this alert entry id does not seem to exist in the database!");
}
// EOF

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,42 +14,54 @@ $alert_rules = cache_alert_rules();
$alert_assoc = cache_alert_assoc();
$alert_table = cache_device_alert_table($device['device_id']);
if (!isset($vars['status'])) { $vars['status'] = 'failed'; }
if (!$vars['entity_type']) { $vars['entity_type'] = 'all'; }
if (!isset($vars['status'])) {
$vars['status'] = 'failed';
}
if (!$vars['entity_type']) {
$vars['entity_type'] = 'all';
}
// Build Navbar
$navbar['class'] = "navbar-narrow";
$navbar['brand'] = "Alert Types";
if ($vars['entity_type'] === 'all') { $navbar['options']['all']['class'] = "active"; }
$navbar['options']['all']['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => 'all'));
if ($vars['entity_type'] === 'all') {
$navbar['options']['all']['class'] = "active";
}
$navbar['options']['all']['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => 'all']);
$navbar['options']['all']['text'] = "All";
foreach ($alert_table as $entity_type => $thing)
{
foreach ($alert_table as $entity_type => $thing) {
if (!$vars['entity_type']) { $vars['entity_type'] = $entity_type; }
if ($vars['entity_type'] == $entity_type) { $navbar['options'][$entity_type]['class'] = "active"; }
if (!$vars['entity_type']) {
$vars['entity_type'] = $entity_type;
}
if ($vars['entity_type'] == $entity_type) {
$navbar['options'][$entity_type]['class'] = "active";
}
$navbar['options'][$entity_type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => $entity_type));
$navbar['options'][$entity_type]['icon'] = $config['entities'][$entity_type]['icon'];
$navbar['options'][$entity_type]['text'] = escape_html(nicecase($entity_type));
$navbar['options'][$entity_type]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => $entity_type]);
$navbar['options'][$entity_type]['icon'] = $config['entities'][$entity_type]['icon'];
$navbar['options'][$entity_type]['text'] = escape_html(nicecase($entity_type));
}
if (isset($config['enable_syslog']) && $config['enable_syslog'] && OBSERVIUM_EDITION != 'community')
{
$entity_type = "syslog";
if (isset($config['enable_syslog']) && $config['enable_syslog'] && OBSERVIUM_EDITION != 'community') {
$entity_type = "syslog";
if (!$vars['entity_type']) { $vars['entity_type'] = 'syslog'; }
if ($vars['entity_type'] === 'syslog') { $navbar['options'][$entity_type]['class'] = "active"; }
if (!$vars['entity_type']) {
$vars['entity_type'] = 'syslog';
}
if ($vars['entity_type'] === 'syslog') {
$navbar['options'][$entity_type]['class'] = "active";
}
$navbar['options'][$entity_type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => $entity_type));
$navbar['options'][$entity_type]['icon'] = $config['icon']['syslog-alerts'];
$navbar['options'][$entity_type]['text'] = 'Syslog';
$navbar['options'][$entity_type]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'],
'tab' => 'alerts', 'entity_type' => $entity_type]);
$navbar['options'][$entity_type]['icon'] = $config['icon']['syslog-alerts'];
$navbar['options'][$entity_type]['text'] = 'Syslog';
}
/* Not required anymore
@ -64,46 +76,44 @@ $navbar['options_right']['filters']['text'] = 'Filter';
$navbar['options_right']['filters']['icon'] = $config['icon']['filter'];
$navbar['options_right']['filters']['link_opts'] = 'data-hover="dropdown" data-toggle="dropdown"';
$filters = array('all' => array('url' => generate_url($vars, array('status' => 'all')),
'url_o' => generate_url($vars, array('status' => 'all')),
'icon' => $config['icon']['info'],
'text' => 'All'),
$filters = ['all' => ['url' => generate_url($vars, ['status' => 'all']),
'url_o' => generate_url($vars, ['status' => 'all']),
'icon' => $config['icon']['info'],
'text' => 'All'],
'failed_delayed' => array('url' => generate_url($vars, array('status' => 'failed_delayed')),
'url_o' => generate_url($vars, array('page' => 'alerts', 'status' => 'all')),
'icon' => $config['icon']['important'],
'text' => 'Failed & Delayed'),
'failed_delayed' => ['url' => generate_url($vars, ['status' => 'failed_delayed']),
'url_o' => generate_url($vars, ['page' => 'alerts', 'status' => 'all']),
'icon' => $config['icon']['important'],
'text' => 'Failed & Delayed'],
'failed' => array('url' => generate_url($vars, array('status' => 'failed')),
'url_o' => generate_url($vars, array('status' => 'all')),
'icon' => $config['icon']['cancel'],
'text' => 'Failed'),
'failed' => ['url' => generate_url($vars, ['status' => 'failed']),
'url_o' => generate_url($vars, ['status' => 'all']),
'icon' => $config['icon']['cancel'],
'text' => 'Failed'],
'suppressed' => array('url' => generate_url($vars, array('status' => 'suppressed')),
'url_o' => generate_url($vars, array('status' => 'all')),
'icon' => $config['icon']['shutdown'],
'text' => 'Suppressed')
);
'suppressed' => ['url' => generate_url($vars, ['status' => 'suppressed']),
'url_o' => generate_url($vars, ['status' => 'all']),
'icon' => $config['icon']['shutdown'],
'text' => 'Suppressed']
];
foreach ($filters as $option => $option_array)
{
foreach ($filters as $option => $option_array) {
$navbar['options_right']['filters']['suboptions'][$option]['text'] = $option_array['text'];
$navbar['options_right']['filters']['suboptions'][$option]['icon'] = $option_array['icon'];
$navbar['options_right']['filters']['suboptions'][$option]['text'] = $option_array['text'];
$navbar['options_right']['filters']['suboptions'][$option]['icon'] = $option_array['icon'];
if ($vars['status'] == $option)
{
$navbar['options_right']['filters']['suboptions'][$option]['class'] = "active";
if ($vars['status'] != "all") {
$navbar['options_right']['filters']['class'] = "active";
if ($vars['status'] == $option) {
$navbar['options_right']['filters']['suboptions'][$option]['class'] = "active";
if ($vars['status'] != "all") {
$navbar['options_right']['filters']['class'] = "active";
}
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url_o'];
$navbar['options_right']['filters']['text'] .= " (" . $option_array['text'] . ")";
$navbar['options_right']['filters']['icon'] = $option_array['icon'];
} else {
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url'];
}
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url_o'];
$navbar['options_right']['filters']['text'] .= " (".$option_array['text'].")";
$navbar['options_right']['filters']['icon'] = $option_array['icon'];
} else {
$navbar['options_right']['filters']['suboptions'][$option]['url'] = $option_array['url'];
}
}
print_navbar($navbar);
@ -123,9 +133,9 @@ $vars['pagination'] = TRUE;
if ($vars['entity_type'] === "syslog") {
print_logalert_log($vars);
print_logalert_log($vars);
} else {
print_alert_table($vars);
print_alert_table($vars);
}
// EOF

View File

@ -4,165 +4,158 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$link_array = array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps');
$link_array = ['page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps'];
$navbar = array();
$navbar['brand'] = "Apps";
$navbar = [];
$navbar['brand'] = "Applications";
$navbar['class'] = "navbar-narrow";
// Group all apps by app_type in an array
$device_app_types = array();
foreach (dbFetchRows("SELECT * FROM `applications` WHERE `device_id` = ?", array($device['device_id'])) as $app)
{
$device_app_types[$app['app_type']][] = $app;
$device_app_types = [];
foreach (dbFetchRows("SELECT * FROM `applications` WHERE `device_id` = ?", [$device['device_id']]) as $app) {
$device_app_types[$app['app_type']][] = $app;
}
// Iterate through each app type and its apps
foreach ($device_app_types as $type_key => $type_data)
{
foreach ($type_data as $app)
{
// Set default app and instance if none given (ie. when user first visits the device's app tab)
if (!$vars['app']) { $vars['app'] = $app['app_type']; }
$url = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps', 'app' => $app['app_type'], 'instance' => $app['app_id'] ));
// Check if an app name was inserted into mysql->observium.applications.app_name
$name = !empty($app['app_name']) ? $app['app_name'] : nicecase($app['app_type']);
// Determine if this is a named instance of app_type
if (!empty($app['app_instance']))
{
$instance = " (".$app['app_instance'].")";
}
// If there is only one instance of the current app type, simply include it as a standard nav link
if (count($device_app_types[$type_key]) == 1)
{
// If the current page is the app type that's being displayed, highlight the nav link
if ($vars['app'] == $app['app_type'])
{
$navbar['options'][$app['app_type']]['class'] = "active";
}
$navbar['options'][$app['app_type']]['text'] = $name;
$navbar['options'][$app['app_type']]['url'] = $url;
// Detect and add application icon
$icon = $app['app_type'];
$image = $config['html_dir'].'/images/apps/'.$icon.'.png';
if (!is_file($image)) {
list($icon) = explode('-', str_replace('_', '-', $app['app_type']));
$image = $config['html_dir'].'/images/apps/'.$icon.'.png';
if ($icon !== $app['app_type'] && is_file($image)) {
// 'postfix_qshape' -> 'postfix'
// 'exim-mailqueue' -> 'exim'
} else {
$icon = 'apps'; // Generic
foreach ($device_app_types as $type_key => $type_data) {
foreach ($type_data as $app) {
// Set default app and instance if none given (ie. when user first visits the device's app tab)
if (!$vars['app']) {
$vars['app'] = $app['app_type'];
}
}
$navbar['options'][$app['app_type']]['image'] = 'images/apps/'.$icon.'.png';
if (is_file($config['html_dir'].'/images/apps/'.$icon.'_2x.png')) {
// HiDPI icon
$navbar['options'][$app['app_type']]['image_2x'] = 'images/apps/'.$icon.'_2x.png';
}
}
// If there is more than one instance of the current app type we need to determine how to render the navbar
// FIXME -- no icons
else
{
// If the current app type and instance is the one being displayed, highlight the navbar root link and show which app/instance
if ($vars['app'] == $app['app_type'] && $vars['instance'] == $app['app_id'])
{
$navbar['options'][$app['app_type']]['class'] = "active";
$navbar['options'][$app['app_type']]['text'] = $name . $instance;
}
// If the current app type is not active then we need to simply add the root nav link to the bar as inactive
else
{
if (!isset($navbar['options'][$app['app_type']]['text']))
{
$navbar['options'][$app['app_type']]['text'] = $name;
if ($vars['app'] == $app['app_type'] && !isset($vars['instance'])) {
$vars['instance'] = $app['app_id'];
}
}
// Add all instances of the app type under the submenu for the app type
$navbar['options'][$app['app_type']]['suboptions'][$app['app_id']]['text'] = $name . $instance;
$navbar['options'][$app['app_type']]['suboptions'][$app['app_id']]['url'] = $url;
$url = generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps', 'app' => $app['app_type']]);
// Check if an app name was inserted into mysql->observium.applications.app_name
$name = !empty($app['app_name']) ? $app['app_name'] : nicecase($app['app_type']);
// Determine if this is a named instance of app_type
if (!empty($app['app_instance'])) {
$instance = " (" . $app['app_instance'] . ")";
}
// If there is only one instance of the current app type, simply include it as a standard nav link
if (count($device_app_types[$type_key]) == 1) {
// If the current page is the app type that's being displayed, highlight the nav link
if ($vars['app'] == $app['app_type']) {
$navbar['options'][$app['app_type']]['class'] = "active";
}
$navbar['options'][$app['app_type']]['text'] = $name;
$navbar['options'][$app['app_type']]['url'] = $url;
// Detect and add application icon
$icon = $app['app_type'];
$image = $config['html_dir'] . '/images/apps/' . $icon . '.png';
if (!is_file($image)) {
[$icon] = explode('-', str_replace('_', '-', $app['app_type']));
$image = $config['html_dir'] . '/images/apps/' . $icon . '.png';
if ($icon !== $app['app_type'] && is_file($image)) {
// 'postfix_qshape' -> 'postfix'
// 'exim-mailqueue' -> 'exim'
} else {
$icon = 'apps'; // Generic
}
}
$navbar['options'][$app['app_type']]['image'] = 'images/apps/' . $icon . '.png';
if (is_file($config['html_dir'] . '/images/apps/' . $icon . '_2x.png')) {
// HiDPI icon
$navbar['options'][$app['app_type']]['image_2x'] = 'images/apps/' . $icon . '_2x.png';
}
}
// If there is more than one instance of the current app type we need to determine how to render the navbar
// FIXME -- no icons
else {
// If the current app type and instance is the one being displayed, highlight the navbar root link and show which app/instance
if ($vars['app'] == $app['app_type'] && $vars['instance'] == $app['app_id']) {
$navbar['options'][$app['app_type']]['class'] = "active";
$navbar['options'][$app['app_type']]['text'] = $name . $instance;
} // If the current app type is not active then we need to simply add the root nav link to the bar as inactive
else {
if (!isset($navbar['options'][$app['app_type']]['text'])) {
$navbar['options'][$app['app_type']]['text'] = $name;
}
}
// Add all instances of the app type under the submenu for the app type
$navbar['options'][$app['app_type']]['suboptions'][$app['app_id']]['text'] = $name . $instance;
$navbar['options'][$app['app_type']]['suboptions'][$app['app_id']]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'apps', 'app' => $app['app_type'], 'instance' => $app['app_id']]);
}
}
}
}
print_navbar($navbar);
unset($navbar, $name, $url, $device_app_types);
$where_array = array($device['device_id'], $vars['app']);
if ($vars['instance'])
{
$where = " AND `app_id` = ?";
$where_array[] = $vars['instance'];
$where_array = [$device['device_id'], $vars['app']];
if ($vars['instance']) {
$where = " AND `app_id` = ?";
$where_array[] = $vars['instance'];
}
$app = dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?".$where, $where_array);
$app = dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?" . $where, $where_array);
$app_filename = $config['html_dir'] . '/pages/device/apps/'.$vars['app'].'.inc.php';
if (is_file($app_filename))
{
// Include app code to output data
include($app_filename);
$app_filename = $config['html_dir'] . '/pages/device/apps/' . $vars['app'] . '.inc.php';
if (is_file($app_filename)) {
// Include app code to output data
include($app_filename);
// If an $app_sections array has been returned, build a menu
if (isset($app_sections) && is_array($app_sections))
{
$navbar['brand'] = nicecase($vars['app']);
$navbar['class'] = "navbar-narrow";
// If an $app_sections array has been returned, build a menu
if (isset($app_sections) && is_array($app_sections)) {
$navbar['brand'] = nicecase($vars['app']);
$navbar['class'] = "navbar-narrow";
foreach ($app_sections as $app_section => $text)
{
// Set the chosen app to be this one if it's not already set.
if (!$vars['app_section']) { $vars['app_section'] = $app_section; }
if ($vars['app_section'] == $app_section) { $navbar['options'][$app_section]['class'] = "active"; }
foreach ($app_sections as $app_section => $text) {
// Set the chosen app to be this one if it's not already set.
if (!$vars['app_section']) {
$vars['app_section'] = $app_section;
}
if ($vars['app_section'] == $app_section) {
$navbar['options'][$app_section]['class'] = "active";
}
$navbar['options'][$app_section]['url'] = generate_url($vars, array('app_section' => $app_section));
$navbar['options'][$app_section]['text'] = $text;
$navbar['options'][$app_section]['url'] = generate_url($vars, ['app_section' => $app_section]);
$navbar['options'][$app_section]['text'] = $text;
}
print_navbar($navbar);
unset($navbar);
} else {
// It appears this app doesn't have multiple sections. We set app_section to default here.
$vars['app_section'] = 'default';
}
print_navbar($navbar);
unset($navbar);
} else {
// It appears this app doesn't have multiple sections. We set app_section to default here.
$vars['app_section'] = 'default';
}
// If a matching app_section array exists within app_graphs, print the graphs.
if (isset($app_graphs[$vars['app_section']]) && is_array($app_graphs[$vars['app_section']]))
{
echo generate_box_open();
// If a matching app_section array exists within app_graphs, print the graphs.
if (isset($app_graphs[$vars['app_section']]) && is_array($app_graphs[$vars['app_section']])) {
echo generate_box_open();
echo '<table class="table table-striped table-hover table-condensed">';
echo '<table class="table table-striped table-hover table-condensed">';
foreach ($app_graphs[$vars['app_section']] as $key => $text)
{
$graph_type = $key;
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_".$key;
echo '<tr><td>';
echo '<h3>',$text,'</h4>';
foreach ($app_graphs[$vars['app_section']] as $key => $text) {
$graph_type = $key;
$graph_array['to'] = get_time();
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_" . $key;
echo '<tr><td>';
echo '<h3>', $text, '</h4>';
print_graph_row($graph_array);
print_graph_row($graph_array);
echo '</td></tr>';
echo '</td></tr>';
}
echo '</table>';
generate_box_close();
}
echo '</table>';
generate_box_close();
}
}
register_html_title("Apps");

View File

@ -4,16 +4,16 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('apache_bits' => 'Traffic',
'apache_hits' => 'Hits',
'apache_cpu' => 'CPU Utilisation',
'apache_scoreboard' => 'Scoreboard Statistics');
$app_graphs['default'] = ['apache_bits' => 'Traffic',
'apache_hits' => 'Hits',
'apache_cpu' => 'CPU Utilisation',
'apache_scoreboard' => 'Scoreboard Statistics'];
// EOF

View File

@ -4,22 +4,25 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$navbar['brand'] = nicecase($app['app_type']);
$navbar['class'] = "navbar-narrow";
foreach ($app_sections as $app_section => $app_section_text)
{
if (!$vars['app_section']) { $vars['app_section'] = $app_section; }
$navbar['brand'] = nicecase($app['app_type']);
$navbar['options'][$app_section]['text'] = $app_section_text;
if ($vars['app_section'] == $app_section) { $navbar['options'][$app_section]['class'] = "active"; }
$navbar['options'][$app_section]['url'] = generate_url($vars,array('app_section'=>$app_section));
foreach ($app_sections as $app_section => $app_section_text) {
if (!$vars['app_section']) {
$vars['app_section'] = $app_section;
}
$navbar['brand'] = nicecase($app['app_type']);
$navbar['options'][$app_section]['text'] = $app_section_text;
if ($vars['app_section'] == $app_section) {
$navbar['options'][$app_section]['class'] = "active";
}
$navbar['options'][$app_section]['url'] = generate_url($vars, ['app_section' => $app_section]);
}
print_navbar($navbar);

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('asterisk_peers' => 'Active Peers',
'asterisk_activecall' => 'Active Calls');
$app_graphs['default'] = ['asterisk_peers' => 'Active Peers',
'asterisk_activecall' => 'Active Calls'];
// EOF

View File

@ -4,33 +4,33 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array('stats' => "Server statistics",
'auth' => "Authoritative",
'resolv' => "Resolving",
'queries' => "Queries");
$app_sections = ['stats' => "Server statistics",
'auth' => "Authoritative",
'resolv' => "Resolving",
'queries' => "Queries"];
$app_graphs['stats'] = array('bind_req_in' => "Incoming requests",
'bind_answers' => "Answers Given",
'bind_updates' => "Dynamic Updates",
'bind_req_proto' => "Request protocol details",
'bind_cache' => "Cache content");
$app_graphs['stats'] = ['bind_req_in' => "Incoming requests",
'bind_answers' => "Answers Given",
'bind_updates' => "Dynamic Updates",
'bind_req_proto' => "Request protocol details",
'bind_cache' => "Cache content"];
$app_graphs['auth'] = array('bind_zone_maint' => "Zone maintenance");
$app_graphs['auth'] = ['bind_zone_maint' => "Zone maintenance"];
$app_graphs['resolv'] = array('bind_resolv_queries' => "Queries",
'bind_resolv_errors' => "Errors",
'bind_resolv_rtt' => "Query RTT",
'bind_resolv_dnssec' => "DNSSEC validation");
$app_graphs['resolv'] = ['bind_resolv_queries' => "Queries",
'bind_resolv_errors' => "Errors",
'bind_resolv_rtt' => "Query RTT",
'bind_resolv_dnssec' => "DNSSEC validation"];
$app_graphs['queries'] = array('bind_query_rejected' => "Rejected queries",
'bind_query_in' => "Incoming queries",
'bind_query_out' => "Outgoing queries");
$app_graphs['queries'] = ['bind_query_rejected' => "Rejected queries",
'bind_query_in' => "Incoming queries",
'bind_query_out' => "Outgoing queries"];
// EOF

View File

@ -4,13 +4,13 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('ceph_osd' => 'OSD','ceph_iops' => 'OPS','ceph_speed' => 'Ceph I/O',);
$app_graphs['default'] = ['ceph_osd' => 'OSD', 'ceph_iops' => 'OPS', 'ceph_speed' => 'Ceph I/O',];
// EOF

View File

@ -3,16 +3,16 @@
/**
* Observium Network Management and Monitoring System
*
* @package observium
* @subpackage applications
* @author Sander Steffann <sander@steffann.nl>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Sander Steffann <sander@steffann.nl>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array(
'dhcpkit_packets' => "Packets",
$app_graphs['default'] = [
'dhcpkit_packets' => "Packets",
'dhcpkit_msgtypes' => "Message types",
);
];
/* End of file dhcpkit.inc.php */

View File

@ -4,22 +4,22 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('dovecot_commands' => 'Commands',
'dovecot_connected' => 'Connected sessions',
'dovecot_auth' => 'Auth',
'dovecot_auth_cache' => 'Auth cache hitrate %',
'dovecot_io' => 'IO',
'dovecot_storage' => 'Storage',
'dovecot_cache' => 'Mail cache hits',
'dovecot_usage' => 'Context Switches',
'dovecot_pages' => 'Page Reclaims',
'dovecot_cpu' => 'CPU usage');
$app_graphs['default'] = ['dovecot_commands' => 'Commands',
'dovecot_connected' => 'Connected sessions',
'dovecot_auth' => 'Auth',
'dovecot_auth_cache' => 'Auth cache hitrate %',
'dovecot_io' => 'IO',
'dovecot_storage' => 'Storage',
'dovecot_cache' => 'Mail cache hits',
'dovecot_usage' => 'Context Switches',
'dovecot_pages' => 'Page Reclaims',
'dovecot_cpu' => 'CPU usage'];
// EOF

View File

@ -4,16 +4,16 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('drbd_network_bits' => 'Network Traffic',
'drbd_disk_bits' => 'Disk Traffic',
'drbd_unsynced' => 'Unsynced Data',
'drbd_queue' => 'Queues');
$app_graphs['default'] = ['drbd_network_bits' => 'Network Traffic',
'drbd_disk_bits' => 'Disk Traffic',
'drbd_unsynced' => 'Unsynced Data',
'drbd_queue' => 'Queues'];
// EOF

View File

@ -4,92 +4,90 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array();
$app_modules = array(
"as" => array(
"rrd" => "wmi-app-exchange-as.rrd",
"descr" => "ActiveSync",
"graphs" => array(
$app_sections = [];
$app_modules = [
"as" => [
"rrd" => "wmi-app-exchange-as.rrd",
"descr" => "ActiveSync",
"graphs" => [
'exchange_as_pingcmd' => 'Ping Commands Pending',
'exchange_as_syncmd' => 'Sync Commands Pending',
'exchange_as_syncmd' => 'Sync Commands Pending',
'exchange_as_curreqs' => 'Current Requests'
)
),
"auto" => array(
"rrd" => "wmi-app-exchange-auto.rrd",
"descr" => "Autodiscover",
"graphs" => array(
]
],
"auto" => [
"rrd" => "wmi-app-exchange-auto.rrd",
"descr" => "Autodiscover",
"graphs" => [
'exchange_auto_totalreqs' => 'Total Requests',
'exchange_auto_errors' => 'Total Error Responses'
)
),
"oab" => array(
"rrd" => "wmi-app-exchange-oab.rrd",
"descr" => "Offline Address Book",
"graphs" => array(
'exchange_oab_dlq' => 'Download Tasks Queued',
'exchange_auto_errors' => 'Total Error Responses'
]
],
"oab" => [
"rrd" => "wmi-app-exchange-oab.rrd",
"descr" => "Offline Address Book",
"graphs" => [
'exchange_oab_dlq' => 'Download Tasks Queued',
'exchange_oab_dlcom' => 'Download Tasks Completed'
)
),
"owa" => array(
"rrd" => "wmi-app-exchange-owa.rrd",
"descr" => "Outlook Web App",
"graphs" => array(
]
],
"owa" => [
"rrd" => "wmi-app-exchange-owa.rrd",
"descr" => "Outlook Web App",
"graphs" => [
'exchange_owa_rtime' => 'Response Times',
'exchange_owa_users' => 'Unique Users'
)
),
"trans" => array(
"rrd" => "wmi-app-exchange-tqs.rrd",
"descr" => "Transport Queues",
"graphs" => array(
'exchange_trans_queue' => 'Total Queues',
'exchange_trans_mbque' => 'Active Mailbox Delivery Queues',
]
],
"trans" => [
"rrd" => "wmi-app-exchange-tqs.rrd",
"descr" => "Transport Queues",
"graphs" => [
'exchange_trans_queue' => 'Total Queues',
'exchange_trans_mbque' => 'Active Mailbox Delivery Queues',
'exchange_trans_subque' => 'Submission Queues'
)
),
"smtp" => array(
"rrd" => "wmi-app-exchange-smtp.rrd",
"descr" => "SMTP",
"graphs" => array(
]
],
"smtp" => [
"rrd" => "wmi-app-exchange-smtp.rrd",
"descr" => "SMTP",
"graphs" => [
'exchange_trans_smtp' => "SMTP Connections"
)
),
"is" => array(
"rrd" => "wmi-app-exchange-is.rrd",
"descr" => "Information Store",
"graphs" => array(
]
],
"is" => [
"rrd" => "wmi-app-exchange-is.rrd",
"descr" => "Information Store",
"graphs" => [
'exchange_is_active' => 'Active Connection Count',
'exchange_is_users' => 'Current User Count',
'exchange_is_rpcreq' => 'RPC Requests',
'exchange_is_rpcfail' => 'Failed RPC Requests'
)
),
"mailbox" => array(
"rrd" => "wmi-app-exchange-mailbox.rrd",
"descr" => "Mailbox",
"graphs" => array(
]
],
"mailbox" => [
"rrd" => "wmi-app-exchange-mailbox.rrd",
"descr" => "Mailbox",
"graphs" => [
'exchange_mb_latency' => 'RPC Average Latency',
'exchange_mb_queued' => 'Messages Queued for Submission',
'exchange_mb_msgs' => 'Messages per Second'
)
)
);
]
]
];
foreach ($app_modules as $module => $data)
{
if (is_file(get_rrd_path($device, $data['rrd'])))
{
$app_sections[$module] = $data['descr'];
$app_graphs[$module] = $data['graphs'];
}
foreach ($app_modules as $module => $data) {
if (is_file(get_rrd_path($device, $data['rrd']))) {
$app_sections[$module] = $data['descr'];
$app_graphs[$module] = $data['graphs'];
}
}
unset($app_modules);

View File

@ -4,13 +4,13 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('exim-mailqueue_total' => 'Total mail in queue');
$app_graphs['default'] = ['exim-mailqueue_total' => 'Total mail in queue'];
// EOF

View File

@ -4,15 +4,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('exim_sent' => 'Exim - Sent / Received',
'exim_spam' => 'Exim - Spam / Virus',
'exim_reject' =>'Exim - Rejected / Bounced');
$app_graphs['default'] = ['exim_sent' => 'Exim - Sent / Received',
'exim_spam' => 'Exim - Spam / Virus',
'exim_reject' => 'Exim - Rejected / Bounced'];
// EOF

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('freeradius_authentication' => 'FreeRADIUS Authentication',
'freeradius_accounting' => 'FreeRADIUS Accounting');
$app_graphs['default'] = ['freeradius_authentication' => 'FreeRADIUS Authentication',
'freeradius_accounting' => 'FreeRADIUS Accounting'];
// EOF

View File

@ -4,16 +4,16 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array(
'icecast_current' => 'IceCast - Current',
'icecast_max' => 'IceCast - Maximum'
);
$app_graphs['default'] = [
'icecast_current' => 'IceCast - Current',
'icecast_max' => 'IceCast - Maximum'
];
// EOF

View File

@ -5,15 +5,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('ioping_timing' => 'I/O Timings',
'ioping_speed' => 'Speed',
'ioping_iops' => 'IOPs');
$app_graphs['default'] = ['ioping_timing' => 'I/O Timings',
'ioping_speed' => 'Speed',
'ioping_iops' => 'IOPs'];
// EOF

View File

@ -4,49 +4,49 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2014, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @copyright (C) Adam Armstrong
*
*/
// defines tabs
$app_sections = array(
'memory' => 'Memory',
$app_sections = [
'memory' => 'Memory',
'threads' => 'Threads',
'classes' => 'Classes',
'gc' => 'Garbage Collector',
'system' => 'System Information',
);
'gc' => 'Garbage Collector',
'system' => 'System Information',
];
// defines graphs in memory tab
$app_graphs['memory'] = array(
$app_graphs['memory'] = [
'jvmoverjmx_memory_summary' => 'Memory Summary',
'jvmoverjmx_heap' => 'Heap',
'jvmoverjmx_nonheap' => 'Non Heap',
'jvmoverjmx_eden' => 'Eden Space',
'jvmoverjmx_perm' => 'Permanent Generation',
'jvmoverjmx_old' => 'Old Generation',
);
'jvmoverjmx_heap' => 'Heap',
'jvmoverjmx_nonheap' => 'Non Heap',
'jvmoverjmx_eden' => 'Eden Space',
'jvmoverjmx_perm' => 'Permanent Generation',
'jvmoverjmx_old' => 'Old Generation',
];
// defines graphs in threads tab
$app_graphs['threads'] = array(
$app_graphs['threads'] = [
'jvmoverjmx_threads' => 'Threads',
);
];
$app_graphs['classes'] = array(
$app_graphs['classes'] = [
'jvmoverjmx_classes' => 'Classes',
);
];
$app_graphs['gc'] = array(
'jvmoverjmx_gc_young_time' => 'GC Young Gen Collection Time',
'jvmoverjmx_gc_old_time' => 'GC Old Gen Collection Time',
$app_graphs['gc'] = [
'jvmoverjmx_gc_young_time' => 'GC Young Gen Collection Time',
'jvmoverjmx_gc_old_time' => 'GC Old Gen Collection Time',
'jvmoverjmx_gc_young_count' => 'GC Young Collection Count',
'jvmoverjmx_gc_old_count' => 'GC Old Collection Count',
);
'jvmoverjmx_gc_old_count' => 'GC Old Collection Count',
];
$app_graphs['system'] = array(
$app_graphs['system'] = [
'jvmoverjmx_system_uptime' => 'Uptime',
);
];
// EOF

View File

@ -4,24 +4,24 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2014, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@memetic.org>
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@memetic.org>
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
$app_graphs['default'] = array(
'kamailio_errors' => 'Errors',
'kamailio_shmen' => 'Shared Memory Usage',
'kamailio_core' => 'Core Stats',
'kamailio_registrar' => 'Registrations',
'kamailio_usrloc' => 'Users',
'kamailio_tmx' => 'TMX',
'kamailio_tcp' => 'TCP',
'kamailio_sl123' => 'SL 100 -> 3XX',
'kamailio_sl4' => 'SL 400 -> 4XX',
'kamailio_sl56' => 'SL 500 -> XXX',
);
$app_graphs['default'] = [
'kamailio_errors' => 'Errors',
'kamailio_shmen' => 'Shared Memory Usage',
'kamailio_core' => 'Core Stats',
'kamailio_registrar' => 'Registrations',
'kamailio_usrloc' => 'Users',
'kamailio_tmx' => 'TMX',
'kamailio_tcp' => 'TCP',
'kamailio_sl123' => 'SL 100 -> 3XX',
'kamailio_sl4' => 'SL 400 -> 4XX',
'kamailio_sl56' => 'SL 500 -> XXX',
];
// EOF

View File

@ -5,15 +5,15 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @package observium
* @subpackage applications
* @copyright (C) 2006 - 2013 Adam Armstrong
*
*/
$app_graphs['default'] = array('lighttpd_hits' => 'Hits',
'lighttpd_traffic' => 'Traffic',
'lighttpd_uptime' => 'Lighttpd Uptime',
'lighttpd_servers' => 'Busy / Idle Workers',
'lighttpd_scoreboardstatistics' => 'Scoreboard Statistics');
$app_graphs['default'] = ['lighttpd_hits' => 'Hits',
'lighttpd_traffic' => 'Traffic',
'lighttpd_uptime' => 'Lighttpd Uptime',
'lighttpd_servers' => 'Busy / Idle Workers',
'lighttpd_scoreboardstatistics' => 'Scoreboard Statistics'];

View File

@ -5,13 +5,13 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @package observium
* @subpackage applications
* @copyright (C) 2006 - 2013 Adam Armstrong
*
*/
$app_graphs['default'] = array('lvs_stats_connections' => 'Connections per Second',
'lvs_stats_packets' => 'Packets per Second',
'lvs_stats_bytes' => 'Bytes per Second');
$app_graphs['default'] = ['lvs_stats_connections' => 'Connections per Second',
'lvs_stats_packets' => 'Packets per Second',
'lvs_stats_bytes' => 'Bytes per Second'];

View File

@ -4,15 +4,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('mailscanner_sent' => 'Sent / Received',
'mailscanner_spam' => 'Spam / Virus',
'mailscanner_reject' => 'Rejected / Waiting / Relayed');
$app_graphs['default'] = ['mailscanner_sent' => 'Sent / Received',
'mailscanner_spam' => 'Spam / Virus',
'mailscanner_reject' => 'Rejected / Waiting / Relayed'];
// EOF

View File

@ -4,19 +4,19 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('memcached_bits' => 'Traffic',
'memcached_commands' => 'Commands',
'memcached_data' => 'Data Size',
'memcached_items' => 'Items',
'memcached_uptime' => 'Uptime',
'memcached_threads' => 'Threads',
);
$app_graphs['default'] = ['memcached_bits' => 'Traffic',
'memcached_commands' => 'Commands',
'memcached_data' => 'Data Size',
'memcached_items' => 'Items',
'memcached_uptime' => 'Uptime',
'memcached_threads' => 'Threads',
];
// EOF

View File

@ -4,21 +4,21 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('mongodb_commands' => 'Commands',
'mongodb_queue' => 'Queues',
'mongodb_mem' => 'Memory',
'mongodb_replication' => 'Replication',
'mongodb_wired' => 'Wired Storage Engine',
'mongodb_connections' => 'Connections',
'mongodb_network' => 'Network',
);
$app_graphs['default'] = ['mongodb_commands' => 'Commands',
'mongodb_queue' => 'Queues',
'mongodb_mem' => 'Memory',
'mongodb_replication' => 'Replication',
'mongodb_wired' => 'Wired Storage Engine',
'mongodb_connections' => 'Connections',
'mongodb_network' => 'Network',
];
// EOF

View File

@ -4,35 +4,38 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage applications
* @author Solomon Seal <slm4996+observium@gmail.com> 2014-04
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage applications
* @author Solomon Seal <slm4996+observium@gmail.com> 2014-04
* @copyright (C) Adam Armstrong
*
*/
$sql = "SELECT * FROM `applications-state` WHERE `application_id` = ?";
$app_state = dbFetchRow($sql, array($app['app_id']));
$app_data = safe_unserialize($app_state['app_state']);
$sql = "SELECT * FROM `applications-state` WHERE `application_id` = ?";
$app_state = dbFetchRow($sql, [$app['app_id']]);
$app_data = safe_unserialize($app_state['app_state']);
$app_sections['system'] = "System";
if (!empty($app_data['stats']))
$app_sections['stats'] = "Stats";
if (!empty($app_data['buffer']))
$app_sections['buffers'] = "Buffers";
if (!empty($app_data['stats'])) {
$app_sections['stats'] = "Stats";
}
if (!empty($app_data['buffer'])) {
$app_sections['buffers'] = "Buffers";
}
$app_graphs['system']['mssql_cpu_usage'] = 'Processor';
if (!empty($app_data['memory']))
$app_graphs['system']['mssql_memory_usage'] = 'Memory';
if (!empty($app_data['memory'])) {
$app_graphs['system']['mssql_memory_usage'] = 'Memory';
}
$app_graphs['stats'] = array(
'mssql_stats' => 'Users'
);
$app_graphs['stats'] = [
'mssql_stats' => 'Users'
];
$app_graphs['buffers'] = array(
'mssql_buffer_page' => 'Page Lookups',
'mssql_buffer_pglife' => 'Page Life Expectancy',
'mssql_buffer_stalls' => 'Free List Stalls'
);
$app_graphs['buffers'] = [
'mssql_buffer_page' => 'Page Lookups',
'mssql_buffer_pglife' => 'Page Life Expectancy',
'mssql_buffer_stalls' => 'Free List Stalls'
];
// EOF

View File

@ -4,20 +4,20 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (!safe_empty($app_data['memory'])) {
$memory_used = $app_data['memory']['used'] - $app_data['memory']['cache'];
$memory_used_perc = round(float_div($memory_used, $app_data['memory']['total']) * 100, 2);
$memory_used = $app_data['memory']['used'] - $app_data['memory']['cache'];
$memory_used_perc = round(float_div($memory_used, $app_data['memory']['total']) * 100, 2);
$memory_cached_perc = round(float_div($app_data['memory']['cache'], $app_data['memory']['total']) * 100, 2);
$memory_free = $app_data['memory']['total'] - $app_data['memory']['used'];
$memory_free_perc = round(float_div($memory_free, $app_data['memory']['total']) * 100, 2);
$memory_free = $app_data['memory']['total'] - $app_data['memory']['used'];
$memory_free_perc = round(float_div($memory_free, $app_data['memory']['total']) * 100, 2);
$graph_array = array();
$graph_array = [];
$graph_array['height'] = "100";
$graph_array['width'] = "512";
$graph_array['to'] = get_time();
@ -25,49 +25,49 @@ if (!safe_empty($app_data['memory'])) {
$graph_array['type'] = 'application_mssql_memory_usage';
$graph_array['from'] = get_time('day');
$graph_array['legend'] = "no";
$graph = generate_graph_tag($graph_array);
$graph = generate_graph_tag($graph_array);
$link_array = $graph_array;
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $app['app_instance'] . " - Memory Usage");
$percentage_bar = array();
$percentage_bar = [];
//$percentage_bar['border'] = "#EA8F00";
$percentage_bar['border'] = "#E25A00";
$percentage_bar['bg'] = "#f0f0f0";
$percentage_bar['width'] = "100%";
$percentage_bar['text'] = $memory_free_perc."%";
$percentage_bar['text'] = $memory_free_perc . "%";
$percentage_bar['text_c'] = "#E25A00";
$percentage_bar['bars'][0] = array('percent' => $memory_used_perc, 'colour' => '#EE9955', 'text' => $memory_used_perc.'%');
$percentage_bar['bars'][1] = array('percent' => $memory_cached_perc, 'colour' => '#f0e0a0', 'text' => '');
$percentage_bar['bars'][0] = ['percent' => $memory_used_perc, 'colour' => '#EE9955', 'text' => $memory_used_perc . '%'];
$percentage_bar['bars'][1] = ['percent' => $memory_cached_perc, 'colour' => '#f0e0a0', 'text' => ''];
echo(overlib_link($link, $graph, $overlib_content, NULL));
?>
<div class="box box-solid">
<div class="title"><i class="<?php echo $config['icon']['mempool']; ?>"></i> Memory</div>
<div class="content">
<table width="100%" class="table table-striped table-condensed-more ">
<tr>
<td colspan="7">
<?php echo(percentage_bar($percentage_bar)); ?>
</td>
</tr>
<tr class="small">
<td><i style="font-size: 7px; line-height: 7px; background-color: #EE9955; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Used</td>
<td><?php echo(formatStorage($memory_used).' ('.$memory_used_perc.'%)'); ?></td>
<td><i style="font-size: 7px; line-height: 7px; background-color: #f0e0a0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Cached</td>
<td><?php echo(formatStorage($app_data['memory']['cache']).' ('.$memory_cached_perc.'%)'); ?></td>
<td><i style="font-size: 7px; line-height: 7px; background-color: #f0f0f0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Free</td>
<td><?php echo(formatStorage($memory_free).' ('.$memory_free_perc.'%)'); ?></td>
</tr>
</table>
</div>
</div>
<?php
?>
<div class="box box-solid">
<div class="title"><i class="<?php echo $config['icon']['mempool']; ?>"></i> Memory</div>
<div class="content">
<table width="100%" class="table table-striped table-condensed-more ">
<tr>
<td colspan="7">
<?php echo(percentage_bar($percentage_bar)); ?>
</td>
</tr>
<tr class="small">
<td><i style="font-size: 7px; line-height: 7px; background-color: #EE9955; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Used</td>
<td><?php echo(format_bytes($memory_used) . ' (' . $memory_used_perc . '%)'); ?></td>
<td><i style="font-size: 7px; line-height: 7px; background-color: #f0e0a0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Cached</td>
<td><?php echo(format_bytes($app_data['memory']['cache']) . ' (' . $memory_cached_perc . '%)'); ?></td>
<td><i style="font-size: 7px; line-height: 7px; background-color: #f0f0f0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Free</td>
<td><?php echo(format_bytes($memory_free) . ' (' . $memory_free_perc . '%)'); ?></td>
</tr>
</table>
</div>
</div>
<?php
}
unset($percentage_bar, $graph_array, $overlib_content, $graph, $link, $link_array);

View File

@ -4,51 +4,51 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$cpu_counter = $app_data['cpu']['proc'];
$time_counter = $app_data['cpu']['time'];
$cpu_counter = $app_data['cpu']['proc'];
$time_counter = $app_data['cpu']['time'];
$cpu_load_percent = round(float_div($cpu_counter, $time_counter) * 100, 2);
$background = get_percentage_colours($cpu_load_percent);
$background = get_percentage_colours($cpu_load_percent);
$graph_array = array();
$graph_array = [];
$graph_array['height'] = "100";
$graph_array['width'] = "512";
$graph_array['to'] = $config['time']['now'];
$graph_array['to'] = get_time();
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_mssql_cpu_usage';
$graph_array['from'] = $config['time']['day'];
$graph_array['from'] = get_time('day');
$graph_array['legend'] = "no";
$graph = generate_graph_tag($graph_array);
$graph = generate_graph_tag($graph_array);
$link_array = $graph_array;
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $app['app_instance'] . " - CPU Usage");
$percentage_bar = array();
$percentage_bar['border'] = "#".$background['left'];
$percentage_bar['bg'] = "#".$background['right'];
$percentage_bar = [];
$percentage_bar['border'] = "#" . $background['left'];
$percentage_bar['bg'] = "#" . $background['right'];
$percentage_bar['width'] = "100%";
$percentage_bar['text'] = $cpu_load_percent."%";
$percentage_bar['text'] = $cpu_load_percent . "%";
$percentage_bar['text_c'] = "#FFFFFF";
$percentage_bar['bars'][0] = array('percent' => $cpu_load_percent);
$percentage_bar['bars'][0] = ['percent' => $cpu_load_percent];
echo(overlib_link($link, $graph, $overlib_content, NULL));
?>
<table width="100%" class="table table-striped table-condensed-more ">
<tr>
<td class="entity">Current CPU Load</td>
<td style="width: 90px;"></td>
<td style="width: 200px;"><?php echo percentage_bar($percentage_bar); ?></td>
</tr>
</table>
<table width="100%" class="table table-striped table-condensed-more ">
<tr>
<td class="entity">Current CPU Load</td>
<td style="width: 90px;"></td>
<td style="width: 200px;"><?php echo percentage_bar($percentage_bar); ?></td>
</tr>
</table>
<?php

View File

@ -4,46 +4,46 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array('system' => "System",
'queries' => "Queries",
'innodb' => "InnoDB");
$app_sections = ['system' => "System",
'queries' => "Queries",
'innodb' => "InnoDB"];
$app_graphs['system'] = array(
'mysql_connections' => 'Connections',
'mysql_status' => 'Process List',
'mysql_files_tables' => 'Files and Tables',
'mysql_myisam_indexes' => 'MyISAM Indexes',
'mysql_network_traffic' => 'Network Traffic',
'mysql_table_locks' => 'Table Locks',
'mysql_temporary_objects' => 'Temporary Objects'
);
$app_graphs['system'] = [
'mysql_connections' => 'Connections',
'mysql_status' => 'Process List',
'mysql_files_tables' => 'Files and Tables',
'mysql_myisam_indexes' => 'MyISAM Indexes',
'mysql_network_traffic' => 'Network Traffic',
'mysql_table_locks' => 'Table Locks',
'mysql_temporary_objects' => 'Temporary Objects'
];
$app_graphs['queries'] = array(
'mysql_command_counters' => 'Command Counters',
'mysql_query_cache' => 'Query Cache',
'mysql_query_cache_memory' => 'Query Cache Memory',
'mysql_select_types' => 'Select Types',
'mysql_slow_queries' => 'Slow Queries',
'mysql_sorts' => 'Sorts',
);
$app_graphs['queries'] = [
'mysql_command_counters' => 'Command Counters',
'mysql_query_cache' => 'Query Cache',
'mysql_query_cache_memory' => 'Query Cache Memory',
'mysql_select_types' => 'Select Types',
'mysql_slow_queries' => 'Slow Queries',
'mysql_sorts' => 'Sorts',
];
$app_graphs['innodb'] = array(
'mysql_innodb_buffer_pool' => 'InnoDB Buffer Pool',
'mysql_innodb_buffer_pool_activity' => 'InnoDB Buffer Pool Activity',
'mysql_innodb_insert_buffer' => 'InnoDB Insert Buffer',
'mysql_innodb_io' => 'InnoDB IO',
'mysql_innodb_io_pending' => 'InnoDB IO Pending',
'mysql_innodb_log' => 'InnoDB Log',
'mysql_innodb_row_operations' => 'InnoDB Row Operations',
'mysql_innodb_semaphores' => 'InnoDB semaphores',
'mysql_innodb_transactions' => 'InnoDB Transactions',
);
$app_graphs['innodb'] = [
'mysql_innodb_buffer_pool' => 'InnoDB Buffer Pool',
'mysql_innodb_buffer_pool_activity' => 'InnoDB Buffer Pool Activity',
'mysql_innodb_insert_buffer' => 'InnoDB Insert Buffer',
'mysql_innodb_io' => 'InnoDB IO',
'mysql_innodb_io_pending' => 'InnoDB IO Pending',
'mysql_innodb_log' => 'InnoDB Log',
'mysql_innodb_row_operations' => 'InnoDB Row Operations',
'mysql_innodb_semaphores' => 'InnoDB semaphores',
'mysql_innodb_transactions' => 'InnoDB Transactions',
];
// EOF

View File

@ -5,14 +5,14 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('nfs_nfs2' => 'NFS2',
'nfs_nfs3' => 'NFS3',
'nfs_nfs4' => 'NFS4');
$app_graphs['default'] = ['nfs_nfs2' => 'NFS2',
'nfs_nfs3' => 'NFS3',
'nfs_nfs4' => 'NFS4'];
// EOF

View File

@ -5,17 +5,17 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('nfsd_rc' => 'NFSd RC',
'nfsd_io' => 'NFSd I/O',
'nfsd_net' => 'NFSd Net',
'nfsd_rpc' => 'NFSd RPC',
'nfsd_proc3' => 'NFSd v3'
);
$app_graphs['default'] = ['nfsd_rc' => 'NFSd RC',
'nfsd_io' => 'NFSd I/O',
'nfsd_net' => 'NFSd Net',
'nfsd_rpc' => 'NFSd RPC',
'nfsd_proc3' => 'NFSd v3'
];
// EOF

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('nginx_connections' => 'Connections',
'nginx_req' => 'Requests');
$app_graphs['default'] = ['nginx_connections' => 'Connections',
'nginx_req' => 'Requests'];
// EOF

View File

@ -5,17 +5,17 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array(
'nsd_queries' => 'NSD - DNS traffic',
'nsd_memory' => 'NSD - Memory statistics',
'nsd_qtype' => 'NSD - Queries by Query type',
'nsd_rcode' => 'NSD - Queries by Return code',
'nsd_axfr' => 'NSD - Requests for AXFR',
'nsd_zones' => 'NSD - Zones');
$app_graphs['default'] = [
'nsd_queries' => 'NSD - DNS traffic',
'nsd_memory' => 'NSD - Memory statistics',
'nsd_qtype' => 'NSD - Queries by Query type',
'nsd_rcode' => 'NSD - Queries by Return code',
'nsd_axfr' => 'NSD - Requests for AXFR',
'nsd_zones' => 'NSD - Zones'];

View File

@ -5,13 +5,13 @@
*
* This files is part of Observium.
*
* @package observium
* @subpackage applications
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('ntpclient_stats' => 'Statistics',
'ntpclient_freq' => 'Frequency');
$app_graphs['default'] = ['ntpclient_stats' => 'Statistics',
'ntpclient_freq' => 'Frequency'];
// EOF

View File

@ -4,19 +4,19 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('ntpdserver_stats' => 'Statistics',
'ntpdserver_freq' => 'Frequency',
'ntpdserver_stratum' => 'Stratum',
'ntpdserver_buffer' => 'Buffer',
'ntpdserver_bits' => 'Packets Sent/Received',
'ntpdserver_packets' => 'Packets Dropped/Ignored',
'ntpdserver_uptime' => 'Uptime');
$app_graphs['default'] = ['ntpdserver_stats' => 'Statistics',
'ntpdserver_freq' => 'Frequency',
'ntpdserver_stratum' => 'Stratum',
'ntpdserver_buffer' => 'Buffer',
'ntpdserver_bits' => 'Packets Sent/Received',
'ntpdserver_packets' => 'Packets Dropped/Ignored',
'ntpdserver_uptime' => 'Uptime'];
// EOF

View File

@ -4,37 +4,36 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
// Set variables
$rrd_server = get_rrd_path($device, "app-ntpd-server-".$app['app_id'].".rrd");
$rrd_client = get_rrd_path($device, "app-ntpd-client-".$app['app_id'].".rrd");
$ntpd_type = (is_file($rrd_server) ? "server" : "client");
$rrd_server = get_rrd_path($device, "app-ntpd-server-" . $app['app_id'] . ".rrd");
$rrd_client = get_rrd_path($device, "app-ntpd-client-" . $app['app_id'] . ".rrd");
$ntpd_type = (is_file($rrd_server) ? "server" : "client");
// Test if this is a server or client install and set app_sections accordingly
if ($ntpd_type == "server")
{
$app_sections = array('server' => "System",
'buffer' => "Buffer",
'packets' => "Packets");
if ($ntpd_type == "server") {
$app_sections = ['server' => "System",
'buffer' => "Buffer",
'packets' => "Packets"];
}
$app_graphs['default'] = array('ntpd_stats' => 'NTP Client - Statistics',
'ntpd_freq' => 'NTP Client - Frequency');
$app_graphs['default'] = ['ntpd_stats' => 'NTP Client - Statistics',
'ntpd_freq' => 'NTP Client - Frequency'];
$app_graphs['server'] = array('ntpd_stats' => 'NTPD Server - Statistics',
'ntpd_freq' => 'NTPD Server - Frequency',
'ntpd_uptime' => 'NTPD Server - Uptime',
'ntpd_stratum' => 'NTPD Server - Stratum');
$app_graphs['server'] = ['ntpd_stats' => 'NTPD Server - Statistics',
'ntpd_freq' => 'NTPD Server - Frequency',
'ntpd_uptime' => 'NTPD Server - Uptime',
'ntpd_stratum' => 'NTPD Server - Stratum'];
$app_graphs['buffer'] = array('ntpd_buffer' => 'NTPD Server - Buffer');
$app_graphs['buffer'] = ['ntpd_buffer' => 'NTPD Server - Buffer'];
$app_graphs['packets'] = array('ntpd_bits' => 'NTPD Server - Packets Sent/Received',
'ntpd_packets' => 'NTPD Server - Packets Dropped/Ignored');
$app_graphs['packets'] = ['ntpd_bits' => 'NTPD Server - Packets Sent/Received',
'ntpd_packets' => 'NTPD Server - Packets Dropped/Ignored'];
// EOF

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('openvpn_nclients' => 'Connected Clients',
'openvpn_bits' => 'VPN Traffic');
$app_graphs['default'] = ['openvpn_nclients' => 'Connected Clients',
'openvpn_bits' => 'VPN Traffic'];
// EOF

View File

@ -4,15 +4,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('postfix_mailgraph_sent' => 'Postfix - Sent / Received',
'postfix_mailgraph_spam' => 'Postfix - Spam / Virus',
'postfix_mailgraph_reject' => 'Postfix - Rejected / Bounced');
$app_graphs['default'] = ['postfix_mailgraph_sent' => 'Postfix - Sent / Received',
'postfix_mailgraph_spam' => 'Postfix - Spam / Virus',
'postfix_mailgraph_reject' => 'Postfix - Rejected / Bounced'];
// EOF

View File

@ -1,5 +1,5 @@
<?php
$app_graphs['default'] = array('postfix_qshape_stats' => 'Postfix - Queue Shape');
$app_graphs['default'] = ['postfix_qshape_stats' => 'Postfix - Queue Shape'];
// EOF

View File

@ -4,22 +4,22 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array('stats' => "Stats",
'live' => "Live");
$app_sections = ['stats' => "Stats",
'live' => "Live"];
$app_graphs['stats'] = array('postgresql_xact' => 'Commit Count',
'postgresql_blks' => 'Blocks Count',
'postgresql_tuples' => 'Tuples Count',
'postgresql_tuples_query' => 'Tuples Count per Query');
$app_graphs['stats'] = ['postgresql_xact' => 'Commit Count',
'postgresql_blks' => 'Blocks Count',
'postgresql_tuples' => 'Tuples Count',
'postgresql_tuples_query' => 'Tuples Count per Query'];
$app_graphs['live'] = array('postgresql_connects' => 'Connection Count',
'postgresql_queries' => 'Query Types');
$app_graphs['live'] = ['postgresql_connects' => 'Connection Count',
'postgresql_queries' => 'Query Types'];
// EOF

View File

@ -4,25 +4,25 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('powerdns-recursor_queries' => 'Questions and answers per second',
'powerdns-recursor_tcpqueries' => 'TCP Questions and answers per second, unauthorized packets/s',
'powerdns-recursor_errors' => 'Packet errors per second',
'powerdns-recursor_limits' => 'Limitations per second',
'powerdns-recursor_latency' => 'Questions answered within latency',
'powerdns-recursor_outqueries' => 'Questions vs Outqueries',
'powerdns-recursor_qalatency' => 'Question/Answer latency in ms',
'powerdns-recursor_timeouts' => 'Corrupt / Failed / Timed out',
'powerdns-recursor_cache' => 'Cache sizes',
'powerdns-recursor_load' => 'Concurrent Queries',
/* 'powerdns-recursor_hitrate' => 'Cache hitrate',*/ // FIXME have to fix up the graph def before uncomment
/* 'powerdns-recursor_cpuload' => 'CPU load',*/ // FIXME have to fix up the graph def before uncomment
);
$app_graphs['default'] = ['powerdns-recursor_queries' => 'Questions and answers per second',
'powerdns-recursor_tcpqueries' => 'TCP Questions and answers per second, unauthorized packets/s',
'powerdns-recursor_errors' => 'Packet errors per second',
'powerdns-recursor_limits' => 'Limitations per second',
'powerdns-recursor_latency' => 'Questions answered within latency',
'powerdns-recursor_outqueries' => 'Questions vs Outqueries',
'powerdns-recursor_qalatency' => 'Question/Answer latency in ms',
'powerdns-recursor_timeouts' => 'Corrupt / Failed / Timed out',
'powerdns-recursor_cache' => 'Cache sizes',
'powerdns-recursor_load' => 'Concurrent Queries',
/* 'powerdns-recursor_hitrate' => 'Cache hitrate',*/ // FIXME have to fix up the graph def before uncomment
/* 'powerdns-recursor_cpuload' => 'CPU load',*/ // FIXME have to fix up the graph def before uncomment
];
// EOF

View File

@ -4,19 +4,19 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('powerdns_latency' => 'Latency',
'powerdns_fail' => 'Corrupt / Failed / Timed out',
'powerdns_packetcache' => 'Packet Cache',
'powerdns_querycache' => 'Query Cache',
'powerdns_recursing' => 'Recursing Queries and Answers',
'powerdns_queries' => 'Total UDP/TCP Queries and Answers',
'powerdns_queries_udp' => 'Detail UDP IPv4/IPv6 Queries and Answers');
$app_graphs['default'] = ['powerdns_latency' => 'Latency',
'powerdns_fail' => 'Corrupt / Failed / Timed out',
'powerdns_packetcache' => 'Packet Cache',
'powerdns_querycache' => 'Query Cache',
'powerdns_recursing' => 'Recursing Queries and Answers',
'powerdns_queries' => 'Total UDP/TCP Queries and Answers',
'powerdns_queries_udp' => 'Detail UDP IPv4/IPv6 Queries and Answers'];
// EOF

View File

@ -4,10 +4,10 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
@ -15,70 +15,63 @@
global $config;
$total = true;
$total = TRUE;
$rrddir = $config['rrd_dir']."/".$device['hostname'];
$files = array();
$rrddir = $config['rrd_dir'] . "/" . $device['hostname'];
$files = [];
if ($handle = opendir($rrddir))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." &&
str_starts($file, "app-shoutcast-".$app['app_id']))
{
array_push($files, $file);
if ($handle = opendir($rrddir)) {
while (FALSE !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." &&
str_starts($file, "app-shoutcast-" . $app['app_id'])) {
array_push($files, $file);
}
}
}
}
if (isset($total) && $total == true)
{
$graphs = array(
'shoutcast_multi_bits' => 'Traffic Statistics - Total of all Shoutcast servers',
'shoutcast_multi_stats' => 'Shoutcast Statistics - Total of all Shoutcast servers'
);
if (isset($total) && $total == TRUE) {
$graphs = [
'shoutcast_multi_bits' => 'Traffic Statistics - Total of all Shoutcast servers',
'shoutcast_multi_stats' => 'Shoutcast Statistics - Total of all Shoutcast servers'
];
foreach ($graphs as $key => $text)
{
$graph_type = $key;
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_".$key;
echo('<h3>'.$text.'</h3>');
echo("<tr bgcolor='$row_colour'><td colspan=5>");
foreach ($graphs as $key => $text) {
$graph_type = $key;
$graph_array['to'] = get_time();
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_" . $key;
echo('<h3>' . $text . '</h3>');
echo("<tr bgcolor='$row_colour'><td colspan=5>");
print_graph_row($graph_array);
print_graph_row($graph_array);
echo("</td></tr>");
}
echo("</td></tr>");
}
}
foreach ($files as $id => $file)
{
$hostname = str_replace(['app-shoutcast-'.$app['app_id'].'-', '.rrd'], '', $file);
list($host, $port) = explode('_', $hostname, 2);
$graphs = array(
'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')',
'shoutcast_stats' => 'Shoutcast Statistics - '.$host.' (Port: '.$port.')'
);
foreach ($files as $id => $file) {
$hostname = str_replace(['app-shoutcast-' . $app['app_id'] . '-', '.rrd'], '', $file);
[$host, $port] = explode('_', $hostname, 2);
$graphs = [
'shoutcast_bits' => 'Traffic Statistics - ' . $host . ' (Port: ' . $port . ')',
'shoutcast_stats' => 'Shoutcast Statistics - ' . $host . ' (Port: ' . $port . ')'
];
foreach ($graphs as $key => $text)
{
$graph_type = $key;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_".$key;
$graph_array['hostname'] = $hostname;
echo('<h3>'.$text.'</h3>');
echo("<tr bgcolor='$row_colour'><td colspan=5>");
foreach ($graphs as $key => $text) {
$graph_type = $key;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = get_time();
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_" . $key;
$graph_array['hostname'] = $hostname;
echo('<h3>' . $text . '</h3>');
echo("<tr bgcolor='$row_colour'><td colspan=5>");
print_graph_row($graph_array);
print_graph_row($graph_array);
echo("</td></tr>");
}
echo("</td></tr>");
}
}
// EOF

View File

@ -4,20 +4,20 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('unbound_queries' => 'DNS traffic and cache hits',
'unbound_queue' => 'Queue statistics',
'unbound_memory' => 'Memory statistics',
'unbound_qtype' => 'Queries by Query type',
'unbound_rcode' => 'Queries by Return code',
'unbound_opcode' => 'Queries by Operation code',
'unbound_class' => 'Queries by Query class',
'unbound_flags' => 'Queries by Flags');
$app_graphs['default'] = ['unbound_queries' => 'DNS traffic and cache hits',
'unbound_queue' => 'Queue statistics',
'unbound_memory' => 'Memory statistics',
'unbound_qtype' => 'Queries by Query type',
'unbound_rcode' => 'Queries by Return code',
'unbound_opcode' => 'Queries by Operation code',
'unbound_class' => 'Queries by Query class',
'unbound_flags' => 'Queries by Flags'];
// EOF

View File

@ -4,17 +4,17 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array(
$app_graphs['default'] = [
'varnish_backend' => 'Varnish Backend',
'varnish_cache' => 'Varnish Cache',
'varnish_lru' => 'Varnish LRU',
);
'varnish_cache' => 'Varnish Cache',
'varnish_lru' => 'Varnish LRU',
];
// EOF

View File

@ -4,14 +4,14 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_graphs['default'] = array('vmwaretools_mem' => 'Memory Resource Allocation',
'vmwaretools_cpu' => 'CPU Resource Allocation');
$app_graphs['default'] = ['vmwaretools_mem' => 'Memory Resource Allocation',
'vmwaretools_cpu' => 'CPU Resource Allocation'];
// EOF

View File

@ -4,30 +4,30 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage applications
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$app_sections = array('system' => "System",
'backend' => "Backend",
'jvm' => "Java VM",
);
$app_sections = ['system' => "System",
'backend' => "Backend",
'jvm' => "Java VM",
];
$app_graphs['system'] = array(
'zimbra_fdcount' => 'Open file descriptors',
);
$app_graphs['system'] = [
'zimbra_fdcount' => 'Open file descriptors',
];
$app_graphs['backend'] = array(
'zimbra_mtaqueue' => 'MTA queue size',
'zimbra_connections' => 'Open connections',
'zimbra_threads' => 'Threads',
);
$app_graphs['backend'] = [
'zimbra_mtaqueue' => 'MTA queue size',
'zimbra_connections' => 'Open connections',
'zimbra_threads' => 'Threads',
];
$app_graphs['jvm'] = array(
'zimbra_jvmthreads' => 'JVM Threads',
);
$app_graphs['jvm'] = [
'zimbra_jvmthreads' => 'JVM Threads',
];
// EOF

View File

@ -30,37 +30,43 @@ load_graph_definitions();
/**
* Send back new list content
*
* @items Array of options values to return to browser
* @method Name of Javascript method that will be called to process data
*/
function dhtml_response_list(&$items, $method) {
header("Content-Type: text/xml");
function dhtml_response_list(&$items, $method)
{
header("Content-Type: text/xml");
print('<?xml version="1.0" encoding="utf-8" ?>'."\n");
print("<response>\n");
printf(" <method>%s</method>\n", escape_html($method));
print(" <result>\n");
foreach ($items as &$item)
printf(' <option>%s</option>'."\n", escape_html($item));
print(" </result>\n");
print("</response>");
print('<?xml version="1.0" encoding="utf-8" ?>' . "\n");
print("<response>\n");
printf(" <method>%s</method>\n", escape_html($method));
print(" <result>\n");
foreach ($items as &$item) {
printf(' <option>%s</option>' . "\n", escape_html($item));
}
print(" </result>\n");
print("</response>");
}
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'collectd');
$link_array = ['page' => 'device',
'device' => $device['device_id'],
'tab' => 'collectd'];
$plugins = collectd_list_plugins($device['hostname']);
#$navbar['brand'] = "CollectD";
$navbar['class'] = "navbar-narrow";
foreach ($plugins as &$plugin)
{
if (!$vars['plugin']) { $vars['plugin'] = $plugin; }
if ($vars['plugin'] == $plugin) { $navbar['options'][$plugin]['class'] = "active"; }
$navbar['options'][$plugin]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'collectd', 'plugin' => $plugin));
$navbar['options'][$plugin]['text'] = escape_html(ucwords($plugin));
foreach ($plugins as &$plugin) {
if (!$vars['plugin']) {
$vars['plugin'] = $plugin;
}
if ($vars['plugin'] == $plugin) {
$navbar['options'][$plugin]['class'] = "active";
}
$navbar['options'][$plugin]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'collectd', 'plugin' => $plugin]);
$navbar['options'][$plugin]['text'] = escape_html(ucwords($plugin));
}
print_navbar($navbar);
@ -69,49 +75,51 @@ echo generate_box_open();
echo '<table class="table table-condensed table-striped table-hover">';
$i=0;
$i = 0;
$pinsts = collectd_list_pinsts($device['hostname'], $vars['plugin']);
foreach ($pinsts as &$instance) {
$pinsts = collectd_list_pinsts($device['hostname'], $vars['plugin']);
foreach ($pinsts as &$instance) {
$types = collectd_list_types($device['hostname'], $vars['plugin'], $instance);
foreach ($types as &$type) {
$types = collectd_list_types($device['hostname'], $vars['plugin'], $instance);
foreach ($types as &$type) {
$typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type);
$typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type);
if ($MetaGraphDefs[$type]) { $typeinstances = array($MetaGraphDefs[$type]); }
if ($MetaGraphDefs[$type]) {
$typeinstances = [$MetaGraphDefs[$type]];
}
foreach ($typeinstances as &$tinst) {
$i++;
$row_colour = !is_intnum($i / 2) ? OBS_COLOUR_LIST_A : OBS_COLOUR_LIST_B;
foreach ($typeinstances as &$tinst) {
$i++;
$row_colour = !is_intnum($i / 2) ? OBS_COLOUR_LIST_A : OBS_COLOUR_LIST_B;
echo('<tr><td>');
echo('<h3>'.$graph_title);
echo('<tr><td>');
echo('<h3>' . $graph_title);
if ($tinst) {
echo($vars['plugin']." $instance - $type - $tinst");
} else {
echo($vars['plugin']." $instance - $type");
}
echo('</h3>');
if ($tinst) {
echo($vars['plugin'] . " $instance - $type - $tinst");
} else {
echo($vars['plugin'] . " $instance - $type");
}
echo('</h3>');
$graph_array['type'] = "device_collectd";
$graph_array['device'] = $device['device_id'];
$graph_array['type'] = "device_collectd";
$graph_array['device'] = $device['device_id'];
$graph_array['c_plugin'] = $vars['plugin'];
$graph_array['c_plugin_instance'] = $instance;
$graph_array['c_type'] = $type;
$graph_array['c_type_instance'] = $tinst;
$graph_array['c_plugin'] = $vars['plugin'];
$graph_array['c_plugin_instance'] = $instance;
$graph_array['c_type'] = $type;
$graph_array['c_type_instance'] = $tinst;
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</tr></td>');
}
}
echo('</tr></td>');
}
}
}
echo '</table>';
echo generate_box_close();

View File

@ -6,64 +6,55 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
// Print permission error and exit if the user doesn't have write permissions
if (!is_entity_write_permitted($device['device_id'], 'device'))
{
print_error_permission();
return;
if (!is_entity_write_permitted($device['device_id'], 'device')) {
print_error_permission();
return;
}
$export_device = $device;
if ($config['snmp']['hide_auth'])
{
$params = array('snmp_community', 'snmp_authlevel', 'snmp_authname', 'snmp_authpass', 'snmp_authalgo', 'snmp_cryptopass', 'snmp_cryptoalgo');
foreach ($params as $param)
{
if (strlen($export_device[$param])) { $export_device[$param] = '***'; }
}
}
$export_device = $device;
device_filter_secrets($export_device, $config['snmp']['hide_auth'], '***');
if (get_var_true($vars['saveas']) && $vars['filename']) {
if (get_var_true($vars['saveas']) && $vars['filename']) {
download_as_file(gzencode(safe_json_encode($export_device)), $vars['filename']);
} else {
if ($config['snmp']['hide_auth'])
{
print_warning("NOTE, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>TRUE</strong>, snmp community and snmp v3 auth hidden from output and export.");
} else {
if ($config['snmp']['hide_auth']) {
print_warning("NOTE, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>TRUE</strong>, snmp community and snmp v3 auth hidden from output and export.");
} else {
print_error("WARNING, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>FALSE</strong>, snmp community and snmp v3 auth <strong>NOT hidden</strong> from output and export.");
print_error("WARNING, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>FALSE</strong>, snmp community and snmp v3 auth <strong>NOT hidden</strong> from output and export.");
}
$form = array('type' => 'rows',
'space' => '10px',
'url' => generate_url($vars));
$form = ['type' => 'rows',
'space' => '10px',
'url' => generate_url($vars)];
// Filename
$form['row'][0]['filename'] = array(
'type' => 'text',
'name' => 'Filename',
'value' => $device['hostname'] . '.json.txt.gz',
//'div_class' => 'col-md-8',
'width' => '100%',
'placeholder' => TRUE);
$form['row'][0]['filename'] = [
'type' => 'text',
'name' => 'Filename',
'value' => $device['hostname'] . '.json.txt.gz',
//'div_class' => 'col-md-8',
'width' => '100%',
'placeholder' => TRUE];
// Compress
//$form['row'][0]['compress'] = array(
// 'type' => 'switch',
// 'value' => 1);
// Search button
$form['row'][0]['saveas'] = array(
'type' => 'submit',
'name' => 'Export',
'icon' => 'icon-save',
'right' => TRUE,
'value' => 'yes'
);
$form['row'][0]['saveas'] = [
'type' => 'submit',
'name' => 'Export',
'icon' => 'icon-save',
'right' => TRUE,
'value' => 'yes'
];
print_form($form);
r($export_device);
}
}
unset($export_device, $params, $param);
unset($export_device, $params, $param);
// EOF

View File

@ -6,13 +6,13 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($_SESSION['userlevel'] < 7 && !is_entity_write_permitted($device['device_id'], 'device')) {
print_error_permission();
return;
print_error_permission();
return;
}
// User level 7-9 only can see config
@ -21,94 +21,108 @@ if ($_SESSION['userlevel'] < 7 && !is_entity_write_permitted($device['device_id'
// Allow write for users with write permission to this entity
$readonly = !is_entity_write_permitted($device['device_id'], 'device');
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'edit');
$link_array = ['page' => 'device',
'device' => $device['device_id'],
'tab' => 'edit'];
$panes['device'] = 'Device Settings';
$panes['snmp'] = 'SNMP';
if ($config['geocoding']['enable']) {
$panes['geo'] = 'Geolocation';
}
$panes['mibs'] = 'MIBs';
$panes['graphs'] = 'Graphs';
$panes['alerts'] = 'Alerts';
$panes['ports'] = 'Ports';
if ($health_exist['sensors']) {
$panes['sensors'] = 'Sensors';
}
if ($health_exist['status']) {
$panes['device'] = 'Device Settings';
$panes['snmp'] = 'SNMP';
if ($config['geocoding']['enable']) {
$panes['geo'] = 'Geolocation';
}
$panes['mibs'] = 'MIBs';
$panes['graphs'] = 'Graphs';
$panes['alerts'] = 'Alerts';
$panes['ports'] = 'Ports';
if ($cache['health_exist'][$device['device_id']]['sensors']) {
$panes['sensors'] = 'Sensors';
}
if ($cache['health_exist'][$device['device_id']]['status']) {
$panes['status'] = 'Statuses';
}
if (safe_count($config['os'][$device['os']]['icons']))
{
$panes['icon'] = 'Icon';
}
}
// if ($cache['health_exist'][$device['device_id']]['counter']) {
// $panes['counter'] = 'Counters';
// }
$panes['modules'] = 'Modules';
$panes['modules'] = 'Modules';
//if ($config['enable_services'])
//{
//$panes['services'] = 'Services';
//}
//if ($config['enable_services'])
//{
//$panes['services'] = 'Services';
//}
// $panes['probes'] = 'Probes';
// $panes['probes'] = 'Probes';
if ($device_loadbalancer_count['netscaler_vsvr']) { $panes['netscaler_vsvrs'] = 'NS vServers'; }
if ($device_loadbalancer_count['netscaler_services']) { $panes['netscaler_svcs'] = 'NS Services'; }
if ($device_loadbalancer_count['netscaler_vsvr']) {
$panes['netscaler_vsvrs'] = 'NS vServers';
}
if ($device_loadbalancer_count['netscaler_services']) {
$panes['netscaler_svcs'] = 'NS Services';
}
if ($device['os'] === 'windows') {
$panes['wmi'] = 'WMI';
}
if ($device['os'] === 'windows') {
$panes['wmi'] = 'WMI';
}
if ($config['os'][$device['os']]['ipmi']) {
$panes['ipmi'] = 'IPMI';
}
if (($config['enable_libvirt'] && $device['os'] === 'linux') || // libvirt-vminfo discovery module
$device['os_group'] === 'unix' || is_module_enabled($device, 'unix-agent', 'poller')) { // unix-agent
$panes['ssh'] = 'SSH';
}
if ($device['os_group'] === 'unix' || $device['os'] === 'generic')
{
$panes['agent'] = 'Agent';
}
if ($device['os_group'] === 'unix' || $device['os'] === 'windows')
{
$panes['apps'] = 'Applications'; /// FIXME. Deprecated?
}
if ($config['os'][$device['os']]['ipmi']) {
$panes['ipmi'] = 'IPMI';
}
if (($config['enable_libvirt'] && $device['os'] === 'linux') || // libvirt-vminfo discovery module
$device['os_group'] === 'unix' || is_module_enabled($device, 'unix-agent', 'poller')) { // unix-agent
$panes['ssh'] = 'SSH';
}
if (($device['os_group'] === 'unix' || $device['os'] === 'generic') && (is_module_enabled($device, 'unix-agent', 'poller'))) {
$panes['agent'] = 'Agent';
}
if ($device['os_group'] === 'unix' || $device['os'] === 'windows') {
$panes['apps'] = 'Applications'; /// FIXME. Deprecated?
}
$navbar['brand'] = "Edit";
$navbar['class'] = "navbar-narrow";
if ($_SESSION['userlevel'] >= 9) {
// Detect (possible) duplicates
$duplicates = [];
get_device_duplicated($device, $duplicates);
if (count($duplicates)) {
$panes['duplicates'] = 'Duplicates';
}
}
foreach ($panes as $type => $text)
{
if (!isset($vars['section'])) { $vars['section'] = $type; }
$navbar['brand'] = "Edit";
$navbar['class'] = "navbar-narrow";
if ($vars['section'] == $type) { $navbar['options'][$type]['class'] = "active"; }
$navbar['options'][$type]['url'] = generate_url($link_array,array('section'=>$type));
foreach ($panes as $type => $text) {
if (!isset($vars['section'])) {
$vars['section'] = $type;
}
if ($vars['section'] == $type) {
$navbar['options'][$type]['class'] = "active";
}
$navbar['options'][$type]['url'] = generate_url($link_array, ['section' => $type]);
$navbar['options'][$type]['text'] = $text;
}
$navbar['options_right']['delete']['url'] = generate_url($link_array,array('section'=>'delete'));
$navbar['options_right']['delete']['text'] = 'Delete';
$navbar['options_right']['delete']['icon'] = $config['icon']['device-delete'];
if ($vars['section'] === 'delete') { $navbar['options_right']['delete']['class'] = 'active'; }
print_navbar($navbar);
}
$navbar['options_right']['delete']['url'] = generate_url($link_array, ['section' => 'delete']);
$navbar['options_right']['delete']['text'] = 'Delete';
$navbar['options_right']['delete']['icon'] = ':wastebasket:';//$config['icon']['device-delete'];
if ($vars['section'] === 'delete') {
$navbar['options_right']['delete']['class'] = 'active';
}
print_navbar($navbar);
$filename = $config['html_dir'] . '/pages/device/edit/' . $vars['section'] . '.inc.php';
if (is_file($filename))
{
$vars = get_vars('POST'); // Note, on edit pages use only method POST!
$filename = $config['html_dir'] . '/pages/device/edit/' . $vars['section'] . '.inc.php';
if (is_file($filename)) {
$vars = get_vars('POST'); // Note, on edit pages use only method POST!
$attribs = get_dev_attribs($device['device_id']);
$model = get_model_array($device);
$model = get_model_array($device);
register_html_resource('js', 'js/jquery.serializejson.js');
register_html_resource('js', 'js/jquery.serializejson.min.js');
include($filename);
} else {
} else {
print_error('<h3>Page does not exist</h4>
The requested page does not exist. Please correct the URL and try again.');
}
}
unset($filename, $navbar, $panes, $link_array);
unset($filename, $navbar, $panes, $link_array, $readonly);
register_html_title("Settings");

View File

@ -4,80 +4,70 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$agent_port = $vars['agent_port'];
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$agent_port = $vars['agent_port'];
if ($agent_port == "")
{
del_dev_attrib($device, 'agent_port');
$updated = 1;
$update_message = "Agent settings updated.";
if ($agent_port == "") {
del_dev_attrib($device, 'agent_port');
$updated = 1;
$update_message = "Agent settings updated.";
} elseif (!is_numeric($agent_port)) {
$update_message = "Agent port must be numeric!";
$updated = 0;
} else {
set_dev_attrib($device, 'agent_port', $agent_port);
$updated = 1;
$update_message = "Agent settings updated.";
}
}
elseif (!is_numeric($agent_port))
{
$update_message = "Agent port must be numeric!";
$updated = 0;
}
else
{
set_dev_attrib($device, 'agent_port', $agent_port);
$updated = 1;
$update_message = "Agent settings updated.";
}
}
if ($updated && $update_message)
{
print_message($update_message);
log_event('Device Agent configuration changed.', $device['device_id'], 'device', $device, 5); // severity 5, for logging user info
}
else if ($update_message)
{
print_error($update_message);
}
if ($updated && $update_message) {
print_message($update_message);
log_event('Device Agent configuration changed.', $device['device_id'], 'device', $device, 5); // severity 5, for logging user info
} elseif ($update_message) {
print_error($update_message);
}
}
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", [$device['device_id']]);
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Agent Connectivity',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['agent_port'] = array(
'type' => 'text',
'name' => 'Agent Port',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'agent_port'));
$form['row'][2]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Agent Connectivity',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
print_form($form);
unset($form);
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['agent_port'] = [
'type' => 'text',
'name' => 'Agent Port',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'agent_port')];
$form['row'][2]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);
// EOF

View File

@ -4,158 +4,157 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$override_sysContact_bool = $vars['override_sysContact'];
if (isset($vars['sysContact'])) { $override_sysContact_string = $vars['sysContact']; }
$disable_notify = $vars['disable_notify'];
if ($override_sysContact_bool) {
set_dev_attrib($device, 'override_sysContact_bool', '1');
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
del_dev_attrib($device, 'override_sysContact_bool');
}
if (isset($override_sysContact_string)) {
set_dev_attrib($device, 'override_sysContact_string', $override_sysContact_string);
}
if ($disable_notify) {
set_dev_attrib($device, 'disable_notify', '1');
} else {
del_dev_attrib($device, 'disable_notify');
$override_sysContact_bool = $vars['override_sysContact'];
if (isset($vars['sysContact'])) {
$override_sysContact_string = $vars['sysContact'];
}
$disable_notify = $vars['disable_notify'];
if ($override_sysContact_bool) {
set_dev_attrib($device, 'override_sysContact_bool', '1');
} else {
del_dev_attrib($device, 'override_sysContact_bool');
}
if (isset($override_sysContact_string)) {
set_dev_attrib($device, 'override_sysContact_string', $override_sysContact_string);
}
if ($disable_notify) {
set_dev_attrib($device, 'disable_notify', '1');
} else {
del_dev_attrib($device, 'disable_notify');
}
// 2019-12-05 23:30:00
if (isset($vars['ignore_until']) && $vars['ignore_until_enable']) {
$update['ignore_until'] = $vars['ignore_until'];
$device['ignore_until'] = $vars['ignore_until'];
} else {
$update['ignore_until'] = ['NULL'];
$device['ignore_until'] = '';
}
foreach (['ignore'] as $param) {
if (!in_array($param, ['purpose', 'poller_id'])) {
// Boolean params
$vars[$param] = get_var_true($vars[$param]) ? '1' : '0';
}
if ($vars[$param] != $device[$param]) {
$update[$param] = $vars[$param];
}
}
dbUpdate($update, 'devices', '`device_id` = ?', [$device['device_id']]);
$update_message = "Device alert settings updated.";
$updated = 1;
// Request for clear WUI cache
set_cache_clear('wui');
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", [$device['device_id']]);
}
// 2019-12-05 23:30:00
if (isset($vars['ignore_until']) && $vars['ignore_until_enable']) {
$update['ignore_until'] = $vars['ignore_until'];
$device['ignore_until'] = $vars['ignore_until'];
} else {
$update['ignore_until'] = array('NULL');
$device['ignore_until'] = '';
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
foreach (array('ignore') as $param)
{
if (!in_array($param, array('purpose', 'poller_id')))
{
// Boolean params
$vars[$param] = get_var_true($vars[$param]) ? '1' : '0';
}
if ($vars[$param] != $device[$param])
{
$update[$param] = $vars[$param];
}
}
dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id']));
$update_message = "Device alert settings updated.";
$updated = 1;
// Request for clear WUI cache
set_cache_clear('wui');
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
}
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
}
$override_sysContact_bool = get_dev_attrib($device,'override_sysContact_bool');
$override_sysContact_string = get_dev_attrib($device,'override_sysContact_string');
$disable_notify = get_dev_attrib($device,'disable_notify');
$override_sysContact_bool = get_dev_attrib($device, 'override_sysContact_bool');
$override_sysContact_string = get_dev_attrib($device, 'override_sysContact_string');
$disable_notify = get_dev_attrib($device, 'disable_notify');
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Alert Settings',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Alert Settings',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['ignore'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Ignore Device',
//'fieldset' => 'edit',
'placeholder' => 'Suppresses alerts and notifications. Hides device from some UI elements.',
'readonly' => $readonly,
'value' => $device['ignore']);
$form['row'][1]['ignore'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Ignore Device',
//'fieldset' => 'edit',
'placeholder' => 'Suppresses alerts and notifications. Hides device from some UI elements.',
'readonly' => $readonly,
'value' => $device['ignore']];
$form['row'][2]['ignore_until'] = array(
'type' => 'datetime',
//'fieldset' => 'edit',
'name' => 'Ignore Until',
'placeholder' => '',
//'width' => '250px',
'readonly' => $readonly,
'disabled' => empty($device['ignore_until']),
'min' => 'current',
'value' => $device['ignore_until'] ?: '');
$form['row'][2]['ignore_until_enable'] = array(
'type' => 'toggle',
'size' => 'large',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'ignore_until')",
'value' => !empty($device['ignore_until']));
$form['row'][2]['ignore_until'] = [
'type' => 'datetime',
//'fieldset' => 'edit',
'name' => 'Ignore Until',
'placeholder' => '',
//'width' => '250px',
'readonly' => $readonly,
'disabled' => empty($device['ignore_until']),
'min' => 'current',
'value' => $device['ignore_until'] ?: ''];
$form['row'][2]['ignore_until_enable'] = [
'type' => 'toggle',
'size' => 'large',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'ignore_until')",
'value' => !empty($device['ignore_until'])];
$form['row'][3]['override_sysContact'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Override sysContact',
//'fieldset' => 'edit',
'placeholder' => 'Use custom contact below',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'sysContact')",
'value' => $override_sysContact_bool);
$form['row'][4]['sysContact'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Custom contact',
'placeholder' => '',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$override_sysContact_bool,
'value' => $override_sysContact_string);
$form['row'][5]['disable_notify'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Disable notifications',
//'fieldset' => 'edit',
'placeholder' => 'Don\'t send alert notifications (but write to eventlog)',
'readonly' => $readonly,
'value' => $disable_notify);
$form['row'][7]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form['row'][3]['override_sysContact'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Override sysContact',
//'fieldset' => 'edit',
'placeholder' => 'Use custom contact below',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'sysContact')",
'value' => $override_sysContact_bool];
$form['row'][4]['sysContact'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Custom contact',
'placeholder' => '',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$override_sysContact_bool,
'value' => $override_sysContact_string];
$form['row'][5]['disable_notify'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Disable notifications',
//'fieldset' => 'edit',
'placeholder' => 'Don\'t send alert notifications (but write to eventlog)',
'readonly' => $readonly,
'value' => $disable_notify];
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);
print_form($form);
unset($form);
// EOF

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
@ -15,122 +15,119 @@ print_warning("This page allows you to disable applications for this device that
# Check if the form was POSTed
if ($vars['device']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$updated = 0;
$param[] = $device['device_id'];
$enabled = [];
foreach (array_keys($vars) as $key) {
if (str_starts($key, 'app_')) {
$param[] = substr($key, 4);
$enabled[] = substr($key, 4);
$replace[] = "?";
}
}
if (count($enabled)) {
$updated += dbDelete('applications', "`device_id` = ? AND `app_type` NOT IN (".implode(",",$replace).")", $param);
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$updated += dbDelete('applications', "`device_id` = ?", array($param));
}
$updated = 0;
$param[] = $device['device_id'];
$enabled = [];
foreach (array_keys($vars) as $key) {
if (str_starts($key, 'app_')) {
$param[] = substr($key, 4);
$enabled[] = substr($key, 4);
$replace[] = "?";
}
}
foreach (dbFetchRows( "SELECT `app_type` FROM `applications` WHERE `device_id` = ?", array($device['device_id'])) as $row) {
$app_in_db[] = $row['app_type'];
}
if (count($enabled)) {
$updated += dbDelete('applications', "`device_id` = ? AND `app_type` NOT IN (" . implode(",", $replace) . ")", $param);
} else {
$updated += dbDelete('applications', "`device_id` = ?", [$param]);
}
foreach ($enabled as $app) {
if (!in_array($app, $app_in_db)) {
$updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app), 'applications');
}
}
foreach (dbFetchRows("SELECT `app_type` FROM `applications` WHERE `device_id` = ?", [$device['device_id']]) as $row) {
$app_in_db[] = $row['app_type'];
}
if ($updated) {
print_message("Applications updated!");
} else {
print_message("No changes.");
foreach ($enabled as $app) {
if (!in_array($app, $app_in_db)) {
$updated += dbInsert(['device_id' => $device['device_id'], 'app_type' => $app], 'applications');
}
}
if ($updated) {
print_message("Applications updated!");
} else {
print_message("No changes.");
}
}
}
}
# Show list of apps with checkboxes
$apps_enabled = dbFetchRows("SELECT * from `applications` WHERE `device_id` = ? ORDER BY app_type", array($device['device_id']));
$apps_enabled = dbFetchRows("SELECT * from `applications` WHERE `device_id` = ? ORDER BY app_type", [ $device['device_id'] ]);
if (safe_count($apps_enabled)) {
foreach ($apps_enabled as $application)
{
$app_enabled[] = $application['app_type'];
}
?>
<form id="appedit" name="appedit" method="post" action="" class="form-inline">
<input type="hidden" name="device" value="<?php echo $device['device_id'];?>">
<?php echo generate_box_open(array('title' => 'Applications', 'header-border' => TRUE)); ?>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 100px;">Enable</th>
<th>Application</th>
</tr>
</thead>
<tbody>
<?php
# Load our list of available applications
if ($handle = opendir($config['install_dir'] . "/includes/polling/applications/")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && strstr($file, ".inc.php")) {
$applications[] = str_replace(".inc.php", "", $file);
$app_enabled = [];
foreach ($apps_enabled as $application) {
$app_enabled[] = $application['app_type'];
}
}
closedir($handle);
}
?>
foreach ($applications as $app) {
if (in_array($app, $app_enabled)) {
echo(" <tr>");
//echo(" <td>");
$item = array(
'id' => 'app_' . $app,
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
'on-text' => 'No',
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => 1
);
echo('<td class="text-center">'.generate_form_element($item).'</td>');
//echo(" </td>");
echo(" <td>". nicecase($app) . "</td>");
echo(" </tr>");
<form id="appedit" name="appedit" method="post" action="" class="form-inline">
<input type="hidden" name="device" value="<?php echo $device['device_id']; ?>">
$row++;
}
}
?>
</tbody>
</table>
</div>
<?php echo generate_box_open(['title' => 'Applications', 'header-border' => TRUE]); ?>
<div class="box-footer">
<button type="submit" class="btn btn-primary pull-right" name="submit" value="save"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</div>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 100px;">Enable</th>
<th>Application</th>
</tr>
</thead>
<tbody>
</form>
<?php
<?php
# Load our list of available applications
$applications = [];
foreach (get_recursive_directory_iterator($config['install_dir'] . "/includes/polling/applications/") as $file => $info) {
if (!str_ends_with($info->getFilename(), '.inc.php')) { continue; }
$applications[] = str_replace(".inc.php", "", $info->getFilename());
}
//r($applications);
foreach ($applications as $app) {
if (in_array($app, $app_enabled)) {
echo(" <tr>");
//echo(" <td>");
$item = [
'id' => 'app_' . $app,
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
'on-text' => 'No',
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => 1
];
echo('<td class="text-center">' . generate_form_element($item) . '</td>');
//echo(" </td>");
echo(" <td>" . nicecase($app) . "</td>");
echo(" </tr>");
}
}
?>
</tbody>
</table>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary pull-right" name="submit" value="save"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</div>
</form>
<?php
} else {
print_error("No applications found on this device.");
print_error("No applications found on this device.");
}
// EOF

View File

@ -6,51 +6,53 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($_SESSION['userlevel'] < 10) {
print_error_permission();
return;
if ($readonly) { // in parent: $readonly = !is_entity_write_permitted($device['device_id'], 'device');
print_error_permission();
return;
}
$form = [
'type' => 'horizontal',
'id' => 'delete_host',
//'space' => '20px',
'title' => 'Delete device',
//'class' => 'box box-solid',
'url' => 'delhost/'
'type' => 'horizontal',
'id' => 'delete_host',
//'space' => '20px',
'title' => 'Delete device',
//'class' => 'box box-solid',
'url' => 'delhost/'
];
$form['row'][0]['id'] = [
'type' => 'hidden',
'value' => $device['device_id']
$form['row'][0]['id'] = [
'type' => 'hidden',
'value' => $device['device_id']
];
$form['row'][4]['deleterrd'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Delete RRDs',
'onchange' => "javascript: showDiv(this.checked);",
'value' => 'confirm'
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Delete RRDs',
'onchange' => "javascript: showDiv(this.checked);",
'value' => 'confirm'
];
$form['row'][5]['confirm'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Confirm Deletion',
'onchange' => "javascript: toggleAttrib('disabled', 'delete');",
'value' => 'confirm'
$form['row'][5]['confirm'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Confirm Deletion',
'onchange' => "javascript: toggleAttrib('disabled', 'delete');",
'value' => 'confirm'
];
$form['row'][6]['delete'] = [
'type' => 'submit',
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE
$form['row'][6]['delete'] = [
'type' => 'submit',
'name' => 'Delete device',
'icon' => 'icon-remove icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE
];
print_warning("<h3>Warning!</h4>

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
@ -15,243 +15,264 @@ $override_type_string = get_entity_attrib('device', $device, 'override_type');
$override_type_bool = !empty($override_type_string);
$default_type = $override_type_bool ? $config['os'][$device['os']]['type'] : $device['type'];
$device_types = array();
$device_types = [];
foreach ($config['device_types'] as $type) {
$device_types[$type['type']] = array('name' => nicecase($type['type']), 'icon' => $type['icon']);
if ($type['type'] == $default_type) {
$device_types[$type['type']]['subtext'] = 'Default';
//$device_types[$type['type']]['class'] = 'error';
}
$device_types[$type['type']] = ['name' => nicecase($type['type']), 'icon' => $type['icon']];
if ($type['type'] == $default_type) {
$device_types[$type['type']]['subtext'] = 'Default';
//$device_types[$type['type']]['class'] = 'error';
}
}
if (!array_key_exists($device['type'], $device_types)) {
$device_types[$device['type']] = array('name' => 'Other', 'icon' => $config['icon']['question']);
$device_types[$device['type']] = ['name' => 'Other', 'icon' => $config['icon']['question']];
}
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
print_debug_vars($vars);
$updated = 0;
// Changed sysLocation
$override_sysLocation_bool = $vars['override_sysLocation'];
if (isset($vars['sysLocation'])) {
$override_sysLocation_string = $vars['sysLocation'];
}
if (get_entity_attrib('device', $device, 'override_sysLocation_bool') != $override_sysLocation_bool ||
get_entity_attrib('device', $device, 'override_sysLocation_string') != $override_sysLocation_string) {
$updated = 2;
}
if ($override_sysLocation_bool) {
set_entity_attrib('device', $device, 'override_sysLocation_bool', '1', $device['device_id']);
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
del_entity_attrib('device', $device, 'override_sysLocation_bool');
}
if (isset($override_sysLocation_string)) { set_entity_attrib('device', $device, 'override_sysLocation_string', $override_sysLocation_string); }
print_debug_vars($vars);
$updated = 0;
// Changed Skip ping
$ping_skip_set = isset($vars['ping_skip']) && get_var_true($vars['ping_skip']);
if ($ping_skip != $ping_skip_set)
{
if ($ping_skip_set) { set_entity_attrib('device', $device, 'ping_skip', '1'); }
else { del_entity_attrib('device', $device, 'ping_skip'); }
$ping_skip = get_entity_attrib('device', $device, 'ping_skip');
$updated++;
}
# FIXME needs more sanity checking! and better feedback
# FIXME -- update location too? Need to trigger geolocation!
$update_array = array();
// Changed Type
if ($vars['type'] != $device['type'] && isset($device_types[$vars['type']]))
{
$update_array['type'] = $vars['type'];
if (!$override_type_bool || $override_type_string != $vars['type'])
{
// Type overridden by user..
if ($vars['type'] == $default_type)
{
del_entity_attrib('device', $device, 'override_type');
$override_type_string = NULL;
} else {
set_entity_attrib('device', $device, 'override_type', $vars['type']);
$override_type_string = $vars['type'];
// Changed sysLocation
$override_sysLocation_bool = $vars['override_sysLocation'];
if (isset($vars['sysLocation'])) {
$override_sysLocation_string = $vars['sysLocation'];
}
$override_type_bool = !empty($override_type_string);
}
$updated++;
}
foreach (array('purpose', 'ignore', 'disabled', 'poller_id') as $param)
{
if (!in_array($param, array('purpose', 'poller_id')))
{
// Boolean params
$vars[$param] = get_var_true($vars[$param]) ? '1' : '0';
}
if ($vars[$param] != $device[$param])
{
$update_array[$param] = $vars[$param];
$updated++;
}
}
if (get_entity_attrib('device', $device, 'override_sysLocation_bool') != $override_sysLocation_bool ||
get_entity_attrib('device', $device, 'override_sysLocation_string') != $override_sysLocation_string) {
$updated = 2;
}
if (count($update_array))
{
$rows_updated = dbUpdate($update_array, 'devices', '`device_id` = ?', array($device['device_id']));
}
//r($updated);
//r($update_array);
//r($rows_updated);
if ($updated) {
if ((bool)$vars['ignore'] != (bool)$device['ignore'])
{
log_event('Device '.((bool)$vars['ignore'] ? 'ignored' : 'attended').': '.$device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
if ((bool)$vars['disabled'] != (bool)$device['disabled'])
{
log_event('Device '.((bool)$vars['disabled'] ? 'disabled' : 'enabled').': '.$device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
$update_message = "Device record updated.";
if ($override_sysLocation_bool) { $update_message.= " Please note that the updated sysLocation string will only be visible after the next poll."; }
$updated = 1;
if ($override_sysLocation_bool) {
set_entity_attrib('device', $device, 'override_sysLocation_bool', '1', $device['device_id']);
} else {
del_entity_attrib('device', $device, 'override_sysLocation_bool');
}
if (isset($override_sysLocation_string)) {
set_entity_attrib('device', $device, 'override_sysLocation_string', $override_sysLocation_string);
}
// Request for clear WUI cache
set_cache_clear('wui');
// Changed Skip ping
$ping_skip_set = isset($vars['ping_skip']) && get_var_true($vars['ping_skip']);
if ($ping_skip != $ping_skip_set) {
if ($ping_skip_set) {
set_entity_attrib('device', $device, 'ping_skip', '1');
} else {
del_entity_attrib('device', $device, 'ping_skip');
}
$ping_skip = get_entity_attrib('device', $device, 'ping_skip');
$updated++;
}
# FIXME needs more sanity checking! and better feedback
# FIXME -- update location too? Need to trigger geolocation!
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
$update_array = [];
// Changed Type
if ($vars['type'] != $device['type'] && isset($device_types[$vars['type']])) {
$update_array['type'] = $vars['type'];
if (!$override_type_bool || $override_type_string != $vars['type']) {
// Type overridden by user..
if ($vars['type'] == $default_type) {
del_entity_attrib('device', $device, 'override_type');
$override_type_string = NULL;
} else {
set_entity_attrib('device', $device, 'override_type', $vars['type']);
$override_type_string = $vars['type'];
}
$override_type_bool = !empty($override_type_string);
}
$updated++;
}
foreach (['purpose', 'ignore', 'disabled', 'poller_id', 'force_discovery'] as $param) {
if (!in_array($param, ['purpose', 'poller_id'])) {
// Boolean params
$vars[$param] = get_var_true($vars[$param]) ? '1' : '0';
}
if ($vars[$param] != $device[$param]) {
$update_array[$param] = $vars[$param];
$updated++;
}
}
if (count($update_array)) {
$rows_updated = dbUpdate($update_array, 'devices', '`device_id` = ?', [$device['device_id']]);
}
//r($updated);
//r($update_array);
//r($rows_updated);
if ($updated) {
if ((bool)$vars['ignore'] != (bool)$device['ignore']) {
log_event('Device ' . ((bool)$vars['ignore'] ? 'ignored' : 'attended') . ': ' . $device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
if ((bool)$vars['disabled'] != (bool)$device['disabled']) {
log_event('Device ' . ((bool)$vars['disabled'] ? 'disabled' : 'enabled') . ': ' . $device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
if ((bool)$vars['force_discovery'] != (bool)$device['force_discovery']) {
log_event('Device forced discovery ' . ((bool)$vars['force_discovery'] ? 'enabled' : 'disabled') . ': ' . $device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
$update_message = "Device record updated.";
if ($override_sysLocation_bool) {
$update_message .= " Please note that the updated sysLocation string will only be visible after the next poll.";
}
$updated = 1;
// Request for clear WUI cache
set_cache_clear('wui');
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", [$device['device_id']]);
} elseif ($rows_updated = '-1') {
$update_message = "Device record unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device record update error.";
}
}
else if ($rows_updated = '-1')
{
$update_message = "Device record unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device record update error.";
}
}
}
$override_sysLocation_bool = get_entity_attrib('device', $device, 'override_sysLocation_bool');
$override_sysLocation_string = get_entity_attrib('device', $device, 'override_sysLocation_string');
if ($updated && $update_message) {
print_message($update_message);
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
print_error($update_message);
}
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'General Device Settings',
'icon' => $config['icon']['tools'],
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form = [
'type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'General Device Settings',
'icon' => $config['icon']['tools'],
//'class' => 'box box-solid',
'fieldset' => [ 'edit' => '' ],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['purpose'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Description',
//'class' => 'input-xlarge',
'width' => '500px',
'readonly' => $readonly,
'value' => $device['purpose']);
$form['row'][2]['type'] = array(
'type' => 'select',
//'fieldset' => 'edit',
'name' => 'Type',
'width' => '250px',
'readonly' => $readonly,
'values' => $device_types,
'value' => $device['type']);
/*
$form['row'][2]['reset_type'] = array(
'type' => 'switch',
//'fieldset' => 'edit',
//'onchange' => "toggleAttrib('disabled', 'sysLocation')",
'readonly' => $readonly,
'on-color' => 'danger',
'off-color' => 'primary',
'on-text' => 'Reset',
'off-text' => 'Keep',
'value' => 0);
*/
$form['row'][3]['sysLocation'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Custom location',
'placeholder' => '',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$override_sysLocation_bool,
'value' => $override_sysLocation_string);
$form['row'][3]['override_sysLocation'] = array(
'type' => 'toggle',
'size' => 'large',
//'fieldset' => 'edit',
//'placeholder' => 'Use custom location below.',
'onchange' => "toggleAttrib('disabled', 'sysLocation')",
'readonly' => $readonly,
'value' => $override_sysLocation_bool);
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
];
$form['row'][1]['purpose'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Description',
//'class' => 'input-xlarge',
'width' => '500px',
'readonly' => $readonly,
'value' => $device['purpose']
];
$form['row'][2]['type'] = [
'type' => 'select',
//'fieldset' => 'edit',
'name' => 'Type',
'width' => '250px',
'readonly' => $readonly,
'values' => $device_types,
'value' => $device['type']
];
/*
$form['row'][2]['reset_type'] = array(
'type' => 'switch',
//'fieldset' => 'edit',
//'onchange' => "toggleAttrib('disabled', 'sysLocation')",
'readonly' => $readonly,
'on-color' => 'danger',
'off-color' => 'primary',
'on-text' => 'Reset',
'off-text' => 'Keep',
'value' => 0);
*/
$form['row'][3]['sysLocation'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Custom location',
'placeholder' => '',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$override_sysLocation_bool,
'value' => $override_sysLocation_string
];
$form['row'][3]['override_sysLocation'] = [
'type' => 'toggle',
'size' => 'large',
//'fieldset' => 'edit',
//'placeholder' => 'Use custom location below.',
'onchange' => "toggleAttrib('disabled', 'sysLocation')",
'readonly' => $readonly,
'value' => $override_sysLocation_bool
];
$poller_list = get_pollers();
$form['row'][4]['poller_id'] = array(
'type' => 'select',
'community' => FALSE, // not available on community edition
'name' => 'Poller',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !(count($poller_list) > 1),
'values' => $poller_list,
'value' => $device['poller_id']);
$poller_list = get_pollers();
$form['row'][5]['ping_skip'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Skip ping',
//'fieldset' => 'edit',
'placeholder' => 'Skip ICMP echo checks, only SNMP availability.',
'readonly' => $readonly,
'value' => $ping_skip);
// FIXME (Mike): $device['ignore'] and get_dev_attrib($device,'disable_notify') it is same/redundant options?
$form['row'][6]['ignore'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Device ignore',
//'fieldset' => 'edit',
'placeholder' => 'Suppress alerts and notifications and hide in some UI elements.',
'readonly' => $readonly,
'value' => $device['ignore']);
$form['row'][7]['disabled'] = array(
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Disable',
//'fieldset' => 'edit',
'placeholder' => 'Disables polling and discovery.',
'readonly' => $readonly,
'value' => $device['disabled']);
$form['row'][8]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form['row'][4]['poller_id'] = [
'type' => 'select',
'community' => FALSE, // not available on community edition
'name' => 'Poller',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !(count($poller_list) > 1),
'values' => $poller_list,
'value' => $device['poller_id']
];
print_form($form);
unset($form);
$form['row'][5]['ping_skip'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Skip ping',
//'fieldset' => 'edit',
'placeholder' => 'Skip ICMP echo checks, only SNMP availability.',
'readonly' => $readonly,
'value' => $ping_skip
];
$form['row'][6]['force_discovery'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'blue',
'name' => 'Force Discovery',
//'fieldset' => 'edit',
'placeholder' => 'Force the device to be rediscovered in the next 5 mins.',
'readonly' => $readonly,
'value' => $device['force_discovery']
];
// FIXME (Mike): $device['ignore'] and get_dev_attrib($device,'disable_notify') it is same/redundant options?
$form['row'][7]['ignore'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'yellow',
'name' => 'Device ignore',
//'fieldset' => 'edit',
'placeholder' => 'Suppress alerts and notifications and hide in some UI elements.',
'readonly' => $readonly,
'value' => $device['ignore']
];
$form['row'][8]['disabled'] = [
'type' => 'toggle',
'view' => 'toggle',
'palette' => 'red',
'name' => 'Disable',
//'fieldset' => 'edit',
'placeholder' => 'Disables polling and discovery.',
'readonly' => $readonly,
'value' => $device['disabled']
];
$form['row'][9]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
];
print_form($form);
unset($form);
// EOF

View File

@ -0,0 +1,75 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
/** @var array $duplicates */
//r($duplicates);
// Display devices as a list in detailed format
$header = ['state-marker' => '',
'',
['hostname' => 'Hostname', 'domain' => 'Domain', 'location' => 'Location'],
'',
['os' => 'Operating System', 'hardware' => 'Hardware Platform'],
['uptime' => 'Uptime', 'sysName' => 'sysName']];
//r($table_header);
foreach ($duplicates as $case => $entries) {
switch ($case) {
case 'hostname':
$title = 'Same Hostname (' . $entries[0]['hostname'] . ')';
break;
case 'ip_snmp':
$title = 'Same IP (' . $entries[0]['ip'] . ') and SNMP port (' . $entries[0]['snmp_port'] . '). Different SNMP community or auth!';
break;
case 'ip_snmp_v1':
$title = 'Same IP (' . $entries[0]['ip'] . ':' . $entries[0]['snmp_port'] . ') and SNMP v1 community!';
break;
case 'ip_snmp_v2c':
$title = 'Same IP (' . $entries[0]['ip'] . ':' . $entries[0]['snmp_port'] . ') and SNMP v2c community!';
break;
case 'ip_snmp_v3':
$title = 'Same IP (' . $entries[0]['ip'] . ':' . $entries[0]['snmp_port'] . ') and SNMP v3 auth!';
break;
}
echo generate_box_open(['title' => $title, 'icon' => count($entries), 'header-border' => TRUE]);
echo '
<table class="table table-hover table-striped table-condensed">
<thead>
<tr>
<th class="state-marker"></th>
<th></th>
<th>Device / Location</th>
<th>Hardware / Features</th>
<th>Operating System</th>
<th>Uptime / sysName</th>
</tr>
</thead>';
//echo generate_table_header($header, $vars);
$vars['view'] = 'basic';
foreach ($entries as $dup) {
if (device_permitted($dup['device_id'])) {
print_device_row($dup, $vars, ['tab' => 'edit', 'section' => 'duplicates']);
}
}
echo('
</table>');
echo generate_box_close();
}
// EOF

View File

@ -6,232 +6,234 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$updated = 0;
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$updated = 0;
if ($vars['submit'] === 'save') {
if (get_var_true($vars['reset_geolocation'])) {
$updated = dbDelete('devices_locations', '`device_id` = ?', [ $device['device_id'] ]);
} elseif ((bool)$vars['location_manual']) {
// Set manual coordinates if present
$pattern = '/(?:^|[\[(])\s*(?<lat>[+-]?\d+(?:\.\d+)*)\s*[,; ]\s*(?<lon>[+-]?\d+(?:\.\d+)*)\s*(?:[\])]|$)/';
if (preg_match($pattern, $vars['coordinates'], $matches)) {
//r($matches);
if ($matches['lat'] >= -90 && $matches['lat'] <= 90 &&
$matches['lon'] >= -180 && $matches['lon'] <= 180) {
$update_geo['location_lat'] = $matches['lat'];
$update_geo['location_lon'] = $matches['lon'];
$update_geo['location_country'] = '';
$update_geo['location_manual'] = 1;
$updated++;
}
}
if (!$updated) { unset($vars); } // If manual set, but coordinates wrong - reset edit
//r($vars);
}
if ($vars['submit'] === 'save') {
if (get_var_true($vars['reset_geolocation'])) {
$updated = dbDelete('devices_locations', '`device_id` = ?', [ $device['device_id'] ]);
} elseif ((bool)$vars['location_manual']) {
// Set manual coordinates if present
if (preg_match(OBS_PATTERN_LATLON, $vars['coordinates'], $matches) ||
preg_match(OBS_PATTERN_LATLON_ALT, $vars['coordinates'], $matches)) {
//r($matches);
if ($matches['lat'] >= -90 && $matches['lat'] <= 90 &&
$matches['lon'] >= -180 && $matches['lon'] <= 180) {
$update_geo['location_lat'] = $matches['lat'];
$update_geo['location_lon'] = $matches['lon'];
$update_geo['location_country'] = '';
$update_geo['location_manual'] = 1;
$updated++;
}
}
if (!$updated) {
unset($vars);
} // If manual set, but coordinates wrong - reset edit
//r($vars);
}
if ((bool)$device['location_manual'] && !(bool)$vars['location_manual']) {
// Reset manual flag, rediscover geo info
$update_geo['location_lat'] = [ 'NULL' ];
$update_geo['location_lon'] = [ 'NULL' ];
$update_geo['location_manual'] = 0;
$updated++;
}
if ((bool)$device['location_manual'] && !(bool)$vars['location_manual']) {
// Reset manual flag, rediscover geo info
$update_geo['location_lat'] = ['NULL'];
$update_geo['location_lon'] = ['NULL'];
$update_geo['location_manual'] = 0;
$updated++;
}
if ($updated) {
//r($update_geo);
if (!safe_empty($update_geo)) {
dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', [ $device['location_id'] ]);
if ($updated) {
//r($update_geo);
if (!safe_empty($update_geo)) {
dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', [$device['location_id']]);
}
$geo_db = dbFetchRow("SELECT * FROM `devices_locations` WHERE `device_id` = ?", [$device['device_id']]);
if (safe_count($geo_db)) {
if (get_var_true($vars['reset_geolocation'])) {
print_warning("Device Geo location dropped. Country/city will be updated on next poll.");
} else {
print_success("Device Geolocation updated. Country/city will be updated on next poll.");
}
}
$device = array_merge($device, (array)$geo_db);
unset($updated, $update_geo, $geo_db);
} else {
print_warning("Some input data wrong. Device Geolocation not changed.");
}
}
$geo_db = dbFetchRow("SELECT * FROM `devices_locations` WHERE `device_id` = ?", [ $device['device_id'] ]);
if (safe_count($geo_db)) {
if (get_var_true($vars['reset_geolocation'])) {
print_warning("Device Geo location dropped. Country/city will be updated on next poll.");
} else {
print_success("Device Geolocation updated. Country/city will be updated on next poll.");
}
}
$device = array_merge($device, (array)$geo_db);
unset($updated, $update_geo, $geo_db);
} else {
print_warning("Some input data wrong. Device Geolocation not changed.");
}
}
}
}
$location = [ 'location_text' => $device['location'] ];
$location = ['location_text' => $device['location']];
$override_sysLocation_bool = get_dev_attrib($device,'override_sysLocation_bool');
$override_sysLocation_bool = get_dev_attrib($device, 'override_sysLocation_bool');
if ($override_sysLocation_bool) {
$override_sysLocation_string = get_dev_attrib($device,'override_sysLocation_string');
if ($override_sysLocation_string != $device['location']) {
// Device not polled since location override
$location['location_help'] = 'NOTE, device not polled since location overridden, Geolocation is old.';
$location['location_text'] = $override_sysLocation_string;
}
$override_sysLocation_string = get_dev_attrib($device, 'override_sysLocation_string');
if ($override_sysLocation_string != $device['location']) {
// Device not polled since location override
$location['location_help'] = 'NOTE, device not polled since location overridden, Geolocation is old.';
$location['location_text'] = $override_sysLocation_string;
}
}
if (safe_empty($location['location_text'])) { $location['location_text'] = OBS_VAR_UNSET; }
foreach ([ 'location_lat', 'location_lon', 'location_city', 'location_county', 'location_state', 'location_country',
'location_geoapi', 'location_status', 'location_manual', 'location_updated' ] as $param) {
$location[$param] = $device[$param];
if (safe_empty($location['location_text'])) {
$location['location_text'] = OBS_VAR_UNSET;
}
foreach (['location_lat', 'location_lon', 'location_city', 'location_county', 'location_state', 'location_country',
'location_geoapi', 'location_status', 'location_manual', 'location_updated'] as $param) {
$location[$param] = $device[$param];
}
if (is_numeric($location['location_lat']) && is_numeric($location['location_lon'])) {
// Generate link to Google maps
// http://maps.google.com/maps?q=46.090271,6.657248+description+(name)
$location['coordinates'] = $location['location_lat'].','.$location['location_lon'];
$location['coordinates_manual'] = $location['coordinates'];
$location['location_link'] = '<a target="_blank" href="https://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="'.$config['icon']['map'].'"></i> View this location on a map</a>';
$location['location_geo'] = country_from_code($location['location_country']).' (Country), '.$location['location_state'].' (State), ';
$location['location_geo'] .= $location['location_county'] .' (County), ' .$location['location_city'] .' (City)';
switch ($location['location_geoapi']) {
//case 'yandex':
// // Generate link to Yandex maps
// $location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="oicon-map"></i> View this location on a map</a>';
// break;
default:
// Generate link to Google maps
// http://maps.google.com/maps?q=46.090271,6.657248+description+(name)
$location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="'.$config['icon']['map'].'"></i> View this location on a map</a>';
}
// Generate link to Google maps
// http://maps.google.com/maps?q=46.090271,6.657248+description+(name)
$location['coordinates'] = $location['location_lat'] . ',' . $location['location_lon'];
$location['coordinates_manual'] = $location['coordinates'];
$location['location_link'] = '<a target="_blank" href="https://maps.google.com/maps?q=' . urlencode($location['coordinates']) . '"><i class="' . $config['icon']['map'] . '"></i> View this location on a map</a>';
$location['location_geo'] = country_from_code($location['location_country']) . ' (Country), ' . $location['location_state'] . ' (State), ';
$location['location_geo'] .= $location['location_county'] . ' (County), ' . $location['location_city'] . ' (City)';
switch ($location['location_geoapi']) {
//case 'yandex':
// // Generate link to Yandex maps
// $location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="oicon-map"></i> View this location on a map</a>';
// break;
default:
// Generate link to Google maps
// http://maps.google.com/maps?q=46.090271,6.657248+description+(name)
$location['location_link'] = '<a target="_blank" href="http://maps.google.com/maps?q=' . urlencode($location['coordinates']) . '"><i class="' . $config['icon']['map'] . '"></i> View this location on a map</a>';
}
} else {
$location['coordinates_manual'] = $config['geocoding']['default']['lat'].','.$config['geocoding']['default']['lon'];
$location['coordinates_manual'] = $config['geocoding']['default']['lat'] . ',' . $config['geocoding']['default']['lon'];
}
if ($updated && $update_message) {
print_message($update_message);
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
print_error($update_message);
}
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Geolocation Options',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'Geolocation Options',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['sysLocation'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'sysLocation string',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_text']);
if ($location['location_help'])
{
$form['row'][1]['location_help'] = array(
'type' => 'raw',
'value' => '<span class="help-block"><small>'.$location['location_help'].'</small></span>');
}
$form['row'][2]['location_geo'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Location Place',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_geo']);
$form['row'][3]['location_lat'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Latitude/Longitude',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => ($location['location_lat'] ? $location['location_lat'] . ',' . $location['location_lon'] : ''));
if ($location['location_link'])
{
$form['row'][3]['location_link'] = array(
'type' => 'raw',
'value' => '<span class="help-block"><small>'.$location['location_link'].'</small></span>');
}
$form['row'][4]['location_geoapi'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'API used',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => strtoupper($location['location_geoapi']));
$form['row'][4]['help_link'] = array(
'type' => 'raw',
'value' => '<span class="help-inline"><small><a target="_blank" href="' . OBSERVIUM_DOCS_URL . '/config_options/#syslocation-configuration">
<i class="'.$config['icon']['question'].'"></i> View available Geolocation APIs and other configuration options</a></small></span>');
$form['row'][5]['location_updated'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Last updated',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_updated']);
$form['row'][6]['location_status'] = array(
'type' => 'textarea',
//'fieldset' => 'edit',
'name' => 'Last update status',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_status']);
$form['row'][7]['coordinates'] = array(
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Manual coordinates',
'placeholder' => '',
'width' => '16.6667%',
'readonly' => $readonly,
'disabled' => !$location['location_manual'],
'value' => $location['coordinates_manual']);
$form['row'][7]['location_manual'] = array(
'type' => 'toggle',
'size' => 'large',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'coordinates')",
'value' => $location['location_manual']);
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['sysLocation'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'sysLocation string',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_text']];
if ($location['location_help']) {
$form['row'][1]['location_help'] = [
'type' => 'raw',
'value' => '<span class="help-block"><small>' . $location['location_help'] . '</small></span>'];
}
$form['row'][2]['location_geo'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Location Place',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_geo']];
$form['row'][3]['location_lat'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Latitude/Longitude',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => ($location['location_lat'] ? $location['location_lat'] . ',' . $location['location_lon'] : '')];
if ($location['location_link']) {
$form['row'][3]['location_link'] = [
'type' => 'raw',
'value' => '<span class="help-block"><small>' . $location['location_link'] . '</small></span>'];
}
$form['row'][4]['location_geoapi'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'API used',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => strtoupper($location['location_geoapi'])];
$form['row'][4]['help_link'] = [
'type' => 'raw',
'value' => '<span class="help-inline"><small><a target="_blank" href="' . OBSERVIUM_DOCS_URL . '/config_options/#syslocation-configuration">
<i class="' . $config['icon']['question'] . '"></i> View available Geolocation APIs and other configuration options</a></small></span>'];
$form['row'][5]['location_updated'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Last updated',
'placeholder' => '',
'width' => '16.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_updated']];
$form['row'][6]['location_status'] = [
'type' => 'textarea',
//'fieldset' => 'edit',
'name' => 'Last update status',
'placeholder' => '',
'width' => '66.6667%',
//'readonly' => $readonly,
'disabled' => TRUE, // Always disabled, just for see
'value' => $location['location_status']];
$form['row'][7]['coordinates'] = [
'type' => 'text',
//'fieldset' => 'edit',
'name' => 'Manual coordinates',
'placeholder' => '',
'width' => '16.6667%',
'readonly' => $readonly,
'disabled' => !$location['location_manual'],
'value' => $location['coordinates_manual']];
$form['row'][7]['location_manual'] = [
'type' => 'toggle',
'size' => 'large',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', 'coordinates')",
'value' => $location['location_manual']];
$form['row'][8]['reset_geolocation'] = array(
'type' => 'switch-ng',
'name' => 'Reset GEO location',
//'fieldset' => 'edit',
'size' => 'small',
'readonly' => $readonly,
'on-color' => 'danger',
'off-color' => 'primary',
'on-text' => 'Reset',
'off-text' => 'Keep',
'value' => 0);
$form['row'][8]['reset_geolocation'] = [
'type' => 'switch-ng',
'name' => 'Reset GEO location',
//'fieldset' => 'edit',
'size' => 'small',
'readonly' => $readonly,
'on-color' => 'danger',
'off-color' => 'primary',
'on-text' => 'Reset',
'off-text' => 'Keep',
'value' => 0];
$form['row'][9]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form['row'][9]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);
print_form($form);
unset($form);
// EOF

View File

@ -1,124 +1,120 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
print_message("This page allows you to disable or enable certain Graphs detected for a device.");
$graphs_db = array();
foreach (dbFetchRows("SELECT `graph`,`enabled` FROM `device_graphs` WHERE `device_id` = ?", array($device['device_id'])) as $entry)
{
$graph = $entry['graph'];
$section = $config['graph_types']['device'][$graph]['section'];
$graphs_db[$graph] = (bool)$entry['enabled'];
// Another array sorted by sections
$graphs_sections[$section][$graph] = (bool)$entry['enabled'];
$graphs_db = [];
foreach (dbFetchRows("SELECT `graph`,`enabled` FROM `device_graphs` WHERE `device_id` = ?", [ $device['device_id'] ]) as $entry) {
$graph = $entry['graph'];
$section = $config['graph_types']['device'][$graph]['section'];
$graphs_db[$graph] = (bool)$entry['enabled'];
// Another array sorted by sections
$graphs_sections[$section][$graph] = (bool)$entry['enabled'];
}
if ($vars['submit'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$graph = $vars['toggle_graph'];
if ($graph && isset($graphs_db[$graph]) &&
!in_array($config['graph_types']['device'][$graph]['section'], array('poller', 'system')))
{
$value = (int)!$graphs_db[$graph]; // Toggle current 'enabled' value
$updated = dbUpdate(array('enabled' => $value), 'device_graphs', '`device_id` = ? AND `graph` = ?', array($device['device_id'], $graph));
if ($updated)
{
print_success("Graph '$graph' ".($value ? 'enabled' : 'disabled').'.');
$graphs_sections[$config['graph_types']['device'][$graph]['section']][$graph] = (bool)$value;
}
if ($vars['submit']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$graph = $vars['toggle_graph'];
if ($graph && isset($graphs_db[$graph]) &&
!in_array($config['graph_types']['device'][$graph]['section'], ['poller', 'system'])) {
$value = (int)!$graphs_db[$graph]; // Toggle current 'enabled' value
$updated = dbUpdate(['enabled' => $value], 'device_graphs', '`device_id` = ? AND `graph` = ?', [$device['device_id'], $graph]);
if ($updated) {
print_success("Graph '$graph' " . ($value ? 'enabled' : 'disabled') . '.');
$graphs_sections[$config['graph_types']['device'][$graph]['section']][$graph] = (bool)$value;
}
}
}
}
}
?>
<div class="row"> <!-- begin row -->
<div class="col-md-6"> <!-- begin poller options -->
<div class="row"> <!-- begin row -->
<div class="col-md-6"> <!-- begin poller options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Device Graphs</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Device Graphs</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed-more">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Section</th>
<th style="width: 60px;">Status</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed-more">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Section</th>
<th style="width: 60px;">Status</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
<?php
foreach ($graphs_sections as $section => $entry)
{
foreach ($entry as $graph => $enabled)
{
echo('<tr><td><strong>'.$graph.'</strong></td><td>');
echo($config['graph_types']['device'][$graph]['descr'].'</td><td>');
echo(nicecase($section).'</td><td>');
foreach ($graphs_sections as $section => $entry) {
foreach ($entry as $graph => $enabled) {
echo('<tr><td><strong>' . $graph . '</strong></td><td>');
echo($config['graph_types']['device'][$graph]['descr'] . '</td><td>');
echo(nicecase($section) . '</td><td>');
if (!$enabled)
{
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok';
} else {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
}
if (!$enabled) {
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
} else {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
}
echo($attrib_status.'</td><td>');
echo($attrib_status . '</td><td>');
if (!in_array($section, array('poller', 'system')))
{
$form = array('type' => 'simple');
// Elements
$form['row'][0]['toggle_graph'] = array('type' => 'hidden',
'value' => $graph);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'graph_toggle');
print_form($form); unset($form);
} else {
echo('<button id="submit" name="submit" type="submit" class="btn btn-default btn-mini pull-right disabled text-nowrap" disabled="1" value="Toggle"><i class="icon-lock"></i>&nbsp;Required</button>');
}
if (!in_array($section, ['poller', 'system'])) {
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_graph'] = ['type' => 'hidden',
'value' => $graph];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'graph_toggle'];
print_form($form);
unset($form);
} else {
echo('<button id="submit" name="submit" type="submit" class="btn btn-default btn-mini pull-right disabled text-nowrap" disabled="1" value="Toggle"><i class="icon-lock"></i>&nbsp;Required</button>');
}
echo('</td></tr>');
}
}
?>
</tbody>
</table>
echo('</td></tr>');
}
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end poller options -->
</div>
</div>
</div> <!-- end poller options -->
</div> <!-- end row -->
</div> <!-- end container -->
</div> <!-- end row -->
</div> <!-- end container -->
<?php
// EOF

View File

@ -1,113 +0,0 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
*
*/
if ($vars['editing'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$param = array('icon' => $vars['icon']);
$rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id']));
if ($rows_updated > 0 || $updated)
{
$update_message = "Device icon updated.";
$updated = 1;
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
}
else if ($rows_updated = '-1')
{
$update_message = "Device icon unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device icon update error.";
}
}
if ($updated && $update_message)
{
print_message($update_message);
}
else if ($update_message)
{
print_error($update_message);
}
}
?>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Device icon</h3>
</div>
<form id="edit" name="edit" method="post" action="" class="form form-inline">
<div class="box-body" style="padding: 10px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<input type="hidden" name="editing" value="yes">
<table border="0">
<tr>
<?php
$numicons = 1;
// Default icon
$icon_default = $config['os'][$device['os']]['icon'];
echo(' <td width="64" align="center"><img src="images/os/' . $icon_default . '.png"><br /><i>' . nicecase($icon_default) . '</i><p />');
echo('<input name="icon" type="radio" value="' . $icon_default . '"' . ($device['icon'] == '' || $device['icon'] == $icon_default ? ' checked="1"' : '') . ' /></td>' . "\n");
foreach ($config['os'][$device['os']]['icons'] as $icon_new)
{
if ($icon_new != $icon)
{
echo(' <td align="center"><img src="images/os/' . $icon_new . '.png"><br /><i>' . ucwords(strtr($icon_new, '_', ' ')) . '</i><p />');
echo('<input name="icon" type="radio" value="' . $icon_new . '"' . ($device['icon'] == $icon_new ? ' checked="1"' : '') . ' /></td>' . "\n");
$numicons++;
}
}
if ($numicons %10 == 0)
{
echo(" </tr>\n");
echo(" <tr>\n");
}
?>
</tr>
</table>
<br />
</td>
</tr>
</table>
</div>
<div id="submit" class="box-footer">
<?php
$item = array('id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary',
'icon' => 'icon-ok icon-white',
'value' => 'save');
echo(generate_form_element($item, 'submit'));
?>
</div>
</form>
</div>
<?php
// EOF

View File

@ -4,129 +4,135 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['ipmi_hostname'] != '') { set_dev_attrib($device, 'ipmi_hostname' , $vars['ipmi_hostname']); } else { del_dev_attrib($device, 'ipmi_hostname'); }
if ($vars['ipmi_username'] != '') { set_dev_attrib($device, 'ipmi_username' , $vars['ipmi_username']); } else { del_dev_attrib($device, 'ipmi_username'); }
if ($vars['ipmi_password'] != '') { set_dev_attrib($device, 'ipmi_password' , $vars['ipmi_password']); } else { del_dev_attrib($device, 'ipmi_password'); }
if (is_numeric($vars['ipmi_port'])) { set_dev_attrib($device, 'ipmi_port' , $vars['ipmi_port']); } else { del_dev_attrib($device, 'ipmi_port'); }
// We check interface & userlevel input from the dropdown against the allowed values in the definition array.
if ($vars['ipmi_interface'] != '' && array_search($vars['ipmi_interface'], array_keys($config['ipmi']['interfaces'])) !== FALSE)
{
set_dev_attrib($device, 'ipmi_interface', $vars['ipmi_interface']);
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
del_dev_attrib($device, 'ipmi_interface');
print_error('Invalid interface specified (' . $vars['ipmi_interface'] . ').');
if ($vars['ipmi_hostname'] != '') {
set_dev_attrib($device, 'ipmi_hostname', $vars['ipmi_hostname']);
} else {
del_dev_attrib($device, 'ipmi_hostname');
}
if ($vars['ipmi_username'] != '') {
set_dev_attrib($device, 'ipmi_username', $vars['ipmi_username']);
} else {
del_dev_attrib($device, 'ipmi_username');
}
if ($vars['ipmi_password'] != '') {
set_dev_attrib($device, 'ipmi_password', $vars['ipmi_password']);
} else {
del_dev_attrib($device, 'ipmi_password');
}
if (is_numeric($vars['ipmi_port'])) {
set_dev_attrib($device, 'ipmi_port', $vars['ipmi_port']);
} else {
del_dev_attrib($device, 'ipmi_port');
}
// We check interface & userlevel input from the dropdown against the allowed values in the definition array.
if ($vars['ipmi_interface'] != '' && array_search($vars['ipmi_interface'], array_keys($config['ipmi']['interfaces'])) !== FALSE) {
set_dev_attrib($device, 'ipmi_interface', $vars['ipmi_interface']);
} else {
del_dev_attrib($device, 'ipmi_interface');
print_error('Invalid interface specified (' . $vars['ipmi_interface'] . ').');
}
if ($vars['ipmi_userlevel'] != '' && array_search($vars['ipmi_userlevel'], array_keys($config['ipmi']['userlevels'])) !== FALSE) {
set_dev_attrib($device, 'ipmi_userlevel', $vars['ipmi_userlevel']);
} else {
del_dev_attrib($device, 'ipmi_userlevel');
print_error('Invalid user level specified (' . $vars['ipmi_userlevel'] . ').');
}
$update_message = "Device IPMI data updated.";
$updated = 1;
}
if ($vars['ipmi_userlevel'] != '' && array_search($vars['ipmi_userlevel'], array_keys($config['ipmi']['userlevels'])) !== FALSE)
{
set_dev_attrib($device, 'ipmi_userlevel', $vars['ipmi_userlevel']);
} else {
del_dev_attrib($device, 'ipmi_userlevel');
print_error('Invalid user level specified (' . $vars['ipmi_userlevel'] . ').');
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
}
$update_message = "Device IPMI data updated.";
$updated = 1;
}
if ($updated && $update_message)
{
print_message($update_message);
}
else if ($update_message)
{
print_error($update_message);
}
}
if (!file_exists($config['ipmitool']))
{
print_warning("The ipmitool binary was not found at the configured path (" . $config['ipmitool'] . "). IPMI polling will not work.");
if (!file_exists($config['ipmitool'])) {
print_warning("The ipmitool binary was not found at the configured path (" . $config['ipmitool'] . "). IPMI polling will not work.");
}
$ipmi_userlevels = array();
foreach ($config['ipmi']['userlevels'] as $type => $descr)
{
$ipmi_userlevels[$type] = array('name' => $descr['text']);
$ipmi_userlevels = [];
foreach ($config['ipmi']['userlevels'] as $type => $descr) {
$ipmi_userlevels[$type] = ['name' => $descr['text']];
}
$ipmi_interfaces = array();
foreach ($config['ipmi']['interfaces'] as $type => $descr)
{
$ipmi_interfaces[$type] = array('name' => $descr['text']);
$ipmi_interfaces = [];
foreach ($config['ipmi']['interfaces'] as $type => $descr) {
$ipmi_interfaces[$type] = ['name' => $descr['text']];
}
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'IPMI Settings',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'IPMI Settings',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['ipmi_hostname'] = array(
'type' => 'text',
'name' => 'IPMI Hostname',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_hostname'));
$form['row'][2]['ipmi_port'] = array(
'type' => 'text',
'name' => 'IPMI Port',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_port'));
$form['row'][3]['ipmi_username'] = array(
'type' => 'text',
'name' => 'IPMI Username',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_username'));
$form['row'][4]['ipmi_password'] = array(
'type' => 'password',
'name' => 'IPMI Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => get_dev_attrib($device, 'ipmi_password'));
$form['row'][5]['ipmi_userlevel'] = array(
'type' => 'select',
'name' => 'IPMI Userlevel',
'width' => '250px',
'readonly' => $readonly,
'values' => $ipmi_userlevels,
'value' => get_dev_attrib($device, 'ipmi_userlevel'));
$form['row'][6]['ipmi_interface'] = array(
'type' => 'select',
'name' => 'IPMI Interface',
'width' => '250px',
'readonly' => $readonly,
'values' => $ipmi_interfaces,
'value' => get_dev_attrib($device, 'ipmi_interface'));
$form['row'][7]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['ipmi_hostname'] = [
'type' => 'text',
'name' => 'IPMI Hostname',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_hostname')];
$form['row'][2]['ipmi_port'] = [
'type' => 'text',
'name' => 'IPMI Port',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_port')];
$form['row'][3]['ipmi_username'] = [
'type' => 'text',
'name' => 'IPMI Username',
'width' => '250px',
'readonly' => $readonly,
'value' => get_dev_attrib($device, 'ipmi_username')];
$form['row'][4]['ipmi_password'] = [
'type' => 'password',
'name' => 'IPMI Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => get_dev_attrib($device, 'ipmi_password')];
$form['row'][5]['ipmi_userlevel'] = [
'type' => 'select',
'name' => 'IPMI Userlevel',
'width' => '250px',
'readonly' => $readonly,
'values' => $ipmi_userlevels,
'value' => get_dev_attrib($device, 'ipmi_userlevel')];
$form['row'][6]['ipmi_interface'] = [
'type' => 'select',
'name' => 'IPMI Interface',
'width' => '250px',
'readonly' => $readonly,
'values' => $ipmi_interfaces,
'value' => get_dev_attrib($device, 'ipmi_interface')];
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,7 +14,9 @@ include_once($config['install_dir'] . '/includes/polling/functions.inc.php');
// Fetch all MIBs we support for this specific OS
$mibs = [];
foreach (get_device_mibs($device) as $mib) { $mibs[$mib]++; }
foreach (get_device_mibs($device) as $mib) {
$mibs[$mib]++;
}
// Sort alphabetically
ksort($mibs);
@ -22,248 +24,250 @@ ksort($mibs);
$mibs_disabled = get_device_mibs_disabled($device);
if ($vars['submit']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['toggle_mib'] && isset($mibs[$vars['toggle_mib']])) {
$mib = $vars['toggle_mib'];
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['toggle_mib'] && isset($mibs[$vars['toggle_mib']])) {
$mib = $vars['toggle_mib'];
$mib_disabled = in_array($mib, $mibs_disabled);
if (!$config['mibs'][$mib]['enable']) {
// Globally disabled MIB
$where = "`device_id` = ? AND `use` = ? AND `mib` = ?";
$params = [ $device['device_id'], 'mib', $mib ];
$disabled = dbFetchCell("SELECT `disabled` FROM `devices_mibs` WHERE $where", $params);
//r($disabled);
$mib_disabled = $disabled !== '0';
if ($mib_disabled) {
set_device_mib_enable($device, $mib);
} else {
set_device_mib_disable($device, $mib, TRUE); // really just remove
}
} else {
if ($mib_disabled) {
set_device_mib_enable($device, $mib, TRUE); // really just remove
} else {
set_device_mib_disable($device, $mib);
}
}
$mib_disabled = in_array($mib, $mibs_disabled);
if (!$config['mibs'][$mib]['enable']) {
// Globally disabled MIB
$where = "`device_id` = ? AND `use` = ? AND `mib` = ?";
$params = [$device['device_id'], 'mib', $mib];
$disabled = dbFetchCell("SELECT `disabled` FROM `devices_mibs` WHERE $where", $params);
//r($disabled);
$mib_disabled = $disabled !== '0';
if ($mib_disabled) {
set_device_mib_enable($device, $mib);
} else {
set_device_mib_disable($device, $mib, TRUE); // really just remove
}
} else {
if ($mib_disabled) {
set_device_mib_enable($device, $mib, TRUE); // really just remove
} else {
set_device_mib_disable($device, $mib);
}
}
// reload attribs
unset($cache['devices']['mibs_disabled'][$device['device_id']]);
$mibs_disabled = get_device_mibs_disabled($device);
// reload attribs
unset($cache['devices']['mibs_disabled'][$device['device_id']]);
$mibs_disabled = get_device_mibs_disabled($device);
}
}
}
}
// Count critical errors into DB (only for poller)
$mib_grid = 12;
$mib_grid = 12;
$snmp_errors = [];
if ($config['snmp']['errors']) {
//$poll_period = 300;
$error_codes = $GLOBALS['config']['snmp']['errorcodes'];
$poll_period = $GLOBALS['config']['rrd']['step'];
//$poll_period = 300;
$error_codes = $GLOBALS['config']['snmp']['errorcodes'];
$poll_period = $GLOBALS['config']['rrd']['step'];
$sql = 'SELECT * FROM `snmp_errors` WHERE `device_id` = ?;';
foreach (dbFetchRows($sql, [ $device['device_id'] ]) as $entry) {
$timediff = $entry['updated'] - $entry['added'];
$poll_count = round(float_div($timediff, $poll_period)) + 1;
$sql = 'SELECT * FROM `snmp_errors` WHERE `device_id` = ?;';
foreach (dbFetchRows($sql, [$device['device_id']]) as $entry) {
$timediff = $entry['updated'] - $entry['added'];
$poll_count = round(float_div($timediff, $poll_period)) + 1;
$entry['error_rate'] = float_div($entry['error_count'], $poll_count); // calculate error rate
if ($oid = str_decompress($entry['oid'])) {
// 512 long oid strings is compressed
$entry['oid'] = $oid;
$entry['error_rate'] = float_div($entry['error_count'], $poll_count); // calculate error rate
if ($oid = str_decompress($entry['oid'])) {
// 512 long oid strings is compressed
$entry['oid'] = $oid;
}
$snmp_errors[$entry['mib']][] = $entry;
}
$snmp_errors[$entry['mib']][] = $entry;
}
if (count($snmp_errors)) {
ksort($snmp_errors);
$mib_grid = 5;
}
if (count($snmp_errors)) {
ksort($snmp_errors);
$mib_grid = 5;
}
}
print_warning("This page allows you to disable certain MIBs to be polled for a device. This configuration disables all discovery modules using this MIB.");
?>
<div class="row"> <!-- begin row -->
<div class="row"> <!-- begin row -->
<div class="col-md-<?php echo($mib_grid); ?>"> <!-- begin MIB options -->
<div class="col-md-<?php echo($mib_grid); ?>"> <!-- begin MIB options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Device MIBs</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Device MIBs</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed-more">
<thead>
<tr>
<th style="padding: 0px;"></th>
<th style="padding: 0px; width: 60px;"></th>
<th style="padding: 0px; width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed-more">
<thead>
<tr>
<th style="padding: 0px;"></th>
<th style="padding: 0px; width: 60px;"></th>
<th style="padding: 0px; width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
<?php
foreach ($mibs as $mib => $count) {
$mib_disabled = in_array($mib, $mibs_disabled);
$mib_errors = isset($snmp_errors[$mib]);
foreach ($mibs as $mib => $count) {
$mib_disabled = in_array($mib, $mibs_disabled);
$mib_errors = isset($snmp_errors[$mib]);
if (!$config['mibs'][$mib]['enable']) {
// Globally disabled MIB
$where = "`device_id` = ? AND `use` = ? AND `mib` = ?";
$params = [ $device['device_id'], 'mib', $mib ];
$disabled = dbFetchCell("SELECT `disabled` FROM `devices_mibs` WHERE $where", $params);
//r($disabled);
$mib_disabled = $disabled !== '0';
}
if ($mib_disabled) {
$attrib_status = '<span class="label label-error">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$class = ' class="ignore"';
} else {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
$class = $mib_errors ? ' class="error"' : '';
}
if (!$config['mibs'][$mib]['enable']) {
// Globally disabled MIB
$where = "`device_id` = ? AND `use` = ? AND `mib` = ?";
$params = [$device['device_id'], 'mib', $mib];
$disabled = dbFetchCell("SELECT `disabled` FROM `devices_mibs` WHERE $where", $params);
//r($disabled);
$mib_disabled = $disabled !== '0';
}
if ($mib_disabled) {
$attrib_status = '<span class="label label-error">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$class = ' class="ignore"';
} else {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
$class = $mib_errors ? ' class="error"' : '';
}
echo('<tr'. $class . '><td><strong>' . $mib . '</strong></td><td>' . $attrib_status . '</td><td>');
echo('<tr' . $class . '><td><strong>' . $mib . '</strong></td><td>' . $attrib_status . '</td><td>');
$form = [ 'type' => 'simple' ];
// Elements
$form['row'][0]['toggle_mib'] = [ 'type' => 'hidden',
'value' => $mib ];
$form['row'][0]['submit'] = [ 'type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'mib_toggle' ];
print_form($form);
unset($form);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_mib'] = ['type' => 'hidden',
'value' => $mib];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'mib_toggle'];
print_form($form);
unset($form);
echo('</td></tr>');
}
?>
</tbody>
</table>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end MIB options -->
<?php
</div>
</div>
</div> <!-- end MIB options -->
<?php
if (count($snmp_errors))
{
//r($snmp_errors);
if (count($snmp_errors)) {
//r($snmp_errors);
?>
<div class="col-md-7 col-md-pull-0"> <!-- begin Errors options -->
?>
<div class="col-md-7 col-md-pull-0"> <!-- begin Errors options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">SNMP errors</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">SNMP errors</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped-two table-condensed-more ">
<thead>
<tr>
<th style="padding: 0px; width: 40px;"></th>
<th style="padding: 0px;"></th>
<!--<th style="padding: 0px; width: 60px;"></th>-->
</tr>
</thead>
<tbody>
<table class="table table-striped-two table-condensed-more ">
<thead>
<tr>
<th style="padding: 0px; width: 40px;"></th>
<th style="padding: 0px;"></th>
<!--<th style="padding: 0px; width: 60px;"></th>-->
</tr>
</thead>
<tbody>
<?php
<?php
foreach ($snmp_errors as $mib => $entries)
{
$attrib_set = isset($attribs['mib_'.$mib]);
foreach ($snmp_errors as $mib => $entries) {
$attrib_set = isset($attribs['mib_' . $mib]);
echo('<tr><td><span class="label"><i class="icon-bell"></i> ' . count($entries) . '</span></td>');
echo('<tr><td><span class="label"><i class="icon-bell"></i> ' . count($entries) . '</span></td>');
//if ($attrib_set && $attribs['mib_'.$mib] == 0)
//{
// $attrib_status = '<span class="label label-error">disabled</span>';
//} else {
// $attrib_status = '<span class="label label-success">enabled</span>';
//}
//echo(<td>$attrib_status.'</td>');
//if ($attrib_set && $attribs['mib_'.$mib] == 0)
//{
// $attrib_status = '<span class="label label-error">disabled</span>';
//} else {
// $attrib_status = '<span class="label label-success">enabled</span>';
//}
//echo(<td>$attrib_status.'</td>');
echo('<td><strong>'.$mib.'</strong></td></tr>' . PHP_EOL);
echo('<td><strong>' . $mib . '</strong></td></tr>' . PHP_EOL);
// OIDs here
echo('<tr><td colspan="3">
// OIDs here
echo('<tr><td colspan="3">
<table class="table table-condensed-more">');
foreach ($entries as $error_db)
{
// Detect if error rate is exceeded
$error_both = isset($error_codes[$error_db['error_code']]['count']) && isset($error_codes[$error_db['error_code']]['rate']);
$error_count = isset($error_codes[$error_db['error_code']]['count']) && ($error_codes[$error_db['error_code']]['count'] < $error_db['error_count']);
$error_rate = isset($error_codes[$error_db['error_code']]['rate']) && ($error_codes[$error_db['error_code']]['rate'] < $error_db['error_rate']);
if ($error_both) { $error_exceeded = $error_count && $error_rate; }
else { $error_exceeded = $error_count || $error_rate; }
foreach ($entries as $error_db) {
// Detect if error rate is exceeded
$error_both = isset($error_codes[$error_db['error_code']]['count']) && isset($error_codes[$error_db['error_code']]['rate']);
$error_count = isset($error_codes[$error_db['error_code']]['count']) && ($error_codes[$error_db['error_code']]['count'] < $error_db['error_count']);
$error_rate = isset($error_codes[$error_db['error_code']]['rate']) && ($error_codes[$error_db['error_code']]['rate'] < $error_db['error_rate']);
if ($error_both) {
$error_exceeded = $error_count && $error_rate;
} else {
$error_exceeded = $error_count || $error_rate;
}
if ($error_exceeded)
{
$error_class = 'danger';
$error_class2 = 'error';
} else {
$error_class = $error_class2 = 'warning';
}
$text_class = (count(explode(' ', $error_db['oid'])) > 3 ? '' : 'text-nowrap');
echo('<tr width="100%" class="'.$error_class2.'"><td style="width: 50%;" class="'.$text_class.'"><strong><i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;'.$error_db['oid'].'</strong></td>' . PHP_EOL);
echo('<td style="width: 100px; white-space: nowrap; text-align: right;">'.generate_tooltip_time($error_db['updated'], 'ago').'</td>' . PHP_EOL);
echo('<td style="width: 80px; white-space: nowrap;"><span class="text-'.$error_class.'">'.$error_codes[$error_db['error_code']]['reason'].'</span></td>' . PHP_EOL);
echo('<td style="width: 40px; text-align: right;"><span class="label">'.$error_db['error_count'].'</span></td>' . PHP_EOL);
echo('<td style="width: 80px; text-align: right;"><span class="label">'.round($error_db['error_rate'], 2).'/poll</span></td>' . PHP_EOL);
if ($error_exceeded) {
$error_class = 'danger';
$error_class2 = 'error';
} else {
$error_class = $error_class2 = 'warning';
}
$text_class = (count(explode(' ', $error_db['oid'])) > 3 ? '' : 'text-nowrap');
echo('<tr width="100%" class="' . $error_class2 . '"><td style="width: 50%;" class="' . $text_class . '"><strong><i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;' . $error_db['oid'] . '</strong></td>' . PHP_EOL);
echo('<td style="width: 100px; white-space: nowrap; text-align: right;">' . generate_tooltip_time($error_db['updated'], 'ago') . '</td>' . PHP_EOL);
echo('<td style="width: 80px; white-space: nowrap;"><span class="text-' . $error_class . '">' . $error_codes[$error_db['error_code']]['reason'] . '</span></td>' . PHP_EOL);
echo('<td style="width: 40px; text-align: right;"><span class="label">' . $error_db['error_count'] . '</span></td>' . PHP_EOL);
echo('<td style="width: 80px; text-align: right;"><span class="label">' . round($error_db['error_rate'], 2) . '/poll</span></td>' . PHP_EOL);
echo('<td>' . PHP_EOL);
$form = array('type' => 'simple');
// Elements
$form['row'][0]['mib'] = array('type' => 'hidden',
'value' => $mib);
$form['row'][0]['toggle_oid'] = array('type' => 'hidden',
'value' => $error_db['oid']);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => '',
'class' => 'btn-mini btn-'.$error_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => TRUE, // This button disabled for now, because disabling oids in progress
'value' => 'toggle_oid');
print_form($form); unset($form);
echo('</td>' . PHP_EOL);
echo('<td>' . PHP_EOL);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['mib'] = ['type' => 'hidden',
'value' => $mib];
$form['row'][0]['toggle_oid'] = ['type' => 'hidden',
'value' => $error_db['oid']];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => '',
'class' => 'btn-mini btn-' . $error_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => TRUE, // This button disabled for now, because disabling oids in progress
'value' => 'toggle_oid'];
print_form($form);
unset($form);
echo('</td>' . PHP_EOL);
echo('</td></tr>' . PHP_EOL);
}
echo(' </table>
echo('</td></tr>' . PHP_EOL);
}
echo(' </table>
</td></tr>' . PHP_EOL);
}
?>
</tbody>
</table>
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end Errors options -->
</div>
</div>
</div> <!-- end Errors options -->
<?php } ?>
<?php } ?>
</div> <!-- end row -->
</div> <!-- end container -->
</div> <!-- end row -->
</div> <!-- end container -->
<?php
// EOF

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,374 +14,376 @@ include_once($config['install_dir'] . '/includes/polling/functions.inc.php');
include_once($config['install_dir'] . '/includes/discovery/functions.inc.php');
$ports_ignored_count = (int)get_entity_attrib('device', $device, 'ports_ignored_count'); // Cache last ports ignored count
$ports_total_count = $ports_ignored_count + dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `deleted` = ?', array($device['device_id'], 0));
$ports_total_count = $ports_ignored_count + dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `deleted` = ?', [$device['device_id'], 0]);
if ($vars['submit'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['toggle_poller'] && isset($config['poller_modules'][$vars['toggle_poller']]))
{
$module = $vars['toggle_poller'];
if (isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] != $config['poller_modules'][$module])
{
del_dev_attrib($device, 'poll_' . $module);
} elseif ($config['poller_modules'][$module] == 0) {
set_dev_attrib($device, 'poll_' . $module, "1");
} else {
set_dev_attrib($device, 'poll_' . $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
}
if ($vars['submit']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['toggle_poller'] && isset($config['poller_modules'][$vars['toggle_poller']])) {
$module = $vars['toggle_poller'];
if (isset($attribs['poll_' . $module]) && $attribs['poll_' . $module] != $config['poller_modules'][$module]) {
del_dev_attrib($device, 'poll_' . $module);
} elseif ($config['poller_modules'][$module] == 0) {
set_dev_attrib($device, 'poll_' . $module, "1");
} else {
set_dev_attrib($device, 'poll_' . $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
}
if ($vars['toggle_ports'] && isset($config[$vars['toggle_ports']]) && strpos($vars['toggle_ports'], 'enable_ports_') === 0)
{
$module = $vars['toggle_ports'];
$module_name = str_replace('enable_', '', $module);
if (isset($config['os'][$device['os']]['modules'][$module_name]))
{
$config_val = $config['os'][$device['os']]['modules'][$module_name];
} else {
$config_val = $config[$module];
}
if ($vars['submit'] === 'Disable' && $attribs[$module] !== '0')
{
set_dev_attrib($device, $module, "0");
}
elseif (isset($attribs[$module]) && $attribs[$module] != $config_val)
{
del_dev_attrib($device, $module);
} elseif ($config_val == 0) {
set_dev_attrib($device, $module, "1");
} else {
set_dev_attrib($device, $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
}
if ($vars['toggle_ports'] && isset($config[$vars['toggle_ports']]) && str_starts_with($vars['toggle_ports'], 'enable_ports_')) {
$module = $vars['toggle_ports'];
$module_name = str_replace('enable_', '', $module);
if ($vars['toggle_discovery'] && isset($config['discovery_modules'][$vars['toggle_discovery']]))
{
$module = $vars['toggle_discovery'];
if (isset($attribs['discover_'.$module]) && $attribs['discover_'.$module] != $config['discovery_modules'][$module])
{
del_dev_attrib($device, 'discover_' . $module);
} elseif ($config['discovery_modules'][$module] == 0) {
set_dev_attrib($device, 'discover_' . $module, "1");
} else {
set_dev_attrib($device, 'discover_' . $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
del_entity_attrib('device', $device, $module);
$config_val = is_module_enabled($device, $module_name, 'poller'); // Note, it's also with attrib check!
if ($vars['submit'] === 'Disable' && $attribs[$module] !== '0') {
//set_dev_attrib($device, $module, "0");
set_entity_attrib('device', $device, $module, '0');
} elseif (isset($attribs[$module]) && $attribs[$module] != $config_val) {
//del_dev_attrib($device, $module);
} elseif ($config_val == 0) {
//set_dev_attrib($device, $module, "1");
set_entity_attrib('device', $device, $module, '1');
} else {
//set_dev_attrib($device, $module, "0");
set_entity_attrib('device', $device, $module, '0');
}
$attribs = get_entity_attribs('device', $device);
}
if ($vars['toggle_discovery'] && isset($config['discovery_modules'][$vars['toggle_discovery']])) {
$module = $vars['toggle_discovery'];
if (isset($attribs['discover_' . $module]) && $attribs['discover_' . $module] != $config['discovery_modules'][$module]) {
del_dev_attrib($device, 'discover_' . $module);
} elseif ($config['discovery_modules'][$module] == 0) {
set_dev_attrib($device, 'discover_' . $module, "1");
} else {
set_dev_attrib($device, 'discover_' . $module, "0");
}
$attribs = get_dev_attribs($device['device_id']);
}
}
}
}
//r($device_state);
?>
<div class="row"> <!-- begin row -->
<div class="row"> <!-- begin row -->
<div class="col-md-6"> <!-- begin poller options -->
<div class="col-md-6"> <!-- begin poller options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Poller Modules</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Poller Modules</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last Poll</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last Poll</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
foreach (array_merge(array('os' => 1, 'system' => 1), $config['poller_modules']) as $module => $module_status)
{
//$module_status = is_module_enabled($device, $module, 'poller');
$attrib_set = isset($attribs['poll_'.$module]);
<?php
foreach (array_merge(['os' => 1, 'system' => 1], $config['poller_modules']) as $module => $module_status) {
//$module_status = is_module_enabled($device, $module, 'poller');
$attrib_set = isset($attribs['poll_' . $module]);
// Last module poll time and row class
$module_row_class = '';
if (!isset($device_state['poller_mod_perf'][$module]))
{
$module_time = '--';
}
elseif ($device_state['poller_mod_perf'][$module] < 0.01)
{
$module_time = $device_state['poller_mod_perf'][$module] . 's';
} else {
$module_time = format_value($device_state['poller_mod_perf'][$module]) . 's';
// Last module poll time and row class
$module_row_class = '';
if (!isset($device_state['poller_mod_perf'][$module])) {
$module_time = '--';
} elseif ($device_state['poller_mod_perf'][$module] < 0.01) {
$module_time = $device_state['poller_mod_perf'][$module] . 's';
} else {
$module_time = format_value($device_state['poller_mod_perf'][$module]) . 's';
if ($device_state['poller_mod_perf'][$module] > 10)
{
$module_row_class = 'error';
}
elseif ($device_state['poller_mod_perf'][$module] > 3)
{
$module_row_class = 'warning';
}
}
if ($device_state['poller_mod_perf'][$module] > 10) {
$module_row_class = 'error';
} elseif ($device_state['poller_mod_perf'][$module] > 3) {
$module_row_class = 'warning';
}
}
echo('<tr class="'.$module_row_class.'"><td><strong>'.$module.'</strong></td>');
echo('<td>'.$module_time.'</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$disabled = FALSE;
if ($module === 'os' || $module === 'system') {
$attrib_status = '<span class="label label-default">locked</span>';
$toggle = "Locked";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (poller_module_excluded($device, $module)) {
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (is_module_enabled($device, $module, 'poller')) {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
} elseif ($module_status) {
// highlight disabled module on device
$module_row_class = 'suppressed';
}
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok';
$disabled = FALSE;
if ($module == 'os' || $module == 'system')
{
$attrib_status = '<span class="label label-default">locked</span>';
$toggle = "Locked"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
}
elseif (poller_module_excluded($device, $module))
{
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
}
//elseif (($attrib_set && $attribs['poll_'.$module]) || (!$attrib_set && $module_status))
elseif (is_module_enabled($device, $module, 'poller'))
{
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
}
echo($attrib_status.'</td><td>');
echo('<tr class="' . $module_row_class . '"><td><strong>' . $module . '</strong></td>');
echo('<td>' . $module_time . '</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
echo($attrib_status . '</td><td>');
$form = array('type' => 'simple');
// Elements
$form['row'][0]['toggle_poller'] = array('type' => 'hidden',
'value' => $module);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => 'Toggle');
print_form($form); unset($form);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_poller'] = ['type' => 'hidden',
'value' => $module];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => 'Toggle'];
print_form($form);
unset($form);
echo('</td></tr>');
}
?>
</tbody>
</table>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end poller options -->
</div>
</div>
</div> <!-- end poller options -->
<div class="col-md-6"> <!-- begin ports options -->
<div class="col-md-6"> <!-- begin ports options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Ports polling options</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Ports polling options</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last Poll</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last Poll</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
foreach (array_keys($config) as $module) {
if (!str_starts($module, 'enable_ports_')) { continue; }
<?php
foreach (array_keys($config) as $module) {
if (!str_starts($module, 'enable_ports_')) {
continue;
}
$attrib_set = isset($attribs[$module]);
$module_name = str_replace('enable_ports_', '', $module);
$module_status = is_module_enabled($device, 'ports_'.$module_name, 'poller', FALSE);
$attrib_set = isset($attribs[$module]);
$module_name = str_replace('enable_ports_', '', $module);
$module_status = is_module_enabled($device, 'ports_' . $module_name, 'poller');
// Last ports module poll time and row class
$module_row_class = '';
if ($module_name === 'separate_walk' || $module_name === '64bit') {
$module_time = ''; // nothing to show for this pseudo-module
} elseif (!isset($device_state['poller_ports_perf'][$module_name])) {
$module_time = '--';
} elseif ($device_state['poller_ports_perf'][$module_name] < 0.01) {
$module_time = $device_state['poller_ports_perf'][$module_name] . 's';
} else {
$module_time = format_value($device_state['poller_ports_perf'][$module_name]) . 's';
// Last ports module poll time and row class
$module_row_class = '';
if ($module_name === 'separate_walk' || $module_name === '64bit') {
$module_time = ''; // nothing to show for this pseudo-module
} elseif (!isset($device_state['poller_ports_perf'][$module_name])) {
$module_time = '--';
} elseif ($device_state['poller_ports_perf'][$module_name] < 0.01) {
$module_time = $device_state['poller_ports_perf'][$module_name] . 's';
} else {
$module_time = format_value($device_state['poller_ports_perf'][$module_name]) . 's';
if ($device_state['poller_ports_perf'][$module_name] > 10) {
$module_row_class = 'error';
} elseif ($device_state['poller_ports_perf'][$module_name] > 3) {
$module_row_class = 'warning';
}
}
if ($device_state['poller_ports_perf'][$module_name] > 10) {
$module_row_class = 'error';
} elseif ($device_state['poller_ports_perf'][$module_name] > 3) {
$module_row_class = 'warning';
}
}
echo('<tr class="'.$module_row_class.'"><td><strong>'.$module_name.'</strong></td>');
echo('<td>'.$module_time.'</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
echo('<tr class="' . $module_row_class . '"><td><strong>' . $module_name . '</strong></td>');
echo('<td>' . $module_time . '</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok';
$value = 'Toggle';
$disabled = FALSE;
if ($module === 'enable_ports_junoseatmvp' && $device['os'] !== 'junose') { /// FIXME. see here includes/discovery/junose-atm-vp.inc.php
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (($attrib_set && $attribs[$module]) || (!$attrib_set && $module_status)) {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
} elseif ($module === 'enable_ports_separate_walk' && !$attrib_set) {
// Model definition can override os definition
$model_separate_walk = isset($model['ports_separate_walk']) && $model['ports_separate_walk'];
if ($model_separate_walk && $ports_total_count > 10) {
$attrib_status = '<span class="label label-warning">FORCED</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
$value = 'Disable';
} elseif ((int)$device['state']['poller_mod_perf']['ports'] < 20 && $ports_total_count <= 10) {
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
}
}
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$value = 'Toggle';
$disabled = FALSE;
if ($module === 'enable_ports_junoseatmvp' && $device['os'] !== 'junose') { /// FIXME. see here includes/discovery/junose-atm-vp.inc.php
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (($attrib_set && $attribs[$module]) || (!$attrib_set && $module_status)) {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
} elseif ($module === 'enable_ports_separate_walk' && !$attrib_set) {
// Model definition can override os definition
$model_separate_walk = isset($model['ports_separate_walk']) && $model['ports_separate_walk'];
if ($model_separate_walk && $ports_total_count > 10) {
$attrib_status = '<span class="label label-warning">FORCED</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
$value = 'Disable';
} elseif ((int)$device['state']['poller_mod_perf']['ports'] < 20 && $ports_total_count <= 10) {
$attrib_status = '<span class="label label-default">excluded</span>';
$toggle = "Excluded";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
}
}
echo($attrib_status . '</td><td>');
echo($attrib_status . '</td><td>');
$form = array('type' => 'simple');
// Elements
$form['row'][0]['toggle_ports'] = array('type' => 'hidden',
'value' => $module);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => $value);
print_form($form); unset($form);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_ports'] = ['type' => 'hidden',
'value' => $module];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => $value];
print_form($form);
unset($form);
echo('</td></tr>');
}
?>
</tbody>
</table>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end ports options -->
</div>
</div>
</div> <!-- end ports options -->
<div class="col-md-6"> <!-- begin discovery options -->
<div class="col-md-6"> <!-- begin discovery options -->
<div class="box box-solid">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Discovery Modules</h3>
</div>
<div class="box-body no-padding">
<div class="box-header with-border">
<h3 class="box-title">Discovery Modules</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Module</th>
<th style="width: 60px;">Last</th>
<th style="width: 60px;">Global</th>
<th style="width: 60px;">Device</th>
<th style="width: 80px;"></th>
</tr>
</thead>
<tbody>
<?php
foreach ($config['discovery_modules'] as $module => $module_status)
{
//$module_status = is_module_enabled($device, $module, 'discovery');
$attrib_set = isset($attribs['discover_'.$module]);
<?php
foreach ($config['discovery_modules'] as $module => $module_status) {
//$module_status = is_module_enabled($device, $module, 'discovery');
$attrib_set = isset($attribs['discover_' . $module]);
// Last module discovery time and row class
$module_row_class = '';
if (!isset($device_state['discovery_mod_perf'][$module]))
{
$module_time = '--';
}
elseif ($device_state['discovery_mod_perf'][$module] < 0.01)
{
$module_time = $device_state['discovery_mod_perf'][$module] . 's';
} else {
$module_time = format_value($device_state['discovery_mod_perf'][$module]) . 's';
// Last module discovery time and row class
$module_row_class = '';
if (!isset($device_state['discovery_mod_perf'][$module])) {
$module_time = '--';
} elseif ($device_state['discovery_mod_perf'][$module] < 0.01) {
$module_time = $device_state['discovery_mod_perf'][$module] . 's';
} else {
$module_time = format_value($device_state['discovery_mod_perf'][$module]) . 's';
if ($device_state['discovery_mod_perf'][$module] > 10)
{
$module_row_class = 'error';
}
elseif ($device_state['discovery_mod_perf'][$module] > 3)
{
$module_row_class = 'warning';
}
}
if ($device_state['discovery_mod_perf'][$module] > 10) {
$module_row_class = 'error';
} elseif ($device_state['discovery_mod_perf'][$module] > 3) {
$module_row_class = 'warning';
}
}
echo('<tr class="'.$module_row_class.'"><td><strong>'.$module.'</strong></td>');
echo('<td>'.$module_time.'</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
echo('<tr class="' . $module_row_class . '"><td><strong>' . $module . '</strong></td>');
echo('<td>' . $module_time . '</td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable'; $btn_class = 'btn-success'; $btn_icon = 'icon-ok';
$disabled = FALSE;
$attrib_status = '<span class="label label-important">disabled</span>';
$toggle = 'Enable';
$btn_class = 'btn-success';
$btn_icon = 'icon-ok';
$disabled = FALSE;
if (in_array($module, (array)$config['os'][$device['os']]['discovery_blacklist']))
{
$attrib_status = '<span class="label label-disabled">excluded</span>';
$toggle = "Excluded"; $btn_class = ''; $btn_icon = 'icon-lock';
$disabled = TRUE;
}
//elseif (($attrib_set && $attribs['discover_'.$module]) || (!$attrib_set && $module_status))
elseif (is_module_enabled($device, $module, 'discovery'))
{
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable"; $btn_class = "btn-danger"; $btn_icon = 'icon-remove';
}
if (in_array($module, (array)$config['os'][$device['os']]['discovery_blacklist'])) {
$attrib_status = '<span class="label label-disabled">excluded</span>';
$toggle = "Excluded";
$btn_class = '';
$btn_icon = 'icon-lock';
$disabled = TRUE;
} elseif (is_module_enabled($device, $module, 'discovery')) {
$attrib_status = '<span class="label label-success">enabled</span>';
$toggle = "Disable";
$btn_class = "btn-danger";
$btn_icon = 'icon-remove';
}
echo($attrib_status . '</td><td>');
echo($attrib_status . '</td><td>');
$form = array('type' => 'simple');
// Elements
$form['row'][0]['toggle_discovery'] = array('type' => 'hidden',
'value' => $module);
$form['row'][0]['submit'] = array('type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => 'Toggle');
print_form($form); unset($form);
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_discovery'] = ['type' => 'hidden',
'value' => $module];
$form['row'][0]['submit'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'disabled' => $disabled,
'value' => 'Toggle'];
print_form($form);
unset($form);
echo('</td></tr>');
}
?>
</tbody>
</table>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div> </div>
</div> <!-- end discovery options -->
</div>
</div>
</div> <!-- end discovery options -->
</div> <!-- end row -->
</div> <!-- end row -->
<?php
// EOF

View File

@ -4,102 +4,102 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$svcs = dbFetchRows("SELECT * FROM `netscaler_services` WHERE `device_id` = ? ORDER BY `svc_name`", array($device['device_id']));
$svcs = dbFetchRows("SELECT * FROM `netscaler_services` WHERE `device_id` = ? ORDER BY `svc_name`", [$device['device_id']]);
#print_vars($svcs);
if ($vars['submit'] == "update-svcs")
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
foreach ($svcs as $svc)
{
if ($vars['svcs'][$svc['svc_id']]['svc_ignore'] == 'on' || $vars['svcs'][$svc['svc_id']]['svc_ignore'] == '1') { $vars['svcs'][$svc['svc_id']]['svc_ignore'] = "1"; } else { $vars['svcs'][$svc['svc_id']]['svc_ignore'] = "0"; }
if ($vars['submit'] == "update-svcs") {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
foreach ($svcs as $svc) {
if ($vars['svcs'][$svc['svc_id']]['svc_ignore'] == 'on' || $vars['svcs'][$svc['svc_id']]['svc_ignore'] == '1') {
$vars['svcs'][$svc['svc_id']]['svc_ignore'] = "1";
} else {
$vars['svcs'][$svc['svc_id']]['svc_ignore'] = "0";
}
foreach (array('svc_ignore','svc_limit_low','svc_limit') as $field)
{
if ($vars['svcs'][$svc['svc_id']][$field] != $svc[$field]) { $sup[$field] = $vars['svcs'][$svc['svc_id']][$field]; }
}
foreach (['svc_ignore', 'svc_limit_low', 'svc_limit'] as $field) {
if ($vars['svcs'][$svc['svc_id']][$field] != $svc[$field]) {
$sup[$field] = $vars['svcs'][$svc['svc_id']][$field];
}
}
if (is_array($sup))
{
dbUpdate($sup, 'netscaler_services', '`svc_id` = ?', array($svc['svc_id']));
$did_update = TRUE;
}
unset($sup);
if (is_array($sup)) {
dbUpdate($sup, 'netscaler_services', '`svc_id` = ?', [$svc['svc_id']]);
$did_update = TRUE;
}
unset($sup);
}
$svcs = dbFetchRows("SELECT * FROM `netscaler_services` WHERE `device_id` = ? ORDER BY `svc_label`", [$device['device_id']]);
}
$svcs = dbFetchRows("SELECT * FROM `netscaler_services` WHERE `device_id` = ? ORDER BY `svc_label`", array($device['device_id']));
}
}
?>
<form id='update-svcs' name='update-svcs' method='post' action=''>
<fieldset>
<legend>Netscaler Service Properties</legend>
<form id='update-svcs' name='update-svcs' method='post' action=''>
<fieldset>
<legend>Netscaler Service Properties</legend>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 120px;">Type</th>
<th>Name</th>
<th style="width: 120px;">Status</th>
<th style="width: 80px;">Alerts</th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 120px;">Type</th>
<th>Name</th>
<th style="width: 120px;">Status</th>
<th style="width: 80px;">Alerts</th>
</tr>
</thead>
<tbody>
<?php
$row=1;
foreach ($svcs as $svc)
{
<?php
$row = 1;
foreach ($svcs as $svc) {
echo('<tr>');
echo('<td>'.escape_html($svc['svc_type']).'</td>');
echo('<td>'.escape_html($svc['svc_label']).'</td>');
echo('<td>'.escape_html($svc['svc_state']).'</td>');
$item = array(
'id' => 'svcs['.$svc['svc_id'].'][svc_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $svc['svc_ignore']);
echo('<td>'.generate_form_element($item).'</td>');
echo('</tr>');
}
?>
echo('<tr>');
echo('<td>' . escape_html($svc['svc_type']) . '</td>');
echo('<td>' . escape_html($svc['svc_label']) . '</td>');
echo('<td>' . escape_html($svc['svc_state']) . '</td>');
$item = [
'id' => 'svcs[' . $svc['svc_id'] . '][svc_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $svc['svc_ignore']];
echo('<td>' . generate_form_element($item) . '</td>');
echo('</tr>');
}
?>
</tbody>
</table>
</fieldset>
</tbody>
</table>
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="update-svcs"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</form>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="update-svcs"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</form>
<?php
// EOF

View File

@ -4,102 +4,102 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$vsvrs = dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_label`", array($device['device_id']));
$vsvrs = dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_label`", [$device['device_id']]);
#print_r($vsvrs);
if ($vars['submit'] == "update-vsvrs")
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
foreach ($vsvrs as $vsvr)
{
if ($vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] == 'on' || $vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] == '1') { $vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] = "1"; } else { $vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] = "0"; }
if ($vars['submit'] == "update-vsvrs") {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
foreach ($vsvrs as $vsvr) {
if ($vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] == 'on' || $vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] == '1') {
$vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] = "1";
} else {
$vars['vsvrs'][$vsvr['vsvr_id']]['vsvr_ignore'] = "0";
}
foreach (array('vsvr_ignore','vsvr_limit_low','vsvr_limit') as $field)
{
if ($vars['vsvrs'][$vsvr['vsvr_id']][$field] != $vsvr[$field]) { $sup[$field] = $vars['vsvrs'][$vsvr['vsvr_id']][$field]; }
}
foreach (['vsvr_ignore', 'vsvr_limit_low', 'vsvr_limit'] as $field) {
if ($vars['vsvrs'][$vsvr['vsvr_id']][$field] != $vsvr[$field]) {
$sup[$field] = $vars['vsvrs'][$vsvr['vsvr_id']][$field];
}
}
if (is_array($sup))
{
dbUpdate($sup, 'netscaler_vservers', '`vsvr_id` = ?', array($vsvr['vsvr_id']));
$did_update = TRUE;
}
unset($sup);
if (is_array($sup)) {
dbUpdate($sup, 'netscaler_vservers', '`vsvr_id` = ?', [$vsvr['vsvr_id']]);
$did_update = TRUE;
}
unset($sup);
}
$vsvrs = dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_label`", [$device['device_id']]);
}
$vsvrs = dbFetchRows("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ? ORDER BY `vsvr_label`", array($device['device_id']));
}
}
?>
<form id='update-vsvrs' name='update-vsvrs' method='post' action=''>
<fieldset>
<legend>Netscaler vServer Properties</legend>
<form id='update-vsvrs' name='update-vsvrs' method='post' action=''>
<fieldset>
<legend>Netscaler vServer Properties</legend>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 120px;">MIB Type</th>
<th>Name</th>
<th style="width: 60px;">Status</th>
<th style="width: 50px;">Alerts</th>
</tr>
</thead>
<tbody>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="width: 120px;">MIB Type</th>
<th>Name</th>
<th style="width: 60px;">Status</th>
<th style="width: 50px;">Alerts</th>
</tr>
</thead>
<tbody>
<?php
$row=1;
foreach ($vsvrs as $vsvr)
{
<?php
$row = 1;
foreach ($vsvrs as $vsvr) {
echo('<tr>');
echo('<td>'.escape_html($vsvr['vsvr_type']).'</td>');
echo('<td>'.escape_html($vsvr['vsvr_label']).'</td>');
echo('<td>'.escape_html($vsvr['vsvr_state']).'</td>');
$item = array(
'id' => 'vsvrs['.$vsvr['vsvr_id'].'][vsvr_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $vsvr['vsvr_ignore']);
echo('<td>'.generate_form_element($item).'</td>');
echo('</tr>');
}
?>
echo('<tr>');
echo('<td>' . escape_html($vsvr['vsvr_type']) . '</td>');
echo('<td>' . escape_html($vsvr['vsvr_label']) . '</td>');
echo('<td>' . escape_html($vsvr['vsvr_state']) . '</td>');
$item = [
'id' => 'vsvrs[' . $vsvr['vsvr_id'] . '][vsvr_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $vsvr['vsvr_ignore']];
echo('<td>' . generate_form_element($item) . '</td>');
echo('</tr>');
}
?>
</tbody>
</table>
</fieldset>
</tbody>
</table>
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="update-vsvrs"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</form>
<div class="form-actions">
<button type="submit" class="btn btn-primary" name="submit" value="update-vsvrs"><i class="icon-ok icon-white"></i> Save Changes</button>
</div>
</form>
<?php
// EOF

View File

@ -6,12 +6,12 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
if ($readonly && $vars['ignoreport']) {
print_error_permission('You have insufficient permissions to edit settings.');
print_error_permission('You have insufficient permissions to edit settings.');
}
?>
@ -26,27 +26,27 @@ if ($readonly && $vars['ignoreport']) {
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element([ 'type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
echo generate_form_element(['type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken']]) . PHP_EOL;
}
$item = [
'id' => 'action',
'id' => 'action',
//'readonly' => $readonly,
'value' => 'ports_update'
];
echo(generate_form_element($item, 'hidden'));
$item = [
'id' => 'ignoreport',
'id' => 'ignoreport',
'readonly' => $readonly,
'value' => 'yes'
'value' => 'yes'
];
echo(generate_form_element($item, 'hidden'));
$item = [
'id' => 'device',
'id' => 'device',
'readonly' => $readonly,
'value' => $device['device_id']
'value' => $device['device_id']
];
echo(generate_form_element($item, 'hidden'));
@ -79,8 +79,8 @@ if ($readonly && $vars['ignoreport']) {
id="alerted-toggle" title="Toggle alerting on all currently-alerted ports">Enabled &
Down
</button>
<button class="btn btn-xs" value="Disabled" id="down-select"
title="Disable alerting on all currently-down ports">Disabled
<button class="btn btn-xs" value="All Down" id="down-select"
title="Disable alerting on all currently-down ports">All Down
</button>
</td>
<td class="text-center">
@ -117,52 +117,52 @@ if ($readonly && $vars['ignoreport']) {
$ports_attribs = get_device_entities_attribs($device['device_id'], 'port'); // Get all attribs
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `deleted` = '0' AND `device_id` = ? ORDER BY `ifIndex` ", array($device['device_id'])) as $port) {
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `deleted` = '0' AND `device_id` = ? ORDER BY CAST(`ifIndex` as SIGNED INTEGER) ", [$device['device_id']]) as $port) {
humanize_port($port);
if (isset($ports_attribs['port'][$port['port_id']])) {
$port = array_merge($port, $ports_attribs['port'][$port['port_id']]);
}
echo('<tr class="' . $port['row_class'] . ' vertical-align">');
echo('<tr class="' . $port['row_class'] . ' vertical-align" data-name="port_' . $port['port_id'] . '">');
echo('<td class="state-marker"></td>');
echo("<td>" . $port['ifIndex'] . "</td>");
echo('<td style="vertical-align: top;"><span class="entity">' . generate_entity_link('port', $port) . '</span><br />' . escape_html($port['ifAlias']) . '</td>');
echo '<td><span class="label label-'.get_type_class($port['ifType']).'">' . $port['human_type'] . '</span><br />';
echo '<td><span class="label label-' . get_type_class($port['ifType']) . '">' . $port['human_type'] . '</span><br />';
//r($port);
echo ('<span class="label label-'.$port['admin_class'].'">' . $port['admin_status'] . '</span>
echo('<span class="label label-' . $port['admin_class'] . '">' . $port['admin_status'] . '</span>
<span data-name="operstatus_' . $port['port_id'] . '" class="label label-' . $port['oper_class'] . '">' . escape_html($port['ifOperStatus']) . '</span></td>');
echo('<td class="text-center">');
$item = array('id' => 'port['.$port['port_id'].']',
'readonly' => $readonly,
'value' => $port['port_id']);
$item = ['id' => 'port[' . $port['port_id'] . ']',
'readonly' => $readonly,
'value' => $port['port_id']];
echo(generate_form_element($item, 'hidden'));
$item = array('id' => 'port[' . $port['port_id'] . '][disabled]',
'size' => 'mini',
'on-text' => 'Disable',
'on-color' => 'danger',
'off-text' => 'Poll',
'off-color' => 'success',
'width' => '58px',
'readonly' => $readonly,
'value' => $port['disabled']);
$item = ['id' => 'port[' . $port['port_id'] . '][disabled]',
'size' => 'mini',
'on-text' => 'Disable',
'on-color' => 'danger',
'off-text' => 'Poll',
'off-color' => 'success',
'width' => '58px',
'readonly' => $readonly,
'value' => $port['disabled']];
echo(generate_form_element($item, 'switch-ng'));
echo("</td>");
echo('<td class="text-center">');
$item = array('id' => 'port[' . $port['port_id'] . '][ignore]',
'size' => 'mini',
'on-text' => 'Ignore',
'on-color' => 'danger',
'off-text' => 'Alerts',
'off-color' => 'success',
'width' => '58px',
'readonly' => $readonly,
'value' => $port['ignore']);
$item = ['id' => 'port[' . $port['port_id'] . '][ignore]',
'size' => 'mini',
'on-text' => 'Ignore',
'on-color' => 'danger',
'off-text' => 'Alerts',
'off-color' => 'success',
'width' => '58px',
'readonly' => $readonly,
'value' => $port['ignore']];
echo(generate_form_element($item, 'switch-ng'));
echo("</td>");
@ -176,27 +176,27 @@ if ($readonly && $vars['ignoreport']) {
// Custom port speed
echo '<td class="text-nowrap">';
$ifSpeed_custom_bool = isset($port['ifSpeed_custom']);
$ifSpeed = $ifSpeed_custom_bool ? $port['ifSpeed_custom'] : $port['ifSpeed'];
$item = array('id' => 'port[' . $port['port_id'] . '][ifSpeed_custom]',
//'name' => 'Group name',
'placeholder' => formatRates($port['ifSpeed'], 4, 4),
'disabled' => !$ifSpeed_custom_bool,
'width' => '75px',
'readonly' => $readonly,
//'ajax' => TRUE,
//'ajax_vars' => array('field' => 'ifspeed'),
'value' => formatRates($ifSpeed, 4, 4));
$ifSpeed = $ifSpeed_custom_bool ? $port['ifSpeed_custom'] : $port['ifSpeed'];
$item = ['id' => 'port[' . $port['port_id'] . '][ifSpeed_custom]',
//'name' => 'Group name',
'placeholder' => format_bps($port['ifSpeed'], 4, 4),
'disabled' => !$ifSpeed_custom_bool,
'width' => '75px',
'readonly' => $readonly,
//'ajax' => TRUE,
//'ajax_vars' => array('field' => 'ifspeed'),
'value' => format_bps($ifSpeed, 4, 4)];
echo(generate_form_element($item, 'text'));
echo('</td>');
echo '<td>';
// Custom port speed toggle switch
$item = array('id' => 'port[' . $port['port_id'] . '][ifSpeed_custom_bool]',
'size' => 'large',
'view' => $locked ? 'lock' : 'square', // note this is data-tt-type, but 'type' key reserved for element type
'onchange' => "toggleAttrib('disabled', obj.attr('data-onchange-id'));",
'onchange-id' => 'port[' . $port['port_id'] . '][ifSpeed_custom]', // target id for onchange, set attrib: data-onchange-id
'value' => (bool)$ifSpeed_custom_bool);
$item = ['id' => 'port[' . $port['port_id'] . '][ifSpeed_custom_bool]',
'size' => 'large',
'view' => $locked ? 'lock' : 'square', // note this is data-tt-type, but 'type' key reserved for element type
'onchange' => "toggleAttrib('disabled', obj.attr('data-onchange-id'));",
'onchange-id' => 'port[' . $port['port_id'] . '][ifSpeed_custom]', // target id for onchange, set attrib: data-onchange-id
'value' => (bool)$ifSpeed_custom_bool];
echo(generate_form_element($item, 'toggle'));
echo '</span>';
@ -206,7 +206,7 @@ if ($readonly && $vars['ignoreport']) {
echo '<td>';
if ($port['port_64bit'] == 1) {
echo '<span class="label label-success">64bit</span>';
} else if ($port['port_64bit'] == 0) {
} elseif ($port['port_64bit'] == 0) {
echo '<span class="label label-warning">32bit</span>';
} else {
echo '<span class="label">Unchecked</span>';
@ -214,7 +214,7 @@ if ($readonly && $vars['ignoreport']) {
echo '</td></tr>' . PHP_EOL;
$row++;
//$row++;
}
?>
</table>
@ -222,12 +222,12 @@ if ($readonly && $vars['ignoreport']) {
<div id="submit" class="box-footer">
<?php
$item = array('id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary pull-right',
'icon' => 'icon-ok icon-white',
'readonly' => $readonly,
'value' => 'save');
$item = ['id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary pull-right',
'icon' => 'icon-ok icon-white',
'readonly' => $readonly,
'value' => 'save'];
echo(generate_form_element($item, 'submit'));
?>
</div>
@ -237,7 +237,7 @@ if ($readonly && $vars['ignoreport']) {
<script type="text/javascript">
$('#disable-toggle').click(function (event) {
// invert selection on all disable buttons
// invert selection on all disabled buttons
event.preventDefault();
$('[name$="[disabled]"]').each(function () {
$(this).bootstrapToggle('toggle');
@ -257,7 +257,8 @@ if ($readonly && $vars['ignoreport']) {
event.preventDefault();
$('.error').each(function () {
var name = $(this).attr('data-name');
if (name) {
if (name.match("^port_")) {
//console.log(name);
// get the interface number from the object name
var port_id = name.split('_')[1];
// find its corresponding checkbox and toggle it

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,7 +14,7 @@ $query = 'SELECT * FROM `sensors`
WHERE `device_id` = ? AND `sensor_deleted` = 0
ORDER BY `sensor_class`,`sensor_type`,`sensor_index`;';
$sensors = dbFetchRows($query, array($device['device_id']));
$sensors = dbFetchRows($query, [$device['device_id']]);
//foreach ($limits_reset_array as $class => $descr)
//{
@ -24,213 +24,214 @@ $sensors = dbFetchRows($query, array($device['device_id']));
?>
<form id="update-sensors">
<form id="update-sensors">
<input type="hidden" name="action" value="sensors_update">
<input type="hidden" name="action" value="sensors_update">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Sensor Properties</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed vertical-align">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Sensor Properties</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed vertical-align">
<thead>
<tr>
<th class="state-marker" rowspan="2"></th>
<th rowspan="2">Description &amp; MIB</th>
<th style="width: 100px;" rowspan="2">Class</th>
<th style="width: 60px;" rowspan="2">Current</th>
<th style="width: 250px; white-space: nowrap;" colspan="6">Limits</th>
<th style="width: 50px;" rowspan="2">Alerts</th>
</tr>
<tr>
<td>[ Min</td>
<td>Min Warn</td>
<td>Max Warn</td>
<td>Max</td>
<td style="width: 4%;">Custom</td>
<td style="width: 4%;">Reset ]</td>
</tr>
</thead>
<thead>
<tr>
<th class="state-marker" rowspan="2"></th>
<th rowspan="2">Description &amp; MIB</th>
<th style="width: 100px;" rowspan="2">Class</th>
<th style="width: 60px;" rowspan="2">Current</th>
<th style="width: 250px; white-space: nowrap;" colspan="6">Limits</th>
<th style="width: 50px;" rowspan="2">Alerts</th>
</tr>
<tr>
<td>[ Min</td>
<td>Min Warn</td>
<td>Max Warn</td>
<td>Max</td>
<td style="width: 4%;">Custom</td>
<td style="width: 4%;">Reset ]</td>
</tr>
</thead>
<tbody>
<tbody>
<?php
<?php
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element([ 'type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
}
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element(['type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken']]) . PHP_EOL;
}
foreach ($sensors as $sensor) {
humanize_sensor($sensor);
foreach ($sensors as $sensor) {
humanize_sensor($sensor);
if ($sensor['sensor_state']) {
$sensor_value = $sensor['state_name'];
$limit_class = 'input-mini hidden';
$limit_switch_class = 'hide';
} else {
$sensor_value = $sensor['human_value'];
$limit_class = 'input-mini';
$limit_switch_class = '';
}
if ($sensor['sensor_state']) {
$sensor_value = $sensor['state_name'];
$limit_class = 'input-mini hidden';
$limit_switch_class = 'hide';
} else {
$sensor_value = $sensor['human_value'];
$limit_class = 'input-mini';
$limit_switch_class = '';
}
echo('<tr class="'.$sensor['row_class'].'">');
echo('<td class="state-marker"></td>');
//echo('<td>'.escape_html($sensor['sensor_index']).'</td>');
echo('<td><span class="entity text-nowrap">'.generate_entity_link('sensor', $sensor).'</span><br /><i>'.$sensor['sensor_type'].'</i></td>');
echo('<td><span class="label label-'.get_type_class($sensor['sensor_class']).'">'.$sensor['sensor_class'].'</span></td>');
echo('<td><span class="'.$sensor['state_class'].'">' . $sensor_value . $sensor['sensor_symbol'] . '</span></td>');
$item = [
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_limit_low]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[".$sensor['sensor_id']."][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_low']
];
echo('<td>'.generate_form_element($item).'</td>');
$item = [
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_limit_low_warn]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[".$sensor['sensor_id']."][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_low_warn']
];
echo('<td>'.generate_form_element($item).'</td>');
$item = [
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_limit_warn]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[".$sensor['sensor_id']."][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_warn']
];
echo('<td>'.generate_form_element($item).'</td>');
$item = [
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_limit]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[".$sensor['sensor_id']."][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit']
];
echo('<td>'.generate_form_element($item).'</td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_low]" size="4" value="'.escape_html($sensor['sensor_limit_low']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_low_warn]" size="4" value="'.escape_html($sensor['sensor_limit_low_warn']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_warn]" size="4" value="'.escape_html($sensor['sensor_limit_warn']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit]" size="4" value="'.escape_html($sensor['sensor_limit']).'" /></td>');
if (OBS_DEBUG) { /*echo('<td>'.$sensor['sensor_multiplier'].'</td>'); */ }
$item = array(
//'id' => 'sensor_custom_limit_'.$sensor['sensor_id'],
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_custom_limit]',
//'type' => 'switch',
'type' => 'switch-ng',
'on-text' => 'Custom',
//'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'off-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'width' => '58px',
//'title' => 'Use custom limits',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_custom_limit']);
echo('<td class="text-center">'.generate_form_element($item).'</td>');
echo('<tr class="' . $sensor['row_class'] . '">');
echo('<td class="state-marker"></td>');
//echo('<td>'.escape_html($sensor['sensor_index']).'</td>');
echo('<td><span class="entity text-nowrap">' . generate_entity_link('sensor', $sensor) . '</span><br /><i>' . $sensor['sensor_type'] . '</i></td>');
echo('<td><span class="label label-' . get_type_class($sensor['sensor_class']) . '">' . $sensor['sensor_class'] . '</span></td>');
echo('<td><span class="' . $sensor['state_class'] . '">' . $sensor_value . $sensor['sensor_symbol'] . '</span></td>');
$item = [
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_limit_low]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[" . $sensor['sensor_id'] . "][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_low']
];
echo('<td>' . generate_form_element($item) . '</td>');
$item = [
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_limit_low_warn]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[" . $sensor['sensor_id'] . "][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_low_warn']
];
echo('<td>' . generate_form_element($item) . '</td>');
$item = [
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_limit_warn]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[" . $sensor['sensor_id'] . "][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit_warn']
];
echo('<td>' . generate_form_element($item) . '</td>');
$item = [
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_limit]',
'type' => 'text',
//'grid' => 1,
'class' => 'input-mini',
'size' => '4',
//'width' => '58px',
'onchange' => "toggleOn('sensors[" . $sensor['sensor_id'] . "][sensor_custom_limit]');",
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_limit']
];
echo('<td>' . generate_form_element($item) . '</td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_low]" size="4" value="'.escape_html($sensor['sensor_limit_low']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_low_warn]" size="4" value="'.escape_html($sensor['sensor_limit_low_warn']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit_warn]" size="4" value="'.escape_html($sensor['sensor_limit_warn']).'" /></td>');
//echo('<td><input type="text" class="'.$limit_class.'" name="sensors['.$sensor['sensor_id'].'][sensor_limit]" size="4" value="'.escape_html($sensor['sensor_limit']).'" /></td>');
if (OBS_DEBUG) { /*echo('<td>'.$sensor['sensor_multiplier'].'</td>'); */
}
$item = [
//'id' => 'sensor_custom_limit_'.$sensor['sensor_id'],
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_custom_limit]',
//'type' => 'switch',
'type' => 'switch-ng',
'on-text' => 'Custom',
//'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'off-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'width' => '58px',
//'title' => 'Use custom limits',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_custom_limit']];
echo('<td class="text-center">' . generate_form_element($item) . '</td>');
$item = array(
//'id' => 'sensor_reset_limit_'.$sensor['sensor_id'],
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_reset_limit]',
//'type' => 'switch',
'type' => 'switch-ng',
'on-text' => 'Reset',
//'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'off-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'class' => 'text-center',
//'width' => '58px',
//'title' => 'Reset limits to auto',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_reset_limit']);
echo('<td class="text-center">'.generate_form_element($item).'</td>');
$item = [
//'id' => 'sensor_reset_limit_'.$sensor['sensor_id'],
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_reset_limit]',
//'type' => 'switch',
'type' => 'switch-ng',
'on-text' => 'Reset',
//'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'off-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'class' => 'text-center',
//'width' => '58px',
//'title' => 'Reset limits to auto',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_reset_limit']];
echo('<td class="text-center">' . generate_form_element($item) . '</td>');
$item = array(
//'id' => 'sensor_ignore_'.$sensor['sensor_id'],
'id' => 'sensors['.$sensor['sensor_id'].'][sensor_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_ignore']);
echo('<td class="text-center">'.generate_form_element($item).'</td>');
echo('</tr>');
}
$item = [
//'id' => 'sensor_ignore_'.$sensor['sensor_id'],
'id' => 'sensors[' . $sensor['sensor_id'] . '][sensor_ignore]',
//'type' => 'switch',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
//'on-icon' => 'icon-trash',
'on-text' => 'No',
//'off-icon' => 'icon-sitemap',
//'grid' => 1,
'size' => 'mini',
//'height' => '15px',
//'title' => 'Show/Hide Removed',
//'placeholder' => 'Removed',
'readonly' => $readonly,
//'disabled' => TRUE,
//'submit_by_key' => TRUE,
'value' => $sensor['sensor_ignore']];
echo('<td class="text-center">' . generate_form_element($item) . '</td>');
echo('</tr>');
}
?>
?>
</tbody>
</table>
</div>
</tbody>
</table>
</div>
<div class="box-footer">
<?php
$item = [
'id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary pull-right',
'icon' => 'icon-ok icon-white',
'readonly' => $readonly,
'value' => 'update-sensors'
];
echo(generate_form_element($item, 'submit'));
?>
</div>
</div>
</form>
<div class="box-footer">
<?php
$item = [
'id' => 'submit',
'name' => 'Save Changes',
'class' => 'btn-primary pull-right',
'icon' => 'icon-ok icon-white',
'readonly' => $readonly,
'value' => 'update-sensors'
];
echo(generate_form_element($item, 'submit'));
?>
</div>
</div>
</form>
<?php

View File

@ -4,201 +4,211 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$ok = FALSE;
if (get_var_true($vars['editing']) && request_token_valid($vars)) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$update = [];
switch ($vars['snmp_version']) {
case 'v3':
switch ($vars['snmp_authlevel']) {
case 'authPriv':
if (is_valid_param($vars['snmp_cryptoalgo'], 'snmp_cryptoalgo')) {
$ok = TRUE;
$update['snmp_cryptoalgo'] = strtoupper($vars['snmp_cryptoalgo']);
$update['snmp_cryptopass'] = $vars['snmp_cryptopass'];
} else {
$error = 'Incorrect SNMP Crypto Algorithm';
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$update = [];
switch ($vars['snmp_version']) {
case 'v3':
switch ($vars['snmp_authlevel']) {
case 'authPriv':
if (is_valid_param($vars['snmp_cryptoalgo'], 'snmp_cryptoalgo')) {
$ok = TRUE;
$update['snmp_cryptoalgo'] = strtoupper($vars['snmp_cryptoalgo']);
$update['snmp_cryptopass'] = $vars['snmp_cryptopass'];
} else {
$error = 'Incorrect SNMP Crypto Algorithm';
}
// no break here
case 'authNoPriv':
if (is_valid_param($vars['snmp_authalgo'], 'snmp_authalgo')) {
$ok = TRUE;
$update['snmp_authalgo'] = strtoupper($vars['snmp_authalgo']);
$update['snmp_authname'] = $vars['snmp_authname'];
$update['snmp_authpass'] = $vars['snmp_authpass'];
} else {
$error = 'Incorrect SNMP Auth parameters';
$ok = FALSE;
}
break;
case 'noAuthNoPriv':
$ok = TRUE;
break;
}
if ($ok) {
$update['snmp_authlevel'] = $vars['snmp_authlevel'];
}
break;
case 'v2c':
case 'v1':
if (is_valid_param($vars['snmp_community'], 'snmp_community')) {
$ok = TRUE;
$update['snmp_community'] = $vars['snmp_community'];
} else {
$error = 'Incorrect SNMP Community';
}
break;
}
if ($ok && $snmpable = trim($vars['snmpable'])) {
$snmp_oids = [];
foreach (explode(' ', $snmpable) as $oid) {
if (preg_match(OBS_PATTERN_SNMP_OID_NUM, $oid)) {
$snmp_oids[] = $oid;
$oid_num = $oid;
} elseif (str_contains($oid, '::') && $oid_num = snmp_translate($oid)) {
// Named MIB::Oid which we can translate
$snmp_oids[] = $oid_num;
} else {
print_warning("Invalid or unknown OID: " . $oid);
break;
}
$data = snmp_get_oid($device, $oid_num);
if (!snmp_status()) {
print_warning("Device currently not respond by OID $oid!");
}
}
// no break here
case 'authNoPriv':
if (is_valid_param($vars['snmp_authalgo'], 'snmp_authalgo')) {
$ok = TRUE;
$update['snmp_authalgo'] = strtoupper($vars['snmp_authalgo']);
$update['snmp_authname'] = $vars['snmp_authname'];
$update['snmp_authpass'] = $vars['snmp_authpass'];
} else {
$error = 'Incorrect SNMP Auth parameters';
$ok = FALSE;
if (empty($snmp_oids)) {
$ok = FALSE;
$error = 'Incorrect or not numeric OIDs passed for check device availability';
}
break;
case 'noAuthNoPriv':
$ok = TRUE;
break;
}
if ($ok) { $update['snmp_authlevel'] = $vars['snmp_authlevel']; }
break;
case 'v2c':
case 'v1':
if (is_valid_param($vars['snmp_community'], 'snmp_community')) {
$ok = TRUE;
$update['snmp_community'] = $vars['snmp_community'];
} else {
$error = 'Incorrect SNMP Community';
if ($ok) {
$update['snmp_version'] = $vars['snmp_version'];
if (in_array($vars['snmp_transport'], $config['snmp']['transports'], TRUE)) {
$update['snmp_transport'] = $vars['snmp_transport'];
} else {
$update['snmp_transport'] = 'udp';
}
if (is_valid_param($vars['snmp_port'], 'port')) {
$update['snmp_port'] = (int)$vars['snmp_port'];
} else {
if (strlen($vars['snmp_port'])) {
print_warning('Passed incorrect SNMP port (' . $vars['snmp_port'] . '). Should be between 1 and 65535.');
}
$update['snmp_port'] = 161;
}
if (is_valid_param($vars['snmp_timeout'], 'snmp_timeout')) {
$update['snmp_timeout'] = (int)$vars['snmp_timeout'];
} else {
if (strlen($vars['snmp_timeout'])) {
print_warning('Passed incorrect SNMP timeout (' . $vars['snmp_timeout'] . '). Should be between 1 and 120 sec.');
}
$update['snmp_timeout'] = ['NULL'];
}
if (is_valid_param($vars['snmp_retries'], 'snmp_retries')) {
$update['snmp_retries'] = (int)$vars['snmp_retries'];
} else {
if (strlen($vars['snmp_retries'])) {
print_warning('Passed incorrect SNMP retries (' . $vars['snmp_retries'] . '). Should be between 1 and 10.');
}
$update['snmp_retries'] = ['NULL'];
}
// SNMPbulk max repetitions, allow 0 for disable snmpbulk(walk|get)
if (is_intnum($vars['snmp_maxrep']) && $vars['snmp_maxrep'] >= 0 && $vars['snmp_maxrep'] <= 500) {
$update['snmp_maxrep'] = (int)$vars['snmp_maxrep'];
} else {
if (strlen($vars['snmp_maxrep'])) {
print_warning('Passed incorrect SNMPbulk max repetitions (' . $vars['snmp_maxrep'] . '). Should be between 0 and 500. When 0 - snmpbulk will disable.');
}
$update['snmp_maxrep'] = ['NULL'];
}
if ($snmpable) {
if ($device['snmpable'] !== $snmpable) {
$update['snmpable'] = $snmpable;
}
} elseif (!empty($device['snmpable'])) {
$update['snmpable'] = ['NULL'];
}
if (strlen(trim($vars['snmp_context']))) {
$update['snmp_context'] = trim($vars['snmp_context']);
} else {
$update['snmp_context'] = ['NULL'];
}
if (dbUpdate($update, 'devices', '`device_id` = ?', [$device['device_id']])) {
print_success("Device SNMP configuration updated");
log_event('Device SNMP configuration changed.', $device['device_id'], 'device', $device['device_id'], 5);
} else {
$ok = FALSE;
print_warning("Device SNMP configuration update is not required");
}
}
break;
if (!$ok) {
if ($error) {
$error = "Device SNMP configuration not updated ($error)";
}
print_error($error);
}
unset($update);
}
if ($ok && $snmpable = trim($vars['snmpable'])) {
$snmp_oids = [];
foreach (explode(' ', $snmpable) as $oid) {
if (preg_match(OBS_PATTERN_SNMP_OID_NUM, $oid)) {
$snmp_oids[] = $oid;
$oid_num = $oid;
} elseif (str_contains($oid, '::') && $oid_num = snmp_translate($oid)) {
// Named MIB::Oid which we can translate
$snmp_oids[] = $oid_num;
} else {
print_warning("Invalid or unknown OID: ".$oid);
break;
}
$data = snmp_get_oid($device, $oid_num);
if (!snmp_status()) {
print_warning("Device currently not respond by OID $oid!");
}
}
if (empty($snmp_oids)) {
$ok = FALSE;
$error = 'Incorrect or not numeric OIDs passed for check device availability';
}
}
if ($ok) {
$update['snmp_version'] = $vars['snmp_version'];
if (in_array($vars['snmp_transport'], $config['snmp']['transports'], TRUE)) {
$update['snmp_transport'] = $vars['snmp_transport'];
} else {
$update['snmp_transport'] = 'udp';
}
if (is_valid_param($vars['snmp_port'], 'port')) {
$update['snmp_port'] = (int)$vars['snmp_port'];
} else {
if (strlen($vars['snmp_port'])) { print_warning('Passed incorrect SNMP port ('.$vars['snmp_port'].'). Should be between 1 and 65535.'); }
$update['snmp_port'] = 161;
}
if (is_valid_param($vars['snmp_timeout'], 'snmp_timeout')) {
$update['snmp_timeout'] = (int)$vars['snmp_timeout'];
} else {
if (strlen($vars['snmp_timeout'])) { print_warning('Passed incorrect SNMP timeout ('.$vars['snmp_timeout'].'). Should be between 1 and 120 sec.'); }
$update['snmp_timeout'] = [ 'NULL' ];
}
if (is_valid_param($vars['snmp_retries'], 'snmp_retries')) {
$update['snmp_retries'] = (int)$vars['snmp_retries'];
} else {
if (strlen($vars['snmp_retries'])) { print_warning('Passed incorrect SNMP retries ('.$vars['snmp_retries'].'). Should be between 1 and 10.'); }
$update['snmp_retries'] = [ 'NULL' ];
}
// SNMPbulk max repetitions, allow 0 for disable snmpbulk(walk|get)
if (is_intnum($vars['snmp_maxrep']) && $vars['snmp_maxrep'] >= 0 && $vars['snmp_maxrep'] <= 500) {
$update['snmp_maxrep'] = (int)$vars['snmp_maxrep'];
} else {
if (strlen($vars['snmp_maxrep'])) { print_warning('Passed incorrect SNMPbulk max repetitions ('.$vars['snmp_maxrep'].'). Should be between 0 and 500. When 0 - snmpbulk will disable.'); }
$update['snmp_maxrep'] = [ 'NULL' ];
}
if ($snmpable) {
if ($device['snmpable'] !== $snmpable) {
$update['snmpable'] = $snmpable;
}
} elseif (!empty($device['snmpable'])) {
$update['snmpable'] = [ 'NULL' ];
}
if (strlen(trim($vars['snmp_context']))) {
$update['snmp_context'] = trim($vars['snmp_context']);
} else {
$update['snmp_context'] = [ 'NULL' ];
}
if (dbUpdate($update, 'devices', '`device_id` = ?', [ $device['device_id'] ])) {
print_success("Device SNMP configuration updated");
log_event('Device SNMP configuration changed.', $device['device_id'], 'device', $device['device_id'], 5);
} else {
$ok = FALSE;
print_warning("Device SNMP configuration update is not required");
}
}
if (!$ok) {
if ($error) {
$error = "Device SNMP configuration not updated ($error)";
}
print_error($error);
}
unset($update);
}
}
$device = device_by_id_cache($device['device_id'], $ok);
$device = device_by_id_cache($device['device_id'], $ok);
$transports = [];
foreach ($config['snmp']['transports'] as $transport) {
$transports[$transport] = strtoupper($transport);
$transports[$transport] = strtoupper($transport);
}
$snmp_version = get_versions('snmp');
if (version_compare($snmp_version, '5.8', '<')) {
$authclass = 'bg-warning';
$authtext = 'Poller required net-snmp >= 5.8';
$authclass = 'bg-warning';
$authtext = 'Poller required net-snmp >= 5.8';
} else {
$authclass = 'bg-success';
$authtext = '';
$authclass = 'bg-success';
$authtext = '';
}
$authalgo = [
'MD5' => [ 'name' => 'MD5' ],
'SHA' => [ 'name' => 'SHA' ],
'SHA-224' => [ 'name' => 'SHA-224', 'class' => $authclass, 'subtext' => $authtext ],
'SHA-256' => [ 'name' => 'SHA-256', 'class' => $authclass, 'subtext' => $authtext ],
'SHA-384' => [ 'name' => 'SHA-384', 'class' => $authclass, 'subtext' => $authtext ],
'SHA-512' => [ 'name' => 'SHA-512', 'class' => $authclass, 'subtext' => $authtext ],
'MD5' => ['name' => 'MD5'],
'SHA' => ['name' => 'SHA'],
'SHA-224' => ['name' => 'SHA-224', 'class' => $authclass, 'subtext' => $authtext],
'SHA-256' => ['name' => 'SHA-256', 'class' => $authclass, 'subtext' => $authtext],
'SHA-384' => ['name' => 'SHA-384', 'class' => $authclass, 'subtext' => $authtext],
'SHA-512' => ['name' => 'SHA-512', 'class' => $authclass, 'subtext' => $authtext],
];
$cryptoalgo = [
'DES' => [ 'name' => 'DES' ],
'AES' => [ 'name' => 'AES' ],
'AES-192' => [ 'name' => 'AES-192', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'AES-192-C' => [ 'name' => 'AES-192 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'AES-256' => [ 'name' => 'AES-256', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'AES-256-C' => [ 'name' => 'AES-256 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
'DES' => ['name' => 'DES'],
'AES' => ['name' => 'AES'],
'AES-192' => ['name' => 'AES-192', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes'],
'AES-192-C' => ['name' => 'AES-192 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes'],
'AES-256' => ['name' => 'AES-256', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes'],
'AES-256-C' => ['name' => 'AES-256 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes'],
];
$form = [
'type' => 'horizontal',
'id' => 'edit',
'type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
//'title' => 'General',
//'class' => 'box',
];
// top row div
$form['fieldset']['edit'] = [
$form['fieldset']['edit'] = [
'div' => 'top',
'title' => 'Basic Configuration',
'class' => 'col-md-6'
];
$form['fieldset']['snmpv2'] = [
$form['fieldset']['snmpv2'] = [
'div' => 'top',
'title' => 'SNMP v1/v2c Authentication',
//'right' => TRUE,
'class' => 'col-md-6 col-md-pull-0'
];
$form['fieldset']['snmpv3'] = [
$form['fieldset']['snmpv3'] = [
'div' => 'top',
'title' => 'SNMP v3 Authentication',
//'right' => TRUE,
@ -219,29 +229,29 @@ $form['fieldset']['submit'] = [
];
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
'type' => 'hidden',
'value' => 'yes'
];
// left fieldset
$form['row'][1]['snmp_version'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'readonly' => $readonly,
'values' => [ 'v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3' ],
'value' => $device['snmp_version']
$form['row'][1]['snmp_version'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Protocol Version',
'width' => '250px',
'readonly' => $readonly,
'values' => ['v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3'],
'value' => $device['snmp_version']
];
$form['row'][2]['snmp_transport'] = [
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'readonly' => $readonly,
'values' => $transports,
'value' => $device['snmp_transport']
'type' => 'select',
'fieldset' => 'edit',
'name' => 'Transport',
'width' => '250px',
'readonly' => $readonly,
'values' => $transports,
'value' => $device['snmp_transport']
];
$form['row'][3]['snmp_port'] = [
$form['row'][3]['snmp_port'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Port',
@ -250,7 +260,7 @@ $form['row'][3]['snmp_port'] = [
'readonly' => $readonly,
'value' => $device['snmp_port']
];
$form['row'][4]['snmp_timeout'] = [
$form['row'][4]['snmp_timeout'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Timeout',
@ -259,7 +269,7 @@ $form['row'][4]['snmp_timeout'] = [
'readonly' => $readonly,
'value' => $device['snmp_timeout']
];
$form['row'][5]['snmp_retries'] = [
$form['row'][5]['snmp_retries'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Retries',
@ -268,7 +278,7 @@ $form['row'][5]['snmp_retries'] = [
'readonly' => $readonly,
'value' => $device['snmp_retries']
];
$form['row'][6]['snmp_maxrep'] = [
$form['row'][6]['snmp_maxrep'] = [
'type' => 'text',
'fieldset' => 'edit',
'name' => 'Max Repetitions',
@ -280,77 +290,77 @@ $form['row'][6]['snmp_maxrep'] = [
// Snmp v1/2c fieldset
$form['row'][7]['snmp_community'] = [
'type' => 'password',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'readonly' => $readonly,
'type' => 'password',
'fieldset' => 'snmpv2',
'name' => 'SNMP Community',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_community'] // FIXME. For passwords we should use filter instead escape!
'value' => $device['snmp_community'] // FIXME. For passwords we should use filter instead escape!
];
// Snmp v3 fieldset
$form['row'][8]['snmp_authlevel'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'readonly' => $readonly,
'values' => [
$form['row'][8]['snmp_authlevel'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Level',
'width' => '250px',
'readonly' => $readonly,
'values' => [
'noAuthNoPriv' => 'noAuthNoPriv',
'authNoPriv' => 'authNoPriv',
'authPriv' => 'authPriv'
],
'value' => $device['snmp_authlevel']
'value' => $device['snmp_authlevel']
];
$form['row'][9]['snmp_authname'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'readonly' => $readonly,
$form['row'][9]['snmp_authname'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Username',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_authname']
'value' => $device['snmp_authname']
];
$form['row'][10]['snmp_authpass'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'readonly' => $readonly,
$form['row'][10]['snmp_authpass'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Auth Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_authpass'] // FIXME. For passwords we should use filter instead escape!
'value' => $device['snmp_authpass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][11]['snmp_authalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $authalgo,
'value' => $device['snmp_authalgo']
$form['row'][11]['snmp_authalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Auth Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $authalgo,
'value' => $device['snmp_authalgo']
];
$form['row'][12]['snmp_cryptopass'] = [
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'readonly' => $readonly,
'type' => 'password',
'fieldset' => 'snmpv3',
'name' => 'Crypto Password',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'value' => $device['snmp_cryptopass'] // FIXME. For passwords we should use filter instead escape!
'value' => $device['snmp_cryptopass'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][13]['snmp_cryptoalgo'] = [
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $cryptoalgo,
'value' => $device['snmp_cryptoalgo']
'type' => 'select',
'fieldset' => 'snmpv3',
'name' => 'Crypto Algorithm',
'width' => '250px',
'readonly' => $readonly,
'values' => $cryptoalgo,
'value' => $device['snmp_cryptoalgo']
];
// Extra fields
$form['row'][14]['snmpable'] = [
$form['row'][14]['snmpable'] = [
'type' => 'text',
'fieldset' => 'snmpextra',
'name' => 'SNMPable OIDs',
@ -360,25 +370,25 @@ $form['row'][14]['snmpable'] = [
'value' => $device['snmpable']
];
$form['row'][15]['snmp_context'] = [
'type' => 'password',
'fieldset' => 'snmpextra',
'name' => 'SNMP Context',
'width' => '250px',
'readonly' => $readonly,
'type' => 'password',
'fieldset' => 'snmpextra',
'name' => 'SNMP Context',
'width' => '250px',
'readonly' => $readonly,
'show_password' => !$readonly,
'placeholder' => '(Optional) Context',
'value' => $device['snmp_context'] // FIXME. For passwords we should use filter instead escape!
'placeholder' => '(Optional) Context',
'value' => $device['snmp_context'] // FIXME. For passwords we should use filter instead escape!
];
$form['row'][20]['submit'] = [
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'type' => 'submit',
'fieldset' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
];
print_form_box($form);
@ -386,43 +396,43 @@ unset($form);
?>
<script type="text/javascript">
<!--
$("#snmp_version").change(function() {
var select = this.value;
if (select === 'v3') {
$('#snmpv3').show();
$("#snmpv2").hide();
} else {
$('#snmpv2').show();
$('#snmpv3').hide();
}
}).change();
<script type="text/javascript">
<!--
$("#snmp_version").change(function () {
var select = this.value;
if (select === 'v3') {
$('#snmpv3').show();
$("#snmpv2").hide();
} else {
$('#snmpv2').show();
$('#snmpv3').hide();
}
}).change();
$("#snmp_authlevel").change(function() {
var select = this.value;
if (select === 'authPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').show();
$('[id^="snmp_cryptoalgo"]').show();
} else if (select === 'authNoPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
} else {
$('[id^="snmp_authname"]').hide();
$('[id^="snmp_authpass"]').hide();
$('[id^="snmp_authalgo"]').hide();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
}
}).change();
// -->
</script>
$("#snmp_authlevel").change(function () {
var select = this.value;
if (select === 'authPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').show();
$('[id^="snmp_cryptoalgo"]').show();
} else if (select === 'authNoPriv') {
$('[id^="snmp_authname"]').show();
$('[id^="snmp_authpass"]').show();
$('[id^="snmp_authalgo"]').show();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
} else {
$('[id^="snmp_authname"]').hide();
$('[id^="snmp_authpass"]').hide();
$('[id^="snmp_authalgo"]').hide();
$('[id^="snmp_cryptopass"]').hide();
$('[id^="snmp_cryptoalgo"]').hide();
}
}).change();
// -->
</script>
<?php

View File

@ -4,85 +4,80 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing'])
{
if ($readonly)
{
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$ssh_port = $vars['ssh_port'];
if (!is_numeric($ssh_port))
{
$update_message = "SSH port must be numeric!";
$updated = 0;
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
$update = array(
'ssh_port' => $ssh_port
);
$ssh_port = $vars['ssh_port'];
$rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id']));
if (!is_numeric($ssh_port)) {
$update_message = "SSH port must be numeric!";
$updated = 0;
} else {
$update = [
'ssh_port' => $ssh_port
];
if ($rows_updated > 0)
{
$update_message = $rows_updated . " Device record updated.";
$updated = 1;
} elseif ($rows_updated = '-1') {
$update_message = "Device record unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device record update error.";
$updated = 0;
}
$rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', [$device['device_id']]);
if ($rows_updated > 0) {
$update_message = $rows_updated . " Device record updated.";
$updated = 1;
} elseif ($rows_updated = '-1') {
$update_message = "Device record unchanged. No update necessary.";
$updated = -1;
} else {
$update_message = "Device record update error.";
$updated = 0;
}
}
}
}
}
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", [$device['device_id']]);
if ($updated && $update_message)
{
print_message($update_message);
if ($updated && $update_message) {
print_message($update_message);
} elseif ($update_message) {
print_error($update_message);
print_error($update_message);
}
print_warning("For now this option used only by 'libvirt-vminfo' discovery module (on linux devices).");
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'SSH Connectivity',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
$form['row'][0]['editing'] = array(
'type' => 'hidden',
'value' => 'yes');
$form['row'][1]['ssh_port'] = array(
'type' => 'text',
'name' => 'SSH Port',
'width' => '250px',
'readonly' => $readonly,
'value' => escape_html($device['ssh_port']));
$form['row'][2]['submit'] = array(
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save');
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'SSH Connectivity',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'];
$form['row'][1]['ssh_port'] = [
'type' => 'text',
'name' => 'SSH Port',
'width' => '250px',
'readonly' => $readonly,
'value' => escape_html($device['ssh_port'])];
$form['row'][2]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'];
print_form($form);
unset($form);
print_form($form);
unset($form);
// EOF

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -14,11 +14,11 @@ $query = 'SELECT * FROM `status`
WHERE `device_id` = ? AND `status_deleted` = 0
ORDER BY `status_mib`, `status_type`, `status_index`;';
$statuses = dbFetchRows($query, array($device['device_id']));
$statuses = dbFetchRows($query, [$device['device_id']]);
?>
<form id="update_statuses" class="form form-inline">
<form id="update_statuses" class="form form-inline">
<input type="hidden" name="action" value="statuses_update">
@ -40,47 +40,47 @@ $statuses = dbFetchRows($query, array($device['device_id']));
</thead>
<tbody>
<?php
<?php
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element([ 'type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
}
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element(['type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken']]) . PHP_EOL;
}
foreach ($statuses as $status)
{
humanize_status($status); //r($status);
foreach ($statuses as $status) {
humanize_status($status); //r($status);
echo '<tr class="'.$status['row_class'].'">';
echo '<td class="state-marker"></td>';
//echo('<td>'.escape_html($sensor['sensor_index']).'</td>');
echo '<td><span class="entity text-nowrap">'.generate_entity_link('status', $status).'</span><br /><i>'.$status['status_type'].'</i></td>';
echo '<td><span class="'.$status['event_class'].'">'.$status['status_name'].'</span></td>';
echo '<td><span class="'.$status['event_class'].'">'.$status['status_event'].'</span></td>';
echo '<tr class="' . $status['row_class'] . '">';
echo '<td class="state-marker"></td>';
//echo('<td>'.escape_html($sensor['sensor_index']).'</td>');
echo '<td><span class="entity text-nowrap">' . generate_entity_link('status', $status) . '</span><br /><i>' . $status['status_type'] . '</i></td>';
echo '<td><span class="' . $status['event_class'] . '">' . $status['status_name'] . '</span></td>';
echo '<td><span class="' . $status['event_class'] . '">' . $status['status_event'] . '</span></td>';
$item = [
'id' => 'status['.$status['status_id'].'][status_ignore]',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
'on-text' => 'No',
'size' => 'mini',
'readonly' => $readonly,
'value' => $status['status_ignore']
];
echo '<td class="text-center">'.generate_form_element($item).'</td>';
echo '</tr>';
}
$item = [
'id' => 'status[' . $status['status_id'] . '][status_ignore]',
'type' => 'switch-ng',
'off-text' => 'Yes',
'off-color' => 'success',
'on-color' => 'danger',
'on-text' => 'No',
'size' => 'mini',
'readonly' => $readonly,
'value' => $status['status_ignore']
];
echo '<td class="text-center">' . generate_form_element($item) . '</td>';
echo '</tr>';
}
?>
?>
</tbody>
</table>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary pull-right" name="submit" value="update_statuses"><i class="icon-ok icon-white"></i> Save Changes</button>
<button type="submit" class="btn btn-primary pull-right" name="submit" value="update_statuses"><i class="icon-ok icon-white"></i> Save Changes
</button>
</div>
</div>
</form>

View File

@ -4,32 +4,49 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if ($vars['editing']) {
if ($readonly) {
print_error_permission('You have insufficient permissions to edit settings.');
} else {
if ($vars['wmi_override']) { set_entity_attrib('device', $device, 'wmi_override', $vars['wmi_override']); } else { del_entity_attrib('device', $device, 'wmi_override'); }
if (!empty($vars['wmi_hostname'])) { set_entity_attrib('device', $device, 'wmi_hostname', $vars['wmi_hostname']); } else { del_entity_attrib('device', $device, 'wmi_hostname'); }
if (!empty($vars['wmi_domain'])) { set_entity_attrib('device', $device, 'wmi_domain', $vars['wmi_domain']); } else { del_entity_attrib('device', $device, 'wmi_domain'); }
if (!empty($vars['wmi_username'])) { set_entity_attrib('device', $device, 'wmi_username', $vars['wmi_username']); } else { del_entity_attrib('device', $device, 'wmi_username'); }
if (!empty($vars['wmi_password'])) { set_entity_attrib('device', $device, 'wmi_password', $vars['wmi_password']); } else { del_entity_attrib('device', $device, 'wmi_password'); }
if ($vars['wmi_override']) {
set_entity_attrib('device', $device, 'wmi_override', $vars['wmi_override']);
} else {
del_entity_attrib('device', $device, 'wmi_override');
}
if (!empty($vars['wmi_hostname'])) {
set_entity_attrib('device', $device, 'wmi_hostname', $vars['wmi_hostname']);
} else {
del_entity_attrib('device', $device, 'wmi_hostname');
}
if (!empty($vars['wmi_domain'])) {
set_entity_attrib('device', $device, 'wmi_domain', $vars['wmi_domain']);
} else {
del_entity_attrib('device', $device, 'wmi_domain');
}
if (!empty($vars['wmi_username'])) {
set_entity_attrib('device', $device, 'wmi_username', $vars['wmi_username']);
} else {
del_entity_attrib('device', $device, 'wmi_username');
}
if (!empty($vars['wmi_password'])) {
set_entity_attrib('device', $device, 'wmi_password', $vars['wmi_password']);
} else {
del_entity_attrib('device', $device, 'wmi_password');
}
$update_message = "Device WMI data updated.";
$updated = 1;
$updated = 1;
if ($vars['toggle_poller'] && isset($GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']]))
{
if ($vars['toggle_poller'] && isset($GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']])) {
$module = $vars['toggle_poller'];
if (isset($attribs['wmi_poll_'.$module]) && $attribs['wmi_poll_'.$module] != $GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']])
{
if (isset($attribs['wmi_poll_' . $module]) && $attribs['wmi_poll_' . $module] != $GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']]) {
del_entity_attrib('device', $device, 'wmi_poll_' . $module);
} elseif ($GLOBALS['config']['wmi']['modules'][$vars['toggle_poller']] == 0) {
set_entity_attrib('device', $device, 'wmi_poll_' . $module, "1");
@ -43,29 +60,26 @@ if ($vars['editing']) {
}
if (!$readonly) {
include_once($GLOBALS['config']['install_dir'] . "/includes/wmi.inc.php");
// Validate cmd path
$wmi_ok = TRUE;
if (!is_executable($config['wmic'])) {
if ($config['wmic'] === '/bin/wmic' && is_executable('/usr/bin/wmic')) {
// This path already fixed in poller wmi
} else {
print_warning("The wmic binary was not found at the configured path (" . $config['wmic'] . "). WMI polling will not work.");
$wmi_ok = FALSE;
}
if (!wmi_cmd($device)) {
print_warning("The wmic binary (or script) was not found at the configured path (" . $config['wmic'] . "). WMI polling will not work.");
$wmi_ok = FALSE;
}
// Validate WMI poller module
if ($wmi_ok && !is_module_enabled($device, 'wmi', 'poller')) {
$modules_link = generate_device_link($device, 'only on this device here', [ 'tab' => 'edit', 'section' => 'modules' ]);
$global_link = generate_link('globally here', [ 'page' => 'settings', 'section' => 'polling' ]);
$modules_link = generate_device_link($device, 'only on this device here', ['tab' => 'edit', 'section' => 'modules']);
$global_link = generate_link('globally here', ['page' => 'settings', 'section' => 'polling']);
print_warning("WMI module not enabled. Enable <strong>Poller</strong> module WMI $modules_link, or $global_link.");
//$wmi_ok = FALSE;
}
// Validate WMI access
if ($wmi_ok) {
include_once($GLOBALS['config']['install_dir'] . "/includes/wmi.inc.php");
$wql = "SELECT Name FROM Win32_ComputerSystem";
$wql = "SELECT Name FROM Win32_ComputerSystem";
$wmi_name = wmi_get($device, $wql, "Name");
if (is_null($wmi_name)) {
$docs_link = '<a target="_blank" href="' . OBSERVIUM_DOCS_URL . '/device_windows/' . '">here</a>';
@ -79,150 +93,150 @@ if (!$readonly) {
?>
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<?php
$wmi_override = get_dev_attrib($device, 'wmi_override');
$form = array('type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'WMI Settings',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => array('edit' => ''),
);
<?php
$wmi_override = get_dev_attrib($device, 'wmi_override');
$form = ['type' => 'horizontal',
'id' => 'edit',
//'space' => '20px',
'title' => 'WMI Settings',
//'icon' => 'oicon-gear',
//'class' => 'box box-solid',
'fieldset' => ['edit' => ''],
];
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
];
$form['row'][1]['wmi_override'] = [
'type' => 'toggle',
'name' => 'Override WMI Config',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', [ 'wmi_hostname', 'wmi_domain', 'wmi_username', 'wmi_password' ])",
'value' => $wmi_override
];
$form['row'][2]['wmi_hostname'] = [
'type' => 'text',
'name' => 'WMI Hostname',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_hostname')
];
$form['row'][3]['wmi_domain'] = [
'type' => 'text',
'name' => 'WMI Domain',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_domain')
];
$form['row'][4]['wmi_username'] = [
'type' => 'text',
'name' => 'WMI Username',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_username')
];
$form['row'][5]['wmi_password'] = [
'type' => 'password',
'name' => 'WMI Password',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'show_password' => !$readonly,
'value' => get_dev_attrib($device, 'wmi_password')
];
$form['row'][0]['editing'] = [
'type' => 'hidden',
'value' => 'yes'
];
$form['row'][1]['wmi_override'] = [
'type' => 'toggle',
'name' => 'Override WMI Config',
'readonly' => $readonly,
'onchange' => "toggleAttrib('disabled', [ 'wmi_hostname', 'wmi_domain', 'wmi_username', 'wmi_password' ])",
'value' => $wmi_override
];
$form['row'][2]['wmi_hostname'] = [
'type' => 'text',
'name' => 'WMI Hostname',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_hostname')
];
$form['row'][3]['wmi_domain'] = [
'type' => 'text',
'name' => 'WMI Domain',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_domain')
];
$form['row'][4]['wmi_username'] = [
'type' => 'text',
'name' => 'WMI Username',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'value' => get_dev_attrib($device, 'wmi_username')
];
$form['row'][5]['wmi_password'] = [
'type' => 'password',
'name' => 'WMI Password',
'width' => '250px',
'readonly' => $readonly,
'disabled' => !$wmi_override,
'show_password' => !$readonly,
'value' => get_dev_attrib($device, 'wmi_password')
];
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
];
print_form($form);
unset($form);
?>
</div>
<div class="col-md-6">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">WMI Poller Modules</h3>
$form['row'][7]['submit'] = [
'type' => 'submit',
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
'class' => 'btn-primary',
'readonly' => $readonly,
'value' => 'save'
];
print_form($form);
unset($form);
?>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed ">
<thead>
<tr>
<th>Module</th>
<th style="width: 80;">Global</th>
<th style="width: 80;">Device</th>
<th style="width: 80;"></th>
</tr>
</thead>
<tbody>
<?php
<div class="col-md-6">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">WMI Poller Modules</h3>
</div>
<div class="box-body no-padding">
<table class="table table-striped table-condensed ">
<thead>
<tr>
<th>Module</th>
<th style="width: 80;">Global</th>
<th style="width: 80;">Device</th>
<th style="width: 80;"></th>
</tr>
</thead>
<tbody>
<?php
foreach ($GLOBALS['config']['wmi']['modules'] as $module => $module_status) {
echo('<tr><td><b>'.$module.'</b></td><td>');
foreach ($GLOBALS['config']['wmi']['modules'] as $module => $module_status) {
echo('<tr><td><b>' . $module . '</b></td><td>');
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>' ));
echo(($module_status ? '<span class="label label-success">enabled</span>' : '<span class="label label-important">disabled</span>'));
echo('</td><td>');
echo('</td><td>');
if (isset($attribs['wmi_poll_'.$module])) {
if ($attribs['wmi_poll_'.$module]) {
echo('<span class="label label-success">enabled</span>');
$toggle = "Disable";
$btn_class = "btn-danger";
} else {
echo('<span class="label label-important">disabled</span>');
$toggle = "Enable";
$btn_class = "btn-success";
}
} else {
if ($module_status) {
echo('<span class="label label-success">enabled</span>');
$toggle = "Disable";
$btn_class = "btn-danger";
} else {
echo('<span class="label label-important">disabled</span>');
$toggle = "Enable";
$btn_class = "btn-success";
}
}
if (isset($attribs['wmi_poll_' . $module])) {
if ($attribs['wmi_poll_' . $module]) {
echo('<span class="label label-success">enabled</span>');
$toggle = "Disable";
$btn_class = "btn-danger";
} else {
echo('<span class="label label-important">disabled</span>');
$toggle = "Enable";
$btn_class = "btn-success";
}
} else {
if ($module_status) {
echo('<span class="label label-success">enabled</span>');
$toggle = "Disable";
$btn_class = "btn-danger";
} else {
echo('<span class="label label-important">disabled</span>');
$toggle = "Enable";
$btn_class = "btn-success";
}
}
echo('</td><td>');
$form = [ 'type' => 'simple' ];
// Elements
$form['row'][0]['toggle_poller'] = [ 'type' => 'hidden',
'value' => $module ];
$form['row'][0]['editing'] = [ 'type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini '.$btn_class,
//'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'toggle_poller' ];
print_form($form);
unset($form);
echo('</td><td>');
echo('</td></tr>');
}
$form = ['type' => 'simple'];
// Elements
$form['row'][0]['toggle_poller'] = ['type' => 'hidden',
'value' => $module];
$form['row'][0]['editing'] = ['type' => 'submit',
'name' => $toggle,
'class' => 'btn-mini ' . $btn_class,
//'icon' => $btn_icon,
'right' => TRUE,
'readonly' => $readonly,
'value' => 'toggle_poller'];
print_form($form);
unset($form);
?>
</tbody>
</table>
</div>
echo('</td></tr>');
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<?php
// EOF

View File

@ -4,10 +4,10 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/

View File

@ -6,84 +6,31 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
// Sections are printed in the order they exist in $config['graph_sections']
// Graphs are printed in the order they exist in $config['graph_types']
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'graphs');
$graphs_sections = array();
foreach ($device['graphs'] as $entry)
{
if (isset($entry['enabled']) && !$entry['enabled']) { continue; } // Skip disabled graphs
$section = $config['graph_types']['device'][$entry['graph']]['section'];
if (in_array($section, $config['graph_sections']))
{
// Collect only enabled and exists graphs
//$graphs_sections[$section][$entry['graph']] = $entry['enabled'];
if (isset($config['graph_types']['device'][$entry['graph']]['order']) && is_numeric($config['graph_types']['device'][$entry['graph']]['order']))
{
$order = $config['graph_types']['device'][$entry['graph']]['order'];
} else {
$order = 999; // Set high order for unordered graphs
}
while (isset($graphs_sections[$section][$order]))
{
$order++;
}
$graphs_sections[$section][$order] = $entry['graph'];
}
}
if (OBSERVIUM_EDITION !== 'community') {
// Custom OIDs
$sql = "SELECT * FROM `oids_entries`";
$sql .= " LEFT JOIN `oids` USING(`oid_id`)";
$sql .= " WHERE `device_id` = ?";
$custom_graphs = dbFetchRows($sql, array($device['device_id']));
if (count($custom_graphs))
{
$graphs_sections['custom'] = TRUE;
}
}
$graphs_sections = get_device_graphs_sections($device);
//print_vars($graphs_sections);
// Graphs navbar
$navbar['brand'] = "Graphs";
$navbar['class'] = "navbar-narrow";
foreach ($graphs_sections as $section => $graph) {
$type = strtolower($section);
if (!$vars['group']) {
$vars['group'] = $type;
}
if ($vars['group'] == $type) {
$navbar['options'][$section]['class'] = "active";
}
$navbar['options'][$section]['url'] = generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'graphs', 'group' => $type ]);
$navbar['options'][$section]['text'] = $config['graph_sections'][$section] ?? nicecase($type);
// Set sections order
$graphs_sections_sorted = array();
foreach ($config['graph_sections'] as $section)
{
if (isset($graphs_sections[$section]))
{
$graphs_sections_sorted[$section] = $graphs_sections[$section];
unset($graphs_sections[$section]);
}
}
$graphs_sections = array_merge($graphs_sections_sorted, $graphs_sections);
//print_vars($graphs_sections);
unset($graphs_sections_sorted);
foreach ($graphs_sections as $section => $graph)
{
$type = strtolower($section);
if (empty($config['graph_sections'][$section])) { $text = nicecase($type); } else { $text = $config['graph_sections'][$section]; }
if (!$vars['group']) { $vars['group'] = $type; }
if ($vars['group'] == $type) { $navbar['options'][$section]['class'] = "active"; }
$navbar['options'][$section]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'graphs', 'group' => $type));
$navbar['options'][$section]['text'] = $text;
//print_vars($graph);
//print_vars($graph);
}
print_navbar($navbar);
@ -91,48 +38,52 @@ print_navbar($navbar);
echo generate_box_open();
echo('<table class="table table-condensed table-striped table-hover ">');
if ($vars['group'] === "custom" && $graphs_sections['custom'])
{
foreach ($custom_graphs as $graph)
{
$graph_array = array();
$graph_title = $graph['oid_descr'];
$graph_array['type'] = "customoid_graph";
$graph_array['id'] = $graph['oid_entry_id'];
if ($vars['group'] === "custom" && isset($graphs_sections['custom'])) {
// Custom OIDs
$sql = "SELECT * FROM `oids_entries`";
$sql .= " LEFT JOIN `oids` USING(`oid_id`)";
$sql .= " WHERE `device_id` = ?";
echo('<tr><td>');
$custom_graphs = dbFetchRows($sql, [ $device['device_id'] ]);
echo('<h3>' . $graph_title . '</h4>');
foreach ($custom_graphs as $graph) {
$graph_array = [];
$graph_title = $graph['oid_descr'];
$graph_array['type'] = "customoid_graph";
$graph_array['id'] = $graph['oid_entry_id'];
print_graph_row($graph_array);
echo('<tr><td>');
echo('</td></tr>');
echo('<h3>' . $graph_title . '</h4>');
}
print_graph_row($graph_array);
echo('</td></tr>');
}
} elseif (isset($graphs_sections[$vars['group']])) {
ksort($graphs_sections[$vars['group']], SORT_NUMERIC);
$graph_enable = $graphs_sections[$vars['group']];
ksort($graphs_sections[$vars['group']], SORT_NUMERIC);
$graph_enable = $graphs_sections[$vars['group']];
// print_vars($graph_enable);
foreach ($graph_enable as $graph)
{
$graph_array = array();
//if ($graph_enable[$graph])
//{
$graph_title = $config['graph_types']['device'][$graph]['descr'];
$graph_array['type'] = "device_" . $graph;
$graph_array['device'] = $device['device_id'];
foreach ($graph_enable as $graph) {
$graph_array = [];
//if ($graph_enable[$graph])
//{
$graph_title = $config['graph_types']['device'][$graph]['descr'];
$graph_array['type'] = "device_" . $graph;
$graph_array['device'] = $device['device_id'];
echo('<tr><td>');
echo('<tr><td>');
echo('<h3>' . $graph_title . '</h4>');
echo('<h3>' . $graph_title . '</h4>');
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</td></tr>');
//}
}
echo('</td></tr>');
//}
}
}
echo('</table>');

View File

@ -4,123 +4,73 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$datas = [ 'overview' => [ 'icon' => $config['icon']['overview'] ] ];
if ($health_exist['processors']) { $datas['processor'] = array('icon' => $config['entities']['processor']['icon']); }
if ($health_exist['mempools']) { $datas['mempool'] = array('icon' => $config['entities']['mempool']['icon']); }
if ($health_exist['storage']) { $datas['storage'] = array('icon' => $config['entities']['storage']['icon']); }
if ($health_exist['diskio']) { $datas['diskio'] = array('icon' => $config['icon']['diskio']); }
if ($health_exist['status']) { $datas['status'] = array('icon' => $config['entities']['status']['icon']); }
if ($health_exist['sensors']) {
// Keep sensors order for base types static
$sensor_types = [ 'temperature', 'humidity', 'fanspeed', 'airflow', 'current', 'voltage', 'power', 'apower', 'rpower', 'frequency' ];
$other_types = array_diff(array_keys($config['sensor_types']), $sensor_types);
$sensor_types = array_merge($sensor_types, $other_types);
//r($sensor_types);
$sensors_device = dbFetchColumn("SELECT DISTINCT `sensor_class` FROM `sensors` WHERE `device_id` = ? AND `sensor_deleted` = ?", [ $device['device_id'], 0 ]);
//r($sensors_device);
foreach (array_intersect($sensor_types, $sensors_device) as $sensor_type) {
//if ($sensor['sensor_class'] == 'counter') { continue; } // DEVEL
$datas[$sensor_type] = [ 'icon' => $config['sensor_types'][$sensor_type]['icon'] ];
}
if (!$vars['metric']) {
$vars['metric'] = "overview";
}
// All counters in single page?
if ($health_exist['counter']) { $datas['counter'] = array('icon' => $config['entities']['counter']['icon']); }
/*
if ($health_exist['counter'])
{
$counters_device = dbFetchRows("SELECT DISTINCT `counter_class` FROM `counters` WHERE `device_id` = ? AND `counter_deleted` = ?", array($device['device_id'], 0));
foreach ($counters_device as $counter)
{
$datas[$counter['counter_class']] = array('icon' => $config['counter_types'][$counter['counter_class']]['icon']);
}
if (!$vars['view']) {
$vars['view'] = "details";
}
*/
$link_array = [
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'health'
];
if (!$vars['metric']) { $vars['metric'] = "overview"; }
if (!$vars['view']) { $vars['view'] = "details"; }
$navbar['brand'] = "Health";
$navbar['class'] = "navbar-narrow";
$navbar_count = count($datas);
foreach ($datas as $type => $options)
{
if ($vars['metric'] == $type) { $navbar['options'][$type]['class'] = "active"; }
else if ($navbar_count > 8 && $type != 'overview') { $navbar['options'][$type]['class'] = "icon"; } // Show only icons if too many items in navbar
if (isset($options['icon']))
{
$navbar['options'][$type]['icon'] = $options['icon'];
}
$navbar['options'][$type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => $type));
$navbar['options'][$type]['text'] = nicecase($type);
$navbar['options']['overview']['icon'] = $config['icon']['overview'];
$navbar['options']['overview']['text'] = 'Overview';
$navbar['options']['overview']['url'] = generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'health' ]);
if ($vars['metric'] === 'overview') {
$navbar['options']['overview']['class'] = 'active';
}
$health_menu = navbar_health_menu($device, $vars);
$navbar['options'] = array_merge($navbar['options'], $health_menu);
//$navbar['options']['graphs']['text'] = 'Graphs';
$navbar['options']['graphs']['icon'] = $config['icon']['graphs'];
$navbar['options']['graphs']['right'] = TRUE;
if ($vars['view'] == "graphs")
{
$navbar['options']['graphs']['class'] = 'active';
$navbar['options']['graphs']['url'] = generate_url($vars, array('view' => "detail"));
if ($vars['view'] === "graphs") {
$navbar['options']['graphs']['class'] = 'active';
$navbar['options']['graphs']['url'] = generate_url($vars, ['view' => "detail"]);
} else {
$navbar['options']['graphs']['url'] = generate_url($vars, array('view' => "graphs"));
$navbar['options']['graphs']['url'] = generate_url($vars, ['view' => "graphs"]);
}
print_navbar($navbar);
unset($navbar);
if (isset($config['sensor_types'][$vars['metric']]) || $vars['metric'] == "sensors")
{
include($config['html_dir']."/pages/device/health/sensors.inc.php");
}
elseif (isset($config['counter_types'][$vars['metric']]) || $vars['metric'] == "counter")
{
include($config['html_dir']."/pages/device/health/counter.inc.php");
}
elseif (is_alpha($vars['metric']) && is_file($config['html_dir']."/pages/device/health/".$vars['metric'].".inc.php"))
{
include($config['html_dir']."/pages/device/health/".$vars['metric'].".inc.php");
if (isset($config['sensor_types'][$vars['metric']]) || $vars['metric'] === "sensors") {
include($config['html_dir'] . "/pages/device/health/sensors.inc.php");
} elseif (isset($config['counter_types'][$vars['metric']]) || $vars['metric'] === "counter") {
include($config['html_dir'] . "/pages/device/health/counter.inc.php");
} elseif (is_alpha($vars['metric']) && is_file($config['html_dir'] . "/pages/device/health/" . $vars['metric'] . ".inc.php")) {
include($config['html_dir'] . "/pages/device/health/" . $vars['metric'] . ".inc.php");
} else {
echo generate_box_open();
// Overview
echo generate_box_open();
echo('<table class="table table-condensed table-striped table-hover ">');
echo('<table class="table table-condensed table-striped table-hover ">');
foreach ($datas as $type => $options)
{
if ($type != "overview")
{
$graph_title = nicecase($type);
$graph_array['type'] = "device_".$type;
$graph_array['device'] = $device['device_id'];
foreach ($health_menu as $type => $options) {
$graph_title = $options['text'];
$graph_array['type'] = "device_" . $type;
$graph_array['device'] = $device['device_id'];
echo('<tr><td>');
echo('<h3>' . $graph_title . '</h3>');
print_graph_row($graph_array);
echo('</td></tr>');
echo('<tr><td>');
echo('<h3>' . $graph_title . '</h3>');
print_graph_row($graph_array);
echo('</td></tr>');
}
}
echo('</table>');
echo('</table>');
echo generate_box_close();
echo generate_box_close();
}

View File

@ -5,31 +5,30 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @copyright (C) Adam Armstrong
*
*/
if ($metric != 'counter' && device_permitted($device))
{
if ($metric != 'counter' && device_permitted($device)) {
// Don't show aggregate graphs to people without device permissions, or for "all sensors" view.
// Don't show aggregate graphs to people without device permissions, or for "all sensors" view.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_open($box_args);
echo generate_box_close();
print_graph_row($graph_array);
echo generate_box_close();
}

View File

@ -4,15 +4,15 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$class = "dbm";
$unit = "dBm";
$class = "dbm";
$unit = "dBm";
$graph_type = "sensor_dbm";
include("sensors.inc.php");

View File

@ -4,33 +4,33 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (device_permitted($device)) {
// Only show aggregate graph if we have access to the entire device.
// Only show aggregate graph if we have access to the entire device.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_diskio_bits";
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_diskio_bits";
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
echo generate_box_open($box_args);
print_graph_row($graph_array);
print_graph_row($graph_array);
$graph_array['type'] = "device_diskio_ops";
print_graph_row($graph_array);
$graph_array['type'] = "device_diskio_ops";
print_graph_row($graph_array);
echo generate_box_close();
echo generate_box_close();
}
@ -43,40 +43,37 @@ echo('<table class="table table-striped table-condensed ">');
// </tr></thead>");
foreach (dbFetchRows("SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr", array($device['device_id'])) as $drive)
{
foreach (dbFetchRows("SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr", [$device['device_id']]) as $drive) {
$fs_url = "device/device=".$device['device_id']."/tab=health/metric=diskio/";
$fs_url = "device/device=" . $device['device_id'] . "/tab=health/metric=diskio/";
$graph_array_zoom['id'] = $drive['diskio_id'];
$graph_array_zoom['type'] = "diskio_ops";
$graph_array_zoom['width'] = "400";
$graph_array_zoom['height'] = "125";
$graph_array_zoom['from'] = $config['time']['twoday'];
$graph_array_zoom['to'] = $config['time']['now'];
$graph_array_zoom['id'] = $drive['diskio_id'];
$graph_array_zoom['type'] = "diskio_ops";
$graph_array_zoom['width'] = "400";
$graph_array_zoom['height'] = "125";
$graph_array_zoom['from'] = get_time('twoday');
$graph_array_zoom['to'] = get_time();
echo("<tr><td><h3>");
echo(overlib_link($fs_url, $drive['diskio_descr'], generate_graph_tag($graph_array_zoom), NULL));
echo("</h3>");
echo("<tr><td><h3>");
echo(overlib_link($fs_url, $drive['diskio_descr'], generate_graph_tag($graph_array_zoom), NULL));
echo("</h3>");
$types = array("diskio_bits", "diskio_ops");
$types = ["diskio_bits", "diskio_ops"];
$rrd_filename = get_rrd_path($device, "diskstat-".$drive['diskio_descr'].".rrd");
if(is_file($rrd_filename))
{
$rrd_filename = get_rrd_path($device, "diskstat-" . $drive['diskio_descr'] . ".rrd");
if (is_file($rrd_filename)) {
$types[] = "diskio_stat";
}
}
foreach ($types as $graph_type)
{
foreach ($types as $graph_type) {
$graph_array = array();
$graph_array['id'] = $drive['diskio_id'];
$graph_array['type'] = $graph_type;
$graph_array = [];
$graph_array['id'] = $drive['diskio_id'];
$graph_array['type'] = $graph_type;
print_graph_row($graph_array);
print_graph_row($graph_array);
}
}
}

View File

@ -4,30 +4,30 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (device_permitted($device)) {
// Only show aggregate graph if we have access to the entire device.
// Only show aggregate graph if we have access to the entire device.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_close();
print_graph_row($graph_array);
echo generate_box_close();
}

View File

@ -4,32 +4,32 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (device_permitted($device)) {
// Only show aggregate graph if we have access to the entire device.
// Only show aggregate graph if we have access to the entire device.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_open($box_args);
$graph_type = "processor_usage";
print_graph_row($graph_array);
echo generate_box_close();
$graph_type = "processor_usage";
echo generate_box_close();
}

View File

@ -1,35 +1,31 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if($metric != 'sensors' && device_permitted($device))
{
if ($vars['metric'] !== 'sensors' && $metric !== 'sensors' && device_permitted($device)) {
// Don't show aggregate graphs to people without device permissions, or for "all sensors" view.
// Don't show aggregate graphs to people without device permissions, or for "all sensors" view.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title, 'header-border' => TRUE];
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_open($box_args);
echo generate_box_close();
print_graph_row($graph_array);
echo generate_box_close();
}

View File

@ -4,36 +4,36 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (device_permitted($device)) {
// Only show aggregate graph if we have access to the entire device.
// Only show aggregate graph if we have access to the entire device.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
echo generate_box_open($box_args);
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
print_graph_row($graph_array);
print_graph_row($graph_array);
echo generate_box_close();
echo generate_box_close();
}

View File

@ -4,30 +4,30 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (device_permitted($device)) {
// Only show aggregate graph if we have access to the entire device.
// Only show aggregate graph if we have access to the entire device.
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_".$vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$graph_title = nicecase($vars['metric']);
$graph_array['type'] = "device_" . $vars['metric'];
$graph_array['device'] = $device['device_id'];
$graph_array['legend'] = 'no';
$box_args = array('title' => $graph_title,
'header-border' => TRUE,
);
$box_args = ['title' => $graph_title,
'header-border' => TRUE,
];
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_open($box_args);
echo generate_box_close();
print_graph_row($graph_array);
echo generate_box_close();
}

View File

@ -4,90 +4,85 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
?>
<div class="box box-solid">
<table class="table table-condensed table-striped">
<thead>
<tr>
<th>#</th>
<th style="width: 450px;">Description</th>
<th style="width: 100px;">Graphs</th>
<th>Type</th>
<th>Status</th>
<th>Errors</th>
<th>Load</th>
</tr>
</thead>
<tbody>
<div class="box box-solid">
<table class="table table-condensed table-striped">
<thead>
<tr>
<th>#</th>
<th style="width: 450px;">Description</th>
<th style="width: 100px;">Graphs</th>
<th>Type</th>
<th>Status</th>
<th>Errors</th>
<th>Load</th>
</tr>
</thead>
<tbody>
<?php
foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", array($device['device_id'])) as $hrdevice)
{
echo(" <tr>\n");
echo(" <td>".$hrdevice['hrDeviceIndex']."</td>\n");
foreach (dbFetchRows("SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`", [$device['device_id']]) as $hrdevice) {
echo(" <tr>\n");
echo(" <td>" . $hrdevice['hrDeviceIndex'] . "</td>\n");
if ($hrdevice['hrDeviceType'] == "hrDeviceProcessor")
{
$proc_id = dbFetchCell('SELECT processor_id FROM processors WHERE device_id = ? AND hrDeviceIndex = ?', array($device['device_id'], $hrdevice['hrDeviceIndex']));
$proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/";
if ($hrdevice['hrDeviceType'] == "hrDeviceProcessor") {
$proc_id = dbFetchCell('SELECT processor_id FROM processors WHERE device_id = ? AND hrDeviceIndex = ?', [$device['device_id'], $hrdevice['hrDeviceIndex']]);
$proc_url = "device/device=" . $device['device_id'] . "/tab=health/metric=processor/";
echo(" <td>" . generate_entity_link('processor', $proc_id) . "</td>\n");
echo(" <td>" . generate_entity_link('processor', $proc_id) . "</td>\n");
$graph_array['height'] = "20";
$graph_array['width'] = "100";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $proc_id;
$graph_array['type'] = 'processor_usage';
$graph_array['from'] = $config['time']['day'];
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$graph_array['height'] = "20";
$graph_array['width'] = "100";
$graph_array['to'] = get_time();
$graph_array['id'] = $proc_id;
$graph_array['type'] = 'processor_usage';
$graph_array['from'] = get_time('day');
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
$mini_graph = overlib_link($proc_url, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
echo(" <td>".$mini_graph."</td>\n");
}
elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork")
{
$int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']);
$interface = dbFetchRow("SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?", array($device['device_id'], $int));
if ($interface['ifIndex'])
{
echo(" <td>".generate_port_link($interface)."</td>\n");
echo(" <td>" . $mini_graph . "</td>\n");
} elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork") {
$int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']);
$interface = dbFetchRow("SELECT * FROM ports WHERE device_id = ? AND ifDescr = ?", [$device['device_id'], $int]);
if ($interface['ifIndex']) {
echo(" <td>" . generate_port_link($interface) . "</td>\n");
$graph_array['height'] = "20";
$graph_array['width'] = "100";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $interface['port_id'];
$graph_array['type'] = 'port_bits';
$graph_array['from'] = $config['time']['day'];
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
$graph_array['height'] = "20";
$graph_array['width'] = "100";
$graph_array['to'] = get_time();
$graph_array['id'] = $interface['port_id'];
$graph_array['type'] = 'port_bits';
$graph_array['from'] = get_time('day');
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";
$graph_array_zoom['width'] = "400";
// FIXME click on graph should also link to port, but can't use generate_port_link here...
$mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
// FIXME click on graph should also link to port, but can't use generate_port_link here...
$mini_graph = overlib_link(generate_port_url($interface), generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
echo(" <td>$mini_graph</td>");
echo(" <td>$mini_graph</td>");
} else {
echo(" <td>" . $hrdevice['hrDeviceDescr'] . "</td>");
echo(" <td></td>");
}
} else {
echo(" <td>".$hrdevice['hrDeviceDescr']."</td>");
echo(" <td></td>");
echo(" <td>" . $hrdevice['hrDeviceDescr'] . "</td>");
echo(" <td></td>");
}
} else {
echo(" <td>".$hrdevice['hrDeviceDescr']."</td>");
echo(" <td></td>");
}
echo(" <td>".$hrdevice['hrDeviceType'].'</td><td>'.$hrdevice['hrDeviceStatus']."</td>");
echo(" <td>".$hrdevice['hrDeviceErrors'].'</td><td>'.$hrdevice['hrProcessorLoad']."</td>");
echo(" </tr>");
echo(" <td>" . $hrdevice['hrDeviceType'] . '</td><td>' . $hrdevice['hrDeviceStatus'] . "</td>");
echo(" <td>" . $hrdevice['hrDeviceErrors'] . '</td><td>' . $hrdevice['hrProcessorLoad'] . "</td>");
echo(" </tr>");
}
echo(" </tbody>\n");

View File

@ -4,60 +4,68 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (!isset($attribs['juniper-firewall-mib'])) {
return;
}
echo generate_box_open();
if (isset($attribs['juniper-firewall-mib'])) {
echo '<table class="table table-striped-two table-condensed">';
echo '<table class="table table-striped-two table-condensed">';
if ($filters = safe_json_decode($attribs['juniper-firewall-mib'])) {
$json = str_decompress($attribs['juniper-firewall-mib']);
if (!$json) {
// Compat with old uncompressed
$json = $attribs['juniper-firewall-mib'];
}
if ($filters = safe_json_decode($json)) {
ksort($filters);
}
foreach ($filters as $filter => $counters) {
}
foreach ($filters as $filter => $counters) {
ksort($counters);
foreach ($counters AS $counter => $types)
{
foreach ($counters as $counter => $types) {
foreach($types as $type => $data)
{
echo '<tr><td><h3><i class="sprite-qos"></i> ' . $filter . ' | <i class="sprite-counter"></i>' . $counter . ' | '.$type.'</h3></td></tr>';
foreach ($types as $type => $data) {
echo '<tr><td><h3><i class="sprite-qos"></i> ' . $filter . ' | <i class="sprite-counter"></i>' . $counter . ' | ' . $type . '</h3></td></tr>';
echo '<tr>';
echo '<td>';
echo '<h4>Packets</h4>';
echo '<tr>';
echo '<td>';
echo '<h4>Packets</h4>';
$graph_array = array('type' => 'device_juniper-firewall-pkts',
'device' => $device['device_id'],
'filter' => safename($filter),
'counter' => safename($counter),
'counter_type' => safename($type)
);
$graph_array = ['type' => 'device_juniper-firewall-pkts',
'device' => $device['device_id'],
'filter' => safename($filter),
'counter' => safename($counter),
'counter_type' => safename($type)
];
print_graph_row($graph_array);
print_graph_row($graph_array);
echo '<h4>Bytes</h4>';
echo '<h4>Bytes</h4>';
$graph_array = array('type' => 'device_juniper-firewall-bits',
'device' => $device['device_id'],
'filter' => safename($filter),
'counter' => safename($counter),
'counter_type' => safename($type)
);
$graph_array = ['type' => 'device_juniper-firewall-bits',
'device' => $device['device_id'],
'filter' => safename($filter),
'counter' => safename($counter),
'counter_type' => safename($type)
];
print_graph_row($graph_array);
print_graph_row($graph_array);
echo '</td></tr>';
}
echo '</td></tr>';
}
}
}
}
echo '</table>';
}
echo '</table>';
unset($json, $filters);
// EOF

View File

@ -4,29 +4,31 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'latency');
$link_array = ['page' => 'device',
'device' => $device['device_id'],
'tab' => 'latency'];
$navbar['brand'] = "Latency";
$navbar['class'] = "navbar-narrow";
foreach (array('incoming', 'outgoing') as $view)
{
if (!strlen($vars['view'])) { $vars['view'] = $view; }
foreach (['incoming', 'outgoing'] as $view) {
if (!strlen($vars['view'])) {
$vars['view'] = $view;
}
if (safe_count($smokeping_files[$view][$device['hostname']]))
{
if ($vars['view'] == $view) { $navbar['options'][$view]['class'] = "active"; }
$navbar['options'][$view]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'latency', 'view' => $view));
$navbar['options'][$view]['text'] = ucwords($view);
}
if (safe_count($smokeping_files[$view][$device['hostname']])) {
if ($vars['view'] == $view) {
$navbar['options'][$view]['class'] = "active";
}
$navbar['options'][$view]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'latency', 'view' => $view]);
$navbar['options'][$view]['text'] = ucwords($view);
}
}
print_navbar($navbar);
@ -35,86 +37,86 @@ echo generate_box_open();
echo '<table class="table table-condensed table-striped table-hover ">';
if ($vars['view'] === "incoming" && safe_count($smokeping_files['incoming'][$device['hostname']])) {
$graph_array['type'] = "device_smokeping_in_all_avg";
$graph_array['device'] = $device['device_id'];
echo('<tr><td>');
echo('<h3>Average</h4>');
$graph_array['type'] = "device_smokeping_in_all_avg";
$graph_array['device'] = $device['device_id'];
echo('<tr><td>');
echo('<h3>Average</h4>');
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</td></tr>');
echo('</td></tr>');
$graph_array['type'] = "device_smokeping_in_all";
$graph_array['legend'] = 'no';
echo('<tr><td>');
echo('<h3>Aggregate</h4>');
$graph_array['type'] = "device_smokeping_in_all";
$graph_array['legend'] = 'no';
echo('<tr><td>');
echo('<h3>Aggregate</h4>');
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</td></tr>');
echo('</td></tr>');
unset($graph_array['legend']);
unset($graph_array['legend']);
ksort($smokeping_files['incoming'][$device['hostname']]);
foreach ($smokeping_files['incoming'][$device['hostname']] AS $src => $host)
{
$hostname = str_replace(".rrd", "", $host);
$host = device_by_name($src);
if (is_numeric($host['device_id']))
{
echo('<tr><td>');
echo('<h3>'.generate_device_link($host).'</h4>');
$graph_array['type'] = "smokeping_in";
$graph_array['device'] = $device['device_id'];
$graph_array['src'] = $host['device_id'];
ksort($smokeping_files['incoming'][$device['hostname']]);
foreach ($smokeping_files['incoming'][$device['hostname']] as $src => $host) {
$hostname = str_replace(".rrd", "", $host);
$host = device_by_name($src);
if (is_numeric($host['device_id'])) {
echo('<tr><td>');
echo('<h3>' . generate_device_link($host) . '</h4>');
$graph_array['type'] = "smokeping_in";
$graph_array['device'] = $device['device_id'];
$graph_array['src'] = $host['device_id'];
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</td></tr>');
echo('</td></tr>');
}
}
}
} elseif ($vars['view'] === "outgoing" && safe_count($smokeping_files['outgoing'][$device['hostname']])) {
$graph_array['type'] = "device_smokeping_out_all_avg";
$graph_array['device'] = $device['device_id'];
echo('<tr><td>');
echo('<h3>Average</h4>');
$graph_array['type'] = "device_smokeping_out_all_avg";
$graph_array['device'] = $device['device_id'];
echo('<tr><td>');
echo('<h3>Average</h4>');
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</td></tr>');
echo('</td></tr>');
$graph_array['type'] = "device_smokeping_out_all";
$graph_array['legend'] = 'no';
echo('<tr><td>');
echo('<h3>Aggregate</h4>');
$graph_array['type'] = "device_smokeping_out_all";
$graph_array['legend'] = 'no';
echo('<tr><td>');
echo('<h3>Aggregate</h4>');
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</td></tr>');
echo('</td></tr>');
unset($graph_array['legend']);
unset($graph_array['legend']);
asort($smokeping_files['outgoing'][$device['hostname']]);
foreach ($smokeping_files['outgoing'][$device['hostname']] AS $host)
{
$hostname = basename($host, ".rrd");
list($hostname) = explode("~", $hostname);
if ($config['smokeping']['suffix']) $hostname = $hostname.$config['smokeping']['suffix'];
if ($config['smokeping']['split_char']) $hostname = str_replace($config['smokeping']['split_char'],".",$hostname);
$host = device_by_name($hostname);
if (is_numeric($host['device_id']))
{
echo('<tr><td>');
echo('<h3>'.generate_device_link($host).'</h4>');
$graph_array['type'] = "smokeping_out";
$graph_array['device'] = $device['device_id'];
$graph_array['dest'] = $host['device_id'];
asort($smokeping_files['outgoing'][$device['hostname']]);
foreach ($smokeping_files['outgoing'][$device['hostname']] as $host) {
$hostname = basename($host, ".rrd");
[$hostname] = explode("~", $hostname);
if ($config['smokeping']['suffix']) {
$hostname = $hostname . $config['smokeping']['suffix'];
}
if ($config['smokeping']['split_char']) {
$hostname = str_replace($config['smokeping']['split_char'], ".", $hostname);
}
$host = device_by_name($hostname);
if (is_numeric($host['device_id'])) {
echo('<tr><td>');
echo('<h3>' . generate_device_link($host) . '</h4>');
$graph_array['type'] = "smokeping_out";
$graph_array['device'] = $device['device_id'];
$graph_array['dest'] = $host['device_id'];
print_graph_row($graph_array);
print_graph_row($graph_array);
echo('</td></tr>');
echo('</td></tr>');
}
}
}
}
echo '</table>';

View File

@ -1,56 +1,52 @@
<?php
/**
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (!isset($vars['section'])) { $vars['section'] = 'eventlog'; }
$sections = array('eventlog');
if ($config['enable_syslog'])
{
$sections[] = 'syslog';
if (OBSERVIUM_EDITION != 'community')
{
$sections[] = 'logalert';
}
// Allowed sections: eventlog, syslog, logalert, alertlog
$sections = [ 'eventlog' ];
if ($config['enable_syslog']) {
$sections[] = 'syslog';
if (OBSERVIUM_EDITION != 'community') {
$sections[] = 'logalert';
}
}
$sections[] = 'alertlog';
if (empty($vars['section'])) {
$vars['section'] = 'eventlog';
} elseif (!is_alpha($vars['section']) || !in_array($vars['section'], $sections, TRUE)) {
//r($vars['section']);
print_error_permission("Unknown Logs section.");
return;
}
$navbar['brand'] = "Logging";
$navbar['class'] = "navbar-narrow";
foreach ($sections as $section)
{
$type = strtolower($section);
if (!isset($vars['section'])) { $vars['section'] = $section; }
foreach ($sections as $section) {
$type = strtolower($section);
if (!isset($vars['section'])) {
$vars['section'] = escape_html($section);
}
if ($vars['section'] == $section) { $navbar['options'][$section]['class'] = "active"; }
$navbar['options'][$section]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'logs', 'section' => $section));
$navbar['options'][$section]['text'] = nicecase($section);
if ($vars['section'] == $section) {
$navbar['options'][$section]['class'] = "active";
}
$navbar['options'][$section]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'logs', 'section' => $section]);
$navbar['options'][$section]['text'] = nicecase($section);
}
print_navbar($navbar);
switch ($vars['section'])
{
case 'syslog':
case 'eventlog':
case 'alertlog':
case 'logalert':
include($config['html_dir'].'/pages/device/logs/'.$vars['section'].'.inc.php');
break;
default:
echo('<h2>Error. No section '.$vars['section'].'.<br /> Please report this to observium developers.</h2>');
break;
}
include($config['html_dir'] . '/pages/device/logs/' . $vars['section'] . '.inc.php');
// EOF

View File

@ -6,91 +6,99 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @copyright (C) Adam Armstrong
*
*/
?>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
<?php
<?php
if (!is_array($alert_rules)) { $alert_rules = cache_alert_rules(); }
if (!is_array($alert_rules)) {
$alert_rules = cache_alert_rules();
}
// Note, this form have more complex grid and class elements for responsive datetime field
$form = array('type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => generate_url($vars));
// Note, this form have more complex grid and class elements for responsive datetime field
$form = [
'type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => generate_url($vars)
];
$where = ' WHERE 1 ' . generate_query_values_and($device['device_id'], 'device_id');
$where = ' WHERE ' . generate_query_values($device['device_id'], 'device_id');
// Checkers Field
$form_filter = dbFetchColumn('SELECT DISTINCT `alert_test_id` FROM `alert_log`' . $where);
$form_items['checkers'] = generate_form_values('alert_log', $form_filter, 'alert_test_id');
$form['row'][0]['alert_test_id'] = array(
'type' => 'multiselect',
'name' => 'Checkers',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-2 col-sm-4',
'subtext' => TRUE,
'value' => $vars['alert_test_id'],
'values' => $form_items['checkers']);
// Checkers Field
$form_filter = dbFetchColumn('SELECT DISTINCT `alert_test_id` FROM `alert_log`' . $where);
$form_items['checkers'] = generate_form_values('alert_log', $form_filter, 'alert_test_id');
$form['row'][0]['alert_test_id'] = [
'type' => 'multiselect',
'name' => 'Checkers',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-2 col-sm-4',
'subtext' => TRUE,
'value' => $vars['alert_test_id'],
'values' => $form_items['checkers']
];
// Status Type Field
$form_filter = dbFetchColumn('SELECT DISTINCT `log_type` FROM `alert_log`' . $where);
$form_items['statuses'] = generate_form_values('alert_log', $form_filter, 'log_type');
$form['row'][0]['log_type'] = array(
'type' => 'multiselect',
'name' => 'Status Type',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-2 col-sm-4',
'size' => '15',
'value' => $vars['log_type'],
'values' => $form_items['statuses']);
// Status Type Field
$form_filter = dbFetchColumn('SELECT DISTINCT `log_type` FROM `alert_log`' . $where);
$form_items['statuses'] = generate_form_values('alert_log', $form_filter, 'log_type');
$form['row'][0]['log_type'] = [
'type' => 'multiselect',
'name' => 'Status Type',
'width' => '100%',
'div_class' => 'col-lg-2 col-md-2 col-sm-4',
'size' => '15',
'value' => $vars['log_type'],
'values' => $form_items['statuses']
];
// Datetime Field
$form['row'][0]['timestamp'] = array(
'type' => 'datetime',
//'grid' => 5,
//'width' => '70%',
'div_class' => 'col-lg-5 col-md-7 col-sm-9',
'presets' => TRUE,
'min' => dbFetchCell('SELECT `timestamp` FROM `alert_log`' . $where . ' ORDER BY `timestamp` LIMIT 0,1;'),
'max' => dbFetchCell('SELECT `timestamp` FROM `alert_log`' . $where . ' ORDER BY `timestamp` DESC LIMIT 0,1;'),
'from' => $vars['timestamp_from'],
'to' => $vars['timestamp_to']);
// Second row with timestamp for sm
//$form['row_options'][1] = array('class' => 'hidden-lg hidden-md hidden-xs');
//$form['row'][1]['timestamp'] = $form['row'][0]['timestamp'];
//$form['row'][1]['timestamp']['div_class'] = 'text-nowrap col-sm-9';
// Datetime Field
$form['row'][0]['timestamp'] = [
'type' => 'datetime',
//'grid' => 5,
//'width' => '70%',
'div_class' => 'col-lg-5 col-md-7 col-sm-9',
'presets' => TRUE,
'min' => dbFetchCell('SELECT `timestamp` FROM `alert_log`' . $where . ' ORDER BY `timestamp` LIMIT 0,1;'),
'max' => dbFetchCell('SELECT `timestamp` FROM `alert_log`' . $where . ' ORDER BY `timestamp` DESC LIMIT 0,1;'),
'from' => $vars['timestamp_from'],
'to' => $vars['timestamp_to']
];
// Second row with timestamp for sm
//$form['row_options'][1] = array('class' => 'hidden-lg hidden-md hidden-xs');
//$form['row'][1]['timestamp'] = $form['row'][0]['timestamp'];
//$form['row'][1]['timestamp']['div_class'] = 'text-nowrap col-sm-9';
// search button
$form['row'][0]['search'] = array(
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'div_class' => 'col-lg-3 col-md-1 col-sm-3',
//'grid' => 1,
'right' => TRUE);
// search button
$form['row'][0]['search'] = [
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'div_class' => 'col-lg-3 col-md-1 col-sm-3',
//'grid' => 1,
'right' => TRUE
];
print_form($form);
unset($form, $form_items, $form_filter);
print_form($form);
unset($form, $form_items, $form_filter);
// Pagination
$vars['pagination'] = TRUE;
// Pagination
$vars['pagination'] = TRUE;
// Print Alert Log
print_alert_log($vars);
// Print Alert Log
print_alert_log($vars);
register_html_title('Alert Log');
register_html_title('Alert Log');
?>
</div> <!-- col-md-12 -->
?>
</div> <!-- col-md-12 -->
</div> <!-- row -->
</div> <!-- row -->
<?php
// EOF

View File

@ -4,74 +4,74 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$where = ' WHERE 1 ' . generate_query_values_and($device['device_id'], 'device_id');
$timestamp_min = dbFetchCell('SELECT `timestamp` FROM `eventlog` '.$where.' ORDER BY `timestamp` LIMIT 0,1;');
$timestamp_max = dbFetchCell('SELECT `timestamp` FROM `eventlog` '.$where.' ORDER BY `timestamp` DESC LIMIT 0,1;');
$timestamp_min = dbFetchCell('SELECT `timestamp` FROM `eventlog` ' . $where . ' ORDER BY `timestamp` LIMIT 0,1;');
$timestamp_max = dbFetchCell('SELECT `timestamp` FROM `eventlog` ' . $where . ' ORDER BY `timestamp` DESC LIMIT 0,1;');
// Note, this form have more complex grid and class elements for responsive datetime field
$form = array('type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => generate_url($vars));
$form = ['type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => generate_url($vars)];
// Message field
$form['row'][0]['message'] = array(
'type' => 'text',
'name' => 'Message',
'placeholder' => 'Message',
'width' => '100%',
'div_class' => 'col-lg-4 col-md-6 col-sm-6',
'value' => $vars['message']);
$form['row'][0]['message'] = [
'type' => 'text',
'name' => 'Message',
'placeholder' => 'Message',
'width' => '100%',
'div_class' => 'col-lg-4 col-md-6 col-sm-6',
'value' => $vars['message']];
// Severities field
$form_filter = dbFetchColumn('SELECT DISTINCT `severity` FROM `eventlog`' . $where);
$form_items['severities'] = generate_form_values('eventlog', $form_filter, 'severity');
$form['row'][0]['severity'] = array(
'type' => 'multiselect',
'name' => 'Severities',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
'subtext' => TRUE,
'value' => $vars['severity'],
'values' => $form_items['severities']);
$form_filter = dbFetchColumn('SELECT DISTINCT `severity` FROM `eventlog`' . $where);
$form_items['severities'] = generate_form_values('eventlog', $form_filter, 'severity');
$form['row'][0]['severity'] = [
'type' => 'multiselect',
'name' => 'Severities',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
'subtext' => TRUE,
'value' => $vars['severity'],
'values' => $form_items['severities']];
// Types field
$form_filter = dbFetchColumn('SELECT DISTINCT `entity_type` FROM `eventlog` IGNORE INDEX (`type`)' . $where);
$form_items['types'] = generate_form_values('eventlog', $form_filter, 'type');
$form['row'][0]['type'] = array(
'type' => 'multiselect',
'name' => 'Types',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
'size' => '15',
'value' => $vars['type'],
'values' => $form_items['types']);
$form_filter = dbFetchColumn('SELECT DISTINCT `entity_type` FROM `eventlog` IGNORE INDEX (`type`)' . $where);
$form_items['types'] = generate_form_values('eventlog', $form_filter, 'type');
$form['row'][0]['type'] = [
'type' => 'multiselect',
'name' => 'Types',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
'size' => '15',
'value' => $vars['type'],
'values' => $form_items['types']];
// Datetime field
$form['row'][0]['timestamp'] = array(
'type' => 'datetime',
'div_class' => 'col-lg-5 col-md-7 col-sm-10',
'presets' => TRUE,
'min' => $timestamp_min,
'max' => $timestamp_max,
'from' => $vars['timestamp_from'],
'to' => $vars['timestamp_to']);
$form['row'][0]['timestamp'] = [
'type' => 'datetime',
'div_class' => 'col-lg-5 col-md-7 col-sm-10',
'presets' => TRUE,
'min' => $timestamp_min,
'max' => $timestamp_max,
'from' => $vars['timestamp_from'],
'to' => $vars['timestamp_to']];
// search button
$form['row'][0]['search'] = array(
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'div_class' => 'col-lg-1 col-md-5 col-sm-2',
//'grid' => 1,
'right' => TRUE);
$form['row'][0]['search'] = [
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'div_class' => 'col-lg-1 col-md-5 col-sm-2',
//'grid' => 1,
'right' => TRUE];
print_form($form);
unset($form, $form_items, $form_devices);

View File

@ -1,5 +1,5 @@
<?php
print_logalert_log($vars);
print_logalert_log($vars);
?>

View File

@ -4,116 +4,115 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$where = ' WHERE 1 ' . generate_query_values_and($device['device_id'], 'device_id');
$timestamp_min = dbFetchCell('SELECT `timestamp` FROM `syslog` '.$where.' ORDER BY `timestamp` LIMIT 0,1;');
if ($timestamp_min)
{
$timestamp_max = dbFetchCell('SELECT `timestamp` FROM `syslog` '.$where.' ORDER BY `timestamp` DESC LIMIT 0,1;');
$timestamp_min = dbFetchCell('SELECT `timestamp` FROM `syslog` ' . $where . ' ORDER BY `timestamp` LIMIT 0,1;');
if ($timestamp_min) {
$timestamp_max = dbFetchCell('SELECT `timestamp` FROM `syslog` ' . $where . ' ORDER BY `timestamp` DESC LIMIT 0,1;');
// Note, this form have more complex grid and class elements for responsive datetime field
$form = array('type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => generate_url($vars));
// Note, this form have more complex grid and class elements for responsive datetime field
$form = ['type' => 'rows',
'space' => '5px',
'submit_by_key' => TRUE,
'url' => generate_url($vars)];
// Message field
$form['row'][0]['message'] = array(
'type' => 'text',
'name' => 'Message',
'placeholder' => 'Message',
'width' => '100%',
'div_class' => 'col-lg-4 col-md-6 col-sm-6',
'value' => $vars['message']);
// Priority field
dbSetVariable('MAX_EXECUTION_TIME', 5000); // Set 5 sec maximum query execution time
if (!$form_filter = dbFetchColumn('SELECT DISTINCT `priority` FROM `syslog`' . $where)) {
$form_filter = NULL;
}
dbSetVariable('MAX_EXECUTION_TIME', 0); // Reset maximum query execution time
$form_items['priorities'] = generate_form_values('syslog', $form_filter, 'priorities');
$form['row'][0]['priority'] = array(
'type' => 'multiselect',
'name' => 'Priorities',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
'subtext' => TRUE,
'value' => $vars['priority'],
'values' => $form_items['priorities']);
// Program field
dbSetVariable('MAX_EXECUTION_TIME', 5000); // Set 5 sec maximum query execution time
$form_filter = dbFetchColumn('SELECT DISTINCT `program` FROM `syslog`' . $where);
dbSetVariable('MAX_EXECUTION_TIME', 0); // Reset maximum query execution time
if (safe_count($form_filter)) {
// Use full multiselect form
$form_items['programs'] = generate_form_values('syslog', $form_filter, 'programs');
$form['row'][0]['program'] = array(
'type' => 'multiselect',
'name' => 'Programs',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
'size' => '15',
'value' => $vars['program'],
'values' => $form_items['programs']);
} else {
// Use input form with speedup indexed ajax program list
$form['row'][0]['program'] = array(
// Message field
$form['row'][0]['message'] = [
'type' => 'text',
'name' => 'Programs',
'placeholder' => 'Program: type for hints',
'name' => 'Message',
'placeholder' => 'Message',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
//'grid' => 3,
'ajax' => TRUE,
'ajax_vars' => [ 'field' => 'syslog_program', 'device_id' => $device['device_id'] ],
'value' => $vars['program']);
}
'div_class' => 'col-lg-4 col-md-6 col-sm-6',
'value' => $vars['message']];
// Datetime field
$form['row'][0]['timestamp'] = array(
'type' => 'datetime',
'div_class' => 'col-lg-5 col-md-7 col-sm-10',
'presets' => TRUE,
'min' => $timestamp_min,
'max' => $timestamp_max,
'from' => $vars['timestamp_from'],
'to' => $vars['timestamp_to']);
// Second row with timestamp for md and sm
//$form['row_options'][1] = array('class' => 'hidden-lg hidden-xs');
//$form['row'][1]['timestamp'] = $form['row'][0]['timestamp'];
//$form['row'][1]['timestamp']['div_class'] = 'text-nowrap col-md-7 col-sm-8';
// Priority field
dbSetVariable('MAX_EXECUTION_TIME', 5000); // Set 5 sec maximum query execution time
if (!$form_filter = dbFetchColumn('SELECT DISTINCT `priority` FROM `syslog`' . $where)) {
$form_filter = NULL;
}
dbSetVariable('MAX_EXECUTION_TIME', 0); // Reset maximum query execution time
$form_items['priorities'] = generate_form_values('syslog', $form_filter, 'priorities');
$form['row'][0]['priority'] = [
'type' => 'multiselect',
'name' => 'Priorities',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
'subtext' => TRUE,
'value' => $vars['priority'],
'values' => $form_items['priorities']];
// search button
$form['row'][0]['search'] = array(
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'div_class' => 'col-lg-1 col-md-5 col-sm-2',
//'grid' => 1,
'right' => TRUE);
// Program field
dbSetVariable('MAX_EXECUTION_TIME', 5000); // Set 5 sec maximum query execution time
$form_filter = dbFetchColumn('SELECT DISTINCT `program` FROM `syslog`' . $where);
dbSetVariable('MAX_EXECUTION_TIME', 0); // Reset maximum query execution time
if (safe_count($form_filter)) {
// Use full multiselect form
$form_items['programs'] = generate_form_values('syslog', $form_filter, 'programs');
$form['row'][0]['program'] = [
'type' => 'multiselect',
'name' => 'Programs',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
'size' => '15',
'value' => $vars['program'],
'values' => $form_items['programs']];
} else {
// Use input form with speedup indexed ajax program list
$form['row'][0]['program'] = [
'type' => 'text',
'name' => 'Programs',
'placeholder' => 'Program: type for hints',
'width' => '100%',
'div_class' => 'col-lg-1 col-md-2 col-sm-2',
//'grid' => 3,
'ajax' => TRUE,
'ajax_vars' => ['field' => 'syslog_program', 'device_id' => $device['device_id']],
'value' => $vars['program']];
}
print_form($form);
unset($form, $form_items, $form_devices);
// Datetime field
$form['row'][0]['timestamp'] = [
'type' => 'datetime',
'div_class' => 'col-lg-5 col-md-7 col-sm-10',
'presets' => TRUE,
'min' => $timestamp_min,
'max' => $timestamp_max,
'from' => $vars['timestamp_from'],
'to' => $vars['timestamp_to']];
// Second row with timestamp for md and sm
//$form['row_options'][1] = array('class' => 'hidden-lg hidden-xs');
//$form['row'][1]['timestamp'] = $form['row'][0]['timestamp'];
//$form['row'][1]['timestamp']['div_class'] = 'text-nowrap col-md-7 col-sm-8';
// Pagination
$vars['pagination'] = TRUE;
// search button
$form['row'][0]['search'] = [
'type' => 'submit',
//'name' => 'Search',
//'icon' => 'icon-search',
'div_class' => 'col-lg-1 col-md-5 col-sm-2',
//'grid' => 1,
'right' => TRUE];
// Print syslog
print_syslogs($vars);
print_form($form);
unset($form, $form_items, $form_devices);
// Pagination
$vars['pagination'] = TRUE;
// Print syslog
print_syslogs($vars);
} else {
print_warning('<h3>No syslog entries found!</h4>
print_warning('<h3>No syslog entries found!</h4>
This device does not have any syslog entries.
Check that the syslog daemon and Observium configuration options are set correctly, that this device is configured to send syslog to Observium and that there are no firewalls blocking the messages.
See <a href="'.OBSERVIUM_DOCS_URL.'/syslog/" target="_blank">Syslog Integration</a> guide and <a href="'.OBSERVIUM_DOCS_URL.'/config_options/#syslog-settings" target="_blank">configuration options</a> for more information.');
See <a href="' . OBSERVIUM_DOCS_URL . '/syslog/" target="_blank">Syslog Integration</a> guide and <a href="' . OBSERVIUM_DOCS_URL . '/config_options/#syslog-settings" target="_blank">configuration options</a> for more information.');
}
register_html_title('Syslog');

View File

@ -4,43 +4,44 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
// Sections are printed in the order they exist in $config['graph_sections']
// Graphs are printed in the order they exist in $config['graph_types']
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'munin');
$link_array = ['page' => 'device',
'device' => $device['device_id'],
'tab' => 'munin'];
foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", array($device['device_id'])) as $mplug)
{
foreach (dbFetchRows("SELECT * FROM munin_plugins WHERE device_id = ? ORDER BY mplug_category, mplug_type", [$device['device_id']]) as $mplug) {
# if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else { }
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id'];
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title'];
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type'];
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id'];
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title'];
$graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type'];
}
$navbar['brand'] = "Munin";
$navbar['class'] = "navbar-narrow";
foreach ($graph_enable as $section => $nothing)
{
if (isset($graph_enable) && is_array($graph_enable[$section]))
{
$type = strtolower($section);
if (!$vars['group']) { $vars['group'] = $type; }
if ($vars['group'] == $type) { $navbar['options'][$type]['class'] = "active"; }
foreach ($graph_enable as $section => $nothing) {
if (isset($graph_enable) && is_array($graph_enable[$section])) {
$type = strtolower($section);
if (!$vars['group']) {
$vars['group'] = $type;
}
if ($vars['group'] == $type) {
$navbar['options'][$type]['class'] = "active";
}
$navbar['options'][$type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'munin', 'group' => $type));
$navbar['options'][$type]['text'] = escape_html(ucwords($section));
$navbar['options'][$type]['url'] = generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'munin', 'group' => $type]);
$navbar['options'][$type]['text'] = escape_html(ucwords($section));
}
}
}
print_navbar($navbar);
@ -52,24 +53,21 @@ echo generate_box_open();
echo '<table class="table table-condensed table-striped table-hover">';
#foreach ($config['graph_types']['device'] as $graph => $entry)
foreach ($graph_enable as $graph => $entry)
{
$graph_array = array();
if ($graph_enable[$graph])
{
if (!empty($entry['plugin']))
{
$graph_title = $entry['title'];
$graph_array['type'] = "munin_graph";
$graph_array['device'] = $device['device_id'];
$graph_array['plugin'] = $entry['plugin'];
} else {
$graph_title = $config['graph_types']['device'][$graph]['descr'];
$graph_array['type'] = "device_" . $graph;
}
foreach ($graph_enable as $graph => $entry) {
$graph_array = [];
if ($graph_enable[$graph]) {
if (!empty($entry['plugin'])) {
$graph_title = $entry['title'];
$graph_array['type'] = "munin_graph";
$graph_array['device'] = $device['device_id'];
$graph_array['plugin'] = $entry['plugin'];
} else {
$graph_title = $config['graph_types']['device'][$graph]['descr'];
$graph_array['type'] = "device_" . $graph;
}
include("includes/print-device-graph.php");
}
include("includes/print-device-graph.php");
}
}
echo '</table>';

View File

@ -4,9 +4,9 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
@ -19,22 +19,22 @@ $datas = [
// Detect Nfsen-ng
$nfsen_rrd_info = rrdtool_file_info($nfsen_rrd_file);
if (isset($nfsen_rrd_info['DS']['bytes'])) {
$datas['Traffic'] = 'nfsen_bytes';
$datas['Traffic'] = 'nfsen_bytes';
}
foreach ($datas as $name => $type) {
$graph_title = nicecase($name);
$graph_array['type'] = "device_".$type;
$graph_array['device'] = $device['device_id'];
#$graph_array['legend'] = 'no';
$graph_title = nicecase($name);
$graph_array['type'] = "device_" . $type;
$graph_array['device'] = $device['device_id'];
#$graph_array['legend'] = 'no';
$box_args = [ 'title' => $graph_title, 'header-border' => TRUE ];
$box_args = ['title' => $graph_title, 'header-border' => TRUE];
echo generate_box_open($box_args);
echo generate_box_open($box_args);
print_graph_row($graph_array);
echo generate_box_close();
print_graph_row($graph_array);
echo generate_box_close();
}
register_html_title("Netflow");

View File

@ -1,59 +1,65 @@
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
register_html_resource('css', 'easymde.min.css');
register_html_resource('js', 'easymde.min.js');
register_html_resource('js', 'purify.min.js');
if (($_SESSION['userlevel'] >= 7 || is_entity_write_permitted($device['device_id'], 'device')) &&
isset($vars['notes_text']) && is_string($vars['notes_text']) && request_token_valid($vars)) {
set_entity_attrib('device', $device['device_id'], 'notes', $vars['notes_text'], $device['device_id']);
unset($vars['notes_text']);
if (isset($attribs) && is_array($attribs)) {
$attribs['notes'] = $vars['notes_text'];
}
}
$notes = get_entity_attrib('device', $device['device_id'], 'notes');
if ($vars['edit']) {
echo generate_box_open();
echo '<form method="POST" id="edit" name="edit" action="'.generate_url($vars, array('edit' => NULL)).'" class="form form-horizontal" style="margin-bottom: 0px;">';
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element([ 'type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken'] ]) . PHP_EOL;
}
//echo generate_form_element([ 'type' => 'textarea', 'id' => 'notes_text', 'value' => $notes ]) . PHP_EOL; // not know why, this broke form
echo ' <textarea name="notes_text" id="notes_text">' . escape_html($notes) . '</textarea>';
echo generate_box_close();
echo ' <button id="submit" name="submit" type="submit" class="btn btn-primary text-nowrap pull-right" value="save"><i class="icon-ok icon-white" style="margin-right: 0px;"></i>&nbsp;&nbsp;Save Changes</button> ';
echo ' </form>';
// https://github.com/Ionaru/easy-markdown-editor
register_html_resource('script', 'const easyMDE = new EasyMDE({ renderingConfig: { singleLineBreaks: false, sanitizerFunction: (renderedHTML) => {return DOMPurify.sanitize(renderedHTML, {ALLOWED_TAGS: [\'b\']}) }, }, });');
} else {
echo generate_box_open(array('padding' => TRUE));
echo get_markdown($notes);
echo generate_box_close();
if (($_SESSION['userlevel'] >= 7 || is_entity_write_permitted($device['device_id'], 'device')) ) {
echo '<a href="'.generate_url($vars, array('edit' => TRUE)).'" id="edit" name="edit" type="submit" class="btn btn-primary text-nowrap pull-right" value="edit"><i class="icon-ok icon-white" style="margin-right: 0px;"></i>&nbsp;&nbsp;Edit Notes</a>';
}
}
// EOF
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
if (!$config['web_show_notes']) {
print_error_permission("Notes disabled by config option \$config['web_show_notes'].");
return;
}
register_html_resource('css', 'easymde.min.css');
register_html_resource('js', 'easymde.min.js');
register_html_resource('js', 'purify.min.js');
if (($_SESSION['userlevel'] >= 7 || is_entity_write_permitted($device['device_id'], 'device')) &&
isset($vars['notes_text']) && is_string($vars['notes_text']) && request_token_valid($vars)) {
set_entity_attrib('device', $device['device_id'], 'notes', $vars['notes_text'], $device['device_id']);
unset($vars['notes_text']);
if (isset($attribs) && is_array($attribs)) {
$attribs['notes'] = $vars['notes_text'];
}
}
$notes = get_entity_attrib('device', $device['device_id'], 'notes');
if ($vars['edit']) {
echo generate_box_open();
echo '<form method="POST" id="edit" name="edit" action="' . generate_url($vars, [ 'edit' => NULL ]) . '" class="form form-horizontal" style="margin-bottom: 0px;">';
// Add CSRF Token
if (isset($_SESSION['requesttoken'])) {
echo generate_form_element(['type' => 'hidden', 'id' => 'requesttoken', 'value' => $_SESSION['requesttoken']]) . PHP_EOL;
}
//echo generate_form_element([ 'type' => 'textarea', 'id' => 'notes_text', 'value' => $notes ]) . PHP_EOL; // not know why, this broke form
echo ' <textarea name="notes_text" id="notes_text">' . escape_html($notes) . '</textarea>';
echo generate_box_close();
echo ' <button id="submit" name="submit" type="submit" class="btn btn-primary text-nowrap pull-right" value="save"><i class="icon-ok icon-white" style="margin-right: 0px;"></i>&nbsp;&nbsp;Save Changes</button> ';
echo ' </form>';
// https://github.com/Ionaru/easy-markdown-editor
register_html_resource('script', 'const easyMDE = new EasyMDE({ renderingConfig: { singleLineBreaks: false, sanitizerFunction: (renderedHTML) => {return DOMPurify.sanitize(renderedHTML, {ALLOWED_TAGS: [\'b\']}) }, }, });');
} else {
echo generate_box_open([ 'padding' => TRUE ]);
echo get_markdown($notes);
echo generate_box_close();
if (($_SESSION['userlevel'] >= 7 || is_entity_write_permitted($device['device_id'], 'device'))) {
echo '<a href="' . generate_url($vars, [ 'edit' => TRUE ]) . '" id="edit" name="edit" type="submit" class="btn btn-primary text-nowrap pull-right" value="edit"><i class="icon-ok icon-white" style="margin-right: 0px;"></i>&nbsp;&nbsp;Edit Notes</a>';
}
}
// EOF

View File

@ -4,78 +4,79 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$overview = 1;
$ports['total'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($device['device_id']));
$ports['up'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'up' AND (`ifOperStatus` = 'up' OR `ifOperStatus` = 'monitoring')", array($device['device_id']));
$ports['down'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'up' AND (`ifOperStatus` = 'lowerLayerDown' OR `ifOperStatus` = 'down')", array($device['device_id']));
$ports['disabled'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'down'", array($device['device_id']));
$ports['total'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", [$device['device_id']]);
$ports['up'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'up' AND (`ifOperStatus` = 'up' OR `ifOperStatus` = 'monitoring')", [$device['device_id']]);
$ports['down'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'up' AND (`ifOperStatus` = 'lowerLayerDown' OR `ifOperStatus` = 'down')", [$device['device_id']]);
$ports['disabled'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'down'", [$device['device_id']]);
if ($ports['down']) { $ports_colour = OBS_COLOUR_WARN_A; } else { $ports_colour = OBS_COLOUR_LIST_A; }
if ($ports['down']) {
$ports_colour = OBS_COLOUR_WARN_A;
} else {
$ports_colour = OBS_COLOUR_LIST_A;
}
?>
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<?php
/* Begin Left Pane */
<?php
/* Begin Left Pane */
include("overview/information.inc.php");
include("overview/information.inc.php");
include("overview/ports.inc.php");
include("overview/ports.inc.php");
include("overview/alertlog.inc.php");
include("overview/alertlog.inc.php");
if ($config['enable_syslog']) {
include("overview/syslog.inc.php");
}
if ($config['enable_syslog']) {
include("overview/syslog.inc.php");
}
echo("</div>");
/* End Left Pane */
echo("</div>");
/* End Left Pane */
/* Begin Right Pane */
echo('<div class="col-md-6">');
/* Begin Right Pane */
echo('<div class="col-md-6">');
if ($device['os_group'] == "unix")
{
include("overview/processors-unix.inc.php");
} else {
include("overview/processors.inc.php");
}
if ($device['os_group'] == "unix") {
include("overview/processors-unix.inc.php");
} else {
include("overview/processors.inc.php");
}
if (is_array($device_state['ucd_mem']))
{
include("overview/ucd_mem.inc.php");
} else {
include("overview/mempools.inc.php");
}
if (is_array($device_state['ucd_mem'])) {
include("overview/ucd_mem.inc.php");
} else {
include("overview/mempools.inc.php");
}
include("overview/storage.inc.php");
include("overview/storage.inc.php");
if (is_array($entity_state['group']['c6kxbar']))
{
include("overview/c6kxbar.inc.php");
}
if (is_array($entity_state['group']['c6kxbar'])) {
include("overview/c6kxbar.inc.php");
}
include("overview/printersupplies.inc.php");
include("overview/status.inc.php");
include("overview/counter.inc.php");
include("overview/sensors.inc.php");
include("overview/printersupplies.inc.php");
include("overview/status.inc.php");
include("overview/counter.inc.php");
include("overview/sensors.inc.php");
include("overview/events.inc.php");
include("overview/events.inc.php");
/* End Right Pane */
/* End Right Pane */
?>
?>
</div>
</div>
</div>
</div>
<?php

View File

@ -4,93 +4,93 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage web
* @copyright (C) Adam Armstrong
*
*/
$overview = 1;
$ports['total'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($device['device_id']));
$ports['up'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'up' AND (`ifOperStatus` = 'up' OR `ifOperStatus` = 'monitoring')", array($device['device_id']));
$ports['down'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'up' AND (`ifOperStatus` = 'lowerLayerDown' OR `ifOperStatus` = 'down')", array($device['device_id']));
$ports['disabled'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'down'", array($device['device_id']));
$ports['total'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", [$device['device_id']]);
$ports['up'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'up' AND (`ifOperStatus` = 'up' OR `ifOperStatus` = 'monitoring')", [$device['device_id']]);
$ports['down'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'up' AND (`ifOperStatus` = 'lowerLayerDown' OR `ifOperStatus` = 'down')", [$device['device_id']]);
$ports['disabled'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ? AND `ifAdminStatus` = 'down'", [$device['device_id']]);
if ($ports['down']) { $ports_colour = OBS_COLOUR_WARN_A; } else { $ports_colour = OBS_COLOUR_LIST_A; }
if ($ports['down']) {
$ports_colour = OBS_COLOUR_WARN_A;
} else {
$ports_colour = OBS_COLOUR_LIST_A;
}
?>
<div class="row">
<div class="col-md-4">
<div class="row">
<div class="col-md-4">
<?php
/* Begin Left Pane */
<?php
/* Begin Left Pane */
include("overview/information.inc.php");
include("overview/information.inc.php");
include("overview/alerts.inc.php");
include("overview/alerts.inc.php");
include("overview/alertlog.inc.php");
include("overview/alertlog.inc.php");
include("overview/events.inc.php");
include("overview/events.inc.php");
if ($config['enable_syslog'])
{
include("overview/syslog.inc.php");
}
if ($config['enable_syslog']) {
include("overview/syslog.inc.php");
}
echo("</div>");
/* End Left Pane */
echo("</div>");
/* End Left Pane */
/* Begin Center Pane */
echo('<div class="col-md-4">');
/* Begin Center Pane */
echo('<div class="col-md-4">');
include("overview/ports.inc.php");
include("overview/ports.inc.php");
include("overview/services.inc.php");
include("overview/services.inc.php");
if (is_array($entity_state['group']['c6kxbar']))
{
include("overview/c6kxbar.inc.php");
}
if (is_array($entity_state['group']['c6kxbar'])) {
include("overview/c6kxbar.inc.php");
}
include("overview/printersupplies.inc.php");
include("overview/printersupplies.inc.php");
include("overview/status.inc.php");
include("overview/counter.inc.php");
include("overview/sensors.inc.php");
include("overview/status.inc.php");
include("overview/counter.inc.php");
include("overview/sensors.inc.php");
echo("</div>");
/* End Left Pane */
echo("</div>");
/* End Left Pane */
/* Begin Center Pane */
echo('<div class="col-md-4">');
/* Begin Center Pane */
echo('<div class="col-md-4">');
if ($device['os_group'] == "unix")
{
include("overview/processors-unix.inc.php");
} else {
include("overview/processors.inc.php");
}
if ($device['os_group'] == "unix") {
include("overview/processors-unix.inc.php");
} else {
include("overview/processors.inc.php");
}
if (is_array($device_state['ucd_mem']))
{
include("overview/ucd_mem.inc.php");
} else {
include("overview/mempools.inc.php");
}
if (is_array($device_state['ucd_mem'])) {
include("overview/ucd_mem.inc.php");
} else {
include("overview/mempools.inc.php");
}
include("overview/storage.inc.php");
include("overview/storage.inc.php");
echo('</div>');
echo('</div>');
/* End Center Pane */
/* End Center Pane */
/* Begin Right Pane */
/* Begin Right Pane */
?>
?>
</div>
</div>
<?php

View File

@ -4,10 +4,10 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
@ -15,57 +15,64 @@ $overview = 1;
?>
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<?php
/* Begin Left Pane */
<?php
/* Begin Left Pane */
include("overview/information.inc.php");
include("overview/information.inc.php");
include("overview/ports.inc.php");
include("overview/ports.inc.php");
include("overview/services.inc.php");
include("overview/services.inc.php");
include("overview/alertlog.inc.php");
include("overview/alertlog.inc.php");
include("overview/syslog.inc.php");
include("overview/syslog.inc.php");
include("overview/events.inc.php");
include("overview/events.inc.php");
echo("</div>");
/* End Left Pane */
echo("</div>");
/* End Left Pane */
/* Begin Right Pane */
echo('<div class="col-md-6">');
/* Begin Right Pane */
echo('<div class="col-md-6">');
include("overview/processors.inc.php");
include("overview/processors.inc.php");
if (is_array($device_state['ucd_mem']))
{
include("overview/ucd_mem.inc.php");
} else {
include("overview/mempools.inc.php");
}
if (is_array($device_state['ucd_mem'])) {
include("overview/ucd_mem.inc.php");
} else {
include("overview/mempools.inc.php");
}
include("overview/storage.inc.php");
include("overview/storage.inc.php");
if (is_array($entity_state['group']['c6kxbar']))
{
include("overview/c6kxbar.inc.php");
}
if (is_array($entity_state['group']['c6kxbar'])) {
include("overview/c6kxbar.inc.php");
}
include("overview/printersupplies.inc.php");
include("overview/status.inc.php");
include("overview/counter.inc.php");
include("overview/sensors.inc.php");
include("overview/printersupplies.inc.php");
/* End Right Pane */
if ($device['type'] == "environment" or $device['type'] == "power") {
// Print status last for power & environmental
include("overview/sensors.inc.php");
include("overview/counter.inc.php");
include("overview/status.inc.php");
} else {
// Else print status & counter first
include("overview/status.inc.php");
include("overview/counter.inc.php");
include("overview/sensors.inc.php");
}
?>
/* End Right Pane */
</div>
</div>
?>
</div>
</div>
<?php

View File

@ -4,21 +4,21 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
print_alert_log(array('device' => $device['device_id'],
'no_empty_message' => TRUE,
'short' => TRUE, 'pagesize' => 7,
'header' => array('title' => 'Alert Log',
'icon' => $config['icon']['alert-log'],
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'logs', 'section' => 'alertlog'))
)
));
print_alert_log(['device' => $device['device_id'],
'no_empty_message' => TRUE,
'short' => TRUE, 'pagesize' => 7,
'header' => ['title' => 'Alert Log',
'icon' => $config['icon']['alert-log'],
'url' => generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'logs', 'section' => 'alertlog'])
]
]);
// EOF

View File

@ -4,24 +4,25 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
?>
<div class="box box-solid">
<div class="box-header ">
<a href="<?php echo(generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'logs', 'section' => 'syslog'))); ?>">
<i class="<?php echo $config['icon']['alert']; ?>"></i><h3 class="box-title">Alerts</h3>
</a>
<div class="box box-solid">
<div class="box-header ">
<a href="<?php echo(generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'logs', 'section' => 'syslog'])); ?>">
<i class="<?php echo $config['icon']['alert']; ?>"></i>
<h3 class="box-title">Alerts</h3>
</a>
</div>
<div class="box-body no-padding">
<?php print_alert_table(['device' => $device['device_id'], 'short' => TRUE, 'pagesize' => 10, 'status' => 'failed', 'no_header' => TRUE]); ?>
</div>
</div>
<div class="box-body no-padding">
<?php print_alert_table(array('device' => $device['device_id'], 'short' => TRUE, 'pagesize' => 10, 'status' => 'failed', 'no_header' => TRUE)); ?>
</div>
</div>
<?php

View File

@ -4,102 +4,101 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
$box_args = array('title' => 'c6500/7600 Crossbar',
'icon' => $config['icon']['crossbar'],
);
$box_args = ['title' => 'c6500/7600 Crossbar',
'icon' => $config['icon']['crossbar'],
];
echo generate_box_open($box_args);
echo('<table class="table table-condensed table-striped">');
foreach ($entity_state['group']['c6kxbar'] as $index => $entry)
{
if (empty($entry['']['cc6kxbarModuleModeSwitchingMode'])) { continue; }
foreach ($entity_state['group']['c6kxbar'] as $index => $entry) {
if (empty($entry['']['cc6kxbarModuleModeSwitchingMode'])) {
continue;
}
// FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :>
$entity = dbFetchRow("SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?", array($device['device_id'], $index+1));
// FIXME i'm not sure if this is the correct way to decide what entphysical index it is. slotnum+1? :>
$entity = dbFetchRow("SELECT * FROM entPhysical WHERE device_id = ? AND entPhysicalIndex = ?", [$device['device_id'], $index + 1]);
echo("<tr bgcolor=$row_colour>
<td colspan=5 width=200><strong>".$entity['entPhysicalName']."</strong></td>
echo("<tr bgcolor=$row_colour>
<td colspan=5 width=200><strong>" . $entity['entPhysicalName'] . "</strong></td>
<td colspan=2>");
switch ($entry['']['cc6kxbarModuleModeSwitchingMode'])
{
case "busmode":
# echo '<a title="Modules in this mode don't use fabric. Backplane is used for both lookup and data forwarding.">Bus</a>';
break;
case "crossbarmode":
echo '<a class="label label-info" title="Modules in this mode use backplane for forwarding decision and fabric for data forwarding.">Crossbar</a>';
break;
case "dcefmode":
echo '<a class="label label-success" title="Modules in this mode use fabric for data forwarding and local forwarding is enabled.">DCEF</a>';
break;
default:
echo '<span class="label">'.$entry['']['cc6kxbarModuleModeSwitchingMode'].'</span>';
}
switch ($entry['']['cc6kxbarModuleModeSwitchingMode']) {
case "busmode":
# echo '<a title="Modules in this mode don't use fabric. Backplane is used for both lookup and data forwarding.">Bus</a>';
break;
case "crossbarmode":
echo '<a class="label label-info" title="Modules in this mode use backplane for forwarding decision and fabric for data forwarding.">Crossbar</a>';
break;
case "dcefmode":
echo '<a class="label label-success" title="Modules in this mode use fabric for data forwarding and local forwarding is enabled.">DCEF</a>';
break;
default:
echo '<span class="label">' . $entry['']['cc6kxbarModuleModeSwitchingMode'] . '</span>';
}
echo("</td>
echo("</td>
</tr>");
foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric)
{
if (is_numeric($subindex))
{
if ($fabric['cc6kxbarModuleChannelFabStatus'] == "ok")
{
$fabric['mode_class'] = "success";
} else {
$fabric['mode_class'] = "warning";
}
foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) {
if (is_numeric($subindex)) {
if ($fabric['cc6kxbarModuleChannelFabStatus'] == "ok") {
$fabric['mode_class'] = "success";
} else {
$fabric['mode_class'] = "warning";
}
$percent_in = $fabric['cc6kxbarStatisticsInUtil'];
$background_in = get_percentage_colours($percent_in);
$percent_in = $fabric['cc6kxbarStatisticsInUtil'];
$background_in = get_percentage_colours($percent_in);
$percent_out = $fabric['cc6kxbarStatisticsOutUtil'];
$background_out = get_percentage_colours($percent_out);
$percent_out = $fabric['cc6kxbarStatisticsOutUtil'];
$background_out = get_percentage_colours($percent_out);
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "210";
$graph_array['to'] = $config['time']['now'];
$graph_array['device'] = $device['device_id'];
$graph_array['mod'] = $index;
$graph_array['chan'] = $subindex;
$graph_array['type'] = "c6kxbar_util";
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no";
$graph_array = [];
$graph_array['height'] = "100";
$graph_array['width'] = "210";
$graph_array['to'] = get_time();
$graph_array['device'] = $device['device_id'];
$graph_array['mod'] = $index;
$graph_array['chan'] = $subindex;
$graph_array['type'] = "c6kxbar_util";
$graph_array['from'] = get_time('day');
$graph_array['legend'] = "no";
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$text_descr = $entity['entPhysicalName'] . " - Fabric " . $subindex;
$text_descr = $entity['entPhysicalName'] . " - Fabric " . $subindex;
$overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr);
$overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $text_descr);
$graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00';
$graph_array['style'][] = 'margin-top: -6px';
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
$graph_array['style'][] = 'margin-top: -6px';
$minigraph = generate_graph_tag($graph_array);
$minigraph = generate_graph_tag($graph_array);
echo('<tr class="'.$background['class'].'">
echo('<tr class="' . $background['class'] . '">
<td class="state-marker"></td>
<td width=150><strong>Fabric '.$subindex.'</strong></td>
<td><span style="font-weight: bold;" class="label label-'.$fabric['mode_class'].'">'.$fabric['cc6kxbarModuleChannelFabStatus']."</span></td>
<td>".formatRates($fabric['cc6kxbarModuleChannelSpeed']*1000000)."</td>
<td>".overlib_link($link, $minigraph, $overlib_content)."</td>
<td width=125>".print_percentage_bar (125, 20, $percent_in, "Ingress", "ffffff", $background['left'], $percent_in . "%", "ffffff", $background['right'])."</td>
<td width=125>".print_percentage_bar (125, 20, $percent_out, "Egress", "ffffff", $background['left'], $percent_out . "%", "ffffff", $background['right'])."</td>
<td width=150><strong>Fabric ' . $subindex . '</strong></td>
<td><span style="font-weight: bold;" class="label label-' . $fabric['mode_class'] . '">' . $fabric['cc6kxbarModuleChannelFabStatus'] . "</span></td>
<td>" . format_bps($fabric['cc6kxbarModuleChannelSpeed'] * 1000000) . "</td>
<td>" . overlib_link($link, $minigraph, $overlib_content) . "</td>
<td width=125>" . print_percentage_bar(125, 20, $percent_in, "Ingress", "ffffff", $background['left'], $percent_in . "%", "ffffff", $background['right']) . "</td>
<td width=125>" . print_percentage_bar(125, 20, $percent_out, "Egress", "ffffff", $background['left'], $percent_out . "%", "ffffff", $background['right']) . "</td>
</tr>");
}
}
}
}
echo("</table>");

View File

@ -4,10 +4,10 @@
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
*
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
* @package observium
* @subpackage webui
* @author Adam Armstrong <adama@observium.org>
* @copyright (C) Adam Armstrong
*
*/
@ -16,106 +16,99 @@
$sql = "SELECT * FROM `counters` WHERE `device_id` = ? AND `counter_deleted` = 0 ORDER BY `counter_class`, `counter_descr`"; // order numerically by entPhysicalIndex for ports
// Cache all counters
foreach (dbFetchRows($sql, array($device['device_id'])) as $entry)
{
if (strlen($entry['measured_class']) && is_numeric($entry['measured_entity']))
{
// Counters bounded with measured class, mostly ports
// array index -> ['measured']['port']['345'][] = counter array
$counters_db['measured'][$entry['measured_class']][$entry['measured_entity']][] = $entry;
foreach (dbFetchRows($sql, [$device['device_id']]) as $entry) {
if (strlen($entry['measured_class']) && is_numeric($entry['measured_entity'])) {
// Counters bounded with measured class, mostly ports
// array index -> ['measured']['port']['345'][] = counter array
$counters_db['measured'][$entry['measured_class']][$entry['measured_entity']][] = $entry;
} else {
// Know counters in separate boxes, all other in counter box
$counter_type = isset($config['counter_types'][$entry['counter_class']]) ? $entry['counter_class'] : 'counter';
//$counter_type = 'counter'; // Keep all counters in single box
$counters_db[$counter_type][$entry['counter_id']] = $entry;
// Know counters in separate boxes, all other in counter box
$counter_type = isset($config['counter_types'][$entry['counter_class']]) ? $entry['counter_class'] : 'counter';
//$counter_type = 'counter'; // Keep all counters in single box
$counters_db[$counter_type][$entry['counter_id']] = $entry;
}
}
//r($counters_db['measured']);
// Now print founded bundle (measured_class+counter)
if (isset($counters_db['measured']))
{
$vars['measured_icon'] = FALSE; // Hide measured icons
foreach ($counters_db['measured'] as $measured_class => $measured_entity)
{
$tab = $measured_class == 'printersupply' ? 'printing' : $measured_class . 's';
$box_args = array('title' => nicecase($measured_class).' Counters',
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => $tab, 'view' => 'counters')),
'icon' => $config['icon']['counter']
);
echo generate_box_open($box_args);
if (isset($counters_db['measured'])) {
$vars['measured_icon'] = FALSE; // Hide measured icons
foreach ($counters_db['measured'] as $measured_class => $measured_entity) {
$tab = $measured_class == 'printersupply' ? 'printing' : $measured_class . 's';
$box_args = ['title' => nicecase($measured_class) . ' Counters',
'url' => generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => $tab, 'view' => 'counters']),
'icon' => $config['icon']['counter']
];
echo generate_box_open($box_args);
echo' <table class="table table-condensed table-striped">';
echo ' <table class="table table-condensed table-striped">';
foreach ($measured_entity as $entity_id => $entry)
{
$entity = get_entity_by_id_cache($measured_class, $entity_id);
//r($entity);
$entity_link = generate_entity_link($measured_class, $entity);
$entity_type = entity_type_translate_array($measured_class);
foreach ($measured_entity as $entity_id => $entry) {
$entity = get_entity_by_id_cache($measured_class, $entity_id);
//r($entity);
$entity_link = generate_entity_link($measured_class, $entity);
$entity_type = entity_type_translate_array($measured_class);
// Remove port name from counter description
$rename_from = [];
if ($measured_class == 'port')
{
$rename_from[] = $entity['port_label'];
$rename_from[] = $entity['ifDescr'];
$rename_from[] = $entity['port_label_short'];
if (strlen($entity['port_label_base']) > 4) { $rename_from[] = $entity['port_label_base']; }
$rename_from = array_unique($rename_from);
} else {
// FIXME. I not remember what should be here, but not its incorrect
$rename_from[] = entity_rewrite($measured_class, $entity);
}
//r($rename_from);
//echo(' <tr class="'.$port['row_class'].'">
// <td class="state-marker"></td>
echo(' <tr>
// Remove port name from counter description
$rename_from = [];
if ($measured_class == 'port') {
$rename_from[] = $entity['port_label'];
$rename_from[] = $entity['ifDescr'];
$rename_from[] = $entity['port_label_short'];
if (strlen($entity['port_label_base']) > 4) {
$rename_from[] = $entity['port_label_base'];
}
$rename_from = array_unique($rename_from);
} else {
// FIXME. I not remember what should be here, but not its incorrect
$rename_from[] = entity_rewrite($measured_class, $entity);
}
//r($rename_from);
//echo(' <tr class="'.$port['row_class'].'">
// <td class="state-marker"></td>
echo(' <tr>
<td colspan="6" class="entity">' . get_icon($entity_type['icon']) . '&nbsp;' . $entity_link . '</td></tr>');
foreach ($entry as $counter)
{
$counter['counter_descr'] = trim(str_ireplace($rename_from, '', $counter['counter_descr']), ":- \t\n\r\0\x0B");
if (empty($counter['counter_descr']))
{
// Some time counter descriptions equals to entity name
$counter['counter_descr'] = nicecase($counter['counter_class']);
foreach ($entry as $counter) {
$counter['counter_descr'] = trim(str_ireplace($rename_from, '', $counter['counter_descr']), ":- \t\n\r\0\x0B");
if (empty($counter['counter_descr'])) {
// Some time counter descriptions equals to entity name
$counter['counter_descr'] = nicecase($counter['counter_class']);
}
print_counter_row($counter, $vars);
}
}
print_counter_row($counter, $vars);
}
?>
</table>
<?php
echo generate_box_close();
}
?>
</table>
<?php
echo generate_box_close();
}
// End for print bounds, unset this array
unset($counters_db['measured']);
// End for print bounds, unset this array
unset($counters_db['measured']);
}
foreach ($counters_db as $counter_type => $counters)
{
if ($counter_type == 'measured') { continue; } // Just be on the safe side
foreach ($counters_db as $counter_type => $counters) {
if ($counter_type == 'measured') {
continue;
} // Just be on the safe side
if (count($counters))
{
$box_args = array('title' => nicecase($counter_type),
//'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => $counter_type)),
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => 'counter')),
'icon' => $config['counter_types'][$counter_type]['icon'],
);
echo generate_box_open($box_args);
if (count($counters)) {
$box_args = ['title' => nicecase($counter_type),
//'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => $counter_type)),
'url' => generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => 'counter']),
'icon' => $config['counter_types'][$counter_type]['icon'],
];
echo generate_box_open($box_args);
echo('<table class="table table-condensed table-striped">');
foreach ($counters as $counter)
{
print_counter_row($counter, $vars);
echo('<table class="table table-condensed table-striped">');
foreach ($counters as $counter) {
print_counter_row($counter, $vars);
}
echo("</table>");
echo generate_box_close();
}
echo("</table>");
echo generate_box_close();
}
}
// EOF

Some files were not shown because too many files have changed in this diff Show More