2014-05-05 11:53:21 +02:00
|
|
|
<?php
|
2020-11-30 14:26:49 +01:00
|
|
|
/**
|
|
|
|
* Funtions real time.
|
|
|
|
*
|
|
|
|
* @category Realtime
|
|
|
|
* @package Pandora FMS
|
|
|
|
* @subpackage Community
|
|
|
|
* @version 1.0.0
|
|
|
|
* @license See below
|
|
|
|
*
|
|
|
|
* ______ ___ _______ _______ ________
|
2023-06-08 12:42:10 +02:00
|
|
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
|
|
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
2020-11-30 14:26:49 +01:00
|
|
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
|
|
*
|
|
|
|
* ============================================================================
|
2023-06-08 11:53:13 +02:00
|
|
|
* Copyright (c) 2005-2023 Pandora FMS
|
2023-06-08 13:19:01 +02:00
|
|
|
* Please see https://pandorafms.com/community/ for full contribution list
|
2020-11-30 14:26:49 +01:00
|
|
|
* 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.
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
2014-05-05 11:53:21 +02:00
|
|
|
|
2018-05-04 10:58:37 +02:00
|
|
|
global $config;
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once $config['homedir'].'/include/graphs/fgraph.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_snmp_browser.php';
|
|
|
|
|
|
|
|
|
2020-11-30 14:26:49 +01:00
|
|
|
/**
|
|
|
|
* Real time charts.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2019-01-30 16:18:44 +01:00
|
|
|
function pandora_realtime_graphs()
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
check_login();
|
|
|
|
|
2022-01-17 10:22:30 +01:00
|
|
|
if ($config['style'] === 'pandora_black' && !is_metaconsole()) {
|
2021-05-12 14:52:44 +02:00
|
|
|
ui_require_css_file('pandora_black', 'include/styles/', true);
|
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$id_network = get_parameter('id_network', 0);
|
|
|
|
$action = get_parameter('action', 'list');
|
|
|
|
|
|
|
|
$onheader = [];
|
|
|
|
|
|
|
|
$hide_header = get_parameter('hide_header', 0);
|
2020-11-30 14:26:49 +01:00
|
|
|
if ($hide_header === 0) {
|
2021-04-29 13:28:03 +02:00
|
|
|
// Header.
|
|
|
|
ui_print_standard_header(
|
2019-04-24 13:53:18 +02:00
|
|
|
__('Realtime graphs'),
|
|
|
|
'images/extensions.png',
|
|
|
|
false,
|
|
|
|
'real_time_view',
|
|
|
|
false,
|
2021-04-29 13:28:03 +02:00
|
|
|
$onheader,
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'link' => '',
|
|
|
|
'label' => __('Monitoring'),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'link' => '',
|
|
|
|
'label' => __('Views'),
|
|
|
|
],
|
|
|
|
]
|
2019-04-24 13:53:18 +02:00
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2022-03-31 13:10:09 +02:00
|
|
|
$table = new stdClass();
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->width = '100%';
|
|
|
|
$table->id = 'table-form';
|
2023-02-24 10:18:52 +01:00
|
|
|
$table->class = 'filter-table-adv';
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->style = [];
|
|
|
|
$table->data = [];
|
|
|
|
|
|
|
|
$graph_fields['cpu_load'] = __('%s Server CPU', get_product_name());
|
2020-11-30 14:26:49 +01:00
|
|
|
$graph_fields['pending_packets'] = __(
|
|
|
|
'Pending packages from %s Server',
|
|
|
|
get_product_name()
|
|
|
|
);
|
|
|
|
$graph_fields['disk_io_wait'] = __(
|
|
|
|
'%s Server Disk IO Wait',
|
|
|
|
get_product_name()
|
|
|
|
);
|
|
|
|
$graph_fields['apache_load'] = __(
|
|
|
|
'%s Server Apache load',
|
|
|
|
get_product_name()
|
|
|
|
);
|
|
|
|
$graph_fields['mysql_load'] = __(
|
|
|
|
'%s Server MySQL load',
|
|
|
|
get_product_name()
|
|
|
|
);
|
|
|
|
$graph_fields['server_load'] = __(
|
|
|
|
'%s Server load',
|
|
|
|
get_product_name()
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
$graph_fields['snmp_interface'] = __('SNMP Interface throughput');
|
|
|
|
|
|
|
|
$graph = get_parameter('graph', 'cpu_load');
|
|
|
|
$refresh = get_parameter('refresh', '1000');
|
|
|
|
|
|
|
|
if ($graph != 'snmp_module') {
|
2023-02-24 10:18:52 +01:00
|
|
|
$data['graph'] = html_print_label_input_block(
|
|
|
|
__('Graph'),
|
|
|
|
html_print_select(
|
|
|
|
$graph_fields,
|
|
|
|
'graph',
|
|
|
|
$graph,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'width: 100%'
|
|
|
|
)
|
2020-11-30 14:26:49 +01:00
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$refresh_fields[1000] = human_time_description_raw(1, true, 'large');
|
|
|
|
$refresh_fields[5000] = human_time_description_raw(5, true, 'large');
|
|
|
|
$refresh_fields[10000] = human_time_description_raw(10, true, 'large');
|
|
|
|
$refresh_fields[30000] = human_time_description_raw(30, true, 'large');
|
|
|
|
|
|
|
|
if ($graph == 'snmp_module') {
|
|
|
|
$agent_alias = io_safe_output(get_parameter('agent_alias', ''));
|
|
|
|
$module_name = io_safe_output(get_parameter('module_name', ''));
|
|
|
|
$module_incremental = get_parameter('incremental', 0);
|
2023-02-24 10:18:52 +01:00
|
|
|
$data['module_info'] = html_print_label_input_block(
|
|
|
|
$agent_alias.': '.$module_name,
|
|
|
|
html_print_input_hidden(
|
|
|
|
'incremental',
|
|
|
|
$module_incremental,
|
|
|
|
true
|
|
|
|
).html_print_select(
|
|
|
|
['snmp_module' => '-'],
|
|
|
|
'graph',
|
|
|
|
'snmp_module',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'width: 100%; display: none;'
|
|
|
|
)
|
2020-11-30 14:26:49 +01:00
|
|
|
);
|
2023-02-24 10:18:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$data['refresh'] = html_print_label_input_block(
|
|
|
|
__('Refresh interval'),
|
|
|
|
html_print_select(
|
|
|
|
$refresh_fields,
|
|
|
|
'refresh',
|
|
|
|
$refresh,
|
2019-01-30 16:18:44 +01:00
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false,
|
2023-02-24 10:18:52 +01:00
|
|
|
'width: 100%'
|
|
|
|
)
|
2020-11-30 14:26:49 +01:00
|
|
|
);
|
2023-02-24 10:18:52 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($graph != 'snmp_module') {
|
2023-02-24 10:18:52 +01:00
|
|
|
$data['incremental'] = html_print_label_input_block(
|
|
|
|
__('Incremental'),
|
|
|
|
html_print_checkbox_switch('incremental', 1, 0, true)
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
2020-11-30 14:26:49 +01:00
|
|
|
// Print the relative path to AJAX calls.
|
2019-01-30 16:18:44 +01:00
|
|
|
html_print_input_hidden('rel_path', get_parameter('rel_path', ''));
|
|
|
|
|
2020-11-30 14:26:49 +01:00
|
|
|
// Print the form.
|
2023-02-24 10:18:52 +01:00
|
|
|
$searchForm = '<form id="realgraph" method="post">';
|
|
|
|
$searchForm .= html_print_table($table, true);
|
|
|
|
$searchForm .= html_print_div(
|
|
|
|
[
|
|
|
|
'class' => 'action-buttons',
|
|
|
|
'content' => html_print_submit_button(
|
|
|
|
__('Clear graph'),
|
|
|
|
'srcbutton',
|
|
|
|
false,
|
|
|
|
[
|
|
|
|
'icon' => 'delete',
|
|
|
|
'mode' => 'mini',
|
|
|
|
'onClick' => 'javascript:realtimeGraphs.clearGraph();',
|
|
|
|
],
|
|
|
|
true
|
|
|
|
),
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$searchForm .= '</form>';
|
|
|
|
|
|
|
|
ui_toggle(
|
|
|
|
$searchForm,
|
|
|
|
'<span class="subsection_header_title">'.__('Filters').'</span>',
|
|
|
|
'filter_form',
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'white-box-content',
|
2023-06-08 08:29:35 +02:00
|
|
|
'box-flat white_table_graph fixed_filter_bar top_0px_important mrgn_btn_35px_imp'
|
2023-02-24 10:18:52 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$chart[time()]['graph'] = '0';
|
|
|
|
$canvas = '<div id="graph_container" class="graph_container">';
|
|
|
|
$canvas .= '<div id="chartLegend" class="chartLegend"></div>';
|
|
|
|
|
|
|
|
$width = 800;
|
|
|
|
$height = 300;
|
|
|
|
|
|
|
|
$data_array['realtime']['data'][0][0] = (time() - 10);
|
|
|
|
$data_array['realtime']['data'][0][1] = 0;
|
|
|
|
$data_array['realtime']['data'][1][0] = time();
|
|
|
|
$data_array['realtime']['data'][1][1] = 0;
|
|
|
|
$data_array['realtime']['color'] = 'green';
|
|
|
|
|
|
|
|
$params = [
|
|
|
|
'agent_module_id' => false,
|
|
|
|
'period' => 300,
|
|
|
|
'width' => $width,
|
|
|
|
'height' => $height,
|
|
|
|
'only_image' => false,
|
|
|
|
'type_graph' => 'area',
|
|
|
|
'font' => $config['fontpath'],
|
|
|
|
'font-size' => $config['font_size'],
|
|
|
|
'array_data_create' => $data_array,
|
|
|
|
'show_legend' => false,
|
|
|
|
'show_menu' => false,
|
|
|
|
'backgroundColor' => 'transparent',
|
|
|
|
];
|
|
|
|
|
|
|
|
$canvas .= grafico_modulo_sparse($params);
|
|
|
|
|
|
|
|
$canvas .= '</div>';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-03-06 15:44:32 +01:00
|
|
|
html_print_div(
|
|
|
|
[
|
|
|
|
'class' => 'white_box',
|
|
|
|
'content' => $canvas,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2023-05-16 11:48:11 +02:00
|
|
|
if ($graph == 'snmp_interface' || $graph == 'snmp_module') {
|
|
|
|
html_print_div(
|
|
|
|
[
|
|
|
|
'class' => 'white_box',
|
|
|
|
'id' => 'graph_snmp_interface',
|
|
|
|
'content' => snmp_browser_print_container(true, '100%', '60%', '', false, false),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-03-06 15:44:32 +01:00
|
|
|
// echo $canvas;
|
2020-11-30 14:26:49 +01:00
|
|
|
// Define a custom action to save
|
|
|
|
// the OID selected in the SNMP browser to the form.
|
|
|
|
html_print_input_hidden(
|
|
|
|
'custom_action',
|
|
|
|
urlencode(
|
|
|
|
base64_encode(
|
2021-03-11 15:40:23 +01:00
|
|
|
' <a href="javascript:realtimeGraphs.setOID();"><img src="'.ui_get_full_url('images').'/input_filter.disabled.png" title="'.__('Use this OID').'" class="vertical_middle"></img></a>'
|
2020-11-30 14:26:49 +01:00
|
|
|
)
|
|
|
|
),
|
|
|
|
false
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
html_print_input_hidden('incremental_base', '0');
|
|
|
|
|
2023-03-24 09:13:22 +01:00
|
|
|
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/pandora_snmp_browser.js').'?v='.$config['current_package'].'"></script>';
|
|
|
|
echo '<script type="text/javascript" src="'.ui_get_full_url('extensions/realtime_graphs/realtime_graphs.js').'?v='.$config['current_package'].'"></script>';
|
2021-05-12 14:52:44 +02:00
|
|
|
if ($config['style'] !== 'pandora_black') {
|
2023-03-24 12:06:40 +01:00
|
|
|
echo '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url('extensions/realtime_graphs/realtime_graphs.css').'?v='.$config['current_package'].'"></style>';
|
2021-05-12 14:52:44 +02:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2020-11-30 14:26:49 +01:00
|
|
|
// Store servers timezone offset to be retrieved from js.
|
2019-01-30 16:18:44 +01:00
|
|
|
set_js_value('timezone_offset', date('Z', time()));
|
2014-05-05 11:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-30 14:26:49 +01:00
|
|
|
extensions_add_operation_menu_option(
|
|
|
|
__('Realtime graphs'),
|
|
|
|
'estado',
|
|
|
|
null,
|
|
|
|
'v1r1',
|
|
|
|
'view'
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
extensions_add_main_function('pandora_realtime_graphs');
|
|
|
|
|
|
|
|
$db = null;
|