commit version 22.12.12447
This commit is contained in:
@ -6,18 +6,17 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_SESSION['userlevel'] < 7 && !is_entity_write_permitted($device['device_id'], 'device'))
|
||||
{
|
||||
if ($_SESSION['userlevel'] < 7 && !is_entity_write_permitted($device['device_id'], 'device')) {
|
||||
print_error_permission();
|
||||
return;
|
||||
}
|
||||
|
||||
// User level 7-9 only can see config
|
||||
$readonly = $_SESSION['userlevel'] < 10;
|
||||
//$readonly = $_SESSION['userlevel'] < 10;
|
||||
|
||||
// Allow write for users with write permission to this entity
|
||||
$readonly = !is_entity_write_permitted($device['device_id'], 'device');
|
||||
|
@ -6,36 +6,26 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
if ($vars['editing'])
|
||||
{
|
||||
if ($readonly)
|
||||
{
|
||||
if ($vars['editing']) {
|
||||
if ($readonly) {
|
||||
print_error_permission('You have insufficient permissions to edit settings.');
|
||||
}
|
||||
else if (get_db_version() < 169)
|
||||
{
|
||||
// FIXME. Remove this block in r7000
|
||||
print_warning("DB scheme is old, must update first. Device Geolocation not changed.");
|
||||
} else {
|
||||
$updated = 0;
|
||||
|
||||
if ($vars['submit'] === 'save')
|
||||
{
|
||||
if ($vars['submit'] === 'save') {
|
||||
if (get_var_true($vars['reset_geolocation'])) {
|
||||
$updated = dbDelete('devices_locations', '`device_id` = ?', array($device['device_id']));
|
||||
$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))
|
||||
{
|
||||
if (preg_match($pattern, $vars['coordinates'], $matches)) {
|
||||
//r($matches);
|
||||
if ($matches['lat'] >= -90 && $matches['lat'] <= 90 &&
|
||||
$matches['lon'] >= -180 && $matches['lon'] <= 180)
|
||||
{
|
||||
$matches['lon'] >= -180 && $matches['lon'] <= 180) {
|
||||
$update_geo['location_lat'] = $matches['lat'];
|
||||
$update_geo['location_lon'] = $matches['lon'];
|
||||
$update_geo['location_country'] = '';
|
||||
@ -47,29 +37,28 @@ if ($vars['editing'])
|
||||
//r($vars);
|
||||
}
|
||||
|
||||
if ((bool)$device['location_manual'] && !(bool)$vars['location_manual'])
|
||||
{
|
||||
if ((bool)$device['location_manual'] && !(bool)$vars['location_manual']) {
|
||||
// Reset manual flag, rediscover geo info
|
||||
$update_geo['location_lat'] = array('NULL');
|
||||
$update_geo['location_lon'] = array('NULL');
|
||||
$update_geo['location_lat'] = [ 'NULL' ];
|
||||
$update_geo['location_lon'] = [ 'NULL' ];
|
||||
$update_geo['location_manual'] = 0;
|
||||
$updated++;
|
||||
}
|
||||
|
||||
if ($updated)
|
||||
{
|
||||
if ($updated) {
|
||||
//r($update_geo);
|
||||
dbUpdate($update_geo, 'devices_locations', '`location_id` = ?', array($device['location_id']));
|
||||
$geo_db = dbFetchRow("SELECT * FROM `devices_locations` WHERE `device_id` = ?", array($device['device_id']));
|
||||
if (count($geo_db))
|
||||
{
|
||||
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, $geo_db);
|
||||
$device = array_merge($device, (array)$geo_db);
|
||||
unset($updated, $update_geo, $geo_db);
|
||||
} else {
|
||||
print_warning("Some input data wrong. Device Geolocation not changed.");
|
||||
@ -78,37 +67,32 @@ if ($vars['editing'])
|
||||
}
|
||||
}
|
||||
|
||||
$location = array('location_text' => $device['location']);
|
||||
$location = [ 'location_text' => $device['location'] ];
|
||||
|
||||
$override_sysLocation_bool = get_dev_attrib($device,'override_sysLocation_bool');
|
||||
if ($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 overrided
|
||||
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 ($location['location_text'] == '') { $location['location_text'] = OBS_VAR_UNSET; }
|
||||
foreach (array('location_lat', 'location_lon', 'location_city', 'location_county', 'location_state', 'location_country',
|
||||
'location_geoapi', 'location_status', 'location_manual', 'location_updated') as $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']))
|
||||
{
|
||||
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="http://maps.google.com/maps?q='.urlencode($location['coordinates']).'"><i class="'.$config['icon']['map'].'"></i> View this location on a map</a>';
|
||||
$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'])
|
||||
{
|
||||
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>';
|
||||
@ -122,8 +106,7 @@ if (is_numeric($location['location_lat']) && is_numeric($location['location_lon'
|
||||
$location['coordinates_manual'] = $config['geocoding']['default']['lat'].','.$config['geocoding']['default']['lon'];
|
||||
}
|
||||
|
||||
if ($updated && $update_message)
|
||||
{
|
||||
if ($updated && $update_message) {
|
||||
print_message($update_message);
|
||||
} elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
|
@ -225,8 +225,7 @@ foreach ($snmp_errors as $mib => $entries)
|
||||
}
|
||||
$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> '.$error_db['oid'].'</strong></td>' . PHP_EOL);
|
||||
$timediff = $GLOBALS['config']['time']['now'] - $error_db['updated'];
|
||||
echo('<td style="width: 100px; white-space: nowrap; text-align: right;">'.generate_tooltip_link('', format_uptime($timediff, "short-3").' ago', format_unixtime($error_db['updated'])).'</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);
|
||||
|
@ -6,16 +6,16 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$ok = FALSE;
|
||||
if ($vars['editing']) {
|
||||
if (get_var_true($vars['editing']) && request_token_valid($vars)) {
|
||||
if ($readonly) {
|
||||
print_error_permission('You have insufficient permissions to edit settings.');
|
||||
} else {
|
||||
$update = array();
|
||||
$update = [];
|
||||
switch ($vars['snmp_version']) {
|
||||
case 'v3':
|
||||
switch ($vars['snmp_authlevel']) {
|
||||
@ -55,9 +55,34 @@ if ($vars['editing']) {
|
||||
}
|
||||
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!");
|
||||
}
|
||||
}
|
||||
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'])) {
|
||||
if (in_array($vars['snmp_transport'], $config['snmp']['transports'], TRUE)) {
|
||||
$update['snmp_transport'] = $vars['snmp_transport'];
|
||||
} else {
|
||||
$update['snmp_transport'] = 'udp';
|
||||
@ -72,13 +97,13 @@ if ($vars['editing']) {
|
||||
$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'] = array('NULL');
|
||||
$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'] = array('NULL');
|
||||
$update['snmp_retries'] = [ 'NULL' ];
|
||||
}
|
||||
|
||||
// SNMPbulk max repetitions, allow 0 for disable snmpbulk(walk|get)
|
||||
@ -89,13 +114,21 @@ if ($vars['editing']) {
|
||||
$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` = ?', array($device['device_id']))) {
|
||||
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 {
|
||||
@ -115,7 +148,7 @@ if ($vars['editing']) {
|
||||
}
|
||||
|
||||
$device = device_by_id_cache($device['device_id'], $ok);
|
||||
$transports = array();
|
||||
$transports = [];
|
||||
foreach ($config['snmp']['transports'] as $transport) {
|
||||
$transports[$transport] = strtoupper($transport);
|
||||
}
|
||||
@ -146,172 +179,207 @@ $cryptoalgo = [
|
||||
'AES-256-C' => [ 'name' => 'AES-256 Cisco', 'class' => 'bg-warning', 'subtext' => 'Poller required net-snmp >= 5.8 compiled with --enable-blumenthal-aes' ],
|
||||
];
|
||||
|
||||
$form = array('type' => 'horizontal',
|
||||
'id' => 'edit',
|
||||
//'space' => '20px',
|
||||
//'title' => 'General',
|
||||
//'class' => 'box',
|
||||
);
|
||||
$form = [
|
||||
'type' => 'horizontal',
|
||||
'id' => 'edit',
|
||||
//'space' => '20px',
|
||||
//'title' => 'General',
|
||||
//'class' => 'box',
|
||||
];
|
||||
// top row div
|
||||
$form['fieldset']['edit'] = array('div' => 'top',
|
||||
'title' => 'Basic Configuration',
|
||||
'class' => 'col-md-6');
|
||||
$form['fieldset']['snmpv2'] = array('div' => 'top',
|
||||
'title' => 'SNMP v1/v2c Authentication',
|
||||
//'right' => TRUE,
|
||||
'class' => 'col-md-6 col-md-pull-0');
|
||||
$form['fieldset']['snmpv3'] = array('div' => 'top',
|
||||
'title' => 'SNMP v3 Authentication',
|
||||
//'right' => TRUE,
|
||||
'class' => 'col-md-6 col-md-pull-0');
|
||||
$form['fieldset']['snmpextra'] = array('div' => 'top',
|
||||
'title' => 'Extra Configuration',
|
||||
//'right' => TRUE,
|
||||
'class' => 'col-sm-12 col-md-6 pull-right');
|
||||
$form['fieldset']['edit'] = [
|
||||
'div' => 'top',
|
||||
'title' => 'Basic Configuration',
|
||||
'class' => 'col-md-6'
|
||||
];
|
||||
$form['fieldset']['snmpv2'] = [
|
||||
'div' => 'top',
|
||||
'title' => 'SNMP v1/v2c Authentication',
|
||||
//'right' => TRUE,
|
||||
'class' => 'col-md-6 col-md-pull-0'
|
||||
];
|
||||
$form['fieldset']['snmpv3'] = [
|
||||
'div' => 'top',
|
||||
'title' => 'SNMP v3 Authentication',
|
||||
//'right' => TRUE,
|
||||
'class' => 'col-md-6 col-md-pull-0'
|
||||
];
|
||||
$form['fieldset']['snmpextra'] = [
|
||||
'div' => 'top',
|
||||
'title' => 'Extra Configuration',
|
||||
//'right' => TRUE,
|
||||
'class' => 'col-sm-12 col-md-6 pull-right'
|
||||
];
|
||||
|
||||
// bottom row div
|
||||
$form['fieldset']['submit'] = array('div' => 'bottom',
|
||||
'style' => 'padding: 0px;',
|
||||
'class' => 'col-md-12');
|
||||
$form['fieldset']['submit'] = [
|
||||
'div' => 'bottom',
|
||||
'style' => 'padding: 0px;',
|
||||
'class' => 'col-md-12'
|
||||
];
|
||||
|
||||
$form['row'][0]['editing'] = array(
|
||||
'type' => 'hidden',
|
||||
'value' => 'yes');
|
||||
$form['row'][0]['editing'] = [
|
||||
'type' => 'hidden',
|
||||
'value' => 'yes'
|
||||
];
|
||||
// left fieldset
|
||||
$form['row'][1]['snmp_version'] = array(
|
||||
'type' => 'select',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Protocol Version',
|
||||
'width' => '250px',
|
||||
'readonly' => $readonly,
|
||||
'values' => array('v1' => 'v1', 'v2c' => 'v2c', 'v3' => 'v3'),
|
||||
'value' => $device['snmp_version']);
|
||||
$form['row'][2]['snmp_transport'] = array(
|
||||
'type' => 'select',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Transport',
|
||||
'width' => '250px',
|
||||
'readonly' => $readonly,
|
||||
'values' => $transports,
|
||||
'value' => $device['snmp_transport']);
|
||||
$form['row'][3]['snmp_port'] = array(
|
||||
'type' => 'text',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Port',
|
||||
'width' => '250px',
|
||||
'placeholder' => '1-65535. Default 161.',
|
||||
'readonly' => $readonly,
|
||||
'value' => $device['snmp_port']);
|
||||
$form['row'][4]['snmp_timeout'] = array(
|
||||
'type' => 'text',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Timeout',
|
||||
'width' => '250px',
|
||||
'placeholder' => '1-120 sec. Default 1 sec.',
|
||||
'readonly' => $readonly,
|
||||
'value' => $device['snmp_timeout']);
|
||||
$form['row'][5]['snmp_retries'] = array(
|
||||
'type' => 'text',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Retries',
|
||||
'width' => '250px',
|
||||
'placeholder' => '1-10. Default 5.',
|
||||
'readonly' => $readonly,
|
||||
'value' => $device['snmp_retries']);
|
||||
$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']
|
||||
];
|
||||
$form['row'][3]['snmp_port'] = [
|
||||
'type' => 'text',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Port',
|
||||
'width' => '250px',
|
||||
'placeholder' => '1-65535. Default 161.',
|
||||
'readonly' => $readonly,
|
||||
'value' => $device['snmp_port']
|
||||
];
|
||||
$form['row'][4]['snmp_timeout'] = [
|
||||
'type' => 'text',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Timeout',
|
||||
'width' => '250px',
|
||||
'placeholder' => '1-120 sec. Default 1 sec.',
|
||||
'readonly' => $readonly,
|
||||
'value' => $device['snmp_timeout']
|
||||
];
|
||||
$form['row'][5]['snmp_retries'] = [
|
||||
'type' => 'text',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Retries',
|
||||
'width' => '250px',
|
||||
'placeholder' => '1-10. Default 5.',
|
||||
'readonly' => $readonly,
|
||||
'value' => $device['snmp_retries']
|
||||
];
|
||||
$form['row'][6]['snmp_maxrep'] = [
|
||||
'type' => 'text',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Max Repetitions',
|
||||
'width' => '250px',
|
||||
'placeholder' => '0-500. Default 10. 0 for disable snmpbulk.',
|
||||
'readonly' => $readonly,
|
||||
'value' => $device['snmp_maxrep']
|
||||
];
|
||||
|
||||
$form['row'][6]['snmp_maxrep'] = array(
|
||||
'type' => 'text',
|
||||
'fieldset' => 'edit',
|
||||
'name' => 'Max Repetitions',
|
||||
'width' => '250px',
|
||||
'placeholder' => '0-500. Default 10. 0 for disable snmpbulk.',
|
||||
'readonly' => $readonly,
|
||||
'value' => $device['snmp_maxrep']);
|
||||
// Snmp v1/2c fieldset
|
||||
$form['row'][7]['snmp_community'] = array(
|
||||
'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!
|
||||
$form['row'][7]['snmp_community'] = [
|
||||
'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!
|
||||
];
|
||||
|
||||
// Snmp v3 fieldset
|
||||
$form['row'][8]['snmp_authlevel'] = array(
|
||||
'type' => 'select',
|
||||
'fieldset' => 'snmpv3',
|
||||
'name' => 'Auth Level',
|
||||
'width' => '250px',
|
||||
'readonly' => $readonly,
|
||||
'values' => array('noAuthNoPriv' => 'noAuthNoPriv',
|
||||
'authNoPriv' => 'authNoPriv',
|
||||
'authPriv' => 'authPriv'),
|
||||
'value' => $device['snmp_authlevel']);
|
||||
$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']
|
||||
];
|
||||
$form['row'][9]['snmp_authname'] = [
|
||||
'type' => 'password',
|
||||
'fieldset' => 'snmpv3',
|
||||
'name' => 'Auth Username',
|
||||
'width' => '250px',
|
||||
'readonly' => $readonly,
|
||||
'show_password' => !$readonly,
|
||||
'value' => $device['snmp_authname']
|
||||
];
|
||||
$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!
|
||||
];
|
||||
$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,
|
||||
'show_password' => !$readonly,
|
||||
'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']
|
||||
];
|
||||
|
||||
$form['row'][9]['snmp_authname'] = array(
|
||||
'type' => 'password',
|
||||
'fieldset' => 'snmpv3',
|
||||
'name' => 'Auth Username',
|
||||
'width' => '250px',
|
||||
'readonly' => $readonly,
|
||||
'show_password' => !$readonly,
|
||||
'value' => $device['snmp_authname']);
|
||||
// Extra fields
|
||||
$form['row'][14]['snmpable'] = [
|
||||
'type' => 'text',
|
||||
'fieldset' => 'snmpextra',
|
||||
'name' => 'SNMPable OIDs',
|
||||
'width' => '250px',
|
||||
'readonly' => $readonly,
|
||||
'placeholder' => '(Optional) Numeric OIDs for check device availability',
|
||||
'value' => $device['snmpable']
|
||||
];
|
||||
$form['row'][15]['snmp_context'] = [
|
||||
'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!
|
||||
];
|
||||
|
||||
$form['row'][10]['snmp_authpass'] = array(
|
||||
'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!
|
||||
|
||||
$form['row'][11]['snmp_authalgo'] = array(
|
||||
'type' => 'select',
|
||||
'fieldset' => 'snmpv3',
|
||||
'name' => 'Auth Algorithm',
|
||||
'width' => '250px',
|
||||
'readonly' => $readonly,
|
||||
'values' => $authalgo,
|
||||
'value' => $device['snmp_authalgo']);
|
||||
|
||||
$form['row'][12]['snmp_cryptopass'] = array(
|
||||
'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!
|
||||
$form['row'][13]['snmp_cryptoalgo'] = array(
|
||||
'type' => 'select',
|
||||
'fieldset' => 'snmpv3',
|
||||
'name' => 'Crypto Algorithm',
|
||||
'width' => '250px',
|
||||
'readonly' => $readonly,
|
||||
'values' => $cryptoalgo,
|
||||
'value' => $device['snmp_cryptoalgo']);
|
||||
|
||||
$form['row'][15]['snmp_context'] = array(
|
||||
'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!
|
||||
|
||||
$form['row'][20]['submit'] = array(
|
||||
'type' => 'submit',
|
||||
'fieldset' => 'submit',
|
||||
'name' => 'Save Changes',
|
||||
'icon' => 'icon-ok icon-white',
|
||||
//'right' => TRUE,
|
||||
'class' => 'btn-primary',
|
||||
'readonly' => $readonly,
|
||||
'value' => 'save');
|
||||
$form['row'][20]['submit'] = [
|
||||
'type' => 'submit',
|
||||
'fieldset' => 'submit',
|
||||
'name' => 'Save Changes',
|
||||
'icon' => 'icon-ok icon-white',
|
||||
//'right' => TRUE,
|
||||
'class' => 'btn-primary',
|
||||
'readonly' => $readonly,
|
||||
'value' => 'save'
|
||||
];
|
||||
|
||||
print_form_box($form);
|
||||
unset($form);
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage webui
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$datas = array('overview' => array('icon' => $config['icon']['overview']));
|
||||
$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']); }
|
||||
@ -19,13 +19,18 @@ if ($health_exist['diskio']) { $datas['diskio'] = array('icon' => $config
|
||||
|
||||
if ($health_exist['status']) { $datas['status'] = array('icon' => $config['entities']['status']['icon']); }
|
||||
|
||||
if ($health_exist['sensors'])
|
||||
{
|
||||
$sensors_device = dbFetchRows("SELECT DISTINCT `sensor_class` FROM `sensors` WHERE `device_id` = ? AND `sensor_deleted` = ?", array($device['device_id'], 0));
|
||||
foreach ($sensors_device as $sensor)
|
||||
{
|
||||
if ($sensor['sensor_class'] == 'counter') { continue; } // DEVEL
|
||||
$datas[$sensor['sensor_class']] = array('icon' => $config['sensor_types'][$sensor['sensor_class']]['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'] ];
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,9 +47,11 @@ if ($health_exist['counter'])
|
||||
}
|
||||
*/
|
||||
|
||||
$link_array = array('page' => 'device',
|
||||
'device' => $device['device_id'],
|
||||
'tab' => 'health');
|
||||
$link_array = [
|
||||
'page' => 'device',
|
||||
'device' => $device['device_id'],
|
||||
'tab' => 'health'
|
||||
];
|
||||
|
||||
if (!$vars['metric']) { $vars['metric'] = "overview"; }
|
||||
if (!$vars['view']) { $vars['view'] = "details"; }
|
||||
|
@ -1,13 +1,12 @@
|
||||
<?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) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -26,7 +25,7 @@ $form = array('type' => 'rows',
|
||||
'submit_by_key' => TRUE,
|
||||
'url' => generate_url($vars));
|
||||
|
||||
$where = ' WHERE 1 ' . generate_query_values($device['device_id'], 'device_id');
|
||||
$where = ' WHERE 1 ' . generate_query_values_and($device['device_id'], 'device_id');
|
||||
|
||||
// Checkers Field
|
||||
$form_filter = dbFetchColumn('SELECT DISTINCT `alert_test_id` FROM `alert_log`' . $where);
|
||||
|
@ -6,11 +6,11 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$where = ' WHERE 1 ' . generate_query_values($device['device_id'], 'device_id');
|
||||
$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;');
|
||||
|
@ -6,11 +6,11 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$where = ' WHERE 1 ' . generate_query_values($device['device_id'], 'device_id');
|
||||
$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)
|
||||
|
@ -6,35 +6,32 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
register_html_resource('css', 'simplemde.min.css');
|
||||
register_html_resource('js', 'simplemde.min.js');
|
||||
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))
|
||||
{
|
||||
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))
|
||||
{
|
||||
if (isset($attribs) && is_array($attribs)) {
|
||||
$attribs['notes'] = $vars['notes_text'];
|
||||
}
|
||||
}
|
||||
|
||||
$notes = get_entity_attrib('device', $device['device_id'], 'notes');
|
||||
|
||||
if ($vars['edit'])
|
||||
{
|
||||
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']))
|
||||
{
|
||||
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
|
||||
@ -43,8 +40,9 @@ if ($vars['edit'])
|
||||
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> Save Changes</button> ';
|
||||
echo ' </form>';
|
||||
|
||||
register_html_resource('script', 'var simplemde = new SimpleMDE();');
|
||||
|
||||
// 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 {
|
||||
|
||||
@ -52,8 +50,7 @@ if ($vars['edit'])
|
||||
echo get_markdown($notes);
|
||||
echo generate_box_close();
|
||||
|
||||
if (($_SESSION['userlevel'] >= 7 || is_entity_write_permitted($device['device_id'], 'device')) )
|
||||
{
|
||||
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> Edit Notes</a>';
|
||||
}
|
||||
|
||||
|
@ -118,9 +118,11 @@ if ($device['state']['la']['5min']) {
|
||||
} else {
|
||||
$la_class = '';
|
||||
}
|
||||
echo('<tr>
|
||||
echo('<tr>
|
||||
<td class="entity">Load average</td>
|
||||
<td class="'.$la_class.'">' . $device['state']['la']['1min'] . ', ' . $device['state']['la']['5min'] . ', ' . $device['state']['la']['15min'] . '</td>
|
||||
<td class="'.$la_class.'">' . number_format((float)$device['state']['la']['1min'],2) . ', ' .
|
||||
number_format((float)$device['state']['la']['5min'], 2) . ', ' .
|
||||
number_format((float)$device['state']['la']['15min'], 2) . '</td>
|
||||
</tr>');
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,9 @@ if ($device['state']['la']['5min']) {
|
||||
}
|
||||
echo('<tr>
|
||||
<td class="entity">Load average</td>
|
||||
<td class="'.$la_class.'">' . $device['state']['la']['1min'] . ', ' . $device['state']['la']['5min'] . ', ' . $device['state']['la']['15min'] . '</td>
|
||||
<td class="'.$la_class.'">' . number_format((float)$device['state']['la']['1min'],2) . ', ' .
|
||||
number_format((float)$device['state']['la']['5min'], 2) . ', ' .
|
||||
number_format((float)$device['state']['la']['15min'], 2) . '</td>
|
||||
</tr>');
|
||||
}
|
||||
|
||||
|
@ -6,22 +6,40 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$sensor_types = array_keys($config['sensor_types']);
|
||||
// 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);
|
||||
|
||||
$measured_entindex = []; // collect measured entities
|
||||
$measured_ifindex = []; // collect measured entities (by ifindex)
|
||||
$measured_multi = [];
|
||||
$sensors_db = [];
|
||||
//foreach ($sensor_types as $sensor_type) {
|
||||
$sql = "SELECT * FROM `sensors`";
|
||||
//$sql .= " WHERE `sensor_class` = ? AND `device_id` = ? AND `sensor_deleted` = 0 ORDER BY `sensor_type`, `entPhysicalIndex` * 1, `sensor_descr`"; // order numerically by entPhysicalIndex for ports
|
||||
$sql .= " WHERE `device_id` = ? " . generate_query_values($sensor_types, 'sensor_class') .
|
||||
$sql .= " WHERE `device_id` = ? " . generate_query_values_and($sensor_types, 'sensor_class') .
|
||||
" AND `sensor_deleted` = 0 ORDER BY `entPhysicalIndex_measured` * 1, `entPhysicalIndex` * 1, `sensor_descr`"; // order numerically by entPhysicalIndex for ports
|
||||
|
||||
// Cache all sensors
|
||||
foreach (dbFetchRows($sql, [ $device['device_id'] ]) as $entry) {
|
||||
if (is_numeric($entry['measured_entity']) && strlen($entry['measured_class'])) {
|
||||
if (is_numeric($entry['measured_entity']) && !safe_empty($entry['measured_class'])) {
|
||||
// Collect entPhysical entities
|
||||
if (!(isset($measured_entindex[$entry['measured_entity']]) || isset($measured_ifindex[$entry['measured_entity']]))) {
|
||||
if ($entry['entPhysicalIndex']) {
|
||||
$measured_entindex[$entry['measured_entity']] = $entry['entPhysicalIndex'];
|
||||
} elseif ($entry['measured_class'] === 'port') {
|
||||
// When not correct entPhysicalIndex stored
|
||||
$port = get_port_by_id_cache($entry['measured_entity']);
|
||||
$measured_ifindex[$entry['measured_entity']] = $port['ifIndex'];
|
||||
}
|
||||
}
|
||||
|
||||
// Sensors bounded with measured class, mostly ports
|
||||
// array index -> ['measured']['port']['345'][] = sensor array
|
||||
switch ($entry['measured_class']) {
|
||||
@ -33,12 +51,16 @@ $measured_multi = [];
|
||||
$lane = 0;
|
||||
}
|
||||
$sensors_db['measured'][$entry['measured_class']][$entry['measured_entity']][$entry['sensor_class']][] = $entry;
|
||||
$measured_multi[$entry['measured_class']][$entry['measured_entity']][$lane][$entry['sensor_class']][] = $entry;
|
||||
$measured_multi[$entry['measured_class']][$entry['measured_entity']][$lane][$entry['sensor_class']][] = $entry;
|
||||
break;
|
||||
default:
|
||||
$sensors_db['measured'][$entry['measured_class']][$entry['measured_entity']][$entry['sensor_class']][] = $entry;
|
||||
}
|
||||
|
||||
} elseif ($entry['measured_class'] === 'outlet' && !safe_empty($entry['measured_entity_label'])) {
|
||||
// Outlet currently not have real entity associations
|
||||
//r($entry);
|
||||
$sensors_db['measured'][$entry['measured_class']][$entry['measured_entity_label']][$entry['sensor_class']][] = $entry;
|
||||
} else {
|
||||
$sensors_db[$entry['sensor_class']][$entry['sensor_id']] = $entry;
|
||||
}
|
||||
@ -47,84 +69,162 @@ $measured_multi = [];
|
||||
//r($sensors_db['measured']);
|
||||
//r($measured_multi);
|
||||
|
||||
// Print Multi sensors at single line for each entity
|
||||
/* WiP
|
||||
if (count($measured_multi)) {
|
||||
$vars['measured_icon'] = FALSE; // Hide measured icons
|
||||
foreach ($measured_multi as $measured_class => $measured_entity) {
|
||||
$box_args = ['title' => nicecase($measured_class) . ' sensors',
|
||||
'url' => generate_url(['page' => 'device', 'device' => $device['device_id'], 'tab' => $measured_class . 's', 'view' => 'sensors']),
|
||||
'icon' => $config['icon']['sensor']
|
||||
];
|
||||
echo generate_box_open($box_args);
|
||||
echo ' <table class="table table-condensed table-striped">';
|
||||
echo ' </table>';
|
||||
echo generate_box_close();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Now print founded bundle (measured_class+sensor)
|
||||
if (isset($sensors_db['measured'])) {
|
||||
$vars['measured_icon'] = FALSE; // Hide measured icons
|
||||
|
||||
// Fetch entphysical serials and part/vendor names
|
||||
$measured_entphysical = [];
|
||||
if ($measured_entindex) {
|
||||
foreach (dbFetchRows('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `deleted` IS NULL' . generate_query_values_and($measured_entindex, 'entPhysicalIndex'), [ $device['device_id'] ]) as $entry) {
|
||||
foreach ($measured_entindex as $entity_id => $entPhysicalIndex) {
|
||||
if ($entPhysicalIndex === $entry['entPhysicalIndex']) {
|
||||
if (empty($entry['entPhysicalModelName']) && empty($entry['entPhysicalSerialNum'])) {
|
||||
// Containers.. try to get inside
|
||||
//r($entry);
|
||||
$tmp_entry = dbFetchRow('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `deleted` IS NULL AND `entPhysicalIndex` = ?', [ $device['device_id'], $entry['entPhysicalContainedIn'] ]);
|
||||
if (!empty($tmp_entry['entPhysicalModelName']) || !empty($tmp_entry['entPhysicalSerialNum'])) {
|
||||
$entry = $tmp_entry;
|
||||
//r($tmp_entry);
|
||||
}
|
||||
}
|
||||
$measured_entphysical[$entity_id] = $entry;
|
||||
unset($measured_entindex[$entity_id]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($measured_ifindex) {
|
||||
foreach (dbFetchRows('SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `deleted` IS NULL' . generate_query_values_and($measured_ifindex, 'ifIndex'), [ $device['device_id'] ]) as $entry) {
|
||||
foreach ($measured_ifindex as $entity_id => $ifIndex) {
|
||||
if ($ifIndex === $entry['ifIndex']) {
|
||||
$measured_entphysical[$entity_id] = $entry;
|
||||
unset($measured_ifindex[$entity_id]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//r($measured_entphysical);
|
||||
|
||||
$show_compact = $config['sensors']['web_measured_compact'];
|
||||
foreach ($sensors_db['measured'] as $measured_class => $measured_entity) {
|
||||
$box_args = array('title' => nicecase($measured_class).' sensors',
|
||||
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => $measured_class.'s', 'view' => 'sensors')),
|
||||
'icon' => $config['icon']['sensor']
|
||||
);
|
||||
$box_args = [
|
||||
'title' => nicecase($measured_class).' sensors',
|
||||
'url' => generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => $measured_class.'s', 'view' => 'sensors' ]),
|
||||
'icon' => $config['icon']['sensor']
|
||||
];
|
||||
$box_args['header-controls'] = [
|
||||
'controls' => [
|
||||
'compact' => [ 'text' => $show_compact ? 'Full View' : 'Compact View',
|
||||
'icon' => $show_compact ? 'glyphicon-th-list' : 'glyphicon-th',
|
||||
'config' => 'sensors|web_measured_compact', // check this config
|
||||
'value' => $show_compact ? 'no' : 'yes', // toggle
|
||||
]
|
||||
]
|
||||
];
|
||||
echo generate_box_open($box_args);
|
||||
|
||||
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);
|
||||
|
||||
// Remove port name from sensor description
|
||||
$rename_from = [];
|
||||
if ($measured_class === 'port') {
|
||||
if (is_numeric($entity['port_label'])) {
|
||||
$rename_from[] = $entity['port_label'].' ';
|
||||
} else {
|
||||
$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);
|
||||
//r($measured_entity);
|
||||
foreach ($measured_entity as $entity_id => $entry) {
|
||||
if ($measured_class === 'outlet') {
|
||||
// Outlets not have real entities association
|
||||
$entity = [];
|
||||
$entity_link = $entity_id; // Just Outlet Label
|
||||
$entity_type = [ 'icon' => 'outlet' ];
|
||||
$entity_parts = '';
|
||||
} else {
|
||||
$rename_from[] = entity_rewrite($measured_class, $entity);
|
||||
// Common known entities
|
||||
$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);
|
||||
$entity_parts = '';
|
||||
if ($measured_entphysical[$entity_id]) {
|
||||
// Entity Vendor/PartNum/Serial
|
||||
if ($measured_entphysical[$entity_id]['entPhysicalMfgName']) {
|
||||
$entity_parts .= ' <span class="label label-info">' . $measured_entphysical[$entity_id]['entPhysicalMfgName'] . '</span>';
|
||||
}
|
||||
if ($measured_entphysical[$entity_id]['entPhysicalModelName']) {
|
||||
$entity_parts .= ' <span class="label label-warning">' . $measured_entphysical[$entity_id]['entPhysicalModelName'] . '</span>';
|
||||
}
|
||||
if ($measured_entphysical[$entity_id]['entPhysicalSerialNum']) {
|
||||
$entity_parts .= ' <span class="label label-primary">SN: ' . $measured_entphysical[$entity_id]['entPhysicalSerialNum'] . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
// Remove port name from sensor description
|
||||
$rename_from = [];
|
||||
if ($measured_class === 'port') {
|
||||
if (is_numeric($entity['port_label'])) {
|
||||
$rename_from[] = $entity['port_label'] . ' ';
|
||||
} else {
|
||||
$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 {
|
||||
entity_rewrite($measured_class, $entity);
|
||||
}
|
||||
$entity['rename_from'] = $rename_from;
|
||||
}
|
||||
//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']) . ' ' . $entity_link . '</td></tr>');
|
||||
<td colspan="6" class="entity">' . get_icon($entity_type['icon']) . ' ' . $entity_link . $entity_parts . '</td></tr>');
|
||||
|
||||
// order dom sensors always by temperature, voltage, current, dbm, power
|
||||
$order = [];
|
||||
if (safe_count($entry) > 0) {
|
||||
$classes = array_keys($entry);
|
||||
//r($types);
|
||||
$order = array_intersect([ 'temperature', 'voltage', 'current', 'dbm', 'power' ], $classes);
|
||||
$order = array_merge($order, array_diff($classes, $order));
|
||||
//r($order);
|
||||
}
|
||||
foreach ($order as $class) {
|
||||
foreach ($entry[$class] as $sensor) {
|
||||
$sensor['sensor_descr'] = trim(str_ireplace($rename_from, '', $sensor['sensor_descr']), ":- \t\n\r\0\x0B");
|
||||
if (empty($sensor['sensor_descr'])) {
|
||||
// Some time sensor descriptions equals to entity name
|
||||
$sensor['sensor_descr'] = nicecase($sensor['sensor_class']);
|
||||
if ($show_compact && $measured_class !== 'outlet') {
|
||||
// In compact view need multi-lane split
|
||||
$lanes_count = safe_count($measured_multi[$measured_class][$entity_id]);
|
||||
if ($lanes_count > 1) {
|
||||
if (isset($measured_multi[$measured_class][$entity_id][0]) && $lanes_count === 5) {
|
||||
// Multilane with separated voltage or others
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
$measured_multi[$measured_class][$entity_id][$i] = array_merge($measured_multi[$measured_class][$entity_id][$i],
|
||||
$measured_multi[$measured_class][$entity_id][0]);
|
||||
}
|
||||
unset($measured_multi[$measured_class][$entity_id][0]);
|
||||
}
|
||||
foreach ($measured_multi[$measured_class][$entity_id] as $lane => $lane_entry) {
|
||||
echo '<tr><td style="width: 10px;" class="vertical-align"><span class="label">L'.$lane.'</span></td>' .
|
||||
get_compact_sensors_line($measured_class, $lane_entry, $vars) . '</tr>';
|
||||
}
|
||||
} else {
|
||||
echo '<tr><td style="width: 10px;"></td>' . get_compact_sensors_line($measured_class, $entry, $vars) . '</tr>';
|
||||
}
|
||||
} else {
|
||||
// order dom sensors always by temperature, voltage, current, dbm, power
|
||||
$order = [];
|
||||
if (safe_count($entry) > 0) {
|
||||
$classes = array_keys($entry);
|
||||
//r($types);
|
||||
$order = array_intersect([ 'temperature', 'voltage', 'current', 'dbm', 'power' ], $classes);
|
||||
$order = array_merge($order, array_diff($classes, $order));
|
||||
//r($order);
|
||||
}
|
||||
|
||||
print_sensor_row($sensor, $vars);
|
||||
foreach ($order as $class) {
|
||||
foreach ($entry[$class] as $sensor) {
|
||||
$sensor['sensor_descr'] = trim(str_ireplace($rename_from, '', $sensor['sensor_descr']), ":- \t\n\r\0\x0B");
|
||||
if (empty($sensor['sensor_descr'])) {
|
||||
// Some time sensor descriptions equals to entity name
|
||||
$sensor['sensor_descr'] = nicecase($sensor['sensor_class']);
|
||||
}
|
||||
|
||||
print_sensor_row($sensor, $vars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if ($show_compact) { echo '<tr>' . $line . '</tr>'; }
|
||||
}
|
||||
|
||||
?>
|
||||
@ -136,27 +236,23 @@ if (isset($sensors_db['measured'])) {
|
||||
unset($sensors_db['measured']);
|
||||
}
|
||||
|
||||
foreach ($sensors_db as $sensor_type => $sensors)
|
||||
{
|
||||
if ($sensor_type === 'measured') { continue; } // Just be on the safe side
|
||||
foreach ($sensor_types as $sensor_type) {
|
||||
if (safe_empty($sensors_db[$sensor_type])) { continue; }
|
||||
|
||||
if (count($sensors))
|
||||
{
|
||||
$box_args = array('title' => nicecase($sensor_type),
|
||||
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => $sensor_type)),
|
||||
'icon' => $config['sensor_types'][$sensor_type]['icon'],
|
||||
);
|
||||
echo generate_box_open($box_args);
|
||||
$box_args = [
|
||||
'title' => nicecase($sensor_type),
|
||||
'url' => generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => $sensor_type ]),
|
||||
'icon' => $config['sensor_types'][$sensor_type]['icon'],
|
||||
];
|
||||
echo generate_box_open($box_args);
|
||||
|
||||
echo('<table class="table table-condensed table-striped">');
|
||||
foreach ($sensors as $sensor)
|
||||
{
|
||||
print_sensor_row($sensor, $vars);
|
||||
}
|
||||
|
||||
echo("</table>");
|
||||
echo generate_box_close();
|
||||
echo('<table class="table table-condensed table-striped">');
|
||||
foreach ($sensors_db[$sensor_type] as $sensor) {
|
||||
print_sensor_row($sensor, $vars);
|
||||
}
|
||||
|
||||
echo("</table>");
|
||||
echo generate_box_close();
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
@ -6,57 +6,50 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
$graph_type = "storage_usage";
|
||||
|
||||
$sql = "SELECT * FROM `storage`";
|
||||
//$sql .= " LEFT JOIN `storage-state` USING(`storage_id`)";
|
||||
$sql .= " WHERE `device_id` = ?";
|
||||
$sql .= " WHERE `device_id` = ? AND `storage_ignore` = ? AND `storage_deleted` = ?";
|
||||
|
||||
$drives = dbFetchRows($sql, array($device['device_id']));
|
||||
$drives = dbFetchRows($sql, [ $device['device_id'], 0, 0 ]);
|
||||
|
||||
if (count($drives))
|
||||
{
|
||||
$drives = array_sort_by($drives, 'storage_descr', SORT_ASC, SORT_STRING);
|
||||
if (!safe_empty($drives)) {
|
||||
$drives = array_sort_by($drives, 'storage_mib', SORT_ASC, SORT_STRING,
|
||||
'storage_descr', SORT_ASC, SORT_STRING);
|
||||
|
||||
$box_args = array('title' => 'Storage',
|
||||
'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => 'storage')),
|
||||
'icon' => $config['icon']['storage'],
|
||||
);
|
||||
$box_args = [
|
||||
'title' => 'Storage',
|
||||
'url' => generate_url([ 'page' => 'device', 'device' => $device['device_id'], 'tab' => 'health', 'metric' => 'storage' ]),
|
||||
'icon' => $config['icon']['storage'],
|
||||
];
|
||||
echo generate_box_open($box_args);
|
||||
|
||||
echo('<table class="table table-condensed table-striped">');
|
||||
|
||||
foreach ($drives as $drive)
|
||||
{
|
||||
foreach ($drives as $drive) {
|
||||
$skipdrive = FALSE;
|
||||
|
||||
if ($device["os"] === "junos")
|
||||
{
|
||||
foreach ($config['ignore_junos_os_drives'] as $jdrive)
|
||||
{
|
||||
if (preg_match($jdrive, $drive["storage_descr"]))
|
||||
{
|
||||
if ($device["os"] === "junos") {
|
||||
foreach ($config['ignore_junos_os_drives'] as $jdrive) {
|
||||
if (preg_match($jdrive, $drive["storage_descr"])) {
|
||||
$skipdrive = TRUE;
|
||||
}
|
||||
}
|
||||
//$drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]);
|
||||
}
|
||||
|
||||
if ($device['os'] === "freebsd")
|
||||
{
|
||||
foreach ($config['ignore_bsd_os_drives'] as $jdrive)
|
||||
{
|
||||
if (preg_match($jdrive, $drive["storage_descr"]))
|
||||
{
|
||||
if ($device['os'] === "freebsd") {
|
||||
foreach ($config['ignore_bsd_os_drives'] as $jdrive) {
|
||||
if (preg_match($jdrive, $drive["storage_descr"])) {
|
||||
$skipdrive = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($drive['storage_ignore']) { $skipdrive = TRUE; }
|
||||
//if ($drive['storage_ignore']) { $skipdrive = TRUE; }
|
||||
|
||||
if ($skipdrive) { continue; }
|
||||
|
||||
@ -69,13 +62,13 @@ if (count($drives))
|
||||
$used = formatStorage($drive['storage_used']);
|
||||
$background = get_percentage_colours($percent);
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array = [];
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "210";
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['to'] = get_time();
|
||||
$graph_array['id'] = $drive['storage_id'];
|
||||
$graph_array['type'] = $graph_type;
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['from'] = get_time('day');
|
||||
$graph_array['legend'] = "no";
|
||||
|
||||
$link_array = $graph_array;
|
||||
@ -85,7 +78,9 @@ if (count($drives))
|
||||
|
||||
$overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $drive['storage_descr']);
|
||||
|
||||
$graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00';
|
||||
$graph_array['width'] = 80;
|
||||
$graph_array['height'] = 20;
|
||||
$graph_array['bg'] = 'ffffff00';
|
||||
// $graph_array['style'][] = 'margin-top: -6px';
|
||||
|
||||
$minigraph = generate_graph_tag($graph_array);
|
||||
|
@ -17,13 +17,10 @@
|
||||
|
||||
<?php
|
||||
|
||||
$graph_array = array('type' => 'device_poller_perf',
|
||||
'device' => $device['device_id']
|
||||
);
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
$graph_array = [
|
||||
'type' => 'device_poller_perf',
|
||||
'device' => $device['device_id']
|
||||
];
|
||||
|
||||
echo generate_box_open(array('title' => 'Poller Performance'));
|
||||
print_graph_row($graph_array);
|
||||
@ -62,6 +59,9 @@ unset($navbar);
|
||||
if (is_array($device['state']['poller_mod_perf'])) {
|
||||
arsort($device['state']['poller_mod_perf']);
|
||||
}
|
||||
if (is_array($device['state']['discovery_mod_perf'])) {
|
||||
arsort($device['state']['discovery_mod_perf']);
|
||||
}
|
||||
|
||||
if ($vars['view'] === 'db')
|
||||
{
|
||||
@ -164,7 +164,7 @@ elseif ($vars['view'] === 'poller')
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-4">
|
||||
<div class="box box-solid">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Poller Module Times</h3>
|
||||
@ -181,21 +181,18 @@ elseif ($vars['view'] === 'poller')
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
foreach ($device['state']['poller_mod_perf'] as $module => $time)
|
||||
{
|
||||
if ($time > 0.001)
|
||||
{
|
||||
foreach ($device['state']['poller_mod_perf'] as $module => $time) {
|
||||
if ($time > 0.001) {
|
||||
$perc = round(float_div($time, $device['last_polled_timetaken']) * 100, 2, 2);
|
||||
|
||||
echo(' <tr>
|
||||
<td><strong>'.$module.'</strong></td>
|
||||
<td style="width: 80px;">'.number_format($time, 4).'s</td>
|
||||
<td style="width: 70px;">'.$perc.'%</td>
|
||||
<td style="width: 70px;"><span style="color:'.percent_colour($perc).'">'.$perc.'%</span></td>
|
||||
</tr>');
|
||||
|
||||
// Separate sub-module perf (ie ports)
|
||||
foreach ($device['state']['poller_'.$module.'_perf'] as $submodule => $subtime)
|
||||
{
|
||||
foreach ($device['state']['poller_'.$module.'_perf'] as $submodule => $subtime) {
|
||||
echo(' <tr>
|
||||
<td> <i class="icon-share-alt icon-flip-vertical"></i><strong style="padding-left:1em"><i>'.$submodule.'</i></strong></td>
|
||||
<td style="width: 80px;"><i>'.number_format($subtime, 4).'s</i></td>
|
||||
@ -212,27 +209,26 @@ foreach ($device['state']['poller_mod_perf'] as $module => $time)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-2">
|
||||
<div class="box box-solid">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Poller Total Times</h3>
|
||||
<h3 class="box-title">Poller Times</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-hover table-striped table-condensed ">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Time</th>
|
||||
<th>Duration</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$times = is_array($device['state']['poller_history']) ? array_slice($device['state']['poller_history'], 0, 30, TRUE) : [];
|
||||
foreach ($times as $start => $duration)
|
||||
{
|
||||
foreach ($times as $start => $duration) {
|
||||
echo(' <tr>
|
||||
<td>'.format_unixtime($start).'</td>
|
||||
<td>'.generate_tooltip_time($start, 'ago').'</td>
|
||||
<td>'.format_uptime($duration).'</td>
|
||||
</tr>');
|
||||
}
|
||||
@ -244,7 +240,57 @@ foreach ($times as $start => $duration)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-4">
|
||||
|
||||
|
||||
<div class="box box-solid">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Discovery Module Times</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-hover table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Module</th>
|
||||
<th colspan="2">Duration</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
//r($device['state']);
|
||||
|
||||
foreach ($device['state']['discovery_mod_perf'] as $module => $time) {
|
||||
if ($time > 0.001) {
|
||||
$perc = round(float_div($time, $device['last_discovered_timetaken']) * 100, 2, 2);
|
||||
|
||||
echo(' <tr>
|
||||
<td><strong>'.$module.'</strong></td>
|
||||
<td style="width: 80px;">'.number_format($time, 4).'s</td>
|
||||
<td style="width: 70px;"><span style="color:'.percent_colour($perc).'">'.$perc.'%</span></td>
|
||||
</tr>');
|
||||
|
||||
// Separate sub-module perf (ie ports)
|
||||
foreach ($device['state']['discovery_'.$module.'_perf'] as $submodule => $subtime) {
|
||||
echo(' <tr>
|
||||
<td> <i class="icon-share-alt icon-flip-vertical"></i><strong style="padding-left:1em"><i>'.$submodule.'</i></strong></td>
|
||||
<td style="width: 80px;"><i>'.number_format($subtime, 4).'s</i></td>
|
||||
<td style="width: 70px;"></td>
|
||||
</tr>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
|
||||
<div class="box box-solid">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Discovery Times</h3>
|
||||
@ -254,20 +300,19 @@ foreach ($times as $start => $duration)
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Time</th>
|
||||
<th>Duration</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$times = is_array($device['state']['discovery_history']) ? array_slice($device['state']['discovery_history'], 0, 30, TRUE) : [];
|
||||
foreach ($times as $start => $duration)
|
||||
{
|
||||
echo(' <tr>
|
||||
<td>'.format_unixtime($start).'</td>
|
||||
$times = is_array($device['state']['discovery_history']) ? array_slice($device['state']['discovery_history'], 0, 30, TRUE) : [];
|
||||
foreach ($times as $start => $duration) {
|
||||
echo(' <tr>
|
||||
<td>'.generate_tooltip_time($start, 'ago').'</td>
|
||||
<td>'.format_uptime($duration).'</td>
|
||||
</tr>');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage web
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
@ -223,7 +223,7 @@ if ($vars['view'] === 'minigraphs') {
|
||||
}
|
||||
|
||||
//$where = ' IN ('.implode(',', array_keys($port_cache)).')';
|
||||
//$where = generate_query_values(array_keys($port_cache), 'port_id');
|
||||
//$where = generate_query_values_and(array_keys($port_cache), 'port_id');
|
||||
//$where = generate_query_permitted(array('ports', 'devices'));
|
||||
foreach ($ext_tables as $table) {
|
||||
// Here stored port_id!
|
||||
|
@ -1,53 +1,94 @@
|
||||
<?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) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
||||
*
|
||||
*/
|
||||
|
||||
register_html_title("OSPF");
|
||||
|
||||
$navbar = array();
|
||||
$navbar = [];
|
||||
$navbar['brand'] = "OSPF";
|
||||
$navbar['class'] = "navbar-narrow";
|
||||
|
||||
$ospf_instances = dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", array($device['device_id']));
|
||||
|
||||
echo generate_box_open();
|
||||
|
||||
echo '<table class="table table-hover table-striped table-condensed">';
|
||||
|
||||
// Loop Instances (There can only ever really be once instance at the moment, thanks to douchebags who decided we should use undiscoverable context names instead of just making tables.)
|
||||
// There only 2 possible instances (V2/V3)
|
||||
foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", [ $device['device_id'] ]) as $instance) {
|
||||
|
||||
foreach ($ospf_instances as $instance)
|
||||
{
|
||||
echo generate_box_open();
|
||||
echo '<table class="table table-hover table-striped table-condensed">';
|
||||
|
||||
$area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id']));
|
||||
$port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ?", array($device['device_id']));
|
||||
$port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id']));
|
||||
$nbr_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id']));
|
||||
$ospf_version = $instance['ospfVersionNumber'];
|
||||
|
||||
$query = "SELECT * FROM `ipv4_addresses` WHERE `ipv4_address` = ? AND `device_id` = ?";
|
||||
//$query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)";
|
||||
//$query .= " AND I.device_id = ?";
|
||||
$ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'], $device['device_id']));
|
||||
$area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ? AND `ospfVersionNumber` = ?", [ $device['device_id'], $ospf_version ]);
|
||||
if ($ospf_version !== 'version3') {
|
||||
$instance_id = $instance['ospfRouterId'];
|
||||
if ($device_routing_count['ospf'] > 1) { $instance_id .= ' <span class="label label-success">V2</span>'; }
|
||||
// V2 always have 5 part index, ie: 95.130.232.140.0
|
||||
$port_params = [ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){4}$' ];
|
||||
// V2 always have 5 part index, ie: .95.130.232.130.0
|
||||
$nbr_params = [ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){4}$' ];
|
||||
} else {
|
||||
$instance_id = long2ip($instance['ospfRouterId']);
|
||||
if ($device_routing_count['ospf'] > 1) { $instance_id .= ' <span class="label label-primary">V3</span>'; }
|
||||
// V3 always have 2 part index, ie: 6.0
|
||||
$port_params = [ $device['device_id'], '^[[:digit:]]+\.[[:digit:]]+$' ];
|
||||
// V3 always have 3 part index, ie: .4.0.1602414725
|
||||
$nbr_params = [ $device['device_id'], '^[[:digit:]]+(\.[[:digit:]]+){2}$' ];
|
||||
}
|
||||
$port_count = 0;
|
||||
$port_count_enabled = 0;
|
||||
$sql = 'SELECT `ospfIfAdminStat`, COUNT(*) AS `count` FROM `ospf_ports`' .
|
||||
' WHERE `device_id` = ? AND `ospf_port_id` REGEXP ? GROUP BY `ospfIfAdminStat`';
|
||||
foreach (dbFetchRows($sql, $port_params) as $entry) {
|
||||
if ($entry['ospfIfAdminStat'] === 'enabled') {
|
||||
$port_count_enabled = (int)$entry['count'];
|
||||
}
|
||||
$port_count += (int)$entry['count'];
|
||||
}
|
||||
$nbr_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` REGEXP ?", $nbr_params);
|
||||
|
||||
if ($instance['ospfAdminStat'] == "enabled") { $enabled = '<span class="green">enabled</span>';
|
||||
$row_class = 'up'; } else { $enabled = '<span class="grey">disabled</span>';
|
||||
$row_class = "disabled"; }
|
||||
if ($instance['ospfAreaBdrRtrStatus'] == "true") { $abr = '<span class="green">yes</span>'; } else { $abr = '<span class="grey">no</span>'; }
|
||||
if ($instance['ospfASBdrRtrStatus'] == "true") { $asbr = '<span class="green">yes</span>'; } else { $asbr = '<span class="grey">no</span>'; }
|
||||
if ($instance['ospfAdminStat'] === "enabled") {
|
||||
$enabled = '<span class="label label-success">enabled</span>';
|
||||
$row_class = 'up';
|
||||
} else {
|
||||
$enabled = '<span class="label">disabled</span>';
|
||||
$row_class = "disabled";
|
||||
}
|
||||
if ($instance['ospfAreaBdrRtrStatus'] === "true") {
|
||||
$abr = '<span class="green">yes</span>';
|
||||
} else {
|
||||
$abr = '<span class="grey">no</span>';
|
||||
}
|
||||
if ($instance['ospfASBdrRtrStatus'] === "true") {
|
||||
$asbr = '<span class="green">yes</span>';
|
||||
} else {
|
||||
$asbr = '<span class="grey">no</span>';
|
||||
}
|
||||
|
||||
echo('<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr></thead>');
|
||||
$cols = [
|
||||
[ NULL, 'class="state-marker"' ],
|
||||
[ 'Router Id', 'style="width: 160px;"' ],
|
||||
'Status',
|
||||
'ABR',
|
||||
'ASBR',
|
||||
'Areas',
|
||||
'Ports',
|
||||
'Neighbours'
|
||||
//'descr' => array('Description', 'style="width: 400px;"'),
|
||||
//'rule' => 'Rule',
|
||||
];
|
||||
|
||||
echo get_table_header($cols, $vars);
|
||||
//echo('<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr></thead>');
|
||||
echo('<tr class="'.$row_class.'">');
|
||||
echo(' <td class="state-marker"></td>');
|
||||
echo(' <td class="entity-title">'.$instance['ospfRouterId'] . '</td>');
|
||||
echo(' <td class="entity-title">' . $instance_id . '</td>');
|
||||
echo(' <td>' . $enabled . '</td>');
|
||||
echo(' <td>' . $abr . '</td>');
|
||||
echo(' <td>' . $asbr . '</td>');
|
||||
@ -64,22 +105,36 @@ foreach ($ospf_instances as $instance)
|
||||
/// Global Areas Table
|
||||
/// FIXME -- humanize_ospf_area()
|
||||
|
||||
echo generate_box_open(array('title' => 'Areas'));
|
||||
echo generate_box_open([ 'title' => 'Areas' ]);
|
||||
|
||||
|
||||
echo('<table class="table table-hover table-striped">');
|
||||
echo('<thead><tr><th class="state-marker"></th><th>Area Id</th><th>Status</th><th>Auth Type</th><th>AS External</th><th>Area LSAs</th><th>Area Summary</th><th>Ports</th></tr></thead>');
|
||||
$cols = [
|
||||
[ NULL, 'class="state-marker"' ],
|
||||
[ 'Area Id', 'style="width: 160px;"' ],
|
||||
'Status',
|
||||
'Auth Type',
|
||||
'AS External',
|
||||
'Area LSAs',
|
||||
'Area Summary',
|
||||
'Ports'
|
||||
];
|
||||
echo get_table_header($cols, $vars);
|
||||
//echo('<thead><tr><th class="state-marker"></th><th>Area Id</th><th>Status</th><th>Auth Type</th><th>AS External</th><th>Area LSAs</th><th>Area Summary</th><th>Ports</th></tr></thead>');
|
||||
|
||||
/// Loop Areas
|
||||
foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id'])) as $area)
|
||||
{
|
||||
foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfVersionNumber` = ?", [ $device['device_id'], $ospf_version ]) as $area) {
|
||||
|
||||
$area_port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId']));
|
||||
$area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId']));
|
||||
$port_params[] = $area['ospfAreaId'];
|
||||
$area_port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospf_port_id` REGEXP ? AND `ospfIfAreaId` = ?", $port_params);
|
||||
$area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospf_port_id` REGEXP ? AND `ospfIfAreaId` = ?", $port_params);
|
||||
|
||||
$area_id = $ospf_version === 'version3' ? long2ip($area['ospfAreaId']) : $area['ospfAreaId'];
|
||||
$area_row_class = $area['ospfAreaStatus'] === 'active' ? 'up' : 'disabled';
|
||||
$enabled = $area['ospfAreaStatus'] === 'active' ? '<span class="label label-success">'.$area['ospfAreaStatus'].'</span>' : '<span class="label">'.$area['ospfAreaStatus'].'</span>';
|
||||
echo('<tr class="'.$area_row_class.'">');
|
||||
echo(' <td class="state-marker"></td>');
|
||||
echo(' <td class="entity-title">'.$area['ospfAreaId'] . '</td>');
|
||||
echo(' <td class="entity-title">' . $area_id . '</td>');
|
||||
echo(' <td>' . $enabled . '</td>');
|
||||
echo ' <td>' . $area['ospfAuthType'] . '</td>';
|
||||
echo ' <td>' . $area['ospfImportAsExtern'] . '</td>';
|
||||
@ -96,20 +151,28 @@ foreach ($ospf_instances as $instance)
|
||||
|
||||
echo generate_box_open();
|
||||
|
||||
echo('<table class="table table-hover table-striped table-condensed ">');
|
||||
echo('<thead><tr><th class="state-marker"></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr></thead>');
|
||||
echo('<table class="table table-hover table-striped table-condensed">');
|
||||
$cols = [
|
||||
[ NULL, 'class="state-marker"' ],
|
||||
[ 'Port', 'style="width: 160px;"' ],
|
||||
[ 'Status', 'style="width: 160px;"' ],
|
||||
'Port Type',
|
||||
'Port State'
|
||||
];
|
||||
echo get_table_header($cols, $vars);
|
||||
//echo('<thead><tr><th class="state-marker"></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr></thead>');
|
||||
|
||||
///# Loop Ports
|
||||
$p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id";
|
||||
foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport)
|
||||
{
|
||||
// Loop Ports
|
||||
$p_sql = 'SELECT * FROM `ospf_ports` LEFT JOIN `ports` USING (`device_id`, `port_id`)' .
|
||||
' WHERE `device_id` = ? AND `ospf_port_id` REGEXP ? AND `ospfIfAreaId` = ? AND `ospfIfAdminStat` = \'enabled\'';
|
||||
//$p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id";
|
||||
foreach (dbFetchRows($p_sql, $port_params) as $ospfport) {
|
||||
|
||||
if ($ospfport['ospfIfAdminStat'] == "enabled")
|
||||
{
|
||||
$port_enabled = '<span class="green">enabled</span>';
|
||||
if ($ospfport['ospfIfAdminStat'] === "enabled") {
|
||||
$port_enabled = '<span class="label label-success">enabled</span>';
|
||||
$port_row_class = 'up';
|
||||
} else {
|
||||
$port_enabled = '<span class="green">disabled</span>';
|
||||
$port_enabled = '<span class="label">'.$ospfport['ospfIfAdminStat'].'</span>';
|
||||
$port_row_class = 'disabled';
|
||||
}
|
||||
|
||||
@ -120,8 +183,6 @@ foreach ($ospf_instances as $instance)
|
||||
echo(' <td>' . $ospfport['ospfIfType'] . '</td>');
|
||||
echo(' <td>' . $ospfport['ospfIfState'] . '</td>');
|
||||
echo('</tr>');
|
||||
|
||||
$i_p++;
|
||||
} // End loop Ports
|
||||
|
||||
echo('</table>');
|
||||
@ -137,26 +198,41 @@ foreach ($ospf_instances as $instance)
|
||||
/// Global Neighbour Table
|
||||
/// FIXME -- humanize_ospf_neighbour()
|
||||
|
||||
echo generate_box_open(array('title' => 'Neighbours'));
|
||||
echo generate_box_open([ 'title' => 'Neighbours' ]);
|
||||
|
||||
echo '<table class="table table-condensed table-hover table-striped">';
|
||||
echo '<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Device</th><th>IP Address</th><th>Status</th></tr></thead>';
|
||||
echo '<table class="table table-condensed table-hover table-striped">';
|
||||
$cols = [
|
||||
[ NULL, 'class="state-marker"' ],
|
||||
[ 'Router Id', 'style="width: 160px;"' ],
|
||||
[ 'Device', 'style="width: 160px;"' ],
|
||||
'IP Address',
|
||||
'Status'
|
||||
];
|
||||
echo get_table_header($cols, $vars);
|
||||
//echo '<thead><tr><th class="state-marker"></th><th>Router Id</th><th>Device</th><th>IP Address</th><th>Status</th></tr></thead>';
|
||||
|
||||
// Loop Neigbours
|
||||
foreach (dbFetchRows("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id'])) as $nbr)
|
||||
{
|
||||
$host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($nbr['ospfNbrRtrId']));
|
||||
// Loop Neighbours
|
||||
foreach (dbFetchRows("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospf_nbr_id` REGEXP ?", $nbr_params) as $nbr) {
|
||||
if ($ospf_version !== 'version3') {
|
||||
$nbr_router_id = $nbr['ospfNbrRtrId'];
|
||||
} else {
|
||||
$nbr_router_id = long2ip($nbr['ospfNbrRtrId']);
|
||||
}
|
||||
$host = dbFetchRow("SELECT `device_id`, `port_id` FROM `ipv4_addresses` WHERE `ipv4_address` = ?", [ $nbr_router_id ]);
|
||||
|
||||
if (is_array($host)) { $rtr_id = generate_device_link($host); } else { $rtr_id = "unknown"; }
|
||||
if (is_array($host)) {
|
||||
$rtr_id = generate_device_link($host);
|
||||
} else {
|
||||
$rtr_id = '<span class="label">unknown</span>';
|
||||
}
|
||||
|
||||
echo('<tr class="' . $port_row_class . '">');
|
||||
echo(' <td class="state-marker"></td>');
|
||||
echo(' <td><span class="entity-title">' . $nbr['ospfNbrRtrId'] . '</span></td>');
|
||||
echo(' <td><span class="entity-title">' . $nbr_router_id . '</span></td>');
|
||||
echo(' <td>' . $rtr_id . '</td>');
|
||||
echo(' <td>' . $nbr['ospfNbrIpAddr'] . '</td>');
|
||||
echo(' <td>' . ip_compress($nbr['ospfNbrIpAddr']) . '</td>');
|
||||
echo(' <td>');
|
||||
switch ($nbr['ospfNbrState'])
|
||||
{
|
||||
switch ($nbr['ospfNbrState']) {
|
||||
case 'full':
|
||||
echo('<span class="green">'.$nbr['ospfNbrState'].'</span>');
|
||||
break;
|
||||
|
@ -48,7 +48,7 @@ if ($device['type'] == 'wireless')
|
||||
if ($vars['view'] == "graphs" || $vars['view'] == "services") { $table_class="table-striped-two"; } else { $table_class="table-striped"; }
|
||||
|
||||
echo generate_box_open();
|
||||
echo '<table class="table table-striped table-condensed" style="margin-top: 10px;">';
|
||||
echo '<table class="table table-striped table-condensed">';
|
||||
echo ' <thead>';
|
||||
echo ' <tr>';
|
||||
echo ' <th class="state-marker"></th>';
|
||||
|
Reference in New Issue
Block a user