Merge branch 'develop' into 'ent-8297-Mejoras-en-gestion-de-acceso-a-pandora-MD5-SHA256-y-Salt-opcional'
# Conflicts: # pandora_console/extras/mr/60.sql
This commit is contained in:
commit
93c1c040dd
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.767-221213
|
||||
Version: 7.0NG.767-221220
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.767-221213"
|
||||
pandora_version="7.0NG.767-221220"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
|
|
@ -1015,7 +1015,7 @@ my $Sem = undef;
|
|||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.767';
|
||||
use constant AGENT_BUILD => '221213';
|
||||
use constant AGENT_BUILD => '221220';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.767
|
||||
%define release 221213
|
||||
%define release 221220
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.767
|
||||
%define release 221213
|
||||
%define release 221220
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.767"
|
||||
PI_BUILD="221213"
|
||||
PI_BUILD="221220"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
|||
{}
|
||||
|
||||
Version
|
||||
{221213}
|
||||
{221220}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.767 Build 221213")
|
||||
#define PANDORA_VERSION ("7.0NG.767 Build 221220")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
|
|
@ -11,7 +11,7 @@ BEGIN
|
|||
VALUE "LegalCopyright", "Artica ST"
|
||||
VALUE "OriginalFilename", "PandoraAgent.exe"
|
||||
VALUE "ProductName", "Pandora FMS Windows Agent"
|
||||
VALUE "ProductVersion", "(7.0NG.767(Build 221213))"
|
||||
VALUE "ProductVersion", "(7.0NG.767(Build 221220))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-console
|
||||
Version: 7.0NG.767-221213
|
||||
Version: 7.0NG.767-221220
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.767-221213"
|
||||
pandora_version="7.0NG.767-221220"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -59,6 +59,7 @@ ui_print_warning_message(
|
|||
]
|
||||
);
|
||||
|
||||
$table = new StdClass();
|
||||
$table->width = '100%';
|
||||
$table->class = 'databox filters';
|
||||
$table->data = [];
|
||||
|
|
|
@ -200,14 +200,14 @@ if ($access_console_node === true) {
|
|||
$sub['gmassive']['type'] = 'direct';
|
||||
$sub['gmassive']['subtype'] = 'nolink';
|
||||
$sub2 = [];
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_agents']['text'] = __('Agents operations');
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_modules']['text'] = __('Modules operations');
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_plugins']['text'] = __('Plugins operations');
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_agents']['text'] = __('Agents operations');
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_modules']['text'] = __('Modules operations');
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_plugins']['text'] = __('Plugins operations');
|
||||
if ((bool) check_acl($config['id_user'], 0, 'UM') === true) {
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_users']['text'] = __('Users operations');
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_users']['text'] = __('Users operations');
|
||||
}
|
||||
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_alerts']['text'] = __('Alerts operations');
|
||||
$sub2['godmode/massive/massive_operations&tab=massive_alerts']['text'] = __('Alerts operations');
|
||||
enterprise_hook('massivepolicies_submenu');
|
||||
enterprise_hook('massivesnmp_submenu');
|
||||
enterprise_hook('massivesatellite_submenu');
|
||||
|
|
|
@ -169,6 +169,7 @@ $visual_format = 0;
|
|||
$filter_search = '';
|
||||
$filter_exclude = '';
|
||||
|
||||
$use_prefix_notation = true;
|
||||
|
||||
// Added for select fields.
|
||||
$total_time = true;
|
||||
|
@ -461,6 +462,7 @@ switch ($action) {
|
|||
$lapse = $item['lapse'];
|
||||
$lapse_calc = $item['lapse_calc'];
|
||||
$visual_format = $item['visual_format'];
|
||||
$use_prefix_notation = $item['use_prefix_notation'];
|
||||
break;
|
||||
|
||||
case 'max_value':
|
||||
|
@ -476,6 +478,7 @@ switch ($action) {
|
|||
$lapse = $item['lapse'];
|
||||
$lapse_calc = $item['lapse_calc'];
|
||||
$visual_format = $item['visual_format'];
|
||||
$use_prefix_notation = $item['use_prefix_notation'];
|
||||
break;
|
||||
|
||||
case 'min_value':
|
||||
|
@ -491,6 +494,7 @@ switch ($action) {
|
|||
$lapse = $item['lapse'];
|
||||
$lapse_calc = $item['lapse_calc'];
|
||||
$visual_format = $item['visual_format'];
|
||||
$use_prefix_notation = $item['use_prefix_notation'];
|
||||
break;
|
||||
|
||||
case 'sumatory':
|
||||
|
@ -504,6 +508,7 @@ switch ($action) {
|
|||
$idAgentModule = $item['id_agent_module'];
|
||||
$period = $item['period'];
|
||||
$uncompressed_module = $item['uncompressed_module'];
|
||||
$use_prefix_notation = $item['use_prefix_notation'];
|
||||
break;
|
||||
|
||||
case 'historical_data':
|
||||
|
@ -773,6 +778,7 @@ switch ($action) {
|
|||
$show_resume = $item['show_resume'];
|
||||
$show_graph = $item['show_graph'];
|
||||
$order_uptodown = $item['order_uptodown'];
|
||||
$use_prefix_notation = $item['use_prefix_notation'];
|
||||
|
||||
$text_agent = '';
|
||||
if (isset($style['text_agent']) === true
|
||||
|
@ -3404,6 +3410,22 @@ $class = 'databox filters';
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_use_prefix_notation" class="datos advanced_elements">
|
||||
<td class="bolder">
|
||||
<?php
|
||||
echo __('Use prefix notation');
|
||||
ui_print_help_tip(
|
||||
__('Use prefix notation for numeric values (example: 20,8Kbytes/sec), otherwise full value will be displayed (example: 20.742 bytes/sec)')
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_checkbox_switch('use_prefix_notation', 1, $use_prefix_notation);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_uncompressed_module" class="datos">
|
||||
<td class="bolder">
|
||||
<?php
|
||||
|
@ -6367,6 +6389,7 @@ function chooseType() {
|
|||
$("#row_show_summary").hide();
|
||||
$("#row_group_by").hide();
|
||||
$("#row_type_show").hide();
|
||||
$("#row_use_prefix_notation").hide();
|
||||
|
||||
// SLA list default state.
|
||||
$("#sla_list").hide();
|
||||
|
@ -6561,6 +6584,7 @@ function chooseType() {
|
|||
$("#row_lapse").show();
|
||||
$("#row_visual_format").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
$("#row_use_prefix_notation").show();
|
||||
break;
|
||||
|
||||
case 'max_value':
|
||||
|
@ -6572,6 +6596,7 @@ function chooseType() {
|
|||
$("#row_lapse").show();
|
||||
$("#row_visual_format").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
$("#row_use_prefix_notation").show();
|
||||
break;
|
||||
|
||||
case 'min_value':
|
||||
|
@ -6583,6 +6608,7 @@ function chooseType() {
|
|||
$("#row_lapse").show();
|
||||
$("#row_visual_format").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
$("#row_use_prefix_notation").show();
|
||||
break;
|
||||
|
||||
case 'sumatory':
|
||||
|
@ -6592,6 +6618,7 @@ function chooseType() {
|
|||
$("#row_period").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
$("#row_uncompressed_module").show();
|
||||
$("#row_use_prefix_notation").show();
|
||||
break;
|
||||
|
||||
case 'historical_data':
|
||||
|
@ -6879,6 +6906,7 @@ function chooseType() {
|
|||
$("#row_show_resume").show();
|
||||
$("#row_show_graph").show();
|
||||
$("#row_historical_db_check").hide();
|
||||
$("#row_use_prefix_notation").show();
|
||||
break;
|
||||
|
||||
case 'exception':
|
||||
|
|
|
@ -1888,6 +1888,9 @@ switch ($action) {
|
|||
$values['visual_format'] = get_parameter(
|
||||
'visual_format'
|
||||
);
|
||||
$values['use_prefix_notation'] = get_parameter(
|
||||
'use_prefix_notation'
|
||||
);
|
||||
$good_format = true;
|
||||
break;
|
||||
|
||||
|
@ -1911,6 +1914,9 @@ switch ($action) {
|
|||
$values['show_graph'] = get_parameter(
|
||||
'combo_graph_options'
|
||||
);
|
||||
$values['use_prefix_notation'] = get_parameter(
|
||||
'use_prefix_notation'
|
||||
);
|
||||
$good_format = true;
|
||||
break;
|
||||
}
|
||||
|
@ -2704,6 +2710,9 @@ switch ($action) {
|
|||
$values['visual_format'] = get_parameter(
|
||||
'visual_format'
|
||||
);
|
||||
$values['use_prefix_notation'] = get_parameter(
|
||||
'use_prefix_notation'
|
||||
);
|
||||
$good_format = true;
|
||||
break;
|
||||
|
||||
|
@ -2720,6 +2729,9 @@ switch ($action) {
|
|||
$values['show_graph'] = get_parameter(
|
||||
'combo_graph_options'
|
||||
);
|
||||
$values['use_prefix_notation'] = get_parameter(
|
||||
'use_prefix_notation'
|
||||
);
|
||||
$good_format = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1312,6 +1312,27 @@ $table_other->data[$row][1] = '<em>'.__('Example').'</em> '.date($config['date_f
|
|||
$table_other->data[$row][1] .= html_print_input_text('date_format', $config['date_format'], '', 30, 100, true);
|
||||
$row++;
|
||||
|
||||
$decimal_separators = [
|
||||
',' => ',',
|
||||
'.' => '.'
|
||||
];
|
||||
|
||||
$table_other->data[$row][0] = __('Decimal separator');
|
||||
$table_other->data[$row][1] = html_print_select(
|
||||
$decimal_separators,
|
||||
'decimal_separator',
|
||||
$config['decimal_separator'],
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
|
||||
$row++;
|
||||
|
||||
if ($config['prominent_time'] == 'comparation') {
|
||||
$timestamp = false;
|
||||
$comparation = true;
|
||||
|
|
|
@ -1450,17 +1450,17 @@ class DiscoveryTaskList extends HTML
|
|||
|
||||
// Header information.
|
||||
if ((int) $task['status'] <= 0 && empty($summary)) {
|
||||
if ($task['type'] == DISCOVERY_APP_VMWARE && $task['utimestamp'] != 0) {
|
||||
$outputMessage = __('Task completed.');
|
||||
if ((int) $task['utimestamp'] !== 0) {
|
||||
$output .= $this->progressTaskGraph($task);
|
||||
} else {
|
||||
$outputMessage = __('This task has never executed');
|
||||
}
|
||||
|
||||
$output .= ui_print_info_message(
|
||||
$outputMessage,
|
||||
'',
|
||||
true
|
||||
);
|
||||
$output .= ui_print_info_message(
|
||||
$outputMessage,
|
||||
'',
|
||||
true
|
||||
);
|
||||
}
|
||||
} else if ($task['status'] == 1
|
||||
|| ($task['utimestamp'] == 0 && $task['interval_sweep'])
|
||||
) {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
|
@ -654,7 +654,7 @@ if ($get_agent_alerts_datatable === true) {
|
|||
}
|
||||
|
||||
$idGroup = $filter_alert['ag_group'];
|
||||
$tag_filter = $filter_alert['tag_filter'];
|
||||
$tag_filter = $filter_alert['tag'];
|
||||
$action_filter = $filter_alert['action'];
|
||||
|
||||
try {
|
||||
|
|
|
@ -429,7 +429,9 @@ if (check_login()) {
|
|||
$table_modules->data[$key][1] = remove_right_zeros(
|
||||
number_format(
|
||||
$value['datos'],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
* ============================================================================
|
||||
*/
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
// Begin.
|
||||
if (check_login()) {
|
||||
global $config;
|
||||
|
@ -59,6 +61,11 @@ if (check_login()) {
|
|||
0
|
||||
);
|
||||
|
||||
$get_data_dataMatrix = (bool) get_parameter(
|
||||
'get_data_dataMatrix',
|
||||
0
|
||||
);
|
||||
|
||||
if ($get_agent_modules_json_by_name === true) {
|
||||
$agent_name = get_parameter('agent_name');
|
||||
|
||||
|
@ -499,7 +506,9 @@ if (check_login()) {
|
|||
$data[] = remove_right_zeros(
|
||||
number_format(
|
||||
$row[$attr[0]],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -507,7 +516,9 @@ if (check_login()) {
|
|||
$data[] = remove_right_zeros(
|
||||
number_format(
|
||||
$row[$attr[0]],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -524,7 +535,9 @@ if (check_login()) {
|
|||
$data[] = remove_right_zeros(
|
||||
number_format(
|
||||
$row[$attr[0]],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -1430,4 +1443,190 @@ if (check_login()) {
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_data_dataMatrix === true) {
|
||||
global $config;
|
||||
|
||||
$table_id = get_parameter('table_id', '');
|
||||
$modules = json_decode(
|
||||
io_safe_output(
|
||||
get_parameter('modules', '')
|
||||
),
|
||||
true
|
||||
);
|
||||
$period = get_parameter('period', 0);
|
||||
$slice = get_parameter('slice', 0);
|
||||
|
||||
// Datatables offset, limit.
|
||||
$start = get_parameter('start', 0);
|
||||
$formatData = (bool) get_parameter('formatData', 0);
|
||||
$length = get_parameter(
|
||||
'length',
|
||||
$config['block_size']
|
||||
);
|
||||
|
||||
$order = get_datatable_order(true);
|
||||
|
||||
// Total time per page.
|
||||
$time_all_box = ($length * $slice);
|
||||
|
||||
// Total number of boxes.
|
||||
$total_box = ceil($period / $slice);
|
||||
|
||||
if ($start > 0) {
|
||||
$start = ($start / $length);
|
||||
}
|
||||
|
||||
// Uncompress.
|
||||
try {
|
||||
ob_start();
|
||||
$dateNow = get_system_time();
|
||||
$final = ($dateNow - $period);
|
||||
$date = ($dateNow - ($time_all_box * $start));
|
||||
|
||||
if (($date - $time_all_box) > $final) {
|
||||
$datelimit = ($date - $time_all_box);
|
||||
} else {
|
||||
$datelimit = $final;
|
||||
}
|
||||
|
||||
foreach ($modules as $key => $value) {
|
||||
if (is_metaconsole() === true) {
|
||||
try {
|
||||
$node = new Node((int) $value['id_node']);
|
||||
$node->connect();
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
$value['thresholds'] = [
|
||||
'min_critical' => (empty($value['c_min']) === true) ? null : $value['c_min'],
|
||||
'max_critical' => (empty($value['c_max']) === true) ? null : $value['c_max'],
|
||||
'min_warning' => (empty($value['w_min']) === true) ? null : $value['w_min'],
|
||||
'max_warning' => (empty($value['w_max']) === true) ? null : $value['w_max'],
|
||||
];
|
||||
|
||||
$module_data = db_uncompress_module_data(
|
||||
$value['id'],
|
||||
$datelimit,
|
||||
$date,
|
||||
$slice,
|
||||
true
|
||||
);
|
||||
|
||||
$uncompressData[] = array_reduce(
|
||||
$module_data,
|
||||
function ($carry, $item) use ($value, $config, $formatData) {
|
||||
// Last value.
|
||||
$vdata = null;
|
||||
if (is_array($item['data']) === true) {
|
||||
foreach ($item['data'] as $v) {
|
||||
$vdata = $v['datos'];
|
||||
}
|
||||
}
|
||||
|
||||
$status = get_status_data_modules(
|
||||
$value['id'],
|
||||
$vdata,
|
||||
$value['thresholds']
|
||||
);
|
||||
|
||||
$resultData = '<span style="color:'.$status['color'].'">';
|
||||
if ($vdata !== null && $vdata !== '' && $vdata !== false) {
|
||||
if (isset($formatData) === true
|
||||
&& (bool) $formatData === true
|
||||
) {
|
||||
$resultData .= format_for_graph(
|
||||
$vdata,
|
||||
$config['graph_precision']
|
||||
);
|
||||
} else {
|
||||
$resultData .= sla_truncate(
|
||||
$vdata,
|
||||
$config['graph_precision']
|
||||
);
|
||||
}
|
||||
|
||||
$resultData .= ' '.$value['unit'];
|
||||
} else {
|
||||
$resultData .= '--';
|
||||
}
|
||||
|
||||
$resultData .= '</span>';
|
||||
$carry[] = [
|
||||
'utimestamp' => $item['utimestamp'],
|
||||
'Column-'.$value['id'] => $resultData,
|
||||
];
|
||||
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($uncompressData) === false) {
|
||||
$data = array_reduce(
|
||||
$uncompressData,
|
||||
function ($carry, $item) {
|
||||
foreach ($item as $data_module) {
|
||||
foreach ($data_module as $key => $value) {
|
||||
if ($key === 'utimestamp') {
|
||||
$carry[$data_module['utimestamp']]['date'] = date('Y-m-d H:i', (int) $value);
|
||||
} else {
|
||||
$carry[$data_module['utimestamp']][$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($data) === false) {
|
||||
$data = array_reverse(array_values($data));
|
||||
} else {
|
||||
$data = [];
|
||||
}
|
||||
|
||||
// RecordsTotal && recordsfiltered resultados totales.
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $total_box,
|
||||
'recordsFiltered' => $total_box,
|
||||
]
|
||||
);
|
||||
|
||||
$response = ob_get_clean();
|
||||
|
||||
// Clean output buffer.
|
||||
while (ob_get_level() !== 0) {
|
||||
ob_end_clean();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(
|
||||
['error' => $e->getMessage()]
|
||||
);
|
||||
}
|
||||
|
||||
// If not valid it will throw an exception.
|
||||
json_decode($response);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
// If valid dump.
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
['error' => $response]
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2636,6 +2636,8 @@ class AgentWizard extends HTML
|
|||
*/
|
||||
private function resultsInterfaceWizard()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$generalInterfaceModules = $this->getInterfacesModules();
|
||||
$generalInterfaceTables = [];
|
||||
$generalInterfaceModulesUpdated = [];
|
||||
|
@ -2849,7 +2851,12 @@ class AgentWizard extends HTML
|
|||
// Format current value with thousands and decimals.
|
||||
if (is_numeric($currentValue) === true) {
|
||||
$decimals = (is_float($currentValue) === true) ? 2 : 0;
|
||||
$currentValue = number_format($currentValue, $decimals);
|
||||
$currentValue = number_format(
|
||||
$currentValue,
|
||||
$decimals,
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
);
|
||||
}
|
||||
|
||||
// It unit of measure have data, attach to current value.
|
||||
|
|
|
@ -987,7 +987,7 @@ class Diagnostics extends Wizard
|
|||
],
|
||||
'tablesFragmentationValue' => [
|
||||
'name' => __('Tables fragmentation (current value)'),
|
||||
'value' => number_format($tFragmentationValue, 2).'%',
|
||||
'value' => number_format($tFragmentationValue, 2, $config['decimal_separator'], $config['thousand_separator']).'%',
|
||||
],
|
||||
'tablesFragmentationStatus' => [
|
||||
'name' => __('Table fragmentation status'),
|
||||
|
@ -1122,7 +1122,9 @@ class Diagnostics extends Wizard
|
|||
if ($totalModuleIntervalTime !== false) {
|
||||
$averageTime = number_format(
|
||||
((int) $totalNetworkModules / (int) $totalModuleIntervalTime),
|
||||
3
|
||||
3,
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1749,7 +1751,7 @@ class Diagnostics extends Wizard
|
|||
$sizeServerLog = number_format($fileSize);
|
||||
$sizeServerLog = (0 + str_replace(',', '', $sizeServerLog));
|
||||
|
||||
$value = number_format(($fileSize / $mega), 3);
|
||||
$value = number_format(($fileSize / $mega), 3, $config['decimal_separator'], $config['thousand_separator']);
|
||||
$message = __('You have more than 10 MB of logs');
|
||||
$status = 0;
|
||||
if ($sizeServerLog <= $tenMega) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,7 +20,7 @@
|
|||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC221213';
|
||||
$build_version = 'PC221220';
|
||||
$pandora_version = 'v7.0NG.767';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
|
|
@ -219,6 +219,8 @@ function list_files($directory, $stringSearch, $searchHandler, $return=false)
|
|||
*/
|
||||
function format_numeric($number, $decimals=1)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Translate to float in case there are characters in the string so
|
||||
// fmod doesn't throw a notice
|
||||
$number = (float) $number;
|
||||
|
@ -227,17 +229,11 @@ function format_numeric($number, $decimals=1)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Translators: This is separator of decimal point
|
||||
$dec_point = __('.');
|
||||
// Translators: This is separator of decimal point
|
||||
$thousands_sep = __(',');
|
||||
|
||||
// If has decimals
|
||||
if (fmod($number, 1) > 0) {
|
||||
return number_format($number, $decimals, $dec_point, $thousands_sep);
|
||||
return number_format($number, $decimals, $config['decimal_separator'], $config['thousand_separator']);
|
||||
}
|
||||
|
||||
return number_format($number, 0, $dec_point, $thousands_sep);
|
||||
return number_format($number, 0, $config['decimal_separator'], $config['thousand_separator']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4084,14 +4080,18 @@ function series_type_graph_array($data, $show_elements_graph)
|
|||
$data_return['legend'][$key] .= remove_right_zeros(
|
||||
number_format(
|
||||
$value['min'],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
);
|
||||
$data_return['legend'][$key] .= ' '.__('Max:');
|
||||
$data_return['legend'][$key] .= remove_right_zeros(
|
||||
number_format(
|
||||
$value['max'],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
);
|
||||
$data_return['legend'][$key] .= ' '._('Avg:');
|
||||
|
@ -4099,7 +4099,8 @@ function series_type_graph_array($data, $show_elements_graph)
|
|||
number_format(
|
||||
$value['avg'],
|
||||
$config['graph_precision'],
|
||||
$config['csv_decimal_separator']
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
).' '.$str;
|
||||
}
|
||||
|
@ -4156,7 +4157,9 @@ function series_type_graph_array($data, $show_elements_graph)
|
|||
$data_return['legend'][$key] .= remove_right_zeros(
|
||||
number_format(
|
||||
$value['data'][0][1],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
).' '.$str;
|
||||
}
|
||||
|
|
|
@ -604,95 +604,6 @@ function api_get_module_last_value($idAgentModule, $trash1, $other=';', $returnT
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
DB column mapping table used by tree_agents (and get module_properties)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Agent related field mappings (output field => column designation for 'tagente').
|
||||
* agent_id is not in this list (because it is mandatory).
|
||||
* agent_id_group is not in this list.
|
||||
*/
|
||||
$agent_field_column_mapping = [
|
||||
'agent_name' => 'nombre as agent_name',
|
||||
'agent_direction' => 'direccion as agent_direction',
|
||||
'agent_comentary' => 'comentarios as agent_comentary',
|
||||
'agent_last_contant' => 'ultimo_contacto as agent_last_contant',
|
||||
'agent_mode' => 'modo as agent_mode',
|
||||
'agent_interval' => 'intervalo as agent_interval',
|
||||
'agent_id_os' => 'id_os as agent_id_os',
|
||||
'agent_os_version' => 'os_version as agent_os_version',
|
||||
'agent_version' => 'agent_version as agent_version',
|
||||
'agent_last_remote_contact' => 'ultimo_contacto_remoto as agent_last_remote_contact',
|
||||
'agent_disabled' => 'disabled as agent_disabled',
|
||||
'agent_id_parent' => 'id_parent as agent_id_parent',
|
||||
'agent_custom_id' => 'custom_id as agent_custom_id',
|
||||
'agent_server_name' => 'server_name as agent_server_name',
|
||||
'agent_cascade_protection' => 'cascade_protection as agent_cascade_protection',
|
||||
'agent_cascade_protection_module' => 'cascade_protection_module as agent_cascade_protection_module',
|
||||
];
|
||||
|
||||
// module related field mappings 1/2 (output field => column for 'tagente_modulo')
|
||||
// module_id_agent_modulo is not in this list
|
||||
$module_field_column_mampping = [
|
||||
'module_id_agent' => 'id_agente as module_id_agent',
|
||||
'module_id_module_type' => 'id_tipo_modulo as module_id_module_type',
|
||||
'module_description' => 'descripcion as module_description',
|
||||
'module_name' => 'nombre as module_name',
|
||||
'module_max' => 'max as module_max',
|
||||
'module_min' => 'min as module_min',
|
||||
'module_interval' => 'module_interval',
|
||||
'module_tcp_port' => 'tcp_port as module_tcp_port',
|
||||
'module_tcp_send' => 'tcp_send as module_tcp_send',
|
||||
'module_tcp_rcv' => 'tcp_rcv as module_tcp_rcv',
|
||||
'module_snmp_community' => 'snmp_community as module_snmp_community',
|
||||
'module_snmp_oid' => 'snmp_oid as module_snmp_oid',
|
||||
'module_ip_target' => 'ip_target as module_ip_target',
|
||||
'module_id_module_group' => 'id_module_group as module_id_module_group',
|
||||
'module_flag' => 'flag as module_flag',
|
||||
'module_id_module' => 'id_modulo as module_id_module',
|
||||
'module_disabled' => 'disabled as module_disabled',
|
||||
'module_id_export' => 'id_export as module_id_export',
|
||||
'module_plugin_user' => 'plugin_user as module_plugin_user',
|
||||
'module_plugin_pass' => 'plugin_pass as module_plugin_pass',
|
||||
'module_plugin_parameter' => 'plugin_parameter as module_plugin_parameter',
|
||||
'module_id_plugin' => 'id_plugin as module_id_plugin',
|
||||
'module_post_process' => 'post_process as module_post_process',
|
||||
'module_prediction_module' => 'prediction_module as module_prediction_module',
|
||||
'module_max_timeout' => 'max_timeout as module_max_timeout',
|
||||
'module_max_retries' => 'max_retries as module_max_retries',
|
||||
'module_custom_id' => 'custom_id as module_custom_id',
|
||||
'module_history_data' => 'history_data as module_history_data',
|
||||
'module_min_warning' => 'min_warning as module_min_warning',
|
||||
'module_max_warning' => 'max_warning as module_max_warning',
|
||||
'module_str_warning' => 'str_warning as module_str_warning',
|
||||
'module_min_critical' => 'min_critical as module_min_critical',
|
||||
'module_max_critical' => 'max_critical as module_max_critical',
|
||||
'module_str_critical' => 'str_critical as module_str_critical',
|
||||
'module_min_ff_event' => 'min_ff_event as module_min_ff_event',
|
||||
'module_delete_pending' => 'delete_pending as module_delete_pending',
|
||||
'module_plugin_macros' => 'macros as module_plugin_macros',
|
||||
'module_macros' => 'module_macros as module_macros',
|
||||
'module_critical_inverse' => 'critical_inverse as module_critical_inverse',
|
||||
'module_warning_inverse' => 'warning_inverse as module_warning_inverse',
|
||||
];
|
||||
|
||||
// module related field mappings 2/2 (output field => column for 'tagente_estado')
|
||||
// module_id_agent_modulo is not in this list
|
||||
$estado_fields_to_columns_mapping = [
|
||||
'module_id_agent_state' => 'id_agente_estado as module_id_agent_state',
|
||||
'module_data' => 'datos as module_data',
|
||||
'module_timestamp' => 'timestamp as module_timestamp',
|
||||
'module_state' => 'estado as module_state',
|
||||
'module_last_try' => 'last_try as module_last_try',
|
||||
'module_utimestamp' => 'utimestamp as module_utimestamp',
|
||||
'module_current_interval' => 'current_interval as module_current_interval',
|
||||
'module_running_by' => 'running_by as module_running_by',
|
||||
'module_last_execution_try' => 'last_execution_try as module_last_execution_try',
|
||||
'module_status_changes' => 'status_changes as module_status_changes',
|
||||
'module_last_status' => 'last_status as module_last_status',
|
||||
];
|
||||
|
||||
/***
|
||||
* end of DB column mapping table
|
||||
***/
|
||||
|
@ -806,9 +717,9 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
|
|||
'module_id_module',
|
||||
'module_disabled',
|
||||
'module_id_export',
|
||||
'module_plugin_user',
|
||||
'module_plugin_pass',
|
||||
'module_plugin_parameter',
|
||||
'module_plugin_pass',
|
||||
'module_plugin_user',
|
||||
'module_id_plugin',
|
||||
'module_post_process',
|
||||
'module_prediction_module',
|
||||
|
@ -897,14 +808,88 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
|
|||
'alert_actions_id_group',
|
||||
];
|
||||
|
||||
// agent related field mappings (output field => column designation for 'tagente')
|
||||
global $agent_field_column_mapping;
|
||||
/*
|
||||
* Agent related field mappings (output field => column designation for 'tagente').
|
||||
* agent_id is not in this list (because it is mandatory).
|
||||
* agent_id_group is not in this list.
|
||||
*/
|
||||
$agent_field_column_mapping = [
|
||||
'agent_name' => 'nombre as agent_name',
|
||||
'agent_direction' => 'direccion as agent_direction',
|
||||
'agent_comentary' => 'comentarios as agent_comentary',
|
||||
'agent_last_contant' => 'ultimo_contacto as agent_last_contant',
|
||||
'agent_mode' => 'modo as agent_mode',
|
||||
'agent_interval' => 'intervalo as agent_interval',
|
||||
'agent_id_os' => 'id_os as agent_id_os',
|
||||
'agent_os_version' => 'os_version as agent_os_version',
|
||||
'agent_version' => 'agent_version as agent_version',
|
||||
'agent_last_remote_contact' => 'ultimo_contacto_remoto as agent_last_remote_contact',
|
||||
'agent_disabled' => 'disabled as agent_disabled',
|
||||
'agent_id_parent' => 'id_parent as agent_id_parent',
|
||||
'agent_custom_id' => 'custom_id as agent_custom_id',
|
||||
'agent_server_name' => 'server_name as agent_server_name',
|
||||
'agent_cascade_protection' => 'cascade_protection as agent_cascade_protection',
|
||||
'agent_cascade_protection_module' => 'cascade_protection_module as agent_cascade_protection_module',
|
||||
];
|
||||
|
||||
// module related field mappings 1/2 (output field => column for 'tagente_modulo')
|
||||
global $module_field_column_mampping;
|
||||
// module_id_agent_modulo is not in this list
|
||||
// module_plugin_user, module_plugin_pass, module_plugin_macros are not in this list due to security purposes.
|
||||
$module_field_column_mapping = [
|
||||
'module_id_agent' => 'id_agente as module_id_agent',
|
||||
'module_id_module_type' => 'id_tipo_modulo as module_id_module_type',
|
||||
'module_description' => 'descripcion as module_description',
|
||||
'module_name' => 'nombre as module_name',
|
||||
'module_max' => 'max as module_max',
|
||||
'module_min' => 'min as module_min',
|
||||
'module_interval' => 'module_interval',
|
||||
'module_tcp_port' => 'tcp_port as module_tcp_port',
|
||||
'module_tcp_send' => 'tcp_send as module_tcp_send',
|
||||
'module_tcp_rcv' => 'tcp_rcv as module_tcp_rcv',
|
||||
'module_snmp_community' => 'snmp_community as module_snmp_community',
|
||||
'module_snmp_oid' => 'snmp_oid as module_snmp_oid',
|
||||
'module_ip_target' => 'ip_target as module_ip_target',
|
||||
'module_id_module_group' => 'id_module_group as module_id_module_group',
|
||||
'module_flag' => 'flag as module_flag',
|
||||
'module_id_module' => 'id_modulo as module_id_module',
|
||||
'module_disabled' => 'disabled as module_disabled',
|
||||
'module_id_export' => 'id_export as module_id_export',
|
||||
'module_plugin_parameter' => 'plugin_parameter as module_plugin_parameter',
|
||||
'module_id_plugin' => 'id_plugin as module_id_plugin',
|
||||
'module_post_process' => 'post_process as module_post_process',
|
||||
'module_prediction_module' => 'prediction_module as module_prediction_module',
|
||||
'module_max_timeout' => 'max_timeout as module_max_timeout',
|
||||
'module_max_retries' => 'max_retries as module_max_retries',
|
||||
'module_custom_id' => 'custom_id as module_custom_id',
|
||||
'module_history_data' => 'history_data as module_history_data',
|
||||
'module_min_warning' => 'min_warning as module_min_warning',
|
||||
'module_max_warning' => 'max_warning as module_max_warning',
|
||||
'module_str_warning' => 'str_warning as module_str_warning',
|
||||
'module_min_critical' => 'min_critical as module_min_critical',
|
||||
'module_max_critical' => 'max_critical as module_max_critical',
|
||||
'module_str_critical' => 'str_critical as module_str_critical',
|
||||
'module_min_ff_event' => 'min_ff_event as module_min_ff_event',
|
||||
'module_delete_pending' => 'delete_pending as module_delete_pending',
|
||||
'module_macros' => 'module_macros as module_macros',
|
||||
'module_critical_inverse' => 'critical_inverse as module_critical_inverse',
|
||||
'module_warning_inverse' => 'warning_inverse as module_warning_inverse',
|
||||
];
|
||||
|
||||
// module related field mappings 2/2 (output field => column for 'tagente_estado')
|
||||
global $estado_fields_to_columns_mapping;
|
||||
// module_id_agent_modulo is not in this list
|
||||
$estado_fields_to_columns_mapping = [
|
||||
'module_id_agent_state' => 'id_agente_estado as module_id_agent_state',
|
||||
'module_data' => 'datos as module_data',
|
||||
'module_timestamp' => 'timestamp as module_timestamp',
|
||||
'module_state' => 'estado as module_state',
|
||||
'module_last_try' => 'last_try as module_last_try',
|
||||
'module_utimestamp' => 'utimestamp as module_utimestamp',
|
||||
'module_current_interval' => 'current_interval as module_current_interval',
|
||||
'module_running_by' => 'running_by as module_running_by',
|
||||
'module_last_execution_try' => 'last_execution_try as module_last_execution_try',
|
||||
'module_status_changes' => 'status_changes as module_status_changes',
|
||||
'module_last_status' => 'last_status as module_last_status',
|
||||
];
|
||||
|
||||
// alert related field mappings (output field => column for 'talert_template_modules', ... )
|
||||
$alert_fields_to_columns_mapping = [
|
||||
|
@ -985,8 +970,8 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
|
|||
$agent_additional_columns .= (', '.$agent_field_column_mapping[$fld] );
|
||||
}
|
||||
|
||||
if (array_key_exists($fld, $module_field_column_mampping)) {
|
||||
$module_additional_columns .= (', '.$module_field_column_mampping[$fld]);
|
||||
if (array_key_exists($fld, $module_field_column_mapping)) {
|
||||
$module_additional_columns .= (', '.$module_field_column_mapping[$fld]);
|
||||
}
|
||||
|
||||
if (array_key_exists($fld, $estado_fields_to_columns_mapping)) {
|
||||
|
@ -1017,6 +1002,10 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
|
|||
}
|
||||
|
||||
foreach ($groups as &$group) {
|
||||
if (check_acl($config['id_user'], $group['group_id'], 'AR') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$group = str_replace('\n', $returnReplace, $group);
|
||||
|
||||
$group['type_row'] = 'group';
|
||||
|
@ -1034,6 +1023,20 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
|
|||
$agents = [];
|
||||
}
|
||||
|
||||
if ((bool) check_acl($config['id_user'], $id_group, 'AW') === true) {
|
||||
if (array_search('module_plugin_user', $fields) !== false) {
|
||||
$module_additional_columns .= ' ,plugin_user as module_plugin_user';
|
||||
}
|
||||
|
||||
if (array_search('module_plugin_pass', $fields) !== false) {
|
||||
$module_additional_columns .= ' ,plugin_pass as module_plugin_pass';
|
||||
}
|
||||
|
||||
if (array_search('module_plugin_macros', $fields) !== false) {
|
||||
$module_additional_columns .= ' ,macros as module_plugin_macros';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($agents as $index => &$agent) {
|
||||
$agent = str_replace('\n', $returnReplace, $agent);
|
||||
|
||||
|
@ -1048,15 +1051,17 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
|
|||
// SKIP collecting MODULES and ALERTS
|
||||
}
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM (SELECT id_agente_modulo as module_id_agent_modulo '.$module_additional_columns.'
|
||||
FROM tagente_modulo t1
|
||||
WHERE id_agente = '.$agent['agent_id'].') t1
|
||||
INNER JOIN (SELECT id_agente_modulo as module_id_agent_modulo '.$estado_additional_columns.'
|
||||
FROM tagente_estado
|
||||
WHERE id_agente = '.$agent['agent_id'].') t2
|
||||
ON t1.module_id_agent_modulo = t2.module_id_agent_modulo';
|
||||
|
||||
$modules = db_get_all_rows_sql(
|
||||
'SELECT *
|
||||
FROM (SELECT id_agente_modulo as module_id_agent_modulo '.$module_additional_columns.'
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente = '.$agent['agent_id'].') t1
|
||||
INNER JOIN (SELECT id_agente_modulo as module_id_agent_modulo '.$estado_additional_columns.'
|
||||
FROM tagente_estado
|
||||
WHERE id_agente = '.$agent['agent_id'].') t2
|
||||
ON t1.module_id_agent_modulo = t2.module_id_agent_modulo'
|
||||
$sql
|
||||
);
|
||||
|
||||
if ($modules === false) {
|
||||
|
@ -1365,10 +1370,66 @@ function get_module_properties($id_module, $fields, $separator, $returnType, $re
|
|||
];
|
||||
|
||||
// module related field mappings 1/2 (output field => column for 'tagente_modulo')
|
||||
global $module_field_column_mampping;
|
||||
// module_id_agent_modulo is not in this list
|
||||
// module_plugin_user, module_plugin_pass, module_plugin_macros are not in this list due to security purposes.
|
||||
$module_field_column_mapping = [
|
||||
'module_id_agent' => 'id_agente as module_id_agent',
|
||||
'module_id_module_type' => 'id_tipo_modulo as module_id_module_type',
|
||||
'module_description' => 'descripcion as module_description',
|
||||
'module_name' => 'nombre as module_name',
|
||||
'module_max' => 'max as module_max',
|
||||
'module_min' => 'min as module_min',
|
||||
'module_interval' => 'module_interval',
|
||||
'module_tcp_port' => 'tcp_port as module_tcp_port',
|
||||
'module_tcp_send' => 'tcp_send as module_tcp_send',
|
||||
'module_tcp_rcv' => 'tcp_rcv as module_tcp_rcv',
|
||||
'module_snmp_community' => 'snmp_community as module_snmp_community',
|
||||
'module_snmp_oid' => 'snmp_oid as module_snmp_oid',
|
||||
'module_ip_target' => 'ip_target as module_ip_target',
|
||||
'module_id_module_group' => 'id_module_group as module_id_module_group',
|
||||
'module_flag' => 'flag as module_flag',
|
||||
'module_id_module' => 'id_modulo as module_id_module',
|
||||
'module_disabled' => 'disabled as module_disabled',
|
||||
'module_id_export' => 'id_export as module_id_export',
|
||||
'module_plugin_parameter' => 'plugin_parameter as module_plugin_parameter',
|
||||
'module_plugin_user' => 'plugin_user as module_plugin_user',
|
||||
'module_plugin_pass' => 'plugin_pass as module_plugin_pass',
|
||||
'module_plugin_macros' => 'macros as module_plugin_macros',
|
||||
'module_id_plugin' => 'id_plugin as module_id_plugin',
|
||||
'module_post_process' => 'post_process as module_post_process',
|
||||
'module_prediction_module' => 'prediction_module as module_prediction_module',
|
||||
'module_max_timeout' => 'max_timeout as module_max_timeout',
|
||||
'module_max_retries' => 'max_retries as module_max_retries',
|
||||
'module_custom_id' => 'custom_id as module_custom_id',
|
||||
'module_history_data' => 'history_data as module_history_data',
|
||||
'module_min_warning' => 'min_warning as module_min_warning',
|
||||
'module_max_warning' => 'max_warning as module_max_warning',
|
||||
'module_str_warning' => 'str_warning as module_str_warning',
|
||||
'module_min_critical' => 'min_critical as module_min_critical',
|
||||
'module_max_critical' => 'max_critical as module_max_critical',
|
||||
'module_str_critical' => 'str_critical as module_str_critical',
|
||||
'module_min_ff_event' => 'min_ff_event as module_min_ff_event',
|
||||
'module_delete_pending' => 'delete_pending as module_delete_pending',
|
||||
'module_macros' => 'module_macros as module_macros',
|
||||
'module_critical_inverse' => 'critical_inverse as module_critical_inverse',
|
||||
'module_warning_inverse' => 'warning_inverse as module_warning_inverse',
|
||||
];
|
||||
|
||||
// module related field mappings 2/2 (output field => column for 'tagente_estado')
|
||||
global $estado_fields_to_columns_mapping;
|
||||
// module_id_agent_modulo is not in this list
|
||||
$estado_fields_to_columns_mapping = [
|
||||
'module_id_agent_state' => 'id_agente_estado as module_id_agent_state',
|
||||
'module_data' => 'datos as module_data',
|
||||
'module_timestamp' => 'timestamp as module_timestamp',
|
||||
'module_state' => 'estado as module_state',
|
||||
'module_last_try' => 'last_try as module_last_try',
|
||||
'module_utimestamp' => 'utimestamp as module_utimestamp',
|
||||
'module_current_interval' => 'current_interval as module_current_interval',
|
||||
'module_running_by' => 'running_by as module_running_by',
|
||||
'module_last_execution_try' => 'last_execution_try as module_last_execution_try',
|
||||
'module_status_changes' => 'status_changes as module_status_changes',
|
||||
'module_last_status' => 'last_status as module_last_status',
|
||||
];
|
||||
|
||||
if ($fields == false) {
|
||||
$fields = $module_properties_master_fields;
|
||||
|
@ -1378,8 +1439,8 @@ function get_module_properties($id_module, $fields, $separator, $returnType, $re
|
|||
$module_additional_columns = '';
|
||||
$estado_additional_columns = '';
|
||||
foreach ($fields as $fld) {
|
||||
if (array_key_exists($fld, $module_field_column_mampping)) {
|
||||
$module_additional_columns .= (', '.$module_field_column_mampping[$fld]);
|
||||
if (array_key_exists($fld, $module_field_column_mapping)) {
|
||||
$module_additional_columns .= (', '.$module_field_column_mapping[$fld]);
|
||||
}
|
||||
|
||||
if (array_key_exists($fld, $estado_fields_to_columns_mapping)) {
|
||||
|
@ -1404,9 +1465,9 @@ function get_module_properties($id_module, $fields, $separator, $returnType, $re
|
|||
$modules = [];
|
||||
}
|
||||
|
||||
$modules = str_replace('\n', $returnReplace, $modules);
|
||||
|
||||
foreach ($modules as &$module) {
|
||||
$module = str_replace('\n', $returnReplace, $module);
|
||||
|
||||
$module['type_row'] = 'module';
|
||||
|
||||
if ($module['module_macros']) {
|
||||
|
|
|
@ -1475,6 +1475,15 @@ function config_update_config()
|
|||
if (config_update_value('use_data_multiplier', get_parameter('use_data_multiplier', '1'), true) === false) {
|
||||
$error_update[] = __('Use data multiplier');
|
||||
}
|
||||
|
||||
if (config_update_value('decimal_separator', (string) get_parameter('decimal_separator', '.'), true) === false) {
|
||||
$error_update[] = __('Decimal separator');
|
||||
} else {
|
||||
$thousand_separator = ((string) get_parameter('decimal_separator', '.') === '.') ? ',' : '.';
|
||||
if (config_update_value('thousand_separator', $thousand_separator, true) === false) {
|
||||
$error_update[] = __('Thousand separator');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'net':
|
||||
|
@ -3479,6 +3488,10 @@ function config_process_config()
|
|||
config_update_value('module_library_password', '');
|
||||
}
|
||||
|
||||
if (!isset($config['decimal_separator'])) {
|
||||
config_update_value('decimal_separator', '.');
|
||||
}
|
||||
|
||||
// Finally, check if any value was overwritten in a form.
|
||||
config_update_config();
|
||||
}
|
||||
|
|
|
@ -757,7 +757,8 @@ function db_uncompress_module_data(
|
|||
$id_agente_modulo,
|
||||
$tstart=false,
|
||||
$tend=false,
|
||||
$slice_size=false
|
||||
$slice_size=false,
|
||||
$force_slice_not_data=false
|
||||
) {
|
||||
global $config;
|
||||
|
||||
|
@ -860,7 +861,10 @@ function db_uncompress_module_data(
|
|||
|
||||
$module_interval = modules_get_interval($id_agente_modulo);
|
||||
|
||||
if (($raw_data === false) && ( $first_utimestamp === false )) {
|
||||
if (($force_slice_not_data === false)
|
||||
&& ($raw_data === false)
|
||||
&& ( $first_utimestamp === false )
|
||||
) {
|
||||
// No data.
|
||||
return false;
|
||||
}
|
||||
|
@ -2313,7 +2317,13 @@ function db_get_lock(string $lockname, int $expiration_time=86400) :?int
|
|||
}
|
||||
|
||||
if ($lock_status === false) {
|
||||
return null;
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_SYSTEM,
|
||||
'Issue in Database Lock',
|
||||
'system'
|
||||
);
|
||||
|
||||
return (int) null;
|
||||
}
|
||||
|
||||
return (int) $lock_status;
|
||||
|
|
|
@ -1950,7 +1950,7 @@ function html_print_extended_select_for_post_process(
|
|||
$found = false;
|
||||
|
||||
if ($selected) {
|
||||
if (array_key_exists(number_format($selected, 14, '.', ','), $fields)) {
|
||||
if (array_key_exists(number_format($selected, 14, $config['decimal_separator'], $config['thousand_separator']), $fields)) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2589,12 +2589,12 @@ function modules_get_agentmodule_data_for_humans($module)
|
|||
$salida = human_milliseconds_to_string($module['datos']);
|
||||
}
|
||||
} else {
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2613,12 +2613,12 @@ function modules_get_agentmodule_data_for_humans($module)
|
|||
$salida = human_milliseconds_to_string($module['datos']);
|
||||
}
|
||||
} else {
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision']));
|
||||
$salida = remove_right_zeros(number_format($module['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2900,7 +2900,7 @@ function modules_get_status($id_agent_module, $db_status, $data, &$status, &$tit
|
|||
}
|
||||
|
||||
if (is_numeric($data)) {
|
||||
$title .= ': '.remove_right_zeros(number_format($data, $config['graph_precision']));
|
||||
$title .= ': '.remove_right_zeros(number_format($data, $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
} else {
|
||||
$text = io_safe_output($data);
|
||||
|
||||
|
@ -4336,3 +4336,129 @@ function modules_get_regex(
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Status for data thresholds modules.
|
||||
*
|
||||
* @param integer $id_module Module ID.
|
||||
* @param mixed $data Data int, bool, null, etc.
|
||||
* @param array $thresholds Array thresholds.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_status_data_modules(int $id_module, $data, $thresholds)
|
||||
{
|
||||
// Check not init.
|
||||
if ($data === false) {
|
||||
return ['color' => COL_NOTINIT];
|
||||
}
|
||||
|
||||
// Check boolean.
|
||||
$is_bolean = modules_is_boolean($id_module);
|
||||
if ($is_bolean === true) {
|
||||
if ($data > 0) {
|
||||
return ['color' => COL_CRITICAL];
|
||||
} else {
|
||||
return ['color' => COL_NORMAL];
|
||||
}
|
||||
}
|
||||
|
||||
$thresholds = calculateThreshold($thresholds);
|
||||
|
||||
foreach (getStatuses() as $status) {
|
||||
if ($thresholds[$status]['min'] === null
|
||||
&& $thresholds[$status]['max'] === null
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($thresholds[$status]['min'] === null
|
||||
&& $thresholds[$status]['max'] >= $data)
|
||||
|| ($thresholds[$status]['max'] === null
|
||||
&& $thresholds[$status]['min'] <= $data)
|
||||
|| ($thresholds[$status]['min'] <= $data
|
||||
&& $thresholds[$status]['max'] >= $data)
|
||||
) {
|
||||
if ($status === 'critical') {
|
||||
return ['color' => COL_CRITICAL];
|
||||
} else if ($status === 'warning') {
|
||||
return ['color' => COL_WARNING];
|
||||
} else {
|
||||
return ['color' => COL_NORMAL];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ['color' => COL_NORMAL];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate thresholds.
|
||||
*
|
||||
* @param array $thresholds_array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function calculateThreshold(array $thresholds_array)
|
||||
{
|
||||
$nMax = null;
|
||||
if ($thresholds_array['min_warning'] !== null) {
|
||||
$nMax = $thresholds_array['min_warning'];
|
||||
} else if ($thresholds_array['min_critical'] !== null) {
|
||||
$nMax = $thresholds_array['min_critical'];
|
||||
}
|
||||
|
||||
$wMin = null;
|
||||
if ($thresholds_array['min_warning'] !== null) {
|
||||
$wMin = $thresholds_array['min_warning'];
|
||||
}
|
||||
|
||||
$wMax = null;
|
||||
if ($thresholds_array['max_warning'] !== null) {
|
||||
$wMax = $thresholds_array['max_warning'];
|
||||
}
|
||||
|
||||
$cMin = null;
|
||||
if ($thresholds_array['min_critical'] !== null) {
|
||||
$cMin = $thresholds_array['min_critical'];
|
||||
}
|
||||
|
||||
$cMax = null;
|
||||
if ($thresholds_array['max_critical'] !== null) {
|
||||
$cMax = $thresholds_array['max_critical'];
|
||||
}
|
||||
|
||||
$thresholds = [
|
||||
'normal' => [
|
||||
'min' => null,
|
||||
'max' => $nMax,
|
||||
],
|
||||
'warning' => [
|
||||
'min' => $wMin,
|
||||
'max' => $wMax,
|
||||
],
|
||||
'critical' => [
|
||||
'min' => $cMin,
|
||||
'max' => $cMax,
|
||||
],
|
||||
];
|
||||
|
||||
return $thresholds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get status.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getStatuses()
|
||||
{
|
||||
return [
|
||||
'critical',
|
||||
'warning',
|
||||
'normal',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1833,14 +1833,24 @@ function reporting_event_top_n(
|
|||
|
||||
$divisor = get_data_multiplier($units[$key_dt]);
|
||||
|
||||
$data['formated_value'] = format_for_graph(
|
||||
$dt,
|
||||
2,
|
||||
'.',
|
||||
',',
|
||||
$divisor,
|
||||
$units[$key_dt]
|
||||
);
|
||||
if ((bool) $content['use_prefix_notation'] === false) {
|
||||
$data['formated_value'] = number_format(
|
||||
$dt,
|
||||
2,
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
).' '.$units[$key_dt];
|
||||
} else {
|
||||
$data['formated_value'] = format_for_graph(
|
||||
$dt,
|
||||
2,
|
||||
'.',
|
||||
',',
|
||||
$divisor,
|
||||
$units[$key_dt]
|
||||
);
|
||||
}
|
||||
|
||||
$data_return[] = $data;
|
||||
}
|
||||
|
||||
|
@ -1901,14 +1911,25 @@ function reporting_event_top_n(
|
|||
$data['agent'] = $an;
|
||||
$data['module'] = $module_name[$key_an];
|
||||
$data['value'] = $data_top[$key_an];
|
||||
$data['formated_value'] = format_for_graph(
|
||||
$data_top[$key_an],
|
||||
2,
|
||||
'.',
|
||||
',',
|
||||
$divisor,
|
||||
$units[$key_an]
|
||||
);
|
||||
|
||||
if ((bool) $content['use_prefix_notation'] === false) {
|
||||
$data['formated_value'] = number_format(
|
||||
$data_top[$key_an],
|
||||
2,
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
).' '.$units[$key_an];
|
||||
} else {
|
||||
$data['formated_value'] = format_for_graph(
|
||||
$data_top[$key_an],
|
||||
2,
|
||||
'.',
|
||||
',',
|
||||
$divisor,
|
||||
$units[$key_an]
|
||||
);
|
||||
}
|
||||
|
||||
$data_return[] = $data;
|
||||
}
|
||||
|
||||
|
@ -6917,6 +6938,13 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
|
||||
if (!$config['simple_module_value']) {
|
||||
$formated_value = $value;
|
||||
} else if ((bool) $content['use_prefix_notation'] === false) {
|
||||
$formated_value = number_format(
|
||||
$value,
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
).' '.$unit;
|
||||
} else {
|
||||
$formated_value = format_for_graph(
|
||||
$value,
|
||||
|
@ -7077,6 +7105,13 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
);
|
||||
if (!$config['simple_module_value']) {
|
||||
$formated_value = $value;
|
||||
} else if ((bool) $content['use_prefix_notation'] === false) {
|
||||
$formated_value = number_format(
|
||||
$value,
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
).' '.$unit;
|
||||
} else {
|
||||
$divisor = get_data_multiplier($unit);
|
||||
|
||||
|
|
|
@ -2292,7 +2292,9 @@ function reporting_html_agent_module_status($table, $item, $pdf=0)
|
|||
$row['data_module'] = remove_right_zeros(
|
||||
number_format(
|
||||
$data['data_module'],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
);
|
||||
} else {
|
||||
|
@ -2785,7 +2787,7 @@ function reporting_html_historical_data($table, $item, $pdf=0)
|
|||
} else {
|
||||
$row = [
|
||||
$data[__('Date')],
|
||||
remove_right_zeros(number_format($data[__('Data')], $config['graph_precision'])),
|
||||
remove_right_zeros(number_format($data[__('Data')], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -2925,7 +2927,9 @@ function reporting_html_last_value($table, $item, $pdf=0)
|
|||
$dataDatos = remove_right_zeros(
|
||||
number_format(
|
||||
$item['data']['datos'],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
);
|
||||
} else {
|
||||
|
@ -3470,7 +3474,9 @@ function reporting_html_monitor_report($table, $item, $mini, $pdf=0)
|
|||
).' '.__('OK').': '.remove_right_zeros(
|
||||
number_format(
|
||||
$item['data']['ok']['value'],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
).' %</p>';
|
||||
|
||||
|
@ -3481,7 +3487,9 @@ function reporting_html_monitor_report($table, $item, $mini, $pdf=0)
|
|||
).' '.__('Not OK').': '.remove_right_zeros(
|
||||
number_format(
|
||||
$item['data']['fail']['value'],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
).' % '.'</p>';
|
||||
}
|
||||
|
@ -3835,7 +3843,9 @@ function reporting_html_value(
|
|||
remove_right_zeros(
|
||||
number_format(
|
||||
$data[__('Maximun')],
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
),
|
||||
];
|
||||
|
|
|
@ -193,7 +193,7 @@ function treeview_printModuleTable($id_module, $server_data=false, $no_head=fals
|
|||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
$data = "<span title='".$last_data['datos']."' class='nowrap'>".human_milliseconds_to_string($last_data['datos']).'</span>';
|
||||
} else if (is_numeric($last_data['datos'])) {
|
||||
$data = "<span class='span_treeview'>".remove_right_zeros(number_format($last_data['datos'], $config['graph_precision'])).'</span>';
|
||||
$data = "<span class='span_treeview'>".remove_right_zeros(number_format($last_data['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])).'</span>';
|
||||
} else {
|
||||
$data = ui_print_truncate_text(
|
||||
io_safe_output($last_data['datos']),
|
||||
|
@ -209,7 +209,7 @@ function treeview_printModuleTable($id_module, $server_data=false, $no_head=fals
|
|||
|
||||
default:
|
||||
if (is_numeric($last_data['datos'])) {
|
||||
$data = "<span class='span_treeview'>".remove_right_zeros(number_format($last_data['datos'], $config['graph_precision'])).'</span>';
|
||||
$data = "<span class='span_treeview'>".remove_right_zeros(number_format($last_data['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])).'</span>';
|
||||
} else {
|
||||
$data = ui_print_truncate_text(
|
||||
io_safe_output($last_data['datos']),
|
||||
|
@ -232,7 +232,7 @@ function treeview_printModuleTable($id_module, $server_data=false, $no_head=fals
|
|||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
$data = "<span title='".human_milliseconds_to_string($last_data['datos'])."' class='nowrap'>".human_milliseconds_to_string($last_data['datos']).'</span>';
|
||||
} else if (is_numeric($last_data['datos'])) {
|
||||
$data = "<span class='span_treeview'>".remove_right_zeros(number_format($last_data['datos'], $config['graph_precision'])).'</span>';
|
||||
$data = "<span class='span_treeview'>".remove_right_zeros(number_format($last_data['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])).'</span>';
|
||||
} else {
|
||||
$data = ui_print_truncate_text(
|
||||
io_safe_output($last_data['datos']),
|
||||
|
@ -248,7 +248,7 @@ function treeview_printModuleTable($id_module, $server_data=false, $no_head=fals
|
|||
|
||||
default:
|
||||
if (is_numeric($last_data['datos'])) {
|
||||
$data = "<span class='span_treeview'>".remove_right_zeros(number_format($last_data['datos'], $config['graph_precision'])).'</span>';
|
||||
$data = "<span class='span_treeview'>".remove_right_zeros(number_format($last_data['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])).'</span>';
|
||||
} else {
|
||||
$data = ui_print_truncate_text(
|
||||
io_safe_output($last_data['datos']),
|
||||
|
@ -271,7 +271,7 @@ function treeview_printModuleTable($id_module, $server_data=false, $no_head=fals
|
|||
$data_macro = modules_get_unit_macro($last_data['datos'], $module['unit']);
|
||||
if ($data_macro) {
|
||||
if (is_numeric($data_macro)) {
|
||||
$last_data_str = "<span class='span_treeview'>".remove_right_zeros(number_format($data_macro, $config['graph_precision'])).'</span>';
|
||||
$last_data_str = "<span class='span_treeview'>".remove_right_zeros(number_format($data_macro, $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])).'</span>';
|
||||
} else {
|
||||
$last_data_str = ui_print_truncate_text(
|
||||
io_safe_output($data_macro),
|
||||
|
@ -594,10 +594,10 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
|
|||
$hashdata = $user.$pwd_deserialiced['auth_token'];
|
||||
|
||||
$hashdata = md5($hashdata);
|
||||
$url = $server_data['server_url'].'/index.php?'.'sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$agent['id_agente'].'&'.'loginhash=auto&'."loginhash_data=$hashdata&".'loginhash_user='.str_rot13($user);
|
||||
$url = $server_data['server_url'].'/index.php?'.'sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$agent['id_agente'];
|
||||
|
||||
if ($grants_on_node && (bool) $user_access_node !== false) {
|
||||
$cellName .= '<a href="'.$url.'">'.'<b><span class="bolder pandora_upper" title="'.$agent['nombre'].'">'.$agent['alias'].'</span></b></a>';
|
||||
$cellName .= '<a onclick="sendHash(\''.$url.'\')" href="#"><b><span class="bolder pandora_upper" title="'.$agent['nombre'].'">'.$agent['alias'].'</span></b></a>';
|
||||
} else {
|
||||
$cellName .= '<b><span class="bolder pandora_upper" title="'.$agent['nombre'].'">'.$agent['alias'].'</span></b>';
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
|
|||
$go_to_agent .= html_print_submit_button(__('Edit cluster'), 'upd_button', false, 'class="sub config"', true);
|
||||
}
|
||||
} else {
|
||||
$go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$url_hash.'">';
|
||||
$go_to_agent .= '<a target=_blank href="'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.$ent.'">';
|
||||
$go_to_agent .= html_print_submit_button(__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
|
||||
}
|
||||
|
||||
|
@ -905,5 +905,12 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
|
|||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
return;
|
||||
echo "
|
||||
<script>
|
||||
function sendHash(url) {
|
||||
window.location = url+'&loginhash=auto&loginhash_data=".$hashdata.'&loginhash_user='.str_rot13($user)."';
|
||||
|
||||
}
|
||||
|
||||
</script>";
|
||||
}
|
||||
|
|
|
@ -6592,10 +6592,11 @@ function ui_print_comments($comments)
|
|||
} else {
|
||||
$rest_time = (time() - $last_comment['utimestamp']);
|
||||
$time_last = (($rest_time / 60) / 60);
|
||||
$comentario = '<i>'.number_format($time_last, 0).' Hours ('.$last_comment['id_user'].'): '.$last_comment['comment'].'';
|
||||
|
||||
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], $config['thousand_separator']).' Hours ('.$last_comment['id_user'].'): '.$last_comment['comment'].'';
|
||||
|
||||
if (strlen($comentario) > '200px') {
|
||||
$comentario = '<i>'.number_format($time_last, 0).' Hours ('.$last_comment['id_user'].'): '.$short_comment.'...';
|
||||
$comentario = '<i>'.number_format($time_last, 0, $config['decimal_separator'], $config['thousand_separator']).' Hours ('.$last_comment['id_user'].'): '.$short_comment.'...';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -924,7 +924,7 @@ function visual_map_print_item(
|
|||
|
||||
$value_text = format_for_graph($module_value, 2);
|
||||
if ($value_text <= 0) {
|
||||
$value_text = remove_right_zeros(number_format($module_value, $config['graph_precision']));
|
||||
$value_text = remove_right_zeros(number_format($module_value, $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
}
|
||||
|
||||
if (!empty($unit_text)) {
|
||||
|
@ -1743,7 +1743,7 @@ function visual_map_print_item(
|
|||
|| (modules_is_boolean($layoutData['id_agente_modulo']) && $layoutData['show_last_value'] != 0)
|
||||
) {
|
||||
if (is_numeric($value)) {
|
||||
$img_style_title .= ' <br>'.__('Last value: ').remove_right_zeros(number_format($value, $config['graph_precision']));
|
||||
$img_style_title .= ' <br>'.__('Last value: ').remove_right_zeros(number_format($value, $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
} else {
|
||||
$img_style_title .= ' <br>'.__('Last value: ').$value;
|
||||
}
|
||||
|
@ -1881,13 +1881,13 @@ function visual_map_print_item(
|
|||
echo '</tr>';
|
||||
echo "<tr class='bg_whitesmoke height_90p'>";
|
||||
echo '<td>';
|
||||
echo "<div class='critical_zeros'>".remove_right_zeros(number_format($stat_agent_cr, 2)).'%</div>';
|
||||
echo "<div class='critical_zeros'>".remove_right_zeros(number_format($stat_agent_cr, 2, $config['decimal_separator'], $config['thousand_separator'])).'%</div>';
|
||||
echo "<div class='critical_vm'>Critical</div>";
|
||||
echo "<div class='warning_zeros'>".remove_right_zeros(number_format($stat_agent_wa, 2)).'%</div>';
|
||||
echo "<div class='warning_zeros'>".remove_right_zeros(number_format($stat_agent_wa, 2, $config['decimal_separator'], $config['thousand_separator'])).'%</div>';
|
||||
echo "<div class='warning_vm'>Warning</div>";
|
||||
echo "<div class='normal_zeros'>".remove_right_zeros(number_format($stat_agent_ok, 2)).'%</div>';
|
||||
echo "<div class='normal_zeros'>".remove_right_zeros(number_format($stat_agent_ok, 2, $config['decimal_separator'], $config['thousand_separator'])).'%</div>';
|
||||
echo "<div class='normal_vm'>Normal</div>";
|
||||
echo "<div class='unknown_zeros'>".remove_right_zeros(number_format($stat_agent_un, 2)).'%</div>';
|
||||
echo "<div class='unknown_zeros'>".remove_right_zeros(number_format($stat_agent_un, 2, $config['decimal_separator'], $config['thousand_separator'])).'%</div>';
|
||||
echo "<div class='unknown_vm'>Unknown</div>";
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
|
@ -2462,7 +2462,7 @@ function visual_map_get_simple_value($type, $id_module, $period=SECONDS_1DAY)
|
|||
} else {
|
||||
if (is_numeric($value)) {
|
||||
if ($config['simple_module_value']) {
|
||||
$value = remove_right_zeros(number_format($value, $config['graph_precision']));
|
||||
$value = remove_right_zeros(number_format($value, $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -499,11 +499,11 @@ function flot_custom_pie_chart(
|
|||
foreach ($graph_values as $label => $value) {
|
||||
if ($value['value']) {
|
||||
if ($value['value'] > 1000000) {
|
||||
$legendvalue = sprintf('%sM', remove_right_zeros(number_format(($value['value'] / 1000000), $config['graph_precision'])));
|
||||
$legendvalue = sprintf('%sM', remove_right_zeros(number_format(($value['value'] / 1000000), $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])));
|
||||
} else if ($value['value'] > 1000) {
|
||||
$legendvalue = sprintf('%sK', remove_right_zeros(number_format(($value['value'] / 1000), $config['graph_precision'])));
|
||||
$legendvalue = sprintf('%sK', remove_right_zeros(number_format(($value['value'] / 1000), $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])));
|
||||
} else {
|
||||
$legendvalue = remove_right_zeros(number_format($value['value'], $config['graph_precision']));
|
||||
$legendvalue = remove_right_zeros(number_format($value['value'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
}
|
||||
} else {
|
||||
$legendvalue = __('No data');
|
||||
|
|
|
@ -419,6 +419,7 @@ class Widget
|
|||
case 'GroupedMeterGraphs':
|
||||
case 'ColorModuleTabs':
|
||||
case 'BlockHistogram':
|
||||
case 'DataMatrix':
|
||||
$className .= '\\'.$name;
|
||||
break;
|
||||
|
||||
|
|
|
@ -0,0 +1,697 @@
|
|||
<?php
|
||||
/**
|
||||
* Widget data matrix Pandora FMS Console
|
||||
*
|
||||
* @category Console Class
|
||||
* @package Pandora FMS
|
||||
* @subpackage Widget
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
namespace PandoraFMS\Dashboard;
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
|
||||
/**
|
||||
* URL Widgets
|
||||
*/
|
||||
class DataMatrix extends Widget
|
||||
{
|
||||
|
||||
private const MAX_MODULES = 10;
|
||||
|
||||
/**
|
||||
* Name widget.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Title widget.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* Page widget;
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $page;
|
||||
|
||||
/**
|
||||
* Class name widget.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $className;
|
||||
|
||||
/**
|
||||
* Values options for each widget.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $values;
|
||||
|
||||
/**
|
||||
* Configuration required.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $configurationRequired;
|
||||
|
||||
/**
|
||||
* Error load widget.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $loadError;
|
||||
|
||||
/**
|
||||
* Width.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $width;
|
||||
|
||||
/**
|
||||
* Heigth.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $height;
|
||||
|
||||
/**
|
||||
* Grid Width.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $gridWidth;
|
||||
|
||||
/**
|
||||
* Cell ID.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $cellId;
|
||||
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param integer $cellId Cell ID.
|
||||
* @param integer $dashboardId Dashboard ID.
|
||||
* @param integer $widgetId Widget ID.
|
||||
* @param integer|null $width New width.
|
||||
* @param integer|null $height New height.
|
||||
* @param integer|null $gridWidth Grid width.
|
||||
*/
|
||||
public function __construct(
|
||||
int $cellId,
|
||||
int $dashboardId=0,
|
||||
int $widgetId=0,
|
||||
?int $width=0,
|
||||
?int $height=0,
|
||||
?int $gridWidth=0
|
||||
) {
|
||||
global $config;
|
||||
|
||||
// WARNING: Do not edit. This chunk must be in the constructor.
|
||||
parent::__construct(
|
||||
$cellId,
|
||||
$dashboardId,
|
||||
$widgetId
|
||||
);
|
||||
|
||||
// Width.
|
||||
$this->width = $width;
|
||||
|
||||
// Height.
|
||||
$this->height = $height;
|
||||
|
||||
// Grid Width.
|
||||
$this->gridWidth = $gridWidth;
|
||||
|
||||
// Cell Id.
|
||||
$this->cellId = $cellId;
|
||||
|
||||
// Options.
|
||||
$this->values = $this->decoders($this->getOptionsWidget());
|
||||
|
||||
// Positions.
|
||||
$this->position = $this->getPositionWidget();
|
||||
|
||||
// Page.
|
||||
$this->page = basename(__FILE__);
|
||||
|
||||
// ClassName.
|
||||
$class = new \ReflectionClass($this);
|
||||
$this->className = $class->getShortName();
|
||||
|
||||
// Title.
|
||||
$this->title = __('Color tabs modules');
|
||||
|
||||
// Name.
|
||||
if (empty($this->name) === true) {
|
||||
$this->name = 'single_graph';
|
||||
}
|
||||
|
||||
// This forces at least a first configuration.
|
||||
$this->configurationRequired = false;
|
||||
if (empty($this->values['moduleDataMatrix']) === true) {
|
||||
$this->configurationRequired = true;
|
||||
}
|
||||
|
||||
$this->overflow_scrollbars = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decoders hack for retrocompability.
|
||||
*
|
||||
* @param array $decoder Values.
|
||||
*
|
||||
* @return array Returns the values with the correct key.
|
||||
*/
|
||||
public function decoders(array $decoder): array
|
||||
{
|
||||
$values = [];
|
||||
// Retrieve global - common inputs.
|
||||
$values = parent::decoders($decoder);
|
||||
|
||||
$values['agentsDataMatrix'] = [];
|
||||
if (isset($decoder['agentsDataMatrix']) === true) {
|
||||
if (isset($decoder['agentsDataMatrix'][0]) === true
|
||||
&& empty($decoder['agentsDataMatrix']) === false
|
||||
) {
|
||||
$values['agentsDataMatrix'] = explode(
|
||||
',',
|
||||
$decoder['agentsDataMatrix'][0]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($decoder['selectionDataMatrix']) === true) {
|
||||
$values['selectionDataMatrix'] = $decoder['selectionDataMatrix'];
|
||||
}
|
||||
|
||||
$values['moduleDataMatrix'] = [];
|
||||
if (isset($decoder['moduleDataMatrix']) === true) {
|
||||
if (empty($decoder['moduleDataMatrix']) === false) {
|
||||
$values['moduleDataMatrix'] = $decoder['moduleDataMatrix'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($decoder['formatData']) === true) {
|
||||
$values['formatData'] = $decoder['formatData'];
|
||||
}
|
||||
|
||||
$values['label'] = 'module';
|
||||
if (isset($decoder['label']) === true) {
|
||||
$values['label'] = $decoder['label'];
|
||||
}
|
||||
|
||||
if (isset($decoder['fontColor']) === true) {
|
||||
$values['fontColor'] = $decoder['fontColor'];
|
||||
}
|
||||
|
||||
if (isset($decoder['period']) === true) {
|
||||
$values['period'] = $decoder['period'];
|
||||
}
|
||||
|
||||
if (isset($decoder['slice']) === true) {
|
||||
$values['slice'] = $decoder['slice'];
|
||||
}
|
||||
|
||||
if (isset($decoder['limit']) === true) {
|
||||
$values['limit'] = $decoder['limit'];
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates inputs for form (specific).
|
||||
*
|
||||
* @return array Of inputs.
|
||||
*
|
||||
* @throws Exception On error.
|
||||
*/
|
||||
public function getFormInputs(): array
|
||||
{
|
||||
global $config;
|
||||
|
||||
$values = $this->values;
|
||||
|
||||
// Retrieve global - common inputs.
|
||||
$inputs = parent::getFormInputs();
|
||||
|
||||
$blocks = [
|
||||
'row1',
|
||||
'row2',
|
||||
];
|
||||
|
||||
$inputs['blocks'] = $blocks;
|
||||
|
||||
foreach ($inputs as $kInput => $vInput) {
|
||||
$inputs['inputs']['row1'][] = $vInput;
|
||||
}
|
||||
|
||||
if (isset($values['formatData']) === false) {
|
||||
$values['formatData'] = 1;
|
||||
}
|
||||
|
||||
// Format Data.
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'label' => __('Format Data'),
|
||||
'arguments' => [
|
||||
'name' => 'formatData',
|
||||
'id' => 'formatData',
|
||||
'type' => 'switch',
|
||||
'value' => $values['formatData'],
|
||||
],
|
||||
];
|
||||
|
||||
if (isset($values['period']) === false) {
|
||||
$values['period'] = SECONDS_1DAY;
|
||||
}
|
||||
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'label' => __('Periodicity'),
|
||||
'arguments' => [
|
||||
'name' => 'period',
|
||||
'type' => 'interval',
|
||||
'value' => $values['period'],
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
'style_icon' => 'flex-grow: 0',
|
||||
],
|
||||
];
|
||||
|
||||
if (isset($values['slice']) === false) {
|
||||
$values['slice'] = SECONDS_5MINUTES;
|
||||
}
|
||||
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'label' => __('Interval'),
|
||||
'arguments' => [
|
||||
'name' => 'slice',
|
||||
'type' => 'interval',
|
||||
'value' => $values['slice'],
|
||||
'nothing' => __('None'),
|
||||
'nothing_value' => 0,
|
||||
'style_icon' => 'flex-grow: 0',
|
||||
],
|
||||
];
|
||||
|
||||
if (isset($values['limit']) === false) {
|
||||
$values['limit'] = $config['block_size'];
|
||||
}
|
||||
|
||||
// Limit Default block_size.
|
||||
$blockSizeD4 = \format_integer_round(($config['block_size'] / 4));
|
||||
$blockSizeD2 = \format_integer_round(($config['block_size'] / 2));
|
||||
$fields = [
|
||||
$config['block_size'] => $config['block_size'],
|
||||
$blockSizeD4 => $blockSizeD4,
|
||||
$blockSizeD2 => $blockSizeD2,
|
||||
($config['block_size'] * 2) => ($config['block_size'] * 2),
|
||||
($config['block_size'] * 3) => ($config['block_size'] * 3),
|
||||
];
|
||||
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'label' => \__('Limit'),
|
||||
'arguments' => [
|
||||
'type' => 'select',
|
||||
'fields' => $fields,
|
||||
'class' => 'event-widget-input',
|
||||
'name' => 'limit',
|
||||
'selected' => $values['limit'],
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
// Type Label.
|
||||
$fields = [
|
||||
'module' => __('Module'),
|
||||
'agent' => __('Agent'),
|
||||
'agent_module' => __('Agent / module'),
|
||||
];
|
||||
|
||||
$inputs['inputs']['row2'][] = [
|
||||
'label' => __('Label'),
|
||||
'arguments' => [
|
||||
'type' => 'select',
|
||||
'fields' => $fields,
|
||||
'name' => 'label',
|
||||
'selected' => $values['label'],
|
||||
'return' => true,
|
||||
],
|
||||
];
|
||||
|
||||
$inputs['inputs']['row2'][] = [
|
||||
'arguments' => [
|
||||
'type' => 'select_multiple_modules_filtered_select2',
|
||||
'agent_values' => agents_get_agents_selected(0),
|
||||
'agent_name' => 'agentsDataMatrix[]',
|
||||
'agent_ids' => $values['agentsDataMatrix'],
|
||||
'selectionModules' => $values['selectionDataMatrix'],
|
||||
'selectionModulesNameId' => 'selectionDataMatrix',
|
||||
'modules_ids' => $values['moduleDataMatrix'],
|
||||
'modules_name' => 'moduleDataMatrix[]',
|
||||
'notStringModules' => true,
|
||||
],
|
||||
];
|
||||
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Post for widget.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPost():array
|
||||
{
|
||||
// Retrieve global - common inputs.
|
||||
$values = parent::getPost();
|
||||
|
||||
$values['agentsDataMatrix'] = \get_parameter(
|
||||
'agentsDataMatrix',
|
||||
[]
|
||||
);
|
||||
$values['selectionDataMatrix'] = \get_parameter(
|
||||
'selectionDataMatrix',
|
||||
0
|
||||
);
|
||||
|
||||
$values['moduleDataMatrix'] = \get_parameter(
|
||||
'moduleDataMatrix'
|
||||
);
|
||||
|
||||
$agColor = [];
|
||||
if (isset($values['agentsDataMatrix'][0]) === true
|
||||
&& empty($values['agentsDataMatrix'][0]) === false
|
||||
) {
|
||||
$agColor = explode(',', $values['agentsDataMatrix'][0]);
|
||||
}
|
||||
|
||||
$agModule = [];
|
||||
if (isset($values['moduleDataMatrix'][0]) === true
|
||||
&& empty($values['moduleDataMatrix'][0]) === false
|
||||
) {
|
||||
$agModule = explode(',', $values['moduleDataMatrix'][0]);
|
||||
}
|
||||
|
||||
$values['moduleDataMatrix'] = \get_same_modules_all(
|
||||
$agColor,
|
||||
$agModule
|
||||
);
|
||||
|
||||
$values['formatData'] = \get_parameter_switch('formatData');
|
||||
|
||||
$values['fontColor'] = \get_parameter('fontColor', '#2c3e50');
|
||||
$values['label'] = \get_parameter('label', 'module');
|
||||
|
||||
$values['period'] = \get_parameter('period', 0);
|
||||
$values['slice'] = \get_parameter('slice', 0);
|
||||
$values['limit'] = \get_parameter('limit', 20);
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw widget.
|
||||
*
|
||||
* @return string;
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
$this->size = parent::getSize();
|
||||
|
||||
$output = '';
|
||||
if (count($this->values['moduleDataMatrix']) > self::MAX_MODULES) {
|
||||
$output .= '<div class="container-center">';
|
||||
$output .= \ui_print_info_message(
|
||||
__(
|
||||
'The maximum number of modules to display is %d, please reconfigure the widget.',
|
||||
self::MAX_MODULES
|
||||
),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$modules_nodes = array_reduce(
|
||||
$this->values['moduleDataMatrix'],
|
||||
function ($carry, $item) {
|
||||
$explode = explode('|', $item);
|
||||
$carry[$explode[0]][] = $explode[1];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
$modules = [];
|
||||
foreach ($modules_nodes as $n => $mod) {
|
||||
try {
|
||||
$node = new Node((int) $n);
|
||||
$node->connect();
|
||||
$node_mods = $this->getInfoModules($mod);
|
||||
if (empty($node_mods) === false) {
|
||||
foreach ($node_mods as $value) {
|
||||
$value['id_node'] = $n;
|
||||
$value['server_name'] = $node->toArray()['server_name'];
|
||||
$modules[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$node->disconnect();
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
$node->disconnect();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$modules = $this->getInfoModules(
|
||||
$this->values['moduleDataMatrix']
|
||||
);
|
||||
}
|
||||
|
||||
if ($modules !== false && empty($modules) === false) {
|
||||
// Datatables list.
|
||||
try {
|
||||
$info_columns = $this->columns($modules);
|
||||
$columns = $info_columns['columns'];
|
||||
$column_names = $info_columns['column_names'];
|
||||
$columns_sort = $info_columns['columns_sort'];
|
||||
|
||||
$tableId = 'dataMatrix_'.$this->dashboardId.'_'.$this->cellId;
|
||||
// Load datatables user interface.
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => $tableId,
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => 'include/ajax/module',
|
||||
'ajax_data' => [
|
||||
'get_data_dataMatrix' => 1,
|
||||
'table_id' => $tableId,
|
||||
'period' => $this->values['period'],
|
||||
'slice' => $this->values['slice'],
|
||||
'formatData' => $this->values['formatData'],
|
||||
'modules' => json_encode($modules),
|
||||
],
|
||||
'default_pagination' => $this->values['limit'],
|
||||
'no_sortable_columns' => $columns_sort,
|
||||
'order' => [
|
||||
'field' => 'date',
|
||||
'direction' => 'desc',
|
||||
],
|
||||
'csv' => 0,
|
||||
]
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$output = '';
|
||||
$output .= '<div class="container-center">';
|
||||
$output .= \ui_print_info_message(
|
||||
__('Not found modules'),
|
||||
'',
|
||||
true
|
||||
);
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get info modules.
|
||||
*
|
||||
* @param array $modules Modules.
|
||||
*
|
||||
* @return array Data.
|
||||
*/
|
||||
private function getInfoModules(array $modules): array
|
||||
{
|
||||
$where = sprintf(
|
||||
'tagente_modulo.id_agente_modulo IN (%s)
|
||||
AND tagente_modulo.delete_pending = 0',
|
||||
implode(',', $modules)
|
||||
);
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT tagente_modulo.id_agente_modulo AS `id`,
|
||||
tagente_modulo.nombre AS `name`,
|
||||
tagente_modulo.unit AS `unit`,
|
||||
tagente_modulo.min_warning AS w_min,
|
||||
tagente_modulo.max_warning AS w_max,
|
||||
tagente_modulo.str_warning AS w_str,
|
||||
tagente_modulo.min_critical AS c_min,
|
||||
tagente_modulo.max_critical AS c_max,
|
||||
tagente_modulo.str_critical AS c_str,
|
||||
tagente_modulo.id_tipo_modulo AS type_module,
|
||||
tagente_estado.datos AS `data`,
|
||||
tagente_estado.timestamp AS `timestamp`,
|
||||
tagente_estado.estado AS `status`,
|
||||
tagente.alias
|
||||
FROM tagente_modulo
|
||||
LEFT JOIN tagente_estado
|
||||
ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
LEFT JOIN tagente
|
||||
ON tagente_modulo.id_agente = tagente.id_agente
|
||||
WHERE %s',
|
||||
$where
|
||||
);
|
||||
|
||||
$modules = db_get_all_rows_sql($sql);
|
||||
|
||||
if ($modules === false) {
|
||||
$modules = [];
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get columns.
|
||||
*
|
||||
* @param array $modules Info modules.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function columns(array $modules)
|
||||
{
|
||||
$columns = [];
|
||||
$columns[] = 'date';
|
||||
$column_names = [];
|
||||
$column_names[] = __('Date');
|
||||
$columns_sort = [];
|
||||
$columns_sort[] = 0;
|
||||
foreach ($modules as $key => $module) {
|
||||
$columns[] = 'Column-'.$module['id'];
|
||||
// Module name.
|
||||
$name = '';
|
||||
switch ($this->values['label']) {
|
||||
case 'agent':
|
||||
$name = $module['alias'];
|
||||
break;
|
||||
|
||||
case 'agent_module':
|
||||
$name = $module['alias'].' / '.$module['name'];
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'module':
|
||||
$name = $module['name'];
|
||||
break;
|
||||
}
|
||||
|
||||
$columns_sort[] = ($key + 1);
|
||||
$column_names[] = $name;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'columns_sort' => $columns_sort,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get description.
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
public static function getDescription()
|
||||
{
|
||||
return __('Data Matrix');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Name.
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'DataMatrix';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get size Modal Configuration.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSizeModalConfiguration(): array
|
||||
{
|
||||
$size = [
|
||||
'width' => (is_metaconsole() === true) ? 1000 : 900,
|
||||
'height' => 480,
|
||||
];
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -555,7 +555,7 @@ class ModuleIconWidget extends Widget
|
|||
// Div value.
|
||||
$output .= '<div style="flex: 0 1 10px; font-size:'.$sizeValue.'px;">';
|
||||
$output .= remove_right_zeros(
|
||||
number_format($data_module, $config['graph_precision'])
|
||||
number_format($data_module, $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])
|
||||
);
|
||||
$output .= '</div>';
|
||||
|
||||
|
|
|
@ -439,7 +439,9 @@ class ModuleValueWidget extends Widget
|
|||
$dataDatos = remove_right_zeros(
|
||||
number_format(
|
||||
$data_module,
|
||||
$config['graph_precision']
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -397,10 +397,12 @@ final class Group extends Item
|
|||
string $groupName,
|
||||
array $agentStats
|
||||
): string {
|
||||
$critical = \number_format($agentStats['critical'], 2).'%';
|
||||
$warning = \number_format($agentStats['warning'], 2).'%';
|
||||
$normal = \number_format($agentStats['normal'], 2).'%';
|
||||
$unknown = \number_format($agentStats['unknown'], 2).'%';
|
||||
global $config;
|
||||
|
||||
$critical = \number_format($agentStats['critical'], 2, $config['decimal_separator'], $config['thousand_separator']).'%';
|
||||
$warning = \number_format($agentStats['warning'], 2, $config['decimal_separator'], $config['thousand_separator']).'%';
|
||||
$normal = \number_format($agentStats['normal'], 2, $config['decimal_separator'], $config['thousand_separator']).'%';
|
||||
$unknown = \number_format($agentStats['unknown'], 2, $config['decimal_separator'], $config['thousand_separator']).'%';
|
||||
|
||||
$html = '<div class="group-container">';
|
||||
$html .= '<div class="group-item-title">';
|
||||
|
|
|
@ -396,8 +396,8 @@ final class Percentile extends Item
|
|||
$data['value'] = (float) \number_format(
|
||||
(float) $moduleValue,
|
||||
(int) $config['graph_precision'],
|
||||
'.',
|
||||
''
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
);
|
||||
$unit = '';
|
||||
if ($moduleId !== null && $moduleId !== 0) {
|
||||
|
|
|
@ -281,7 +281,7 @@ final class StaticGraph extends Item
|
|||
) {
|
||||
if (\is_numeric($value)) {
|
||||
$imgTitle .= __('Last value: ').\remove_right_zeros(
|
||||
\number_format((float) $value, (int) $config['graph_precision'])
|
||||
\number_format((float) $value, (int) $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])
|
||||
);
|
||||
} else {
|
||||
$imgTitle .= __('Last value: ').$value;
|
||||
|
|
|
@ -9156,3 +9156,16 @@ div#err_msg_centralised {
|
|||
.tag-editor .tag-editor-delete:hover i:before {
|
||||
color: #ccc !important;
|
||||
}
|
||||
|
||||
.snmp-td {
|
||||
padding: 0 !important;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.snmp-div {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: start;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.767';
|
||||
$build = '221213';
|
||||
$build = '221220';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
|
|
@ -2048,7 +2048,12 @@ if (is_ajax() === true) {
|
|||
|
||||
$array_filter = json_decode($networkmap['filter']);
|
||||
if (isset($array_filter->z_dash)) {
|
||||
$array_filter->z_dash = number_format($scale, 2);
|
||||
$array_filter->z_dash = number_format(
|
||||
$scale,
|
||||
2,
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
);
|
||||
}
|
||||
|
||||
$filter = json_encode($array_filter);
|
||||
|
|
|
@ -1589,7 +1589,7 @@ if (!empty($result)) {
|
|||
if (is_numeric($row['datos'])) {
|
||||
$data[6] = ui_print_status_image(
|
||||
STATUS_MODULE_OK,
|
||||
__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])),
|
||||
__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])),
|
||||
true
|
||||
);
|
||||
} else {
|
||||
|
@ -1604,7 +1604,12 @@ if (!empty($result)) {
|
|||
$data[6] = ui_print_status_image(
|
||||
STATUS_MODULE_CRITICAL,
|
||||
__('CRITICAL').': '.remove_right_zeros(
|
||||
number_format($row['datos'], $config['graph_precision'])
|
||||
number_format(
|
||||
$row['datos'],
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
),
|
||||
true
|
||||
);
|
||||
|
@ -1620,7 +1625,12 @@ if (!empty($result)) {
|
|||
$data[6] = ui_print_status_image(
|
||||
STATUS_MODULE_WARNING,
|
||||
__('WARNING').': '.remove_right_zeros(
|
||||
number_format($row['datos'], $config['graph_precision'])
|
||||
number_format(
|
||||
$row['datos'],
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
),
|
||||
true
|
||||
);
|
||||
|
@ -1636,7 +1646,12 @@ if (!empty($result)) {
|
|||
$data[6] = ui_print_status_image(
|
||||
STATUS_MODULE_UNKNOWN,
|
||||
__('UNKNOWN').': '.remove_right_zeros(
|
||||
number_format($row['datos'], $config['graph_precision'])
|
||||
number_format(
|
||||
$row['datos'],
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
),
|
||||
true
|
||||
);
|
||||
|
@ -1652,7 +1667,12 @@ if (!empty($result)) {
|
|||
$data[6] = ui_print_status_image(
|
||||
STATUS_MODULE_NO_DATA,
|
||||
__('NO DATA').': '.remove_right_zeros(
|
||||
number_format($row['datos'], $config['graph_precision'])
|
||||
number_format(
|
||||
$row['datos'],
|
||||
$config['graph_precision'],
|
||||
$config['decimal_separator'],
|
||||
$config['thousand_separator']
|
||||
)
|
||||
),
|
||||
true
|
||||
);
|
||||
|
@ -1672,7 +1692,7 @@ if (!empty($result)) {
|
|||
if (is_numeric($row['datos'])) {
|
||||
$data[6] = ui_print_status_image(
|
||||
STATUS_MODULE_UNKNOWN,
|
||||
__('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])),
|
||||
__('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])),
|
||||
true
|
||||
);
|
||||
} else {
|
||||
|
@ -1688,7 +1708,7 @@ if (!empty($result)) {
|
|||
if (is_numeric($row['datos'])) {
|
||||
$data[6] = ui_print_status_image(
|
||||
STATUS_MODULE_UNKNOWN,
|
||||
__('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])),
|
||||
__('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])),
|
||||
true
|
||||
);
|
||||
} else {
|
||||
|
@ -1704,7 +1724,7 @@ if (!empty($result)) {
|
|||
if (is_numeric($row['datos'])) {
|
||||
$data[6] = ui_print_status_image(
|
||||
STATUS_MODULE_UNKNOWN,
|
||||
__('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])),
|
||||
__('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator'])),
|
||||
true
|
||||
);
|
||||
} else {
|
||||
|
@ -1849,12 +1869,12 @@ if (!empty($result)) {
|
|||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
$salida = human_milliseconds_to_string($row['datos']);
|
||||
} else {
|
||||
$salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision']));
|
||||
$salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision']));
|
||||
$salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -1866,12 +1886,12 @@ if (!empty($result)) {
|
|||
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
|
||||
$salida = human_milliseconds_to_string($row['datos']);
|
||||
} else {
|
||||
$salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision']));
|
||||
$salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision']));
|
||||
$salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'], $config['decimal_separator'], $config['thousand_separator']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ require_once $config['homedir'].'/include/functions_reporting.php';
|
|||
enterprise_include('operation/reporting/custom_reporting.php');
|
||||
|
||||
$searchAgents = $searchAlerts = $searchModules = check_acl($config['id_user'], 0, 'AR');
|
||||
$searchUsers = $searchPolicies = (check_acl($config['id_user'], 0, 'AR') && enterprise_installed());
|
||||
$searchUsers = (check_acl($config['id_user'], 0, 'AR'));
|
||||
$searchPolicies = (check_acl($config['id_user'], 0, 'AR') && enterprise_installed());
|
||||
$searchReports = $searchGraphs = check_acl($config['id_user'], 0, 'RR');
|
||||
$searchMaps = check_acl($config['id_user'], 0, 'VR');
|
||||
$searchMain = true;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.767
|
||||
%define release 221213
|
||||
%define release 221220
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.767
|
||||
%define release 221213
|
||||
%define release 221220
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.767
|
||||
%define release 221213
|
||||
%define release 221220
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
|
|
@ -1624,6 +1624,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
|
|||
`ipam_ip_not_assigned_to_agent` TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`macros_definition` TEXT,
|
||||
`render_definition` TEXT,
|
||||
`use_prefix_notation` TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY(`id_rc`),
|
||||
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
|
||||
ON UPDATE CASCADE ON DELETE CASCADE
|
||||
|
@ -3255,6 +3256,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
|
|||
`ipam_ip_not_assigned_to_agent` TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`macros_definition` TEXT,
|
||||
`render_definition` TEXT,
|
||||
`use_prefix_notation` TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY(`id_rc`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -142,26 +142,26 @@ function main_intel_dcm_agent_view()
|
|||
$sql = "SELECT description FROM tagent_custom_data WHERE id_field = $id_field_derated_power AND id_agent = $id_agent";
|
||||
$derated_power = db_get_value_sql($sql);
|
||||
|
||||
$percent = number_format((($avg_power / $derated_power) * 100), 2);
|
||||
$percent = number_format((($avg_power / $derated_power) * 100), 2, $config['decimal_separator'], $config['thousand_separator']);
|
||||
|
||||
$data[0] = '<b>'.__('Power utilization')." $percent%</b>";
|
||||
$data[0] .= progress_bar($percent, 400, 30, '', 2);
|
||||
$data[0] .= '<br><br>';
|
||||
$data[0] .= '<b>'.__('Current stats').'</b>';
|
||||
$data[0] .= '<br><br>';
|
||||
$data[0] .= __('Power demand').': <b>'.number_format($avg_power, 2).' Wh</b>';
|
||||
$data[0] .= __('Power demand').': <b>'.number_format($avg_power, 2, $config['decimal_separator'], $config['thousand_separator']).' Wh</b>';
|
||||
$data[0] .= '<br>';
|
||||
$data[0] .= __('Inlet temp').': <b>'.number_format($avg_temp, 2).' ºC</b>';
|
||||
$data[0] .= __('Inlet temp').': <b>'.number_format($avg_temp, 2, $config['decimal_separator'], $config['thousand_separator']).' ºC</b>';
|
||||
$data[0] .= '<br><br><br>';
|
||||
$data[0] .= '<b>'.__('Last week summary').'</b>';
|
||||
$data[0] .= '<br><br>';
|
||||
$data[0] .= __('Equipment energy consumed').': <b>'.number_format($mnged_energy, 2).' Wh</b>';
|
||||
$data[0] .= __('Equipment energy consumed').': <b>'.number_format($mnged_energy, 2, $config['decimal_separator'], $config['thousand_separator']).' Wh</b>';
|
||||
$data[0] .= '<br>';
|
||||
$data[0] .= __('Equipment energy bill').': <b>'.number_format($mnged_energy_bill, 2).' €</b>';
|
||||
$data[0] .= __('Equipment energy bill').': <b>'.number_format($mnged_energy_bill, 2, $config['decimal_separator'], $config['thousand_separator']).' €</b>';
|
||||
$data[0] .= '<br>';
|
||||
$data[0] .= __('Calculated cooling energy').': <b>'.number_format($cooling_energy, 2).' Wh</b>';
|
||||
$data[0] .= __('Calculated cooling energy').': <b>'.number_format($cooling_energy, 2, $config['decimal_separator'], $config['thousand_separator']).' Wh</b>';
|
||||
$data[0] .= '<br>';
|
||||
$data[0] .= __('Calculated cooling energy bill').': <b>'.number_format($cooling_energy_bill, 2).' €</b>';
|
||||
$data[0] .= __('Calculated cooling energy bill').': <b>'.number_format($cooling_energy_bill, 2, $config['decimal_separator'], $config['thousand_separator']).' €</b>';
|
||||
|
||||
// Print avg. power graph
|
||||
$start_date = date('Y-m-d');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package: pandorafms-server
|
||||
Version: 7.0NG.767-221213
|
||||
Version: 7.0NG.767-221220
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
pandora_version="7.0NG.767-221213"
|
||||
pandora_version="7.0NG.767-221220"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
|
|
@ -46,7 +46,7 @@ our @EXPORT = qw(
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.767";
|
||||
my $pandora_build = "221213";
|
||||
my $pandora_build = "221220";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
|
|
@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
|
|||
|
||||
# version: Defines actual version of Pandora Server for this module only
|
||||
my $pandora_version = "7.0NG.767";
|
||||
my $pandora_build = "221213";
|
||||
my $pandora_build = "221220";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.767
|
||||
%define release 221213
|
||||
%define release 221220
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.767
|
||||
%define release 221213
|
||||
%define release 221220
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.767"
|
||||
PI_BUILD="221213"
|
||||
PI_BUILD="221220"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
|
|
@ -35,7 +35,7 @@ use PandoraFMS::Config;
|
|||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.767 Build 221213";
|
||||
my $version = "7.0NG.767 Build 221220";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
|
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
|||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.767 Build 221213";
|
||||
my $version = "7.0NG.767 Build 221220";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
@ -1296,7 +1296,6 @@ sub help_screen_line($$$){
|
|||
|
||||
sub check_values($) {
|
||||
my ($check) = @_;
|
||||
use experimental 'smartmatch';
|
||||
|
||||
my $arg_cont = 2;
|
||||
my $cont = 0;
|
||||
|
@ -1316,7 +1315,7 @@ sub check_values($) {
|
|||
|
||||
# Check values.
|
||||
if (defined($check->[$cont]->{'values'})) {
|
||||
if (!($args[$arg_cont] ~~ $check->[$cont]->{'values'})) {
|
||||
if (!(is_in_array($check->[$cont]->{'values'}, $args[$arg_cont]))) {
|
||||
print "\nError: value `$args[$arg_cont]` is not valid for $check->[$cont]->{'name'}\n";
|
||||
print "\tAvailable options: \t$check->[$cont]->{'values'}->[0]";
|
||||
if (defined($check->[$cont]->{'text_extra'}->[0])) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
################################################################################
|
||||
#
|
||||
# Bandwith usage plugin
|
||||
# Bandwidth usage plugin
|
||||
#
|
||||
# Requirements:
|
||||
# snmpget
|
||||
|
@ -55,7 +55,7 @@ Where OPTIONS could be:
|
|||
|
||||
[EXTRA]
|
||||
-ifIndex Target interface to retrieve, if not specified, total
|
||||
bandwith will be reported.
|
||||
bandwidth will be reported.
|
||||
-uniqid Use custom temporary file name.
|
||||
-inUsage Show only input usage (in percentage) - 1, or not 0.
|
||||
-outUsage Show only output usage (in percentage) - 1, or not 0.
|
||||
|
@ -66,7 +66,7 @@ e.g. -v is equal to -version, -c to -community, etc.
|
|||
EO_HELP
|
||||
|
||||
use constant {
|
||||
UNKNOWN_DUPLEX => 0,
|
||||
UNKNOWN_DUPLEX => 1,
|
||||
HALF_DUPLEX => 2,
|
||||
FULL_DUPLEX => 3,
|
||||
};
|
||||
|
@ -133,9 +133,9 @@ sub update_config_key ($) {
|
|||
if ($arg eq 'inUsage') {
|
||||
return "inUsage";
|
||||
}
|
||||
if ($arg eq 'outUsage') {
|
||||
return "outUsage";
|
||||
}
|
||||
if ($arg eq 'outUsage') {
|
||||
return "outUsage";
|
||||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
@ -188,7 +188,7 @@ sub prepare_tree {
|
|||
|
||||
my $inOctets = snmp_get(\%inOctets_call);
|
||||
if (ref($inOctets) eq "HASH") {
|
||||
if ($inOctets->{'data'} eq '') {
|
||||
if (! exists($inOctets->{'data'}) || $inOctets->{'data'} eq '') {
|
||||
$inOctets = 0;
|
||||
} else {
|
||||
$inOctets = int $inOctets->{'data'};
|
||||
|
@ -198,18 +198,18 @@ sub prepare_tree {
|
|||
next;
|
||||
}
|
||||
|
||||
my %outOctets_call = %{$config};
|
||||
if (is_enabled($config->{'use_x64'})) {
|
||||
$outOctets_call{'oid'} = $config->{'oid_base'};
|
||||
$outOctets_call{'oid'} .= $config->{'x64_indexes'}{'outOctets'}.$ifIndex;
|
||||
} else {
|
||||
$outOctets_call{'oid'} = $config->{'oid_base'};
|
||||
$outOctets_call{'oid'} .= $config->{'x86_indexes'}{'outOctets'}.$ifIndex;
|
||||
}
|
||||
my %outOctets_call = %{$config};
|
||||
if (is_enabled($config->{'use_x64'})) {
|
||||
$outOctets_call{'oid'} = $config->{'oid_base'};
|
||||
$outOctets_call{'oid'} .= $config->{'x64_indexes'}{'outOctets'}.$ifIndex;
|
||||
} else {
|
||||
$outOctets_call{'oid'} = $config->{'oid_base'};
|
||||
$outOctets_call{'oid'} .= $config->{'x86_indexes'}{'outOctets'}.$ifIndex;
|
||||
}
|
||||
|
||||
my $outOctets = snmp_get(\%outOctets_call);
|
||||
if (ref($outOctets) eq "HASH") {
|
||||
if ($outOctets->{'data'} eq '') {
|
||||
if (! exists($outOctets->{'data'}) || $outOctets->{'data'} eq '') {
|
||||
$outOctets = 0;
|
||||
} else {
|
||||
$outOctets = int $outOctets->{'data'};
|
||||
|
@ -220,28 +220,27 @@ sub prepare_tree {
|
|||
}
|
||||
|
||||
my %duplex_call = %{$config};
|
||||
if (is_enabled($config->{'use_x64'})) {
|
||||
$duplex_call{'oid'} = $config->{'oid_base'};
|
||||
$duplex_call{'oid'} .= $config->{'x64_indexes'}{'duplex'}.$ifIndex;
|
||||
} else {
|
||||
$duplex_call{'oid'} = $config->{'oid_base'};
|
||||
$duplex_call{'oid'} .= $config->{'x86_indexes'}{'duplex'}.$ifIndex;
|
||||
}
|
||||
if (is_enabled($config->{'use_x64'})) {
|
||||
$duplex_call{'oid'} = $config->{'oid_base'};
|
||||
$duplex_call{'oid'} .= $config->{'x64_indexes'}{'duplex'}.$ifIndex;
|
||||
} else {
|
||||
$duplex_call{'oid'} = $config->{'oid_base'};
|
||||
$duplex_call{'oid'} .= $config->{'x86_indexes'}{'duplex'}.$ifIndex;
|
||||
}
|
||||
|
||||
my $duplex = snmp_get(\%duplex_call);
|
||||
if (ref($duplex) eq "HASH") {
|
||||
if ($duplex->{'data'} eq '') {
|
||||
if (! exists($duplex->{'data'}) || $duplex->{'data'} eq '') {
|
||||
$duplex = 0;
|
||||
} else {
|
||||
$duplex = int $duplex->{'data'};
|
||||
}
|
||||
|
||||
} else {
|
||||
# Ignore, cannot retrieve inOctets.
|
||||
next;
|
||||
}
|
||||
|
||||
my %speed = %{$config};
|
||||
my %speed = %{$config};
|
||||
if (is_enabled($config->{'use_x64'})) {
|
||||
$speed{'oid'} = $config->{'oid_base'};
|
||||
$speed{'oid'} .= $config->{'x64_indexes'}{'ifSpeed'}.$ifIndex;
|
||||
|
@ -492,9 +491,9 @@ $config->{'tmp_separator'} = ';' if empty($config->{'tmp_separator'});
|
|||
$config->{'tmp'} = (($^O =~ /win/)?$ENV{'TMP'}:'/tmp') if empty($config->{'tmp'});
|
||||
|
||||
# Create unique name for tmp and log file for host
|
||||
my $filename = $config->{'tmp'}.'/pandora_bandwith_'.$config->{'host'};
|
||||
my $filename = $config->{'tmp'}.'/pandora_bandwidth_'.$config->{'host'};
|
||||
if (!empty($config->{'uniqid'})) {
|
||||
$filename = $config->{'tmp'}.'/pandora_bandwith_'.$config->{'uniqid'};
|
||||
$filename = $config->{'tmp'}.'/pandora_bandwidth_'.$config->{'uniqid'};
|
||||
}
|
||||
# Replace every dot for underscore
|
||||
$filename =~ tr/./_/;
|
||||
|
@ -511,7 +510,7 @@ if ( defined($sysobjectid->{'error'}) || $sysobjectid->{'data'} eq '' ) {
|
|||
|
||||
# Check SNMP x64 interfaces
|
||||
my $walk64 = snmp_walk({%{$config}, 'oid' => '.1.3.6.1.2.1.31.1.1.1.6'});
|
||||
if ( $walk64 =~ 'No Such Instance currently exists at this OID' || $walk64 =~ 'No more variables left in this MIB View') {
|
||||
if ( $walk64 !~ /.*\.[0-9]+ = Counter64: [0-9]+/ ) {
|
||||
$config->{'use_x64'} = 0;
|
||||
} else {
|
||||
$config->{'use_x64'} = 1;
|
||||
|
@ -556,35 +555,35 @@ my $j = 0;
|
|||
my $k = 0;
|
||||
foreach my $iface (keys %{$analysis_tree}) {
|
||||
# Calculate summary;
|
||||
if (is_enabled($analysis_tree->{$iface}{'bandwidth'})) {
|
||||
$bandwidth = $analysis_tree->{$iface}{'bandwidth'};
|
||||
if (is_enabled($analysis_tree->{$iface}{'bandwidth'}) || $analysis_tree->{$iface}{'bandwidth'} == 0) {
|
||||
$bandwidth += $analysis_tree->{$iface}{'bandwidth'};
|
||||
$i++;
|
||||
}
|
||||
if (is_enabled($analysis_tree->{$iface}{'inUsage'})) {
|
||||
$inUsage = $analysis_tree->{$iface}{'inUsage'};
|
||||
if (is_enabled($analysis_tree->{$iface}{'inUsage'}) || $analysis_tree->{$iface}{'inUsage'} == 0) {
|
||||
$inUsage += $analysis_tree->{$iface}{'inUsage'};
|
||||
$j++;
|
||||
}
|
||||
if (is_enabled($analysis_tree->{$iface}{'outUsage'})) {
|
||||
$outUsage = $analysis_tree->{$iface}{'outUsage'};
|
||||
if (is_enabled($analysis_tree->{$iface}{'outUsage'}) || $analysis_tree->{$iface}{'inUsage'} == 0) {
|
||||
$outUsage += $analysis_tree->{$iface}{'outUsage'};
|
||||
$k++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($j > 0 && is_enabled($config->{'inUsage'})) {
|
||||
$inUsage /= $j;
|
||||
print sprintf("%.9f\n", $inUsage);
|
||||
$inUsage /= $j;
|
||||
print sprintf("%.9f\n", $inUsage);
|
||||
} elsif ($k > 0 && is_enabled($config->{'outUsage'})) {
|
||||
$outUsage /= $k;
|
||||
print sprintf("%.9f\n", $outUsage);
|
||||
$outUsage /= $k;
|
||||
print sprintf("%.9f\n", $outUsage);
|
||||
}
|
||||
|
||||
if ($i > 0
|
||||
&& !is_enabled($config->{'inUsage'})
|
||||
&& !is_enabled($config->{'outUsage'})
|
||||
) {
|
||||
$bandwidth /= $i;
|
||||
print sprintf("%.9f\n", $bandwidth);
|
||||
$bandwidth /= $i;
|
||||
print sprintf("%.9f\n", $bandwidth);
|
||||
}
|
||||
|
||||
logger($config, 'info', "Plugin ends") if (is_enabled($config->{'debug'}));
|
||||
|
|
Loading…
Reference in New Issue