pandorafms/pandora_console/include/functions_graph.php

5100 lines
138 KiB
PHP
Raw Normal View History

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2011 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 Lesser General Public License
// as published by the Free Software Foundation; 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.
include_once($config['homedir'] . "/include/graphs/fgraph.php");
include_once($config['homedir'] . "/include/functions_reporting.php");
* include/functions_graph.php include/functions_html.php include/functions_messages.php include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/ajax/skins.ajax.php include/ajax/reporting.ajax.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/config_process.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_incidents.php include/api.php include/functions_reports.php include/functions_ui_renders.php extensions/insert_data.php extensions/system_info.php extensions/extension_uploader.php extensions/pandora_logs.php extensions/agents_modules.php extensions/update_manager.php extensions/ssh_console.php extensions/dbmanager.php extensions/vnc_view.php extensions/resource_registration.php extensions/resource_exportation.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php extensions/update_manager/settings.php extensions/update_manager/main.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/incidents/incident_statistics.php operation/search_modules.php operation/visual_console/render_view.php operation/visual_console/index.php operation/extensions.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/agent_fields.php operation/agentes/tactical.php operation/agentes/group_view.php operation/agentes/networkmap.php operation/agentes/stat_win.php operation/servers/view_server.php operation/servers/view_server_detail.php operation/menu.php operation/search_agents.php operation/search_graphs.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/integria_incidents/incident.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident_statistics.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_validate.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/search_reports.php operation/search_maps.php operation/search_users.php extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php mobile/index.php general/error_authconfig.php general/links_menu.php general/logon_ok.php general/error_dbconfig.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/db/db_audit.php godmode/db/db_sanity.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_event.php godmode/db/db_purge.php godmode/extensions.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/configure_field.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/configure_alert_command.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/setup/file_manager.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/gis_step_2.php godmode/setup/links.php godmode/setup/setup.php godmode/setup/os.php godmode/setup/performance.php godmode/setup/setup_auth.php godmode/setup/gis.php godmode/setup/os.builder.php godmode/setup/setup_visuals.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/users/user_list.php godmode/users/configure_profile.php godmode/gis_maps/configure_gis_map.php godmode/gis_maps/index.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_operations.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/manage_network_components_form.php godmode/modules/manage_nc_groups_form.php godmode/modules/manage_network_templates.php godmode/modules/module_list.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components_form_network.php godmode/modules/manage_network_templates_form.php godmode/modules/manage_network_components_form_wmi.php godmode/modules/manage_network_components.php godmode/modules/manage_nc_groups.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/visual_console_builder.preview.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/reporting/graph_builder.preview.php include/functions_db.php: Added some includes and functions of this code have "db_" prefix. * include/functions.php: Moved function check_login(), check_acl(), dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php. * include/functions_groups.php: Moved functions get_childrens(), safe_acl_group() and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(), get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(), get_group_name(), get_group_users() from functions_db.php to this code. * include/functions_profile.php: New library with profile functions. Moved functions get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(), delete_profile() from functions_db.php to this code. Added new parameter in function get_profile() to retrieve profiles with filter conditions applied. * include/functions_users.php: New library with users functions. Moved functions get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(), get_user_first_group(), user_access_to_agent() from funtions_db.php to this code. * godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile(). * include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(), get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(), check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(), agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(), get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(), get_agent_group() from functions_db.php to this code. * include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(), get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(), get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(), get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(), get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(), get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(), get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(), give_modulecategory_name(), give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(), get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(), get_modulegroup_name() from functions_db.php to this code. * include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(), get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(), get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(), get_agentmodule_last_status() from functions_db.php to this code. * include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion() from functions_db.php to this code. * include/functions_events.php: Moved functions get_group_events(), get_agent_events(), get_module_events() from functions_db.php to this code. * include/functions_servers.php: Moved functions get_server_name(), show_server_type(), check_server_status(), server_status() from functions_db.php to this code. * include/functions_network_profiles.php: Moved function get_networkprofile_name() from functions_db.php to this code. * include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y() from fucntions_db.php to this code. * include/functions_io.php: Moved function __() from functions_db.php to this code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
include_once($config['homedir'] . "/include/functions_agents.php");
include_once($config['homedir'] . "/include/functions_modules.php");
2012-03-05 Miguel de Dios <miguel.dedios@artica.es> * extensions/update_manager/main.php, general/shortcut_bar.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.preview.php, include/functions_api.php, include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, operation/events/events_list.php, operation/netflow/nf_live_view.php: cleaned source code style. * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the enterprise feature that have been wrong for years. * general/header.php: changed to load the jquery-ui and jquery javascript library to last version. * extensions/insert_data.php, extensions/snmp_explorer.php, godmode/agentes/agent_manager.php, include/ajax/agent.php, include/javascript/pandora.js, operation/agentes/exportdata.php, operation/events/events.php: changed the unknow plugin autocomplete for the autocomple from jquery-ui. * include/functions_ui.php: cleaned source code style and into the function "ui_process_page_head" added the blacklist hardwrote for to use old jquery. * include/styles/jquery-ui-1.8.17.custom.css, include/javascript/jquery-1.7.1.min.js, include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last version of Jquery and Jquery-ui. Merge from the branch "pandora_4.0" * godmode/reporting/visual_console_builder.constans.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.editor.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/javascript/pandora_visual_console.js: changed the unknow plugin autocomplete for the autocomple from jquery-ui and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". * images/percentile_item.disabled.png, images/percentile_item.png: added images for button of percentile item (new item in visual map). * include/styles/pandora.css: added the style for the new button percentile item. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/functions_gd.php: cleaned source code style, and added the params to set text and color in the function "progress_bar" and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-03-05 18:56:56 +01:00
include_once($config['homedir'] . "/include/functions_users.php");
function get_graph_statistics ($chart_array) {
2016-10-18 16:32:39 +02:00
global $config;
2018-02-27 16:28:00 +01:00
/// IMPORTANT!
///
/// The calculus for AVG, MIN and MAX values are in this function
2018-02-27 16:28:00 +01:00
/// because it must be done based on graph array data not using reporting
/// function to get coherent data between stats and graph visualization
2018-02-27 16:28:00 +01:00
$stats = array ();
2018-02-27 16:28:00 +01:00
$count = 0;
2018-02-27 16:28:00 +01:00
$size = sizeof($chart_array);
2018-02-27 16:28:00 +01:00
//Initialize stats array
$stats = array ("avg" => 0, "min" => null, "max" => null, "last" => 0);
2018-02-27 16:28:00 +01:00
foreach ($chart_array as $item) {
2018-02-27 16:28:00 +01:00
//Sum all values later divide by the number of elements
$stats['avg'] = $stats['avg'] + $item;
2018-02-27 16:28:00 +01:00
//Get minimum
if ($stats['min'] == null) {
$stats['min'] = $item;
}
else if ($item < $stats['min']) {
$stats['min'] = $item;
}
2018-02-27 16:28:00 +01:00
//Get maximum
if ($stats['max'] == null) {
$stats['max'] = $item;
}
else if ($item > $stats['max']) {
$stats['max'] = $item;
}
2018-02-27 16:28:00 +01:00
$count++;
2018-02-27 16:28:00 +01:00
//Get last data
if ($count == $size) {
$stats['last'] = $item;
}
}
2018-02-27 16:28:00 +01:00
//End the calculus for average
if ($count > 0) {
2018-02-27 16:28:00 +01:00
$stats['avg'] = $stats['avg'] / $count;
}
2018-02-27 16:28:00 +01:00
//Format stat data to display properly
$stats['last'] = remove_right_zeros(number_format($stats['last'], $config['graph_precision']));
$stats['avg'] = remove_right_zeros(number_format($stats['avg'], $config['graph_precision']));
$stats['min'] = remove_right_zeros(number_format($stats['min'], $config['graph_precision']));
$stats['max'] = remove_right_zeros(number_format($stats['max'], $config['graph_precision']));
2018-02-27 16:28:00 +01:00
return $stats;
}
function get_statwin_graph_statistics ($chart_array, $series_suffix = '') {
2018-02-27 16:28:00 +01:00
/// IMPORTANT!
///
/// The calculus for AVG, MIN and MAX values are in this function
2018-02-27 16:28:00 +01:00
/// because it must be done based on graph array data not using reporting
/// function to get coherent data between stats and graph visualization
2018-02-27 16:28:00 +01:00
$stats = array ();
2018-02-27 16:28:00 +01:00
$count = 0;
2018-02-27 16:28:00 +01:00
$size = sizeof($chart_array);
2018-02-27 16:28:00 +01:00
//Initialize stats array
$stats['sum'] = array ("avg" => 0, "min" => null, "max" => null, "last" => 0);
$stats['min'] = array ("avg" => 0, "min" => null, "max" => null, "last" => 0);
$stats['max'] = array ("avg" => 0, "min" => null, "max" => null, "last" => 0);
2018-02-27 16:28:00 +01:00
foreach ($chart_array as $item) {
if ($series_suffix != '') {
if (isset($item['sum' . $series_suffix]))
$item['sum'] = $item['sum' . $series_suffix];
if (isset($item['min' . $series_suffix]))
$item['min'] = $item['min' . $series_suffix];
if (isset($item['max' . $series_suffix]))
$item['max'] = $item['max' . $series_suffix];
}
2018-02-27 16:28:00 +01:00
//Get stats for normal graph
if (isset($item['sum']) && $item['sum']) {
2018-02-27 16:28:00 +01:00
//Sum all values later divide by the number of elements
$stats['sum']['avg'] = $stats['sum']['avg'] + $item['sum'];
2018-02-27 16:28:00 +01:00
//Get minimum
if ($stats['sum']['min'] == null) {
$stats['sum']['min'] = $item['sum'];
}
else if ($item['sum'] < $stats['sum']['min']) {
$stats['sum']['min'] = $item['sum'];
}
2018-02-27 16:28:00 +01:00
//Get maximum
if ($stats['sum']['max'] == null) {
$stats['sum']['max'] = $item['sum'];
}
else if ($item['sum'] > $stats['sum']['max']) {
$stats['sum']['max'] = $item['sum'];
}
}
2018-02-27 16:28:00 +01:00
//Get stats for min graph
if (isset($item['min']) && $item['min']) {
//Sum all values later divide by the number of elements
$stats['min']['avg'] = $stats['min']['avg'] + $item['min'];
2018-02-27 16:28:00 +01:00
//Get minimum
if ($stats['min']['min'] == null) {
$stats['min']['min'] = $item['min'];
}
else if ($item['min'] < $stats['min']['min']) {
$stats['min']['min'] = $item['min'];
}
2018-02-27 16:28:00 +01:00
//Get maximum
if ($stats['min']['max'] == null) {
$stats['min']['max'] = $item['min'];
}
else if ($item['min'] > $stats['min']['max']) {
$stats['min']['max'] = $item['min'];
}
}
2018-02-27 16:28:00 +01:00
//Get stats for max graph
if (isset($item['max']) && $item['max']) {
//Sum all values later divide by the number of elements
$stats['max']['avg'] = $stats['max']['avg'] + $item['max'];
2018-02-27 16:28:00 +01:00
//Get minimum
if ($stats['max']['min'] == null) {
$stats['max']['min'] = $item['max'];
}
else if ($item['max'] < $stats['max']['min']) {
$stats['max']['min'] = $item['max'];
}
2018-02-27 16:28:00 +01:00
//Get maximum
if ($stats['max']['max'] == null) {
$stats['max']['max'] = $item['max'];
}
else if ($item['max'] > $stats['max']['max']) {
$stats['max']['max'] = $item['max'];
}
}
2018-02-27 16:28:00 +01:00
//Count elements
$count++;
2018-02-27 16:28:00 +01:00
//Get last data
if ($count == $size) {
if (isset($item['sum']) && $item['sum']) {
$stats['sum']['last'] = $item['sum'];
}
2018-02-27 16:28:00 +01:00
if (isset($item['min']) && $item['min']) {
$stats['min']['last'] = $item['min'];
}
2018-02-27 16:28:00 +01:00
if (isset($item['max']) && $item['max']) {
$stats['max']['last'] = $item['max'];
}
}
}
2018-02-27 16:28:00 +01:00
//End the calculus for average
if ($count > 0) {
2018-02-27 16:28:00 +01:00
$stats['sum']['avg'] = $stats['sum']['avg'] / $count;
$stats['min']['avg'] = $stats['min']['avg'] / $count;
$stats['max']['avg'] = $stats['max']['avg'] / $count;
}
2018-02-27 16:28:00 +01:00
//Format stat data to display properly
$stats['sum']['last'] = round($stats['sum']['last'], 2);
$stats['sum']['avg'] = round($stats['sum']['avg'], 2);
$stats['sum']['min'] = round($stats['sum']['min'], 2);
$stats['sum']['max'] = round($stats['sum']['max'], 2);
2018-02-27 16:28:00 +01:00
$stats['min']['last'] = round($stats['min']['last'], 2);
$stats['min']['avg'] = round($stats['min']['avg'], 2);
$stats['min']['min'] = round($stats['min']['min'], 2);
$stats['min']['max'] = round($stats['min']['max'], 2);
2018-02-27 16:28:00 +01:00
$stats['max']['last'] = round($stats['max']['last'], 2);
$stats['max']['avg'] = round($stats['max']['avg'], 2);
$stats['max']['min'] = round($stats['max']['min'], 2);
$stats['max']['max'] = round($stats['max']['max'], 2);
2018-02-27 16:28:00 +01:00
return $stats;
}
2018-02-27 16:28:00 +01:00
function grafico_modulo_sparse_data_chart (
2018-02-21 11:54:24 +01:00
$agent_module_id,
$date_array,
$data_module_graph,
2018-05-28 17:47:40 +02:00
$params,
2018-02-21 11:54:24 +01:00
$series_suffix
) {
global $config;
2018-06-14 16:47:23 +02:00
//To avoid showing all the data at the same time which can be reloaded, a system of boxes is made starting from a constant = 250
//and the selected period of time in addition to being able to reduce the level of boxes, that is, increasing the level of detail of the graph
//until the full option that would show all the points (data) that that period contains.
$data_slice = $date_array['period'] / (250 * $params['zoom']);
2018-06-12 15:46:05 +02:00
2018-05-30 17:45:17 +02:00
if( $data_module_graph['id_module_type'] == 23 ||
2018-07-06 11:56:38 +02:00
$data_module_graph['id_module_type'] == 3 ||
2018-05-30 17:45:17 +02:00
$data_module_graph['id_module_type'] == 17 ||
$data_module_graph['id_module_type'] == 10 ||
$data_module_graph['id_module_type'] == 33 ){
$data = db_get_all_rows_filter (
'tagente_datos_string',
array ('id_agente_modulo' => (int)$agent_module_id,
"utimestamp > '". $date_array['start_date']. "'",
"utimestamp < '". $date_array['final_date'] . "'",
2018-06-12 15:46:05 +02:00
'group' => "ROUND(utimestamp / $data_slice)",
2018-05-30 17:45:17 +02:00
'order' => 'utimestamp ASC'),
array ('count(*) as datos', 'min(utimestamp) as utimestamp'),
'AND',
$data_module_graph['history_db']
);
}
else{
2018-06-27 16:17:17 +02:00
//all points(data) and boolean
2018-07-06 11:56:38 +02:00
if( $data_module_graph['id_module_type'] == 2 ||
$data_module_graph['id_module_type'] == 6 ||
2018-06-27 16:17:17 +02:00
$data_module_graph['id_module_type'] == 21 ||
$data_module_graph['id_module_type'] == 18 ||
2018-07-06 11:56:38 +02:00
$data_module_graph['id_module_type'] == 9 ||
2018-06-27 16:17:17 +02:00
$data_module_graph['id_module_type'] == 31 ||
2018-07-11 12:33:28 +02:00
$data_module_graph['id_module_type'] == 100 ||
2018-07-11 13:47:00 +02:00
$params['baseline'] || $params['projection']
2018-07-11 12:33:28 +02:00
){
2018-06-27 16:17:17 +02:00
$data = db_get_all_rows_filter (
'tagente_datos',
array ('id_agente_modulo' => (int)$agent_module_id,
"utimestamp > '". $date_array['start_date']. "'",
"utimestamp < '". $date_array['final_date'] . "'",
'order' => 'utimestamp ASC'),
array ('datos', 'utimestamp'),
'AND',
$data_module_graph['history_db']
);
}
2018-05-30 17:45:17 +02:00
}
2018-02-27 16:28:00 +01:00
if($data === false){
$data = array();
}
2018-02-21 11:54:24 +01:00
// Get previous data
$previous_data = modules_get_previous_data (
2018-02-27 16:28:00 +01:00
$agent_module_id,
$date_array['start_date']
);
2018-02-21 11:54:24 +01:00
if ($previous_data !== false) {
$previous_data['utimestamp'] = $date_array['start_date'];
unset($previous_data['id_agente_modulo']);
array_unshift ($data, $previous_data);
}
// Get next data
$nextData = modules_get_next_data (
2018-02-27 16:28:00 +01:00
$agent_module_id,
$date_array['final_date']
);
2018-02-21 11:54:24 +01:00
if ($nextData !== false) {
unset($nextData['id_agente_modulo']);
array_push ($data, $nextData);
}
else if (count ($data) > 0) {
// Propagate the last known data to the end of the interval
$nextData = array(
'datos' => $data[count($data)-1]['datos'],
2018-02-27 16:28:00 +01:00
'utimestamp' => $date_array['final_date'],
2018-02-21 11:54:24 +01:00
);
array_push ($data, $nextData);
}
2018-02-27 16:28:00 +01:00
2018-02-21 11:54:24 +01:00
// Check available data
if (count ($data) < 1) {
2018-02-27 16:28:00 +01:00
//return fs_error_image ();
return false;
2018-02-21 11:54:24 +01:00
}
2018-02-27 16:28:00 +01:00
2018-02-21 11:54:24 +01:00
$array_data = array();
$min_value = PHP_INT_MAX-1;
$max_value = PHP_INT_MIN+1;
$array_percentil = array();
foreach ($data as $k => $v) {
//convert array
2018-05-28 17:47:40 +02:00
if($params['flag_overlapped']){
2018-02-21 11:54:24 +01:00
$array_data["sum" . $series_suffix]['data'][$k] = array(
($v['utimestamp'] + $date_array['period'] )* 1000,
$v['datos']
);
}
else{
$array_data["sum" . $series_suffix]['data'][$k] = array(
$v['utimestamp'] * 1000,
$v['datos']
);
}
2018-02-27 16:28:00 +01:00
2018-02-21 11:54:24 +01:00
//min
if($min_value > $v['datos']){
$min_value = $v['datos'];
}
2018-02-27 16:28:00 +01:00
2018-02-21 11:54:24 +01:00
//max
if($max_value < $v['datos']){
$max_value = $v['datos'];
}
//avg
$sum_data += $v['datos'];
$count_data++;
//percentil
2018-05-28 17:47:40 +02:00
if (!is_null($params['percentil']) && $params['percentil']) {
2018-02-21 11:54:24 +01:00
$array_percentil[] = $v['datos'];
}
}
2018-06-06 11:18:39 +02:00
$array_data["sum" . $series_suffix]['min'] = $min_value;
$array_data["sum" . $series_suffix]['max'] = $max_value;
$array_data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
$array_data["sum" . $series_suffix]['agent_module_id']= $agent_module_id;
$array_data["sum" . $series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
$array_data["sum" . $series_suffix]['agent_name'] = $data_module_graph['agent_name'];
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name'];
2018-06-11 13:53:10 +02:00
$array_data["sum" . $series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
2018-05-18 14:22:39 +02:00
2018-05-28 17:47:40 +02:00
if (!is_null($params['percentil']) &&
$params['percentil'] &&
!$params['flag_overlapped']) {
$percentil_result = get_percentile($params['percentil'], $array_percentil);
2018-02-21 11:54:24 +01:00
$array_data["percentil" . $series_suffix]['data'][0] = array(
2018-02-27 16:28:00 +01:00
$date_array['start_date'] * 1000,
2018-02-21 11:54:24 +01:00
$percentil_result
);
$array_data["percentil" . $series_suffix]['data'][1] = array(
2018-02-27 16:28:00 +01:00
$date_array['final_date'] * 1000,
2018-02-21 11:54:24 +01:00
$percentil_result
);
2018-06-06 11:18:39 +02:00
$array_data["percentil" . $series_suffix]['agent_module_id'] = $agent_module_id;
2018-02-21 11:54:24 +01:00
}
return $array_data;
}
2018-02-27 16:28:00 +01:00
function grafico_modulo_sparse_data(
$agent_module_id, $date_array,
2018-05-28 17:47:40 +02:00
$data_module_graph, $params,
2018-06-06 11:18:39 +02:00
$series_suffix) {
2018-02-16 13:41:31 +01:00
2018-02-12 13:29:25 +01:00
global $config;
2018-02-28 08:46:51 +01:00
global $array_events_alerts;
2018-02-16 13:41:31 +01:00
2018-05-28 17:47:40 +02:00
if($params['fullscale']){
2018-02-27 16:28:00 +01:00
$array_data = fullscale_data(
2018-02-21 11:54:24 +01:00
$agent_module_id,
$date_array,
2018-05-28 17:47:40 +02:00
$params['show_unknown'],
$params['percentil'],
2018-02-21 11:54:24 +01:00
$series_suffix,
$params['flag_overlapped'],
false,
$params['type_mode_graph']
2018-02-16 13:41:31 +01:00
);
}
else{
2018-07-06 11:56:38 +02:00
//uncompress data except boolean and string.
if( $data_module_graph['id_module_type'] == 23 ||
$data_module_graph['id_module_type'] == 3 ||
$data_module_graph['id_module_type'] == 17 ||
$data_module_graph['id_module_type'] == 10 ||
$data_module_graph['id_module_type'] == 33 ||
$data_module_graph['id_module_type'] == 2 ||
$data_module_graph['id_module_type'] == 6 ||
$data_module_graph['id_module_type'] == 21 ||
$data_module_graph['id_module_type'] == 18 ||
$data_module_graph['id_module_type'] == 9 ||
$data_module_graph['id_module_type'] == 31 ||
2018-07-11 13:47:00 +02:00
$data_module_graph['id_module_type'] == 100 ||
$params['projection'] ){
2018-07-06 11:56:38 +02:00
$array_data = grafico_modulo_sparse_data_chart (
$agent_module_id,
$date_array,
$data_module_graph,
$params,
$series_suffix
);
}
else{
$array_data = fullscale_data(
$agent_module_id,
$date_array,
$params['show_unknown'],
$params['percentil'],
$series_suffix,
$params['flag_overlapped'],
$data_slice = $date_array['period'] / (250 * $params['zoom']) + 100,
$params['type_mode_graph']
);
}
2018-02-12 13:29:25 +01:00
}
2018-02-16 13:41:31 +01:00
2018-02-27 16:28:00 +01:00
if($array_data === false){
return false;
}
2018-07-06 11:56:38 +02:00
$array_data["sum" . $series_suffix]['agent_module_id']= $agent_module_id;
$array_data["sum" . $series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
$array_data["sum" . $series_suffix]['agent_name'] = $data_module_graph['agent_name'];
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name'];
$array_data["sum" . $series_suffix]['agent_alias'] = $data_module_graph['agent_alias'];
2018-06-14 16:47:23 +02:00
//This is for a specific type of report that consists in passing an interval and doing the average sum and avg.
2018-05-28 17:47:40 +02:00
if($params['force_interval'] != ''){
$period_time_interval = $date_array['period'] * 1000;
$start_period = $date_array['start_date'] * 1000;
$i = 0;
$sum_data = 0;
$count_data = 0;
$data_last_acum = $array_data['sum1']['data'][0][1];
while($period_time_interval > 0) {
foreach ($array_data['sum1']['data'] as $key => $value) {
if($value[0] >= $start_period && $value[0] < $start_period + $params['time_interval'] * 1000){
$sum_data = $value[1];
$array_data_only[] = $value[1];
$count_data++;
unset($array_data['sum1']['data'][$key]);
}
else{
if($params['force_interval'] == 'max_only'){
$acum_array_data[$i][0] = $start_period;
if(is_array($array_data_only) && count($array_data_only) > 0){
$acum_array_data[$i][1] = max($array_data_only);
$data_last_acum = $array_data_only[count($array_data_only) - 1];
}
else{
$acum_array_data[$i][1] = $data_last_acum;
}
}
if($params['force_interval'] == 'min_only'){
$acum_array_data[$i][0] = $start_period;
if(is_array($array_data_only) && count($array_data_only) > 0){
$acum_array_data[$i][1] = min($array_data_only);
$data_last_acum = $array_data_only[count($array_data_only) - 1];
}
else{
$acum_array_data[$i][1] = $data_last_acum;
}
}
if($params['force_interval'] == 'avg_only'){
$acum_array_data[$i][0] = $start_period;
if(is_array($array_data_only) && count($array_data_only) > 0){
$acum_array_data[$i][1] = $sum_data / $count_data;
}
else{
$acum_array_data[$i][1] = $data_last_acum;
}
}
$start_period = $start_period + $params['time_interval'] * 1000;
$array_data_only = array();
$sum_data = 0;
$count_data = 0;
$i++;
break;
}
}
$period_time_interval = $period_time_interval - $params['time_interval'];
}
$array_data['sum1']['data'] = $acum_array_data;
}
if($params['percentil']){
2018-02-21 11:54:24 +01:00
$percentil_value = $array_data['percentil' . $series_suffix]['data'][0][1];
2018-02-16 13:41:31 +01:00
}
else{
$percentil_value = 0;
}
$events = array();
if(isset($array_data['sum' . $series_suffix]['max'])){
$max = $array_data['sum'. $series_suffix]['max'];
$min = $array_data['sum'. $series_suffix]['min'];
$avg = $array_data['sum'. $series_suffix]['avg'];
}
2018-05-28 17:47:40 +02:00
if(!$params['flag_overlapped']){
if($params['fullscale']){
if( $params['show_unknown'] &&
2018-02-21 11:54:24 +01:00
isset($array_data['unknown' . $series_suffix]) &&
is_array($array_data['unknown' . $series_suffix]['data']) ){
foreach ($array_data['unknown' . $series_suffix]['data'] as $key => $s_date) {
if ($s_date[1] == 1) {
$array_data['unknown' . $series_suffix]['data'][$key] = array($s_date[0], $max * 1.05);
}
}
}
}
else{
2018-05-28 17:47:40 +02:00
if( $params['show_unknown'] ) {
2018-02-21 11:54:24 +01:00
$unknown_events = db_get_module_ranges_unknown(
2018-02-27 16:28:00 +01:00
$agent_module_id,
$date_array['start_date'],
$date_array['final_date'],
$data_module_graph['history_db'],
1 // fix the time ranges to start_date - final_date
2018-02-21 11:54:24 +01:00
);
if($unknown_events !== false){
foreach ($unknown_events as $key => $s_date) {
2018-02-27 16:28:00 +01:00
if( isset($s_date['time_from'])) {
$array_data['unknown' . $series_suffix]['data'][] = array(
2018-02-21 11:54:24 +01:00
($s_date['time_from'] - 1) * 1000,
0
);
2018-02-27 16:28:00 +01:00
$array_data['unknown' . $series_suffix]['data'][] = array(
2018-02-21 11:54:24 +01:00
$s_date['time_from'] * 1000,
$max * 1.05
);
}
else{
2018-02-27 16:28:00 +01:00
$array_data['unknown' . $series_suffix]['data'][] = array(
2018-02-21 11:54:24 +01:00
$date_array['start_date'] * 1000,
$max * 1.05
);
}
2018-02-27 16:28:00 +01:00
2018-02-21 11:54:24 +01:00
if( isset($s_date['time_to']) ){
$array_data['unknown' . $series_suffix]['data'][] = array(
$s_date['time_to'] * 1000,
$max * 1.05
);
2018-02-27 16:28:00 +01:00
$array_data['unknown' . $series_suffix]['data'][] = array(
2018-02-21 11:54:24 +01:00
($s_date['time_to'] + 1) * 1000,
0
);
}
else{
2018-02-27 16:28:00 +01:00
$array_data['unknown' . $series_suffix]['data'][] = array(
2018-02-21 11:54:24 +01:00
$date_array['final_date'] * 1000,
$max * 1.05
);
}
}
}
2018-02-16 13:41:31 +01:00
}
}
2018-02-27 16:28:00 +01:00
2018-05-28 17:47:40 +02:00
if ($params['show_events'] ||
$params['show_alerts'] ) {
2018-02-27 16:28:00 +01:00
2018-02-21 11:54:24 +01:00
$events = db_get_all_rows_filter (
'tevento',
array ('id_agentmodule' => $agent_module_id,
"utimestamp > " . $date_array['start_date'],
"utimestamp < " . $date_array['final_date'],
'order' => 'utimestamp ASC'
),
2018-02-27 16:28:00 +01:00
false,
2018-02-21 11:54:24 +01:00
'AND',
$data_module_graph['history_db']
);
2018-02-16 13:41:31 +01:00
2018-02-21 11:54:24 +01:00
$alerts_array = array();
$events_array = array();
2018-02-16 13:41:31 +01:00
2018-02-21 11:54:24 +01:00
if($events && is_array($events)){
2018-02-28 08:46:51 +01:00
$count_events=0;
$count_alerts=0;
2018-02-21 11:54:24 +01:00
foreach ($events as $k => $v) {
if (strpos($v["event_type"], "alert") !== false){
2018-05-28 17:47:40 +02:00
if($params['flag_overlapped']){
2018-02-28 08:46:51 +01:00
$alerts_array['data'][$count_alerts] = array(
($v['utimestamp'] + $date_array['period'] *1000),
$max * 1.10
);
2018-02-21 11:54:24 +01:00
}
else{
2018-02-28 08:46:51 +01:00
$alerts_array['data'][$count_alerts] = array(
($v['utimestamp']*1000),
$max * 1.10
);
2018-02-21 11:54:24 +01:00
}
2018-02-28 08:46:51 +01:00
$count_alerts++;
2018-02-21 11:54:24 +01:00
}
else{
2018-05-28 17:47:40 +02:00
if($params['flag_overlapped']){
2018-05-10 08:43:09 +02:00
if( ( strstr($v['event_type'], 'going_up') ) ||
( strstr($v['event_type'], 'going_down') ) ){
$events_array['data'][$count_events] = array(
(($v['utimestamp'] + 1 + $date_array['period']) * 1000),
$max * 1.15
);
}
else{
$events_array['data'][$count_events] = array(
($v['utimestamp'] + $date_array['period'] *1000),
$max * 1.15
);
}
2018-02-21 11:54:24 +01:00
}
else{
2018-05-10 08:43:09 +02:00
if( ( strstr($v['event_type'], 'going_up') ) ||
( strstr($v['event_type'], 'going_down') ) ){
$events_array['data'][$count_events] = array(
(($v['utimestamp'] + 1) *1000),
$max * 1.15
);
}
else{
$events_array['data'][$count_events] = array(
($v['utimestamp']*1000),
$max * 1.15
);
}
2018-02-21 11:54:24 +01:00
}
2018-02-28 08:46:51 +01:00
$count_events++;
2018-02-21 11:54:24 +01:00
}
2018-02-16 13:41:31 +01:00
}
}
}
2018-02-27 16:28:00 +01:00
2018-05-28 17:47:40 +02:00
if($params['show_events']){
2018-02-21 11:54:24 +01:00
$array_data['event' . $series_suffix] = $events_array;
}
2018-02-16 13:41:31 +01:00
2018-05-28 17:47:40 +02:00
if($params['show_alerts']){
2018-02-21 11:54:24 +01:00
$array_data['alert' . $series_suffix] = $alerts_array;
}
2018-02-16 13:41:31 +01:00
}
2018-05-28 17:47:40 +02:00
if ($params['return_data'] == 1) {
2018-02-16 13:41:31 +01:00
return $array_data;
}
2018-02-27 16:28:00 +01:00
2018-02-28 08:46:51 +01:00
$array_events_alerts[$series_suffix] = $events;
2018-05-10 08:43:09 +02:00
2018-05-18 14:22:39 +02:00
return $array_data;
2018-02-12 13:29:25 +01:00
}
2018-05-28 17:47:40 +02:00
/*
$params =array(
'agent_module_id' => $agent_module_id,
'period' => $period,
'show_events' => false,
'width' => $width,
'height' => $height,
'title' => '',
'unit_name' => null,
'show_alerts' => false,
'date' => 0,
'unit' => '',
'baseline' => 0,
'return_data' => 0,
'show_title' => true,
'only_image' => false,
2018-06-06 11:18:39 +02:00
'homeurl' => $config['homeurl'],
2018-05-28 17:47:40 +02:00
'ttl' => 1,
'adapt_key' => '',
'compare' => false,
'show_unknown' => false,
'menu' => true,
'backgroundColor' => 'white',
'percentil' => null,
'dashboard' => false,
'vconsole' => false,
'type_graph' => 'area',
'fullscale' => false,
'id_widget_dashboard' => false,
'force_interval' => '',
'time_interval' => 300,
2018-06-06 11:18:39 +02:00
'array_data_create' => 0,
'show_legend' => true,
2018-06-06 17:23:32 +02:00
'show_overview' => true,
'return_img_base_64' => false,
'image_treshold' => false,
2018-06-13 19:13:42 +02:00
'graph_combined' => false,
2018-06-14 19:19:58 +02:00
'zoom' => 1,
'server_id' => null
2018-05-28 17:47:40 +02:00
);
*/
function grafico_modulo_sparse ($params) {
global $config;
2018-05-18 14:22:39 +02:00
2018-05-28 17:47:40 +02:00
/*XXXXXXXXXXXX Documnetar
*Set all variable
*/
if(!isset($params) || !is_array($params)){
return false;
}
if(!isset($params['agent_module_id'])){
return false;
}
else{
$agent_module_id = $params['agent_module_id'];
}
if(!isset($params['period'])){
return false;
}
if(!isset($params['show_events'])){
$params['show_events'] = false;
}
if(!isset($params['width'])){
$params['width'] = '90%';
}
if(!isset($params['height'])){
$params['height'] = 450;
}
if(!isset($params['title'])){
$params['title'] = '';
}
if(!isset($params['unit_name'])){
$params['unit_name'] = null;
}
if(!isset($params['show_alerts'])){
$params['show_alerts'] = false;
}
if(!isset($params['date']) || !$params['date']){
$params['date'] = get_system_time();
}
if(!isset($params['unit'])){
$params['unit'] = '';
}
if(!isset($params['baseline'])){
$params['baseline'] = 0;
}
if(!isset($params['return_data'])){
$params['return_data'] = 0;
}
if(!isset($params['show_title'])){
$show_title = true;
}
if(!isset($params['only_image'])){
$params['only_image'] = false;
}
if(!isset($params['homeurl'])){
2018-06-06 11:18:39 +02:00
$params['homeurl'] = $config['homeurl'];
2018-05-28 17:47:40 +02:00
}
if(!isset($params['ttl'])){
$params['ttl'] = 1;
}
if(!isset($params['adapt_key'])){
$params['adapt_key'] = '';
}
if(!isset($params['compare'])){
$params['compare'] = false;
}
if(!isset($params['show_unknown'])){
$params['show_unknown'] = false;
}
if(!isset($params['menu'])){
$params['menu'] = true;
}
2018-06-06 11:18:39 +02:00
if(!isset($params['show_legend'])){
$params['show_legend'] = true;
}
if(!isset($params['show_overview'])){
$params['show_overview'] = true;
}
if(!isset($params['show_export_csv'])){
$params['show_export_csv'] = true;
}
2018-05-28 17:47:40 +02:00
if(!isset($params['backgroundColor'])){
$params['backgroundColor'] = 'white';
}
if(!isset($params['percentil'])){
$params['percentil'] = null;
}
if(!isset($params['dashboard'])){
$params['dashboard'] = false;
}
2018-06-01 13:58:29 +02:00
if(!isset($params['vconsole']) || $params['vconsole'] == false){
2018-05-28 17:47:40 +02:00
$params['vconsole'] = false;
}
else{
$params['menu'] = false;
}
if(!isset($params['type_graph'])){
$params['type_graph'] = $config['type_module_charts'];
}
if(!isset($params['fullscale'])){
$params['fullscale'] = false;
}
if(!isset($params['id_widget_dashboard'])){
$params['id_widget_dashboard'] = false;
}
if(!isset($params['force_interval'])){
$params['force_interval'] = '';
}
if(!isset($params['time_interval'])){
$params['time_interval'] = 300;
}
if(!isset($params['array_data_create'])){
$params['array_data_create'] = 0;
}
2018-06-06 17:23:32 +02:00
if(!isset($params['return_img_base_64'])){
$params['return_img_base_64'] = false;
}
if(!isset($params['image_treshold'])){
$params['image_treshold'] = false;
}
if(!isset($params['graph_combined'])){
$params['graph_combined'] = false;
}
if(!isset($params['zoom'])){
$params['zoom'] = $config['zoom_graph'];
}
if(!isset($params['type_mode_graph'])){
//$config['type_mode_graph']
$params['type_mode_graph'] = $config['type_mode_graph'];
}
2018-07-11 13:47:00 +02:00
if(!isset($params['projection'])){
$params['projection'] = false;
}
//XXXX Configurable
$params['grid_color'] = '#C1C1C1';
$params['legend_color'] = '#636363';
2018-05-28 17:47:40 +02:00
$params['font'] = $config['fontpath'];
2018-06-13 19:13:42 +02:00
$params['font_size'] = $config['font_size'];
$params['short_data'] = $config['short_module_graph_data'];
2018-05-28 17:47:40 +02:00
if($params['only_image']){
2018-06-01 13:58:29 +02:00
return generator_chart_to_pdf('sparse', $params);
2018-05-28 17:47:40 +02:00
}
global $graphic_type;
2018-02-28 08:46:51 +01:00
global $array_events_alerts;
2018-02-16 13:41:31 +01:00
2018-02-28 08:46:51 +01:00
$array_data = array();
$legend = array();
$array_events_alerts = array();
2018-02-12 13:29:25 +01:00
2018-02-16 13:41:31 +01:00
2018-02-08 15:47:12 +01:00
$date_array = array();
2018-05-28 17:47:40 +02:00
$date_array["period"] = $params['period'];
$date_array["final_date"] = $params['date'];
$date_array["start_date"] = $params['date'] - $params['period'];
2018-02-16 13:41:31 +01:00
2018-06-06 11:18:39 +02:00
if($agent_module_id){
$module_data = db_get_row_sql (
'SELECT * FROM tagente_modulo
WHERE id_agente_modulo = ' .
$agent_module_id
);
2018-02-16 13:41:31 +01:00
2018-06-06 11:18:39 +02:00
$data_module_graph = array();
$data_module_graph['history_db'] = db_search_in_history_db($date_array["start_date"]);
2018-06-11 13:53:10 +02:00
$data_module_graph['agent_name'] = modules_get_agentmodule_agent_name($agent_module_id);
$data_module_graph['agent_alias'] = modules_get_agentmodule_agent_alias($agent_module_id);
2018-06-06 11:18:39 +02:00
$data_module_graph['agent_id'] = $module_data['id_agente'];
$data_module_graph['module_name'] = $module_data['nombre'];
$data_module_graph['id_module_type'] = $module_data['id_tipo_modulo'];
2018-06-11 13:53:10 +02:00
$data_module_graph['module_type'] = modules_get_moduletype_name($data_module_graph['id_module_type']);
$data_module_graph['uncompressed'] = is_module_uncompressed($data_module_graph['module_type']);
2018-06-06 11:18:39 +02:00
$data_module_graph['w_min'] = $module_data['min_warning'];
$data_module_graph['w_max'] = $module_data['max_warning'];
$data_module_graph['w_inv'] = $module_data['warning_inverse'];
$data_module_graph['c_min'] = $module_data['min_critical'];
$data_module_graph['c_max'] = $module_data['max_critical'];
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
}
else{
$data_module_graph = false;
}
2018-02-08 15:47:12 +01:00
//format of the graph
2018-05-28 17:47:40 +02:00
if (empty($params['unit'])) {
$params['unit'] = $module_data['unit'];
if(modules_is_unit_macro($params['unit'])){
$params['unit'] = "";
2018-02-16 13:41:31 +01:00
}
}
2018-05-28 17:47:40 +02:00
if(!$params['array_data_create']){
if ($params['compare'] !== false) {
2018-05-18 14:22:39 +02:00
$series_suffix = 2;
2018-02-21 11:54:24 +01:00
2018-05-18 14:22:39 +02:00
$date_array_prev['final_date'] = $date_array['start_date'];
$date_array_prev['start_date'] = $date_array['start_date'] - $date_array['period'];
$date_array_prev['period'] = $date_array['period'];
2018-02-27 16:28:00 +01:00
2018-05-28 17:47:40 +02:00
if ($params['compare'] === 'overlapped') {
$params['flag_overlapped'] = 1;
2018-05-18 14:22:39 +02:00
}
else{
2018-05-28 17:47:40 +02:00
$params['flag_overlapped'] = 0;
2018-05-18 14:22:39 +02:00
}
$array_data = grafico_modulo_sparse_data(
2018-06-06 11:18:39 +02:00
$agent_module_id,
$date_array_prev,
$data_module_graph,
$params,
$series_suffix
2018-05-18 14:22:39 +02:00
);
2018-05-28 17:47:40 +02:00
switch ($params['compare']) {
2018-05-18 14:22:39 +02:00
case 'separated':
case 'overlapped':
// Store the chart calculated
2018-05-21 17:25:09 +02:00
$array_data_prev = $array_data;
$legend_prev = $legend;
2018-05-18 14:22:39 +02:00
break;
}
2018-02-21 11:54:24 +01:00
}
2018-02-27 16:28:00 +01:00
2018-05-18 14:22:39 +02:00
$series_suffix = 1;
2018-05-28 17:47:40 +02:00
$params['flag_overlapped'] = 0;
2018-05-18 14:22:39 +02:00
$array_data = grafico_modulo_sparse_data(
2018-06-06 11:18:39 +02:00
$agent_module_id,
$date_array,
$data_module_graph,
$params,
$series_suffix
2018-02-21 11:54:24 +01:00
);
2018-05-28 17:47:40 +02:00
if($params['compare']){
if ($params['compare'] === 'overlapped') {
2018-05-18 14:22:39 +02:00
$array_data = array_merge($array_data, $array_data_prev);
$legend = array_merge($legend, $legend_prev);
}
2018-02-21 11:54:24 +01:00
}
}
2018-05-18 14:22:39 +02:00
else{
2018-05-28 17:47:40 +02:00
$array_data = $params['array_data_create'];
2018-05-18 14:22:39 +02:00
}
2018-02-21 11:54:24 +01:00
2018-05-28 17:47:40 +02:00
if($params['return_data']){
2018-05-18 14:22:39 +02:00
return $array_data;
2018-02-21 11:54:24 +01:00
}
2018-05-21 17:25:09 +02:00
$series_type_array = series_type_graph_array(
$array_data,
2018-05-28 17:47:40 +02:00
$params
2018-05-18 14:22:39 +02:00
);
2018-05-21 17:25:09 +02:00
$series_type = $series_type_array['series_type'];
2018-06-08 14:30:15 +02:00
$legend = $series_type_array['legend'];
$color = $series_type_array['color'];
2018-05-21 17:25:09 +02:00
2018-06-07 09:15:45 +02:00
if($config["fixed_graph"] == false){
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url(
"/images/logo_vertical_water.png",
false,
false,
false
)
);
}
2018-03-01 09:46:52 +01:00
$data_module_graph['series_suffix'] = $series_suffix;
2018-02-27 16:28:00 +01:00
// Check available data
2018-05-28 17:47:40 +02:00
if ($params['compare'] === 'separated') {
2018-02-27 16:28:00 +01:00
if (!empty($array_data)) {
$return = area_graph(
$agent_module_id,
$array_data,
$legend,
$series_type,
2018-06-08 14:30:15 +02:00
$color,
2018-02-27 16:28:00 +01:00
$date_array,
$data_module_graph,
2018-05-28 17:47:40 +02:00
$params,
2018-02-27 16:28:00 +01:00
$water_mark,
2018-02-28 08:46:51 +01:00
$array_events_alerts
2018-02-27 16:28:00 +01:00
);
}
else{
2018-05-28 17:47:40 +02:00
$return = graph_nodata_image($params['width'], $params['height']);
2018-02-27 16:28:00 +01:00
}
$return .= '<br>';
if (!empty($array_data_prev)) {
2018-05-18 14:22:39 +02:00
2018-05-21 17:25:09 +02:00
$series_type_array = series_type_graph_array(
$array_data_prev,
2018-05-28 17:47:40 +02:00
$params
2018-05-18 14:22:39 +02:00
);
2018-05-21 17:25:09 +02:00
$series_type = $series_type_array['series_type'];
2018-06-08 14:30:15 +02:00
$legend = $series_type_array['legend'];
$color = $series_type_array['color'];
2018-05-21 17:25:09 +02:00
2018-02-27 16:28:00 +01:00
$return .= area_graph(
$agent_module_id,
$array_data_prev,
$legend,
$series_type,
2018-06-08 14:30:15 +02:00
$color,
2018-06-11 15:35:04 +02:00
$date_array_prev,
2018-02-27 16:28:00 +01:00
$data_module_graph,
2018-05-28 17:47:40 +02:00
$params,
2018-02-27 16:28:00 +01:00
$water_mark,
2018-02-28 08:46:51 +01:00
$array_events_alerts
2018-02-27 16:28:00 +01:00
);
}
else{
2018-05-28 17:47:40 +02:00
$return .= graph_nodata_image($params['width'], $params['height']);
2018-02-27 16:28:00 +01:00
}
2018-02-21 11:54:24 +01:00
}
else{
2018-02-27 16:28:00 +01:00
if (!empty($array_data)) {
$return = area_graph(
2018-02-16 13:41:31 +01:00
$agent_module_id,
$array_data,
$legend,
$series_type,
2018-06-08 14:30:15 +02:00
$color,
2018-02-16 13:41:31 +01:00
$date_array,
$data_module_graph,
2018-05-28 17:47:40 +02:00
$params,
2018-02-16 13:41:31 +01:00
$water_mark,
2018-02-28 08:46:51 +01:00
$array_events_alerts
2018-02-16 13:41:31 +01:00
);
2018-02-27 16:28:00 +01:00
}
else{
2018-06-06 11:18:39 +02:00
$return = graph_nodata_image(
$params['width'],
$params['height']
);
2018-02-27 16:28:00 +01:00
}
2018-02-21 11:54:24 +01:00
}
2018-02-08 15:47:12 +01:00
2018-02-27 16:28:00 +01:00
return $return;
}
/**
* Produces a combined/user defined graph
*
* @param array List of source modules
* @param array List of weighs for each module
* @param int Period (in seconds)
* @param int Width, in pixels
* @param int Height, in pixels
* @param string Title for graph
* @param string Unit name, for render in legend
* @param int Show events in graph (set to 1)
* @param int Show alerts in graph (set to 1)
* @param int Pure mode (without titles) (set to 1)
* @param int Date to start of getting info.
* @param mixed If is a projection graph this parameter will be module data with prediction data (the projection)
* or false in other case.
* @param array List of names for the items. Should have the same size as the module list.
* @param array List of units for the items. Should have the same size as the module list.
* @param bool Show the last value of the item on the list.
* @param bool Show the max value of the item on the list.
* @param bool Show the min value of the item on the list.
* @param bool Show the average value of the item on the list.
2018-04-27 10:03:05 +02:00
*
* @return Mixed
*/
2018-06-01 13:58:29 +02:00
/*
$params =array(
'period' => $period,
'show_events' => false,
'width' => $width,
'height' => $height,
'title' => '',
'unit_name' => null,
'show_alerts' => false,
'date' => 0,
'unit' => '',
'only_image' => false,
'homeurl' => '',
'ttl' => 1,
'percentil' => null,
'dashboard' => false,
'vconsole' => false,
'fullscale' => false,
'id_widget_dashboard' => false,
);
$params_combined = array(
'weight_list' => array(),
'stacked' => 0,
'projection' => false,
'labels' => array(),
'from_interface' => false,
'summatory' => 0,
'average' => 0,
'modules_series' => 0,
'id_graph' => 0,
'return' => 1
);
*/
function graphic_combined_module (
$module_list,
2018-06-01 13:58:29 +02:00
$params,
$params_combined
) {
2018-06-13 19:13:42 +02:00
global $config;
2018-06-01 13:58:29 +02:00
if(!isset($params_combined['from_interface'])){
$params_combined['from_interface'] = false;
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if(!isset($params_combined['stacked'])){
if ($params_combined['from_interface']) {
if ($config["type_interface_charts"] == 'line') {
$params_combined['stacked'] = CUSTOM_GRAPH_LINE;
}
else {
$params_combined['stacked'] = CUSTOM_GRAPH_AREA;
}
}
else {
2018-06-13 19:13:42 +02:00
if ($params_combined['id_graph'] == 0) {
2018-06-06 17:23:32 +02:00
$params_combined['stacked'] = CUSTOM_GRAPH_AREA;
2018-06-01 13:58:29 +02:00
}
else {
2018-06-13 19:13:42 +02:00
$params_combined['stacked'] = db_get_row('tgraph', 'id_graph', $params_combined['id_graph']);
2018-06-01 13:58:29 +02:00
}
}
}
$params['stacked'] = $params_combined['stacked'];
if(!isset($params_combined['projection'])){
$params_combined['projection'] = false;
}
else{
$params['stacked'] = 'area';
2018-07-11 13:47:00 +02:00
$params['projection'] = $params_combined['projection'];
2018-06-01 13:58:29 +02:00
}
if(!isset($params_combined['labels'])){
$params_combined['labels'] = array();
}
if(!isset($params_combined['summatory'])){
$params_combined['summatory'] = 0;
}
if(!isset($params_combined['average'])){
$params_combined['average'] = 0;
}
if(!isset($params_combined['modules_series'])){
$params_combined['modules_series'] = 0;
}
if(!isset($params_combined['return'])){
$params_combined['return'] = 1;
}
if(!isset($params_combined['id_graph'])){
$params_combined['id_graph'] = 0;
}
2018-06-06 11:18:39 +02:00
if(!isset($params['percentil'])){
$params_combined['percentil'] = null;
}
else{
$params_combined['percentil'] = $params['percentil'];
}
2018-06-01 13:58:29 +02:00
if(!isset($params['period'])){
return false;
}
if(!isset($params['width'])){
$params['width'] = '90%';
}
if(!isset($params['height'])){
$params['height'] = 450;
}
if(!isset($params['title'])){
$params['title'] = '';
}
if(!isset($params['unit_name'])){
$params['unit_name'] = null;
}
if(!isset($params['show_alerts'])){
$params['show_alerts'] = false;
}
if(!isset($params['date']) || !$params['date']){
$params['date'] = get_system_time();
}
if(!isset($params['only_image'])){
$params['only_image'] = false;
}
if(!isset($params['ttl'])){
$params['ttl'] = 1;
}
if(!isset($params['backgroundColor'])){
$params['backgroundColor'] = 'white';
}
if(!isset($params['dashboard'])){
$params['dashboard'] = false;
}
if(!isset($params['menu']) || $params['only_image']){
$params['menu'] = true;
}
else{
$params['menu'] = false;
}
if(!isset($params['vconsole']) || $params['vconsole'] == false){
$params['vconsole'] = false;
}
else{
$params['menu'] = false;
}
2018-06-06 17:23:32 +02:00
if(!isset($params['type_graph'])){
$params['type_graph'] = $config['type_module_charts'];
}
2018-06-01 13:58:29 +02:00
if(!isset($params['percentil'])){
$params['percentil'] = null;
}
if(!isset($params['fullscale'])){
$params['fullscale'] = false;
}
if(!isset($params['id_widget_dashboard'])){
$params['id_widget_dashboard'] = false;
}
2018-06-01 13:58:29 +02:00
if(!isset($params['homeurl'])){
$params['homeurl'] = ui_get_full_url(false, false, false, false);
}
2018-04-26 10:24:37 +02:00
2018-06-06 11:18:39 +02:00
if(!isset($params['show_legend'])){
$params['show_legend'] = true;
}
if(!isset($params['show_overview'])){
$params['show_overview'] = true;
}
if(!isset($params['show_export_csv'])){
$params['show_export_csv'] = true;
}
2018-06-06 17:23:32 +02:00
if(!isset($params['return_img_base_64'])){
$params['return_img_base_64'] = false;
}
if(!isset($params['image_treshold'])){
$params['image_treshold'] = false;
}
if(!isset($params['show_unknown'])){
$params['show_unknown'] = false;
}
2018-07-06 11:56:38 +02:00
if(!isset($params['type_mode_graph'])){
//$config['type_mode_graph']
$params['type_mode_graph'] = 0;
}
2018-06-07 09:15:45 +02:00
$params['graph_combined'] = true;
2018-06-13 19:13:42 +02:00
$params_combined['graph_combined'] = true;
2018-06-01 13:58:29 +02:00
if($params['only_image']){
return generator_chart_to_pdf('combined', $params, $params_combined, $module_list);
2018-04-26 10:24:37 +02:00
}
if(!isset($params['zoom'])){
$params['zoom'] = 1;
}
//XXXX Configurable
$params['grid_color'] = '#C1C1C1';
$params['legend_color'] = '#636363';
$params['font'] = $config['fontpath'];
2018-06-13 19:13:42 +02:00
$params['font_size'] = $config['font_size'];
$params['short_data'] = $config['short_module_graph_data'];
2018-06-01 13:58:29 +02:00
global $config;
global $graphic_type;
$sources = false;
2018-06-13 19:13:42 +02:00
2018-06-01 13:58:29 +02:00
if ($params_combined['id_graph'] == 0) {
$count_modules = count($module_list);
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if(!$params_combined['weight_list']){
$weights = array_fill(0, $count_modules, 1);
}
if ($count_modules > 0){
$sources = true;
}
}
else {
$sources = db_get_all_rows_field_filter(
'tgraph_source',
'id_graph',
$params_combined['id_graph'],
'field_order'
2018-04-26 10:24:37 +02:00
);
2018-06-01 13:58:29 +02:00
$series = db_get_all_rows_sql(
'SELECT summatory_series,average_series,modules_series
FROM tgraph
WHERE id_graph = '.
$params_combined['id_graph']
);
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
$summatory = $series[0]['summatory_series'];
$average = $series[0]['average_series'];
$modules_series = $series[0]['modules_series'];
$weights = array ();
$labels = array ();
$modules = array ();
if(isset($sources) && is_array($sources)){
foreach ($sources as $source) {
array_push ($modules, $source['id_agent_module']);
array_push ($weights, $source['weight']);
if ($source['label'] != ''){
$item['type'] = 'custom_graph';
$item['id_agent'] = agents_get_module_id($source['id_agent_module']);
$item['id_agent_module'] = $source['id_agent_module'];
$labels[$source['id_agent_module']] = reporting_label_macro($item, $source['label']);
2018-04-27 10:03:05 +02:00
}
}
}
2018-06-01 13:58:29 +02:00
}
2018-04-27 10:03:05 +02:00
2018-06-13 19:13:42 +02:00
if($module_list){
$params_combined['modules_id'] = $module_list;
}
else{
$params_combined['modules_id'] = $modules;
}
2018-06-06 11:18:39 +02:00
if(isset($summatory)){
$params_combined['summatory'] = $summatory;
}
if(isset($average)){
$params_combined['average'] = $average;
}
if(isset($modules_series)){
$params_combined['modules_series'] = $modules_series;
}
2018-06-01 13:58:29 +02:00
if(isset($labels)){
$params_combined['labels'] = $labels;
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if(isset($weights)){
$params_combined['weight_list'] = $weights;
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if(!$module_list){
$module_list = $modules;
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if ($sources === false) {
if ($params_combined['return']){
return false;
}
2018-06-01 13:58:29 +02:00
else{
ui_print_info_message (
array (
'no_close' => true,
'message' => __('No items.')
)
);
return;
}
2018-06-01 13:58:29 +02:00
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
$width = $params['width'];
$height = $params['height'];
$homeurl = $params['homeurl'];
$ttl = $params['ttl'];
$background_color = $params['backgroundColor'];
$datelimit = $date_array["start_date"];
2018-06-07 09:15:45 +02:00
$fixed_font_size = $config['font_size'];
2018-06-01 13:58:29 +02:00
$flash_charts = false;
2018-04-26 10:24:37 +02:00
2018-06-07 09:15:45 +02:00
if($config["fixed_graph"] == false){
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url(
"/images/logo_vertical_water.png",
false,
false,
false
)
);
}
//XXX arreglar estas
2018-06-14 16:47:23 +02:00
$long_index = '';
2018-06-01 13:58:29 +02:00
switch ($params_combined['stacked']) {
default:
case CUSTOM_GRAPH_STACKED_LINE:
case CUSTOM_GRAPH_STACKED_AREA:
case CUSTOM_GRAPH_AREA:
case CUSTOM_GRAPH_LINE:
$date_array = array();
$date_array["period"] = $params['period'];
$date_array["final_date"] = $params['date'];
$date_array["start_date"] = $params['date'] - $params['period'];
$i=0;
$array_data = array();
foreach ($module_list as $key => $agent_module_id) {
$module_data = db_get_row_sql (
'SELECT * FROM tagente_modulo
WHERE id_agente_modulo = ' .
$agent_module_id
);
2018-05-21 17:25:09 +02:00
2018-06-01 13:58:29 +02:00
$data_module_graph = array();
$data_module_graph['history_db'] = db_search_in_history_db($date_array["start_date"]);
2018-06-11 13:53:10 +02:00
$data_module_graph['agent_name'] = modules_get_agentmodule_agent_name($agent_module_id);
$data_module_graph['agent_alias'] = modules_get_agentmodule_agent_alias($agent_module_id);
2018-06-01 13:58:29 +02:00
$data_module_graph['agent_id'] = $module_data['id_agente'];
$data_module_graph['module_name'] = $module_data['nombre'];
$data_module_graph['id_module_type'] = $module_data['id_tipo_modulo'];
2018-06-11 13:53:10 +02:00
$data_module_graph['module_type'] = modules_get_moduletype_name($data_module_graph['id_module_type']);
$data_module_graph['uncompressed'] = is_module_uncompressed($data_module_graph['module_type']);
2018-06-01 13:58:29 +02:00
$data_module_graph['w_min'] = $module_data['min_warning'];
$data_module_graph['w_max'] = $module_data['max_warning'];
$data_module_graph['w_inv'] = $module_data['warning_inverse'];
$data_module_graph['c_min'] = $module_data['min_critical'];
$data_module_graph['c_max'] = $module_data['max_critical'];
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
$data_module_graph['module_id'] = $agent_module_id;
//stract data
$array_data_module = grafico_modulo_sparse_data(
$agent_module_id,
$date_array,
$data_module_graph,
$params,
2018-06-06 11:18:39 +02:00
$i
2018-06-01 13:58:29 +02:00
);
2018-05-18 14:22:39 +02:00
2018-06-01 13:58:29 +02:00
$series_suffix = $i;
//convert to array graph and weight
foreach ($array_data_module as $key => $value) {
$array_data[$key] = $value;
if($params_combined['weight_list'][$i] > 1){
foreach ($value['data'] as $k => $v) {
$array_data[$key]['data'][$k][1] = $v[1] * $params_combined['weight_list'][$i];
}
}
}
$max = $array_data['sum' . $i]['max'];
$min = $array_data['sum' . $i]['min'];
$avg = $array_data['sum' . $i]['avg'];
$percentil_value = $array_data['percentil' . $i]['data'][0][1];
2018-05-21 17:25:09 +02:00
2018-06-01 13:58:29 +02:00
if($config["fixed_graph"] == false){
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
//Work around for fixed the agents name with huge size chars.
$fixed_font_size = $config['font_size'];
//$array_events_alerts[$series_suffix] = $events;
$i++;
}
if($params_combined['projection'] && is_array($params_combined['projection'])){
2018-06-13 19:13:42 +02:00
$date_array_projection = max($params_combined['projection']);
$date_array['final_date'] = $date_array_projection[0] / 1000;
2018-06-01 13:58:29 +02:00
$array_data['projection']['data']= $params_combined['projection'];
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
//summatory and average series
if($params_combined['stacked'] == CUSTOM_GRAPH_AREA || $params_combined['stacked'] == CUSTOM_GRAPH_LINE) {
if($params_combined['summatory'] || $params_combined['average']) {
$array_data = combined_graph_summatory_average (
$array_data,
$params_combined['average'],
$params_combined['summatory'],
$params_combined['modules_series']
);
}
}
$series_type_array = series_type_graph_array(
$array_data,
2018-06-06 11:18:39 +02:00
$params_combined
2018-06-01 13:58:29 +02:00
);
$series_type = $series_type_array['series_type'];
$legend = $series_type_array['legend'];
2018-06-08 14:30:15 +02:00
$color = $series_type_array['color'];
2018-06-01 13:58:29 +02:00
$threshold_data = array();
if ($params_combined['from_interface']) {
$yellow_threshold = 0;
$red_threshold = 0;
$yellow_up = 0;
$red_up = 0;
$yellow_inverse = 0;
$red_inverse = 0;
$compare_warning = false;
$compare_critical = false;
$do_it_warning_min = true;
$do_it_critical_min = true;
$do_it_warning_max = true;
$do_it_critical_max = true;
$do_it_warning_inverse = true;
$do_it_critical_inverse = true;
foreach ($module_list as $index => $id_module) {
// Get module warning_min and critical_min
$warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$id_module);
$critical_min = db_get_value('min_critical','tagente_modulo','id_agente_modulo',$id_module);
if ($index == 0) {
$compare_warning = $warning_min;
}
else {
if ($compare_warning != $warning_min) {
$do_it_warning_min = false;
}
}
if ($index == 0) {
$compare_critical = $critical_min;
}
else {
if ($compare_critical != $critical_min) {
$do_it_critical_min = false;
}
}
}
if ($do_it_warning_min || $do_it_critical_min) {
foreach ($module_list as $index => $id_module) {
$warning_max = db_get_value('max_warning','tagente_modulo','id_agente_modulo',$id_module);
$critical_max = db_get_value('max_critical','tagente_modulo','id_agente_modulo',$id_module);
if ($index == 0) {
$yellow_up = $warning_max;
}
else {
if ($yellow_up != $warning_max) {
$do_it_warning_max = false;
}
}
if ($index == 0) {
$red_up = $critical_max;
}
else {
if ($red_up != $critical_max) {
$do_it_critical_max = false;
}
}
}
}
if ($do_it_warning_min || $do_it_critical_min) {
foreach ($module_list as $index => $id_module) {
$warning_inverse = db_get_value('warning_inverse','tagente_modulo','id_agente_modulo',$id_module);
$critical_inverse = db_get_value('critical_inverse','tagente_modulo','id_agente_modulo',$id_module);
if ($index == 0) {
$yellow_inverse = $warning_inverse;
}
else {
if ($yellow_inverse != $warning_inverse) {
$do_it_warning_inverse = false;
}
}
if ($index == 0) {
$red_inverse = $critical_inverse;
}
else {
if ($red_inverse != $critical_inverse) {
$do_it_critical_inverse = false;
}
}
}
}
if ($do_it_warning_min && $do_it_warning_max && $do_it_warning_inverse) {
$yellow_threshold = $compare_warning;
$threshold_data['yellow_threshold'] = $compare_warning;
$threshold_data['yellow_up'] = $yellow_up;
$threshold_data['yellow_inverse'] = (bool)$yellow_inverse;
2018-06-01 13:58:29 +02:00
}
if ($do_it_critical_min && $do_it_critical_max && $do_it_critical_inverse) {
$red_threshold = $compare_critical;
$threshold_data['red_threshold'] = $compare_critical;
$threshold_data['red_up'] = $red_up;
$threshold_data['red_inverse'] = (bool)$red_inverse;
2018-06-01 13:58:29 +02:00
}
2018-06-07 09:15:45 +02:00
$params['threshold_data'] = $threshold_data;
2018-06-01 13:58:29 +02:00
}
$output = area_graph(
$agent_module_id,
$array_data,
$legend,
$series_type,
2018-06-08 14:30:15 +02:00
$color,
2018-06-01 13:58:29 +02:00
$date_array,
$data_module_graph,
$params,
$water_mark,
$array_events_alerts
);
2018-06-06 11:18:39 +02:00
2018-06-01 13:58:29 +02:00
break;
2018-04-27 10:03:05 +02:00
case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD:
case CUSTOM_GRAPH_BULLET_CHART:
$number_elements = count($module_list);
2018-06-01 13:58:29 +02:00
if($params_combined['stacked'] == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
2018-04-27 10:03:05 +02:00
$acumulador = 0;
foreach ($module_list as $module_item) {
$module = $module_item;
$query_last_value = sprintf('
SELECT datos
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp < %d
ORDER BY utimestamp DESC',
2018-06-01 13:58:29 +02:00
$module, $params['date']);
2018-04-27 10:03:05 +02:00
$temp_data = db_get_value_sql($query_last_value);
if ($acumulador < $temp_data){
$acumulador = $temp_data;
}
}
}
2018-06-01 13:58:29 +02:00
2018-04-27 10:03:05 +02:00
foreach ($module_list as $module_item) {
$automatic_custom_graph_meta = false;
if ($config['metaconsole']) {
// Automatic custom graph from the report template in metaconsole
if (is_array($module_list[$i])) {
$server = metaconsole_get_connection_by_id ($module_item['server']);
metaconsole_connect($server);
$automatic_custom_graph_meta = true;
}
}
2018-04-26 10:24:37 +02:00
2018-04-27 10:03:05 +02:00
if ($automatic_custom_graph_meta)
$module = $module_item['module'];
else
$module = $module_item;
$search_in_history_db = db_search_in_history_db($datelimit);
$temp[$module] = modules_get_agentmodule($module);
$query_last_value = sprintf('
SELECT datos
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp < %d
ORDER BY utimestamp DESC',
2018-06-01 13:58:29 +02:00
$module, $params['date']);
2018-04-27 10:03:05 +02:00
$temp_data = db_get_value_sql($query_last_value);
if ($temp_data) {
if (is_numeric($temp_data))
$value = $temp_data;
else
$value = count($value);
}
else {
2018-06-06 11:18:39 +02:00
$value = false;
2018-04-27 10:03:05 +02:00
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if ( !empty($params_combined['labels']) && isset($params_combined['labels'][$module]) ){
$label = io_safe_input($params_combined['labels'][$module]);
2018-04-27 10:03:05 +02:00
}else{
$alias = db_get_value ("alias","tagente","id_agente",$temp[$module]['id_agente']);
$label = $alias . ': ' . $temp[$module]['nombre'];
}
2018-04-26 10:24:37 +02:00
2018-04-27 10:03:05 +02:00
$temp[$module]['label'] = $label;
$temp[$module]['value'] = $value;
2018-06-01 13:58:29 +02:00
$temp_max = reporting_get_agentmodule_data_max($module, $params['period'], $params['date']);
2018-04-27 10:03:05 +02:00
if ($temp_max < 0)
$temp_max = 0;
if (isset($acumulador)){
$temp[$module]['max'] = $acumulador;
}else{
$temp[$module]['max'] = ($temp_max === false) ? 0 : $temp_max;
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
$temp_min = reporting_get_agentmodule_data_min($module, $params['period'], $params['date']);
2018-04-27 10:03:05 +02:00
if ($temp_min < 0)
$temp_min = 0;
$temp[$module]['min'] = ($temp_min === false) ? 0 : $temp_min;
2018-04-26 10:24:37 +02:00
2018-04-27 10:03:05 +02:00
if ($config['metaconsole']) {
// Automatic custom graph from the report template in metaconsole
if (is_array($module_list[0])) {
metaconsole_restore_db();
}
}
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
$graph_values = $temp;
if(!$params['vconsole']){
$width = 1024;
$height = 50;
}
else{
$height = $height/$number_elements;
}
2018-06-06 11:18:39 +02:00
2018-06-08 14:30:15 +02:00
$color = color_graph_array();
2018-06-01 13:58:29 +02:00
$output = stacked_bullet_chart(
$graph_values,
$width,
$height,
$color,
$module_name_list,
$long_index,
ui_get_full_url("images/image_problem_area_small.png", false, false, false),
"",
"",
$water_mark,
$config['fontpath'],
($config['font_size']+1),
"",
$ttl,
$homeurl,
$background_color
);
2018-06-06 11:18:39 +02:00
2018-04-27 10:03:05 +02:00
break;
2018-06-01 13:58:29 +02:00
case CUSTOM_GRAPH_GAUGE:
$i = 0;
$number_elements = count($module_list);
2018-04-27 10:03:05 +02:00
foreach ($module_list as $module_item) {
$automatic_custom_graph_meta = false;
if ($config['metaconsole']) {
// Automatic custom graph from the report template in metaconsole
if (is_array($module_list[$i])) {
$server = metaconsole_get_connection_by_id ($module_item['server']);
metaconsole_connect($server);
$automatic_custom_graph_meta = true;
}
}
2018-04-26 10:24:37 +02:00
2018-04-27 10:03:05 +02:00
if ($automatic_custom_graph_meta)
$module = $module_item['module'];
else
$module = $module_item;
2018-06-01 13:58:29 +02:00
$temp[$module] = modules_get_agentmodule($module);
2018-04-27 10:03:05 +02:00
$query_last_value = sprintf('
SELECT datos
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp < %d
ORDER BY utimestamp DESC',
2018-06-01 13:58:29 +02:00
$module, $params['date']);
2018-04-27 10:03:05 +02:00
$temp_data = db_get_value_sql($query_last_value);
2018-06-01 13:58:29 +02:00
if ( $temp_data ) {
if (is_numeric($temp_data))
$value = $temp_data;
else
$value = count($value);
}
else {
$value = false;
}
$temp[$module]['label'] = ($params_combined['labels'][$module] != '') ? $params_combined['labels'][$module] : $temp[$module]['nombre'];
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
$temp[$module]['value'] = $value;
$temp[$module]['label'] = ui_print_truncate_text($temp[$module]['label'],"module_small",false,true,false,"..");
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if ($temp[$module]['unit'] == '%') {
$temp[$module]['min'] = 0;
$temp[$module]['max'] = 100;
2018-04-27 10:03:05 +02:00
}
2018-06-01 13:58:29 +02:00
else {
$min = $temp[$module]['min'];
if ($temp[$module]['max'] == 0)
$max = reporting_get_agentmodule_data_max($module, $params['period'], $params['date']);
else
$max = $temp[$module]['max'];
$temp[$module]['min'] = ($min == 0 ) ? 0 : $min;
$temp[$module]['max'] = ($max == 0 ) ? 100 : $max;
}
$temp[$module]['gauge'] = uniqid('gauge_');
2018-04-26 10:24:37 +02:00
2018-04-27 10:03:05 +02:00
if ($config['metaconsole']) {
// Automatic custom graph from the report template in metaconsole
if (is_array($module_list[0])) {
metaconsole_restore_db();
}
}
2018-06-01 13:58:29 +02:00
$i++;
2018-04-27 10:03:05 +02:00
}
2018-06-01 13:58:29 +02:00
$graph_values = $temp;
2018-06-08 14:30:15 +02:00
$color = color_graph_array();
if(!$params['vconsole']){
$width = 200;
$height = 200;
}
else{
$width = $width/$number_elements;
$height = $height/$number_elements;
}
2018-06-06 11:18:39 +02:00
2018-06-01 13:58:29 +02:00
$output = stacked_gauge(
$graph_values,
$width,
$height,
$color,
$module_name_list,
ui_get_full_url("images/image_problem_area_small.png", false, false, false),
$config['fontpath'],
$fixed_font_size,
"",
2018-06-06 11:18:39 +02:00
$homeurl
2018-06-01 13:58:29 +02:00
);
2018-04-27 10:03:05 +02:00
break;
2018-06-01 13:58:29 +02:00
case CUSTOM_GRAPH_HBARS:
case CUSTOM_GRAPH_VBARS:
$label = '';
2018-04-27 10:03:05 +02:00
foreach ($module_list as $module_item) {
$automatic_custom_graph_meta = false;
if ($config['metaconsole']) {
// Automatic custom graph from the report template in metaconsole
if (is_array($module_list[$i])) {
$server = metaconsole_get_connection_by_id ($module_item['server']);
metaconsole_connect($server);
$automatic_custom_graph_meta = true;
}
}
2018-04-26 10:24:37 +02:00
2018-04-27 10:03:05 +02:00
if ($automatic_custom_graph_meta)
$module = $module_item['module'];
else
$module = $module_item;
2018-06-01 13:58:29 +02:00
$module_data = modules_get_agentmodule($module);
2018-04-27 10:03:05 +02:00
$query_last_value = sprintf('
SELECT datos
FROM tagente_datos
WHERE id_agente_modulo = %d
AND utimestamp < %d
ORDER BY utimestamp DESC',
2018-06-01 13:58:29 +02:00
$module, $params['date']);
2018-04-27 10:03:05 +02:00
$temp_data = db_get_value_sql($query_last_value);
2018-06-01 13:58:29 +02:00
$agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($module));
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if (!empty($params_combined['labels']) && isset($params_combined['labels'][$module]) ){
$label = $params_combined['labels'][$module];
2018-04-27 10:03:05 +02:00
}else {
2018-06-01 13:58:29 +02:00
$alias = db_get_value ("alias","tagente","id_agente",$module_data['id_agente']);
$label = $alias . " - " .$module_data['nombre'];
2018-04-27 10:03:05 +02:00
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
$temp[$label]['g'] = round($temp_data,4);
2018-04-27 10:03:05 +02:00
if ($config['metaconsole']) {
// Automatic custom graph from the report template in metaconsole
if (is_array($module_list[0])) {
metaconsole_restore_db();
}
}
}
2018-06-01 13:58:29 +02:00
2018-06-08 14:30:15 +02:00
$color = color_graph_array();
2018-06-01 13:58:29 +02:00
$graph_values = $temp;
if(!$params['vconsole']){
$width = 1024;
$height = 500;
}
2018-06-06 11:18:39 +02:00
$flash_charts = true;
2018-06-01 13:58:29 +02:00
if($params_combined['stacked'] == CUSTOM_GRAPH_HBARS){
$output = hbar_graph(
2018-06-06 11:18:39 +02:00
true,
2018-06-01 13:58:29 +02:00
$graph_values,
$width,
$height,
$color,
$module_name_list,
$long_index,
ui_get_full_url("images/image_problem_area_small.png", false, false, false),
"",
"",
$water_mark,
$config['fontpath'],
$fixed_font_size,
"",
$ttl,
$homeurl,
$background_color,
'#c1c1c1'
2018-06-01 13:58:29 +02:00
);
}
if($params_combined['stacked'] == CUSTOM_GRAPH_VBARS){
$output = vbar_graph(
2018-06-06 11:18:39 +02:00
true,
2018-06-01 13:58:29 +02:00
$graph_values,
$width,
$height,
$color,
$module_name_list,
$long_index,
ui_get_full_url("images/image_problem_area_small.png", false, false, false),
"",
"",
$water_mark,
$config['fontpath'],
$fixed_font_size,
"",
$ttl,
$homeurl,
$background_color,
true,
false,
"#c1c1c1"
2018-06-01 13:58:29 +02:00
);
}
2018-04-26 10:24:37 +02:00
2018-04-27 10:03:05 +02:00
break;
2018-06-01 13:58:29 +02:00
case CUSTOM_GRAPH_PIE:
$total_modules = 0;
2018-04-27 10:03:05 +02:00
foreach ($module_list as $module_item) {
$automatic_custom_graph_meta = false;
if ($config['metaconsole']) {
// Automatic custom graph from the report template in metaconsole
if (is_array($module_list[$i])) {
$server = metaconsole_get_connection_by_id ($module_item['server']);
metaconsole_connect($server);
$automatic_custom_graph_meta = true;
}
}
2018-04-26 10:24:37 +02:00
2018-04-27 10:03:05 +02:00
if ($automatic_custom_graph_meta)
$module = $module_item['module'];
else
$module = $module_item;
2018-06-01 13:58:29 +02:00
$data_module = modules_get_agentmodule($module);
2018-04-27 10:03:05 +02:00
$query_last_value = sprintf('
SELECT datos
FROM tagente_datos
WHERE id_agente_modulo = %d
2018-06-01 13:58:29 +02:00
AND utimestamp > %d
2018-04-27 10:03:05 +02:00
AND utimestamp < %d
ORDER BY utimestamp DESC',
2018-06-01 13:58:29 +02:00
$module, $datelimit, $params['date']);
2018-04-27 10:03:05 +02:00
$temp_data = db_get_value_sql($query_last_value);
2018-06-01 13:58:29 +02:00
if ( $temp_data ){
2018-04-27 10:03:05 +02:00
if (is_numeric($temp_data))
$value = $temp_data;
else
$value = count($value);
}
else {
$value = false;
}
2018-06-01 13:58:29 +02:00
$total_modules += $value;
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if ( !empty($params_combined['labels']) && isset($params_combined['labels'][$module]) ){
$label = io_safe_output($params_combined['labels'][$module]);
}else {
$alias = db_get_value ("alias","tagente","id_agente",$data_module['id_agente']);
$label = io_safe_output($alias . ": " . $data_module['nombre']);
2018-04-27 10:03:05 +02:00
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
$temp[$label] = array('value'=>$value,
'unit'=>$data_module['unit']);
2018-04-27 10:03:05 +02:00
if ($config['metaconsole']) {
// Automatic custom graph from the report template in metaconsole
if (is_array($module_list[0])) {
metaconsole_restore_db();
}
}
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
$temp['total_modules'] = $total_modules;
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
$graph_values = $temp;
2018-04-26 10:24:37 +02:00
if(!$params['vconsole']){
$width = 1024;
$height = 500;
}
2018-06-06 11:18:39 +02:00
2018-06-08 14:30:15 +02:00
$color = color_graph_array();
2018-06-01 13:58:29 +02:00
$output = ring_graph(
2018-06-06 11:18:39 +02:00
true,
2018-06-01 13:58:29 +02:00
$graph_values,
$width,
$height,
$others_str,
$homeurl,
$water_mark,
$config['fontpath'],
($config['font_size']+1),
$ttl,
false,
$color,
false,
$background_color
);
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
break;
2017-10-31 11:51:19 +01:00
}
2018-04-26 10:24:37 +02:00
2018-06-01 13:58:29 +02:00
if ($params_combined['return']){
return $output;
}
2018-06-01 13:58:29 +02:00
echo $output;
}
2018-05-21 17:25:09 +02:00
function combined_graph_summatory_average ($array_data, $average = false, $summatory = false, $modules_series = false, $baseline = false){
2018-05-18 14:22:39 +02:00
if(isset($array_data) && is_array($array_data)){
foreach ($array_data as $key => $value) {
if(strpos($key, 'sum') !== false){
$data_array_reverse[$key] = array_reverse($value['data']);
if(!$modules_series) {
unset($array_data[$key]);
}
}
}
if(isset($data_array_reverse) && is_array($data_array_reverse)){
$array_sum_reverse = array();
$array_avg_reverse = array();
$data_array_prev = false;
$data_array_pop = array();
$count = 0;
while(count($data_array_reverse['sum0']) > 0){
foreach ($data_array_reverse as $key_reverse => $value_reverse) {
if(is_array($value_reverse) && count($value_reverse) > 0){
$data_array_pop[$key_reverse] = array_pop($data_array_reverse[$key_reverse]);
}
}
if(isset($data_array_pop) && is_array($data_array_pop)){
$acum_data = 0;
$acum_array = array();
$sum_data = 0;
$count_pop = 0;
foreach ($data_array_pop as $key_pop => $value_pop) {
if( $value_pop[0] > $acum_data ){
if($acum_data != 0){
$sum_data = $sum_data + $data_array_prev[$key_pop][1];
$data_array_reverse[$key_pop][] = $value_pop;
$data_array_prev[$acum_key] = $acum_array;
}
else{
if($data_array_prev[$key_pop] == false){
$data_array_prev[$key_pop] = $value_pop;
}
$acum_key = $key_pop;
$acum_data = $value_pop[0];
$acum_array = $value_pop;
$sum_data = $value_pop[1];
}
}
elseif($value_pop[0] < $acum_data){
$sum_data = $sum_data + $data_array_prev[$key_pop][1];
$data_array_reverse[$acum_key][] = $acum_array;
$data_array_prev[$key_pop] = $value_pop;
$acum_key = $key_pop;
$acum_data = $value_pop[0];
$acum_array = $value_pop;
}
elseif($value_pop[0] == $acum_data){
$data_array_prev[$key_pop] = $value_pop;
$sum_data += $value_pop[1];
}
$count_pop++;
}
2018-05-21 17:25:09 +02:00
if($summatory){
$array_sum_reverse[$count][0] = $acum_data;
$array_sum_reverse[$count][1] = $sum_data;
}
if($average){
2018-05-18 14:22:39 +02:00
$array_avg_reverse[$count][0] = $acum_data;
$array_avg_reverse[$count][1] = $sum_data / $count_pop;
2018-05-21 17:25:09 +02:00
}
2018-05-18 14:22:39 +02:00
}
$count++;
}
2018-05-21 17:25:09 +02:00
if($summatory && isset($array_sum_reverse) && is_array($array_sum_reverse) && count($array_sum_reverse) > 0){
$array_data['summatory']['data'] = $array_sum_reverse;
$array_data['summatory']['color'] = 'purple';
}
if($average && isset($array_avg_reverse) && is_array($array_avg_reverse) && count($array_avg_reverse) > 0){
if($baseline){
$array_data['baseline']['data'] = $array_avg_reverse;
$array_data['baseline']['color'] = 'green';
}
else{
$array_data['average']['data'] = $array_avg_reverse;
$array_data['average']['color'] = 'orange';
}
}
2018-05-18 14:22:39 +02:00
}
2018-05-21 17:25:09 +02:00
return $array_data;
2018-05-18 14:22:39 +02:00
}
else{
return false;
}
}
/**
* Print a graph with access data of agents
2018-04-27 10:03:05 +02:00
*
* @param integer id_agent Agent ID
* @param integer width pie graph width
* @param integer height pie graph height
* @param integer period time period
* @param bool return or echo the result flag
*/
2018-06-06 11:18:39 +02:00
function graphic_agentaccess ($id_agent, $width, $height, $period = 0, $return = false, $tree = false) {
global $config;
global $graphic_type;
2018-02-27 16:28:00 +01:00
2018-06-06 11:18:39 +02:00
$date = get_system_time();
$datelimit = $date - $period;
$data_array = array ();
$data = db_get_all_rows_sql(
"SELECT count(*) as data, min(utimestamp) as utimestamp
FROM tagent_access
WHERE id_agent = $id_agent
AND utimestamp > $datelimit
AND utimestamp < $date
GROUP by ROUND(utimestamp / 1800)"
2018-06-06 11:18:39 +02:00
);
2018-02-27 16:28:00 +01:00
2018-06-06 11:18:39 +02:00
if(isset($data) && is_array($data)){
foreach ($data as $key => $value) {
$data_array['Agent access']['data'][$key][0] = $value['utimestamp'] * 1000;
$data_array['Agent access']['data'][$key][1] = $value['data'];
}
2018-06-06 11:18:39 +02:00
$data_array['Agent access']['color'] = 'green';
}
else{
if ($return) {
return graph_nodata_image($width, $height);
}
2018-06-06 11:18:39 +02:00
else{
echo graph_nodata_image($width, $height);
}
}
2018-02-27 16:28:00 +01:00
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
2018-06-06 11:18:39 +02:00
$params =array(
'agent_module_id' => false,
'period' => $period,
'width' => $width,
'height' => $height,
'unit' => $unit,
'only_image' => $only_image,
'homeurl' => $homeurl,
'menu' => true,
'backgroundColor' => 'transparent',
2018-06-06 11:18:39 +02:00
'type_graph' => 'area',
'font' => $config['fontpath'],
2018-06-13 19:13:42 +02:00
'font_size' => $config['font_size'],
2018-06-06 11:18:39 +02:00
'array_data_create' => $data_array,
'show_overview' => false,
'show_export_csv' => false,
'vconsole' => true,
'show_legend' => false,
'grid_color' => 'grey'
2018-06-06 11:18:39 +02:00
);
2018-02-27 16:28:00 +01:00
if ($return) {
2018-06-06 11:18:39 +02:00
return grafico_modulo_sparse($params);
}
else {
2018-06-06 11:18:39 +02:00
echo grafico_modulo_sparse($params);
}
}
/**
* Print a pie graph with alerts defined/fired data
*
* @param integer Number of defined alerts
* @param integer Number of fired alerts
* @param integer width pie graph width
* @param integer height pie graph height
* @param bool return or echo flag
*/
function graph_alert_status ($defined_alerts, $fired_alerts, $width = 300, $height = 200, $return = false) {
global $config;
$data = array(__('Not fired alerts') => $defined_alerts - $fired_alerts, __('Fired alerts') => $fired_alerts);
$colors = array(COL_NORMAL, COL_ALERTFIRED);
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
$out = pie2d_graph($config['flash_charts'], $data, $width, $height, __("other"),
'', '', $config['fontpath'], $config['font_size'], 1, "hidden", $colors);
if ($return) {
return $out;
}
else {
echo $out;
}
}
// If any value is negative, truncate it to 0
function truncate_negatives(&$element) {
if ($element < 0) {
$element = 0;
}
}
/**
* Print a pie graph with events data of agent or all agents (if id_agent = false)
*
* @param integer id_agent Agent ID
* @param integer width pie graph width
* @param integer height pie graph height
* @param bool return or echo flag
* @param bool show_not_init flag
*/
function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $return = false, $show_not_init = false, $data_agents=false) {
global $config;
if ($data_agents == false) {
$groups = implode(',', array_keys(users_get_groups(false, 'AR', false)));
$data = db_get_row_sql(sprintf('SELECT
SUM(critical_count) AS Critical,
SUM(warning_count) AS Warning,
SUM(normal_count) AS Normal,
SUM(unknown_count) AS Unknown
%s
FROM tagente ta LEFT JOIN tagent_secondary_group tasg
ON ta.id_agente = tasg.id_agent
WHERE
ta.disabled = 0 AND
%s
(ta.id_grupo IN (%s) OR tasg.id_group IN (%s))',
$show_not_init ? ', SUM(notinit_count) "Not init"' : '',
empty($id_agent) ? '' : "ta.id_agente = $id_agent AND",
$groups,
$groups
));
} else {
$data = $data_agents;
}
if (empty($data)) {
$data = array();
}
array_walk($data, 'truncate_negatives');
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
//$colors = array(COL_CRITICAL, COL_WARNING, COL_NORMAL, COL_UNKNOWN);
$colors[__('Critical')] = COL_CRITICAL;
$colors[__('Warning')] = COL_WARNING;
$colors[__('Normal')] = COL_NORMAL;
$colors[__('Unknown')] = COL_UNKNOWN;
if ($show_not_init) {
$colors[__('Not init')] = COL_NOTINIT;
}
2013-05-23 Sergio Martin <sergio.martin@artica.es> * include/functions_html.php include/styles/pandora_minimal.css include/styles/dialog.css include/styles/menu.css include/styles/jquery-ui-1.10.0.custom.css include/functions_events.php operation/events/events_list.php include/functions_snmp_browser.php include/styles/pandora.css: A lot of graphic changes including events form and snmp browser layout * include/ajax/module.php include/functions_ui.php include/functions.php include/functions_agents.php include/functions_graph.php include/graphs/functions_gd.php include/graphs/fgraph.php include/functions_reporting.php include/functions_filemanager.php include/javascript/pandora_snmp_browser.js include/functions_treeview.php include/constants.php index.php extensions/net_tools.php extensions/pandora_logs.php extensions/ssh_gateway.php extensions/update_manager/settings.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/visual_console/render_view.php operation/users/user_edit.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/estado_monitores.php operation/agentes/agent_fields.php operation/agentes/stat_win.php operation/servers/recon_view.php operation/integria_incidents/incident_detail.php operation/netflow/nf_live_view.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/db/db_refine.php godmode/db/db_event.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/modificar_agente.php godmode/agentes/module_manager_editor.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/setup/news.php godmode/setup/links.php godmode/setup/gis.php godmode/users/configure_profile.php godmode/massive/massive_add_alerts.php godmode/massive/massive_delete_profiles.php godmode/modules/module_list.php godmode/reporting/visual_console_builder.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/tag/tag.php godmode/tag/edit_tag.php: Changing the old way of print errors to encapsulated UI function to unify styles * images/status_sets/color_text/agent_no_monitors.png images/status_sets/color_text/agent_no_monitors_ball.pn images/status_sets/color_text/agent_down_ball.png images/status_sets/color_text/agent_down.png images/status_sets/default/agent_no_monitors.png images/status_sets/default/agent_no_monitors_ball.png images/status_sets/default/agent_down_ball.png images/status_sets/default/agent_down.png: Modify some status set images * images/gis_map/icons/star.default.png images/gis_map/icons/cross.warning.png images/gis_map/icons/star.bad.png images/gis_map/icons/cross.ok.png images/gis_map/icons/marker.default.png images/gis_map/icons/square_marker.warning.png images/gis_map/icons/circle.warning.png images/gis_map/icons/marker.bad.png images/gis_map/icons/square_marker.ok.png images/gis_map/icons/circle.ok.png images/gis_map/icons/triangle.warning.png images/gis_map/icons/cross.default.png images/gis_map/icons/star.warning.png images/gis_map/icons/triangle.ok.png images/gis_map/icons/cross.bad.png images/gis_map/icons/star.ok.png images/gis_map/icons/square_marker.default.png images/gis_map/icons/circle.default.png images/gis_map/icons/marker.warning.png images/gis_map/icons/square_marker.bad.png images/gis_map/icons/circle.bad.png images/gis_map/icons/triangle.default.png images/gis_map/icons/marker.ok.png images/gis_map/icons/triangle.bad.png: Change whole the gis icons by new ones * images/os_icons/so_win.png images/os_icons/so_linux.png images/os_icons/so_mac.png images/os_icons/so_cisco.png images/os_icons/so_vmware.png images/os_icons/so_bsd.png images/os_icons/android.png images/os_icons/so_aix.png images/os_icons/so_other.png images/os_icons/so_hpux.png images/os_icons/network.png images/os_icons/embedded.png: Reduce the operating system icons size * images/vnc.png images/op_inventory.png images/refresh_mc.png images/heart.png images/service.png images/go.png images/graphmenu_arrow_hide.png images/submenu_tree_first.png images/config_mc.png images/cross_double.png images/wand.png images/expand.png images/submenu_tree_middle.png images/visual_console.png images/down.png images/chart_curve_threshold.png images/people_1.png images/cancel.png images/graphmenu_arrow.png images/people_2.png images/collapse.png images/camera_mc.png: Improve a lot of icons git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8198 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-05-23 17:42:32 +02:00
if (array_sum($data) == 0) {
$data = array();
}
$out = pie2d_graph($config['flash_charts'], $data, $width, $height,
__("other"), ui_get_full_url(false, false, false, false), '',
$config['fontpath'], $config['font_size'], 1, "hidden", $colors);
if ($return) {
return $out;
}
else {
echo $out;
}
}
/**
* Print a pie graph with events data of agent
*
* @param integer width pie graph width
* @param integer height pie graph height
* @param integer id_agent Agent ID
*/
function graph_event_module ($width = 300, $height = 200, $id_agent) {
global $config;
global $graphic_type;
// Fix: tag filters implemented! for tag functionality groups have to be all user_groups (propagate ACL funct!)
$groups = users_get_groups($config["id_user"]);
$tags_condition = tags_get_acl_tags($config['id_user'], array_keys($groups), 'ER', 'event_condition', 'AND');
$data = array ();
$max_items = 6;
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT COUNT(id_evento) AS count_number,
id_agentmodule
FROM tevento
WHERE tevento.id_agente = %d %s
GROUP BY id_agentmodule ORDER BY count_number DESC LIMIT %d', $id_agent, $tags_condition, $max_items);
break;
case "oracle":
$sql = sprintf ('SELECT COUNT(id_evento) AS count_number,
id_agentmodule
FROM tevento
WHERE tevento.id_agente = %d AND rownum <= %d
GROUP BY id_agentmodule ORDER BY count_number DESC', $id_agent, $max_items);
break;
}
* include/functions_graph.php include/functions_html.php include/functions_messages.php include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/ajax/skins.ajax.php include/ajax/reporting.ajax.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/config_process.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_incidents.php include/api.php include/functions_reports.php include/functions_ui_renders.php extensions/insert_data.php extensions/system_info.php extensions/extension_uploader.php extensions/pandora_logs.php extensions/agents_modules.php extensions/update_manager.php extensions/ssh_console.php extensions/dbmanager.php extensions/vnc_view.php extensions/resource_registration.php extensions/resource_exportation.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php extensions/update_manager/settings.php extensions/update_manager/main.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/incidents/incident_statistics.php operation/search_modules.php operation/visual_console/render_view.php operation/visual_console/index.php operation/extensions.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/agent_fields.php operation/agentes/tactical.php operation/agentes/group_view.php operation/agentes/networkmap.php operation/agentes/stat_win.php operation/servers/view_server.php operation/servers/view_server_detail.php operation/menu.php operation/search_agents.php operation/search_graphs.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/integria_incidents/incident.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident_statistics.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_validate.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/search_reports.php operation/search_maps.php operation/search_users.php extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php mobile/index.php general/error_authconfig.php general/links_menu.php general/logon_ok.php general/error_dbconfig.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/db/db_audit.php godmode/db/db_sanity.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_event.php godmode/db/db_purge.php godmode/extensions.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/configure_field.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/configure_alert_command.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/setup/file_manager.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/gis_step_2.php godmode/setup/links.php godmode/setup/setup.php godmode/setup/os.php godmode/setup/performance.php godmode/setup/setup_auth.php godmode/setup/gis.php godmode/setup/os.builder.php godmode/setup/setup_visuals.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/users/user_list.php godmode/users/configure_profile.php godmode/gis_maps/configure_gis_map.php godmode/gis_maps/index.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_operations.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/manage_network_components_form.php godmode/modules/manage_nc_groups_form.php godmode/modules/manage_network_templates.php godmode/modules/module_list.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components_form_network.php godmode/modules/manage_network_templates_form.php godmode/modules/manage_network_components_form_wmi.php godmode/modules/manage_network_components.php godmode/modules/manage_nc_groups.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/visual_console_builder.preview.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/reporting/graph_builder.preview.php include/functions_db.php: Added some includes and functions of this code have "db_" prefix. * include/functions.php: Moved function check_login(), check_acl(), dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php. * include/functions_groups.php: Moved functions get_childrens(), safe_acl_group() and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(), get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(), get_group_name(), get_group_users() from functions_db.php to this code. * include/functions_profile.php: New library with profile functions. Moved functions get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(), delete_profile() from functions_db.php to this code. Added new parameter in function get_profile() to retrieve profiles with filter conditions applied. * include/functions_users.php: New library with users functions. Moved functions get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(), get_user_first_group(), user_access_to_agent() from funtions_db.php to this code. * godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile(). * include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(), get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(), check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(), agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(), get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(), get_agent_group() from functions_db.php to this code. * include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(), get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(), get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(), get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(), get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(), get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(), get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(), give_modulecategory_name(), give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(), get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(), get_modulegroup_name() from functions_db.php to this code. * include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(), get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(), get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(), get_agentmodule_last_status() from functions_db.php to this code. * include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion() from functions_db.php to this code. * include/functions_events.php: Moved functions get_group_events(), get_agent_events(), get_module_events() from functions_db.php to this code. * include/functions_servers.php: Moved functions get_server_name(), show_server_type(), check_server_status(), server_status() from functions_db.php to this code. * include/functions_network_profiles.php: Moved function get_networkprofile_name() from functions_db.php to this code. * include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y() from fucntions_db.php to this code. * include/functions_io.php: Moved function __() from functions_db.php to this code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
$events = db_get_all_rows_sql ($sql);
if ($events === false) {
if (! $graphic_type) {
return fs_error_image ();
}
graphic_error ();
return;
}
foreach ($events as $event) {
if ($event['id_agentmodule'] == 0) {
$key = __('System') . ' ('.$event['count_number'].')';
}
else {
$key = modules_get_agentmodule_name ($event['id_agentmodule']) .
' ('.$event['count_number'].')';
}
$data[$key] = $event["count_number"];
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, $width, $height, __("other"),
'', $water_mark, $config['fontpath'], $config['font_size'], 1, "bottom");
}
function progress_bar($progress, $width, $height, $title = '', $mode = 1, $value_text = false, $color = false, $options = false) {
global $config;
$out_of_lim_str = io_safe_output(__("Out of limits"));
$title = "";
2012-03-05 Miguel de Dios <miguel.dedios@artica.es> * extensions/update_manager/main.php, general/shortcut_bar.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.preview.php, include/functions_api.php, include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, operation/events/events_list.php, operation/netflow/nf_live_view.php: cleaned source code style. * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the enterprise feature that have been wrong for years. * general/header.php: changed to load the jquery-ui and jquery javascript library to last version. * extensions/insert_data.php, extensions/snmp_explorer.php, godmode/agentes/agent_manager.php, include/ajax/agent.php, include/javascript/pandora.js, operation/agentes/exportdata.php, operation/events/events.php: changed the unknow plugin autocomplete for the autocomple from jquery-ui. * include/functions_ui.php: cleaned source code style and into the function "ui_process_page_head" added the blacklist hardwrote for to use old jquery. * include/styles/jquery-ui-1.8.17.custom.css, include/javascript/jquery-1.7.1.min.js, include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last version of Jquery and Jquery-ui. Merge from the branch "pandora_4.0" * godmode/reporting/visual_console_builder.constans.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.editor.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/javascript/pandora_visual_console.js: changed the unknow plugin autocomplete for the autocomple from jquery-ui and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". * images/percentile_item.disabled.png, images/percentile_item.png: added images for button of percentile item (new item in visual map). * include/styles/pandora.css: added the style for the new button percentile item. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/functions_gd.php: cleaned source code style, and added the params to set text and color in the function "progress_bar" and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-03-05 18:56:56 +01:00
if ($value_text === false) {
$value_text = $progress . "%";
}
$colorRGB = '';
if ($color !== false) {
$colorRGB = html_html2rgb($color);
$colorRGB = implode('|', $colorRGB);
}
$class_tag = '';
$id_tag = '';
if ($options !== false) {
foreach ($options as $option_type => $option_value) {
if ($option_type == 'class')
$class_tag = ' class="' . $option_value . '" ';
else if ($option_type == 'id')
$id_tag = ' id="' . $option_value . '" ';
}
}
require_once("include_graph_dependencies.php");
include_graphs_dependencies($config['homedir'].'/');
$src = ui_get_full_url(
"/include/graphs/fgraph.php?graph_type=progressbar" .
"&width=".$width."&height=".$height."&progress=".$progress.
2012-03-05 Miguel de Dios <miguel.dedios@artica.es> * extensions/update_manager/main.php, general/shortcut_bar.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.preview.php, include/functions_api.php, include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, operation/events/events_list.php, operation/netflow/nf_live_view.php: cleaned source code style. * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the enterprise feature that have been wrong for years. * general/header.php: changed to load the jquery-ui and jquery javascript library to last version. * extensions/insert_data.php, extensions/snmp_explorer.php, godmode/agentes/agent_manager.php, include/ajax/agent.php, include/javascript/pandora.js, operation/agentes/exportdata.php, operation/events/events.php: changed the unknow plugin autocomplete for the autocomple from jquery-ui. * include/functions_ui.php: cleaned source code style and into the function "ui_process_page_head" added the blacklist hardwrote for to use old jquery. * include/styles/jquery-ui-1.8.17.custom.css, include/javascript/jquery-1.7.1.min.js, include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last version of Jquery and Jquery-ui. Merge from the branch "pandora_4.0" * godmode/reporting/visual_console_builder.constans.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.editor.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/javascript/pandora_visual_console.js: changed the unknow plugin autocomplete for the autocomple from jquery-ui and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". * images/percentile_item.disabled.png, images/percentile_item.png: added images for button of percentile item (new item in visual map). * include/styles/pandora.css: added the style for the new button percentile item. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/functions_gd.php: cleaned source code style, and added the params to set text and color in the function "progress_bar" and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-03-05 18:56:56 +01:00
"&mode=" . $mode . "&out_of_lim_str=".$out_of_lim_str .
"&title=".$title."&value_text=". $value_text .
"&colorRGB=". $colorRGB, false, false, false
);
return "<img title='" . $title . "' alt='" . $title . "'" . $class_tag . $id_tag .
" src='" . $src . "' />";
2012-03-05 Miguel de Dios <miguel.dedios@artica.es> * extensions/update_manager/main.php, general/shortcut_bar.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.preview.php, include/functions_api.php, include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, operation/events/events_list.php, operation/netflow/nf_live_view.php: cleaned source code style. * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the enterprise feature that have been wrong for years. * general/header.php: changed to load the jquery-ui and jquery javascript library to last version. * extensions/insert_data.php, extensions/snmp_explorer.php, godmode/agentes/agent_manager.php, include/ajax/agent.php, include/javascript/pandora.js, operation/agentes/exportdata.php, operation/events/events.php: changed the unknow plugin autocomplete for the autocomple from jquery-ui. * include/functions_ui.php: cleaned source code style and into the function "ui_process_page_head" added the blacklist hardwrote for to use old jquery. * include/styles/jquery-ui-1.8.17.custom.css, include/javascript/jquery-1.7.1.min.js, include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last version of Jquery and Jquery-ui. Merge from the branch "pandora_4.0" * godmode/reporting/visual_console_builder.constans.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.editor.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/javascript/pandora_visual_console.js: changed the unknow plugin autocomplete for the autocomple from jquery-ui and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". * images/percentile_item.disabled.png, images/percentile_item.png: added images for button of percentile item (new item in visual map). * include/styles/pandora.css: added the style for the new button percentile item. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/functions_gd.php: cleaned source code style, and added the params to set text and color in the function "progress_bar" and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-03-05 18:56:56 +01:00
}
2012-03-05 Miguel de Dios <miguel.dedios@artica.es> * extensions/update_manager/main.php, general/shortcut_bar.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.preview.php, include/functions_api.php, include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, operation/events/events_list.php, operation/netflow/nf_live_view.php: cleaned source code style. * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the enterprise feature that have been wrong for years. * general/header.php: changed to load the jquery-ui and jquery javascript library to last version. * extensions/insert_data.php, extensions/snmp_explorer.php, godmode/agentes/agent_manager.php, include/ajax/agent.php, include/javascript/pandora.js, operation/agentes/exportdata.php, operation/events/events.php: changed the unknow plugin autocomplete for the autocomple from jquery-ui. * include/functions_ui.php: cleaned source code style and into the function "ui_process_page_head" added the blacklist hardwrote for to use old jquery. * include/styles/jquery-ui-1.8.17.custom.css, include/javascript/jquery-1.7.1.min.js, include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last version of Jquery and Jquery-ui. Merge from the branch "pandora_4.0" * godmode/reporting/visual_console_builder.constans.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.editor.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/javascript/pandora_visual_console.js: changed the unknow plugin autocomplete for the autocomple from jquery-ui and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". * images/percentile_item.disabled.png, images/percentile_item.png: added images for button of percentile item (new item in visual map). * include/styles/pandora.css: added the style for the new button percentile item. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/functions_gd.php: cleaned source code style, and added the params to set text and color in the function "progress_bar" and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-03-05 18:56:56 +01:00
function progress_bubble($progress, $width, $height, $title = '', $mode = 1, $value_text = false, $color = false) {
global $config;
$hack_metaconsole = '';
if (defined('METACONSOLE'))
$hack_metaconsole = '../../';
$out_of_lim_str = io_safe_output(__("Out of limits"));
2012-03-05 Miguel de Dios <miguel.dedios@artica.es> * extensions/update_manager/main.php, general/shortcut_bar.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.preview.php, include/functions_api.php, include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, operation/events/events_list.php, operation/netflow/nf_live_view.php: cleaned source code style. * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the enterprise feature that have been wrong for years. * general/header.php: changed to load the jquery-ui and jquery javascript library to last version. * extensions/insert_data.php, extensions/snmp_explorer.php, godmode/agentes/agent_manager.php, include/ajax/agent.php, include/javascript/pandora.js, operation/agentes/exportdata.php, operation/events/events.php: changed the unknow plugin autocomplete for the autocomple from jquery-ui. * include/functions_ui.php: cleaned source code style and into the function "ui_process_page_head" added the blacklist hardwrote for to use old jquery. * include/styles/jquery-ui-1.8.17.custom.css, include/javascript/jquery-1.7.1.min.js, include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last version of Jquery and Jquery-ui. Merge from the branch "pandora_4.0" * godmode/reporting/visual_console_builder.constans.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.editor.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/javascript/pandora_visual_console.js: changed the unknow plugin autocomplete for the autocomple from jquery-ui and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". * images/percentile_item.disabled.png, images/percentile_item.png: added images for button of percentile item (new item in visual map). * include/styles/pandora.css: added the style for the new button percentile item. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/functions_gd.php: cleaned source code style, and added the params to set text and color in the function "progress_bar" and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-03-05 18:56:56 +01:00
$title = "";
if ($value_text === false) {
$value_text = $progress . "%";
}
$colorRGB = '';
if ($color !== false) {
$colorRGB = html_html2rgb($color);
$colorRGB = implode('|', $colorRGB);
}
require_once("include_graph_dependencies.php");
include_graphs_dependencies($config['homedir'].'/');
return "<img title='" . $title . "' alt='" . $title . "'" .
" src='" . $config['homeurl'] . $hack_metaconsole . "/include/graphs/fgraph.php?graph_type=progressbubble" .
2012-03-05 Miguel de Dios <miguel.dedios@artica.es> * extensions/update_manager/main.php, general/shortcut_bar.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.preview.php, include/functions_api.php, include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, operation/events/events_list.php, operation/netflow/nf_live_view.php: cleaned source code style. * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the enterprise feature that have been wrong for years. * general/header.php: changed to load the jquery-ui and jquery javascript library to last version. * extensions/insert_data.php, extensions/snmp_explorer.php, godmode/agentes/agent_manager.php, include/ajax/agent.php, include/javascript/pandora.js, operation/agentes/exportdata.php, operation/events/events.php: changed the unknow plugin autocomplete for the autocomple from jquery-ui. * include/functions_ui.php: cleaned source code style and into the function "ui_process_page_head" added the blacklist hardwrote for to use old jquery. * include/styles/jquery-ui-1.8.17.custom.css, include/javascript/jquery-1.7.1.min.js, include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last version of Jquery and Jquery-ui. Merge from the branch "pandora_4.0" * godmode/reporting/visual_console_builder.constans.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.editor.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/javascript/pandora_visual_console.js: changed the unknow plugin autocomplete for the autocomple from jquery-ui and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". * images/percentile_item.disabled.png, images/percentile_item.png: added images for button of percentile item (new item in visual map). * include/styles/pandora.css: added the style for the new button percentile item. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/functions_gd.php: cleaned source code style, and added the params to set text and color in the function "progress_bar" and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-03-05 18:56:56 +01:00
"&width=".$width."&height=".$height."&progress=".$progress.
"&mode=" . $mode . "&out_of_lim_str=".$out_of_lim_str .
"&title=".$title."&value_text=". $value_text .
2012-03-05 Miguel de Dios <miguel.dedios@artica.es> * extensions/update_manager/main.php, general/shortcut_bar.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.preview.php, include/functions_api.php, include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, operation/events/events_list.php, operation/netflow/nf_live_view.php: cleaned source code style. * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the enterprise feature that have been wrong for years. * general/header.php: changed to load the jquery-ui and jquery javascript library to last version. * extensions/insert_data.php, extensions/snmp_explorer.php, godmode/agentes/agent_manager.php, include/ajax/agent.php, include/javascript/pandora.js, operation/agentes/exportdata.php, operation/events/events.php: changed the unknow plugin autocomplete for the autocomple from jquery-ui. * include/functions_ui.php: cleaned source code style and into the function "ui_process_page_head" added the blacklist hardwrote for to use old jquery. * include/styles/jquery-ui-1.8.17.custom.css, include/javascript/jquery-1.7.1.min.js, include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last version of Jquery and Jquery-ui. Merge from the branch "pandora_4.0" * godmode/reporting/visual_console_builder.constans.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.editor.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/javascript/pandora_visual_console.js: changed the unknow plugin autocomplete for the autocomple from jquery-ui and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". * images/percentile_item.disabled.png, images/percentile_item.png: added images for button of percentile item (new item in visual map). * include/styles/pandora.css: added the style for the new button percentile item. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/functions_gd.php: cleaned source code style, and added the params to set text and color in the function "progress_bar" and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-03-05 18:56:56 +01:00
"&colorRGB=". $colorRGB . "' />";
}
function graph_sla_slicebar ($id, $period, $sla_min, $sla_max, $date, $daysWeek = null, $time_from = null, $time_to = null, $width, $height, $home_url, $ttl = 1, $data = false, $round_corner = null) {
global $config;
if ($round_corner === null) {
$round_corner = $config['round_corner'];
}
// If the data is not provided, we got it
if ($data === false) {
$data = reporting_get_agentmodule_sla_array ($id, $period,
$sla_min, $sla_max, $date, $daysWeek, null, null);
}
$col_planned_downtime = '#20973F';
$colors = array(1 => COL_NORMAL,
2 => COL_WARNING,
3 => COL_CRITICAL,
4 => COL_UNKNOWN,
2018-04-11 16:22:16 +02:00
5 => COL_DOWNTIME,
6 => COL_NOTINIT,
2018-04-11 16:22:16 +02:00
7 => COL_IGNORED);
return slicesbar_graph($data, $period, $width, $height, $colors,
$config['fontpath'], $round_corner, $home_url, $ttl);
}
/**
* Print a pie graph with purge data of agent
*
* @param integer id_agent ID of agent to show
* @param integer width pie graph width
* @param integer height pie graph height
*/
function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
global $config;
global $graphic_type;
$filter = array();
if ($id_agent < 1) {
$query = "";
}
else {
$modules = agents_get_modules($id_agent);
$module_ids = array_keys($modules);
if (!empty($module_ids))
$filter['id_agente_modulo'] = $module_ids;
}
// All data (now)
$time_now = time();
// 1 day ago
$time_1day = $time_now - SECONDS_1DAY;
// 1 week ago
$time_1week = $time_now - SECONDS_1WEEK;
// 1 month ago
$time_1month = $time_now - SECONDS_1MONTH;
// Three months ago
$time_3months = $time_now - SECONDS_3MONTHS;
$query_error = false;
// Data from 1 day ago
$num_1day = 0;
2015-10-26 10:03:42 +01:00
$num_1day += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1day);
$num_1day += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1day);
$num_1day += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1day);
if ($num_1day >= 0) {
// Data from 1 week ago
$num_1week = 0;
2015-10-26 10:03:42 +01:00
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1week . '
AND utimestamp < ' . $time_1day);
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1week . '
AND utimestamp < ' . $time_1day);
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1week . '
AND utimestamp < ' . $time_1day);
if ($num_1week >= 0) {
if ($num_1week > 0) {
$num_1week = 0;
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1week);
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1week);
$num_1week += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1week);
}
// Data from 1 month ago
$num_1month = 0;
2015-10-26 10:03:42 +01:00
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1month . '
AND utimestamp < ' . $time_1week);
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1month . '
AND utimestamp < ' . $time_1week);
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1month . '
AND utimestamp < ' . $time_1week);
if ($num_1month >= 0) {
if ($num_1month > 0) {
$num_1month = 0;
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_1month);
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > ' . $time_1month);
$num_1month += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > ' . $time_1month);
}
// Data from 3 months ago
$num_3months = 0;
2015-10-26 10:03:42 +01:00
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months . '
AND utimestamp < ' . $time_1month);
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months . '
AND utimestamp < ' . $time_1month);
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months . '
AND utimestamp < ' . $time_1month);
if ($num_3months >= 0) {
if ($num_3months > 0) {
$num_3months = 0;
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months);
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months);
$num_3months += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > ' . $time_3months);
}
// All data
2015-10-26 10:03:42 +01:00
$num_all = 0;
$num_all += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
$num_all += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
$num_all += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
if ($num_all >= 0) {
$num_older = $num_all - $num_3months;
if ($config['history_db_enabled'] == 1) {
// All data in common and history database
2015-10-26 10:03:42 +01:00
$num_all_w_history = 0;
$num_all_w_history += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
2015-10-26 10:03:42 +01:00
$num_all_w_history += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
2015-10-26 10:03:42 +01:00
$num_all_w_history += (int) db_get_sql('SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp < ' . $time_3months);
2015-10-26 10:03:42 +01:00
if ($num_all_w_history >= 0) {
$num_history = $num_all_w_history - $num_all;
}
}
}
}
}
}
2015-10-26 10:03:42 +01:00
}
else if (($num_1day == 0) && ($num_1week == 0) && ($num_1month == 0) && ($num_3months == 0) && ($num_all == 0)) {
//If no data, returns empty
$query_error = true;
}
// Error
if ($query_error || $num_older < 0 || ($config['history_db_enabled'] == 1 && $num_history < 0)
|| (empty($num_1day) && empty($num_1week) && empty($num_1month)
&& empty($num_3months) && empty($num_all)
&& ($config['history_db_enabled'] == 1 && empty($num_all_w_history)))) {
return html_print_image('images/image_problem_area_small.png', true);
}
// Data indexes
$str_1day = __("Today");
$str_1week = "1 ".__("Week");
$str_1month = "1 ".__("Month");
$str_3months = "3 ".__("Months");
$str_older = "> 3 ".__("Months");
// Filling the data array
$data = array();
if (!empty($num_1day))
$data[$str_1day] = $num_1day;
if (!empty($num_1week))
$data[$str_1week] = $num_1week;
if (!empty($num_1month))
$data[$str_1month] = $num_1month;
if (!empty($num_3months))
$data[$str_3months] = $num_3months;
if (!empty($num_older))
$data[$str_older] = $num_older;
if ($config['history_db_enabled'] == 1 && !empty($num_history)) {
// In this pie chart only 5 elements are shown, so we need to remove
// an element. With a history db enabled the >3 months element are dispensable
if (count($data) >= 5 && isset($data[$str_3months]))
unset($data[$str_3months]);
$time_historic_db = time() - ((int)$config['history_db_days'] * SECONDS_1DAY);
$date_human = human_time_comparation($time_historic_db);
$str_history = "> $date_human (".__("History db").")";
$data[$str_history] = $num_history;
}
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)
);
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $water_mark, $config['fontpath'], $config['font_size']);
}
/**
* Print a horizontal bar graph with packets data of agents
*
* @param integer width pie graph width
* @param integer height pie graph height
*/
function grafico_db_agentes_paquetes($width = 380, $height = 300) {
global $config;
global $graphic_type;
$data = array ();
$legend = array ();
2012-12-28 Sergio Martin <sergio.martin@artica.es> * pandoradb_data.sql include/functions_users.php include/functions_visual_map.php include/ajax/skins.ajax.php include/ajax/events.php include/functions_custom_graphs.php include/functions.php include/functions_agents.php include/functions_graph.php include/functions_events.php include/functions_reporting.php include/functions_config.php include/functions_reports.php operation/visual_console/render_view.php operation/agentes/exportdata.php operation/menu.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/reporting/reporting_viewer.php pandoradb.data.postgreSQL.sql pandoradb.data.oracle.sql extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql general/main_menu.php godmode/menu.php godmode/events/event_edit_filter.php godmode/events/events.php godmode/events/event_filter.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/graph_builder.main.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/graphs.php: Change all the event and reporting acl control to new flags ER,EW,EM,RR,RW,RM git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7342 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-28 18:06:17 +01:00
$agents = agents_get_group_agents (array_keys (users_get_groups (false, 'RR')), false, "none");
2011-05-10 Juan Manuel Ramon <juanmanuel.ramon@artica.es> * include/functions_graph.php include/functions_users.php include/functions_html.php include/functions_menu.php include/functions_messages.php include/functions_modules.php include/functions_reporting.php include/functions_groups.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/functions_visual_map.php include/functions_profile.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_agents.php include/functions_db.php include/functions_alerts.php include/functions_reports.php index.php extensions/insert_data.php extensions/agents_modules.php extensions/resource_registration.php extensions/resource_exportation.php extensions/module_groups.php operation/incidents/incident_detail.php operation/search_modules.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/estado_agente.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/group_view.php operation/search_agents.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/integria_incidents/incident_detail.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/events/events_rss.php operation/events/export_csv.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/search_users.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php ajax.php general/ui/agents_list.php godmode/groups/configure_group.php godmode/groups/group_list.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_purge.php godmode/agentes/module_manager_editor_common.php godmode/agentes/module_manager_editor_network.php godmode/agentes/module_manager_editor_wmi.php godmode/agentes/module_manager_editor_plugin.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/setup/setup_auth.php godmode/users/user_list.php godmode/users/configure_user.php godmode/users/configure_profile.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/reporting_builder.item_editor.php: Functions in functions_profile.php, functions_agents.php, functions_users.php, functions_massive_policies.php, functions_audit.php, functions_backup.php, functions_collection.php, functions_skins.php, functions_enterprise.php, functions_groups.php, functions_local_components.php, functions_metaconsole.php, functions_policies.php, functions_reporting.php, functions_reporting_csv.php, functions_reporting_pdf2.php, functions_services.php have their own prefixes. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4333 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-10 20:51:09 +02:00
$count = agents_get_modules_data_count (array_keys ($agents));
unset ($count["total"]);
arsort ($count, SORT_NUMERIC);
$count = array_slice ($count, 0, 8, true);
foreach ($count as $agent_id => $value) {
$data[$agents[$agent_id]]['g'] = $value;
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return hbar_graph($config['flash_charts'], $data, $width, $height, array(),
$legend, "", "", true, "", $water_mark,
$config['fontpath'], $config['font_size'], false, 1, $config['homeurl'],
'white',
'black');
}
/**
* Print a horizontal bar graph with modules data of agents
*
* @param integer height graph height
* @param integer width graph width
*/
function graph_db_agentes_modulos($width, $height) {
global $config;
global $graphic_type;
$data = array ();
2015-06-08 11:05:19 +02:00
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
2015-06-08 11:05:19 +02:00
$modules = db_get_all_rows_sql ('
SELECT COUNT(id_agente_modulo), id_agente
FROM tagente_modulo
WHERE delete_pending = 0
GROUP BY id_agente
ORDER BY 1 DESC LIMIT 10');
break;
case "oracle":
2015-06-08 11:05:19 +02:00
$modules = db_get_all_rows_sql ('
SELECT COUNT(id_agente_modulo), id_agente
FROM tagente_modulo
WHERE rownum <= 10
AND delete_pending = 0
GROUP BY id_agente
ORDER BY 1 DESC');
break;
}
if ($modules === false)
$modules = array ();
$data = array();
foreach ($modules as $module) {
2011-05-10 Juan Manuel Ramon <juanmanuel.ramon@artica.es> * include/functions_graph.php include/functions_users.php include/functions_html.php include/functions_menu.php include/functions_messages.php include/functions_modules.php include/functions_reporting.php include/functions_groups.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/functions_visual_map.php include/functions_profile.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_agents.php include/functions_db.php include/functions_alerts.php include/functions_reports.php index.php extensions/insert_data.php extensions/agents_modules.php extensions/resource_registration.php extensions/resource_exportation.php extensions/module_groups.php operation/incidents/incident_detail.php operation/search_modules.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/estado_agente.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/group_view.php operation/search_agents.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/integria_incidents/incident_detail.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/events/events_rss.php operation/events/export_csv.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/search_users.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php ajax.php general/ui/agents_list.php godmode/groups/configure_group.php godmode/groups/group_list.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_purge.php godmode/agentes/module_manager_editor_common.php godmode/agentes/module_manager_editor_network.php godmode/agentes/module_manager_editor_wmi.php godmode/agentes/module_manager_editor_plugin.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/setup/setup_auth.php godmode/users/user_list.php godmode/users/configure_user.php godmode/users/configure_profile.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/reporting_builder.item_editor.php: Functions in functions_profile.php, functions_agents.php, functions_users.php, functions_massive_policies.php, functions_audit.php, functions_backup.php, functions_collection.php, functions_skins.php, functions_enterprise.php, functions_groups.php, functions_local_components.php, functions_metaconsole.php, functions_policies.php, functions_reporting.php, functions_reporting_csv.php, functions_reporting_pdf2.php, functions_services.php have their own prefixes. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4333 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-10 20:51:09 +02:00
$agent_name = agents_get_name ($module['id_agente'], "none");
if (empty($agent_name)) {
continue;
}
2015-06-08 11:05:19 +02:00
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$data[$agent_name]['g'] = $module['COUNT(id_agente_modulo)'];
break;
case "oracle":
$data[$agent_name]['g'] = $module['count(id_agente_modulo)'];
break;
}
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return hbar_graph($config['flash_charts'],
$data, $width, $height, array(),
array(), "", "", true, "",
$water_mark,
$config['fontpath'], $config['font_size'], false, 1, $config['homeurl'],
'white',
'black');
}
/**
* Print a pie graph with users activity in a period of time
*
* @param integer width pie graph width
* @param integer height pie graph height
* @param integer period time period
*/
function graphic_user_activity ($width = 350, $height = 230) {
global $config;
global $graphic_type;
$data = array ();
$max_items = 5;
switch ($config['dbtype']) {
case "mysql":
case "postgresql":
$sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario
FROM tsesion
GROUP BY id_usuario
ORDER BY 1 DESC LIMIT %d', $max_items);
break;
case "oracle":
$sql = sprintf ('SELECT COUNT(id_usuario) n_incidents, id_usuario
FROM tsesion
WHERE rownum <= %d
GROUP BY id_usuario
ORDER BY 1 DESC', $max_items);
break;
}
* include/functions_graph.php include/functions_html.php include/functions_messages.php include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/ajax/skins.ajax.php include/ajax/reporting.ajax.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/config_process.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_incidents.php include/api.php include/functions_reports.php include/functions_ui_renders.php extensions/insert_data.php extensions/system_info.php extensions/extension_uploader.php extensions/pandora_logs.php extensions/agents_modules.php extensions/update_manager.php extensions/ssh_console.php extensions/dbmanager.php extensions/vnc_view.php extensions/resource_registration.php extensions/resource_exportation.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php extensions/update_manager/settings.php extensions/update_manager/main.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/incidents/incident_statistics.php operation/search_modules.php operation/visual_console/render_view.php operation/visual_console/index.php operation/extensions.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/agent_fields.php operation/agentes/tactical.php operation/agentes/group_view.php operation/agentes/networkmap.php operation/agentes/stat_win.php operation/servers/view_server.php operation/servers/view_server_detail.php operation/menu.php operation/search_agents.php operation/search_graphs.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/integria_incidents/incident.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident_statistics.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_validate.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/search_reports.php operation/search_maps.php operation/search_users.php extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php mobile/index.php general/error_authconfig.php general/links_menu.php general/logon_ok.php general/error_dbconfig.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/db/db_audit.php godmode/db/db_sanity.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_event.php godmode/db/db_purge.php godmode/extensions.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/configure_field.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/configure_alert_command.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/setup/file_manager.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/gis_step_2.php godmode/setup/links.php godmode/setup/setup.php godmode/setup/os.php godmode/setup/performance.php godmode/setup/setup_auth.php godmode/setup/gis.php godmode/setup/os.builder.php godmode/setup/setup_visuals.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/users/user_list.php godmode/users/configure_profile.php godmode/gis_maps/configure_gis_map.php godmode/gis_maps/index.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_operations.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/manage_network_components_form.php godmode/modules/manage_nc_groups_form.php godmode/modules/manage_network_templates.php godmode/modules/module_list.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components_form_network.php godmode/modules/manage_network_templates_form.php godmode/modules/manage_network_components_form_wmi.php godmode/modules/manage_network_components.php godmode/modules/manage_nc_groups.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/visual_console_builder.preview.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/reporting/graph_builder.preview.php include/functions_db.php: Added some includes and functions of this code have "db_" prefix. * include/functions.php: Moved function check_login(), check_acl(), dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php. * include/functions_groups.php: Moved functions get_childrens(), safe_acl_group() and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(), get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(), get_group_name(), get_group_users() from functions_db.php to this code. * include/functions_profile.php: New library with profile functions. Moved functions get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(), delete_profile() from functions_db.php to this code. Added new parameter in function get_profile() to retrieve profiles with filter conditions applied. * include/functions_users.php: New library with users functions. Moved functions get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(), get_user_first_group(), user_access_to_agent() from funtions_db.php to this code. * godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile(). * include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(), get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(), check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(), agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(), get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(), get_agent_group() from functions_db.php to this code. * include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(), get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(), get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(), get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(), get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(), get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(), get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(), give_modulecategory_name(), give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(), get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(), get_modulegroup_name() from functions_db.php to this code. * include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(), get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(), get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(), get_agentmodule_last_status() from functions_db.php to this code. * include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion() from functions_db.php to this code. * include/functions_events.php: Moved functions get_group_events(), get_agent_events(), get_module_events() from functions_db.php to this code. * include/functions_servers.php: Moved functions get_server_name(), show_server_type(), check_server_status(), server_status() from functions_db.php to this code. * include/functions_network_profiles.php: Moved function get_networkprofile_name() from functions_db.php to this code. * include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y() from fucntions_db.php to this code. * include/functions_io.php: Moved function __() from functions_db.php to this code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
$logins = db_get_all_rows_sql ($sql);
if ($logins == false) {
$logins = array();
}
foreach ($logins as $login) {
$data[$login['id_usuario']] = $login['n_incidents'];
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
/**
* Print a pie graph with priodity incident
*/
function grafico_incidente_prioridad () {
global $config;
global $graphic_type;
$data_tmp = array (0, 0, 0, 0, 0, 0);
$sql = 'SELECT COUNT(id_incidencia) n_incidents, prioridad
FROM tincidencia
GROUP BY prioridad
ORDER BY 2 DESC';
* include/functions_graph.php include/functions_html.php include/functions_messages.php include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/ajax/skins.ajax.php include/ajax/reporting.ajax.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/config_process.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_incidents.php include/api.php include/functions_reports.php include/functions_ui_renders.php extensions/insert_data.php extensions/system_info.php extensions/extension_uploader.php extensions/pandora_logs.php extensions/agents_modules.php extensions/update_manager.php extensions/ssh_console.php extensions/dbmanager.php extensions/vnc_view.php extensions/resource_registration.php extensions/resource_exportation.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php extensions/update_manager/settings.php extensions/update_manager/main.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/incidents/incident_statistics.php operation/search_modules.php operation/visual_console/render_view.php operation/visual_console/index.php operation/extensions.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/agent_fields.php operation/agentes/tactical.php operation/agentes/group_view.php operation/agentes/networkmap.php operation/agentes/stat_win.php operation/servers/view_server.php operation/servers/view_server_detail.php operation/menu.php operation/search_agents.php operation/search_graphs.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/integria_incidents/incident.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident_statistics.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_validate.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/search_reports.php operation/search_maps.php operation/search_users.php extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php mobile/index.php general/error_authconfig.php general/links_menu.php general/logon_ok.php general/error_dbconfig.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/db/db_audit.php godmode/db/db_sanity.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_event.php godmode/db/db_purge.php godmode/extensions.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/configure_field.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/configure_alert_command.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/setup/file_manager.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/gis_step_2.php godmode/setup/links.php godmode/setup/setup.php godmode/setup/os.php godmode/setup/performance.php godmode/setup/setup_auth.php godmode/setup/gis.php godmode/setup/os.builder.php godmode/setup/setup_visuals.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/users/user_list.php godmode/users/configure_profile.php godmode/gis_maps/configure_gis_map.php godmode/gis_maps/index.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_operations.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/manage_network_components_form.php godmode/modules/manage_nc_groups_form.php godmode/modules/manage_network_templates.php godmode/modules/module_list.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components_form_network.php godmode/modules/manage_network_templates_form.php godmode/modules/manage_network_components_form_wmi.php godmode/modules/manage_network_components.php godmode/modules/manage_nc_groups.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/visual_console_builder.preview.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/reporting/graph_builder.preview.php include/functions_db.php: Added some includes and functions of this code have "db_" prefix. * include/functions.php: Moved function check_login(), check_acl(), dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php. * include/functions_groups.php: Moved functions get_childrens(), safe_acl_group() and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(), get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(), get_group_name(), get_group_users() from functions_db.php to this code. * include/functions_profile.php: New library with profile functions. Moved functions get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(), delete_profile() from functions_db.php to this code. Added new parameter in function get_profile() to retrieve profiles with filter conditions applied. * include/functions_users.php: New library with users functions. Moved functions get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(), get_user_first_group(), user_access_to_agent() from funtions_db.php to this code. * godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile(). * include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(), get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(), check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(), agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(), get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(), get_agent_group() from functions_db.php to this code. * include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(), get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(), get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(), get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(), get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(), get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(), get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(), give_modulecategory_name(), give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(), get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(), get_modulegroup_name() from functions_db.php to this code. * include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(), get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(), get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(), get_agentmodule_last_status() from functions_db.php to this code. * include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion() from functions_db.php to this code. * include/functions_events.php: Moved functions get_group_events(), get_agent_events(), get_module_events() from functions_db.php to this code. * include/functions_servers.php: Moved functions get_server_name(), show_server_type(), check_server_status(), server_status() from functions_db.php to this code. * include/functions_network_profiles.php: Moved function get_networkprofile_name() from functions_db.php to this code. * include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y() from fucntions_db.php to this code. * include/functions_io.php: Moved function __() from functions_db.php to this code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
$incidents = db_get_all_rows_sql ($sql);
if ($incidents == false) {
$incidents = array();
}
foreach ($incidents as $incident) {
if ($incident['prioridad'] < 5)
$data_tmp[$incident['prioridad']] = $incident['n_incidents'];
else
$data_tmp[5] += $incident['n_incidents'];
}
$data = array (__('Informative') => $data_tmp[0],
__('Low') => $data_tmp[1],
__('Medium') => $data_tmp[2],
__('Serious') => $data_tmp[3],
__('Very serious') => $data_tmp[4],
__('Maintenance') => $data_tmp[5]);
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, 320, 200,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
/**
* Print a pie graph with incidents data
*/
function graph_incidents_status () {
global $config;
global $graphic_type;
$data = array (0, 0, 0, 0);
$data = array ();
$data[__('Open incident')] = 0;
$data[__('Closed incident')] = 0;
$data[__('Outdated')] = 0;
$data[__('Invalid')] = 0;
* include/functions_graph.php include/functions_html.php include/functions_messages.php include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/ajax/skins.ajax.php include/ajax/reporting.ajax.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/config_process.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_incidents.php include/api.php include/functions_reports.php include/functions_ui_renders.php extensions/insert_data.php extensions/system_info.php extensions/extension_uploader.php extensions/pandora_logs.php extensions/agents_modules.php extensions/update_manager.php extensions/ssh_console.php extensions/dbmanager.php extensions/vnc_view.php extensions/resource_registration.php extensions/resource_exportation.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php extensions/update_manager/settings.php extensions/update_manager/main.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/incidents/incident_statistics.php operation/search_modules.php operation/visual_console/render_view.php operation/visual_console/index.php operation/extensions.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/agent_fields.php operation/agentes/tactical.php operation/agentes/group_view.php operation/agentes/networkmap.php operation/agentes/stat_win.php operation/servers/view_server.php operation/servers/view_server_detail.php operation/menu.php operation/search_agents.php operation/search_graphs.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/integria_incidents/incident.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident_statistics.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_validate.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/search_reports.php operation/search_maps.php operation/search_users.php extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php mobile/index.php general/error_authconfig.php general/links_menu.php general/logon_ok.php general/error_dbconfig.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/db/db_audit.php godmode/db/db_sanity.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_event.php godmode/db/db_purge.php godmode/extensions.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/configure_field.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/configure_alert_command.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/setup/file_manager.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/gis_step_2.php godmode/setup/links.php godmode/setup/setup.php godmode/setup/os.php godmode/setup/performance.php godmode/setup/setup_auth.php godmode/setup/gis.php godmode/setup/os.builder.php godmode/setup/setup_visuals.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/users/user_list.php godmode/users/configure_profile.php godmode/gis_maps/configure_gis_map.php godmode/gis_maps/index.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_operations.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/manage_network_components_form.php godmode/modules/manage_nc_groups_form.php godmode/modules/manage_network_templates.php godmode/modules/module_list.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components_form_network.php godmode/modules/manage_network_templates_form.php godmode/modules/manage_network_components_form_wmi.php godmode/modules/manage_network_components.php godmode/modules/manage_nc_groups.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/visual_console_builder.preview.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/reporting/graph_builder.preview.php include/functions_db.php: Added some includes and functions of this code have "db_" prefix. * include/functions.php: Moved function check_login(), check_acl(), dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php. * include/functions_groups.php: Moved functions get_childrens(), safe_acl_group() and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(), get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(), get_group_name(), get_group_users() from functions_db.php to this code. * include/functions_profile.php: New library with profile functions. Moved functions get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(), delete_profile() from functions_db.php to this code. Added new parameter in function get_profile() to retrieve profiles with filter conditions applied. * include/functions_users.php: New library with users functions. Moved functions get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(), get_user_first_group(), user_access_to_agent() from funtions_db.php to this code. * godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile(). * include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(), get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(), check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(), agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(), get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(), get_agent_group() from functions_db.php to this code. * include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(), get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(), get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(), get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(), get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(), get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(), get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(), give_modulecategory_name(), give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(), get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(), get_modulegroup_name() from functions_db.php to this code. * include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(), get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(), get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(), get_agentmodule_last_status() from functions_db.php to this code. * include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion() from functions_db.php to this code. * include/functions_events.php: Moved functions get_group_events(), get_agent_events(), get_module_events() from functions_db.php to this code. * include/functions_servers.php: Moved functions get_server_name(), show_server_type(), check_server_status(), server_status() from functions_db.php to this code. * include/functions_network_profiles.php: Moved function get_networkprofile_name() from functions_db.php to this code. * include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y() from fucntions_db.php to this code. * include/functions_io.php: Moved function __() from functions_db.php to this code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
$incidents = db_get_all_rows_filter ('tincidencia',
array ('estado' => array (0, 2, 3, 13)),
array ('estado'));
if ($incidents === false)
$incidents = array ();
foreach ($incidents as $incident) {
if ($incident["estado"] == 0)
$data[__("Open incident")]++;
if ($incident["estado"] == 2)
$data[__("Closed incident")]++;
if ($incident["estado"] == 3)
$data[__("Outdated")]++;
if ($incident["estado"] == 13)
$data[__("Invalid")]++;
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, 320, 200,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
/**
* Print a pie graph with incident data by group
*/
function graphic_incident_group () {
global $config;
global $graphic_type;
$data = array ();
$max_items = 5;
switch ($config["dbtype"]) {
case 'mysql':
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incidents, nombre
FROM tincidencia,tgrupo
WHERE tgrupo.id_grupo = tincidencia.id_grupo
GROUP BY tgrupo.id_grupo, nombre ORDER BY 1 DESC LIMIT %d',
$max_items);
break;
case 'oracle':
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incidents, nombre
FROM tincidencia,tgrupo
WHERE tgrupo.id_grupo = tincidencia.id_grupo
AND rownum <= %d
GROUP BY tgrupo.id_grupo, nombre ORDER BY 1 DESC',
$max_items);
break;
}
* include/functions_graph.php include/functions_html.php include/functions_messages.php include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/ajax/skins.ajax.php include/ajax/reporting.ajax.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/config_process.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_incidents.php include/api.php include/functions_reports.php include/functions_ui_renders.php extensions/insert_data.php extensions/system_info.php extensions/extension_uploader.php extensions/pandora_logs.php extensions/agents_modules.php extensions/update_manager.php extensions/ssh_console.php extensions/dbmanager.php extensions/vnc_view.php extensions/resource_registration.php extensions/resource_exportation.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php extensions/update_manager/settings.php extensions/update_manager/main.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/incidents/incident_statistics.php operation/search_modules.php operation/visual_console/render_view.php operation/visual_console/index.php operation/extensions.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/agent_fields.php operation/agentes/tactical.php operation/agentes/group_view.php operation/agentes/networkmap.php operation/agentes/stat_win.php operation/servers/view_server.php operation/servers/view_server_detail.php operation/menu.php operation/search_agents.php operation/search_graphs.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/integria_incidents/incident.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident_statistics.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_validate.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/search_reports.php operation/search_maps.php operation/search_users.php extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php mobile/index.php general/error_authconfig.php general/links_menu.php general/logon_ok.php general/error_dbconfig.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/db/db_audit.php godmode/db/db_sanity.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_event.php godmode/db/db_purge.php godmode/extensions.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/configure_field.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/configure_alert_command.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/setup/file_manager.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/gis_step_2.php godmode/setup/links.php godmode/setup/setup.php godmode/setup/os.php godmode/setup/performance.php godmode/setup/setup_auth.php godmode/setup/gis.php godmode/setup/os.builder.php godmode/setup/setup_visuals.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/users/user_list.php godmode/users/configure_profile.php godmode/gis_maps/configure_gis_map.php godmode/gis_maps/index.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_operations.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/manage_network_components_form.php godmode/modules/manage_nc_groups_form.php godmode/modules/manage_network_templates.php godmode/modules/module_list.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components_form_network.php godmode/modules/manage_network_templates_form.php godmode/modules/manage_network_components_form_wmi.php godmode/modules/manage_network_components.php godmode/modules/manage_nc_groups.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/visual_console_builder.preview.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/reporting/graph_builder.preview.php include/functions_db.php: Added some includes and functions of this code have "db_" prefix. * include/functions.php: Moved function check_login(), check_acl(), dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php. * include/functions_groups.php: Moved functions get_childrens(), safe_acl_group() and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(), get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(), get_group_name(), get_group_users() from functions_db.php to this code. * include/functions_profile.php: New library with profile functions. Moved functions get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(), delete_profile() from functions_db.php to this code. Added new parameter in function get_profile() to retrieve profiles with filter conditions applied. * include/functions_users.php: New library with users functions. Moved functions get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(), get_user_first_group(), user_access_to_agent() from funtions_db.php to this code. * godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile(). * include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(), get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(), check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(), agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(), get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(), get_agent_group() from functions_db.php to this code. * include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(), get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(), get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(), get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(), get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(), get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(), get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(), give_modulecategory_name(), give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(), get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(), get_modulegroup_name() from functions_db.php to this code. * include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(), get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(), get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(), get_agentmodule_last_status() from functions_db.php to this code. * include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion() from functions_db.php to this code. * include/functions_events.php: Moved functions get_group_events(), get_agent_events(), get_module_events() from functions_db.php to this code. * include/functions_servers.php: Moved functions get_server_name(), show_server_type(), check_server_status(), server_status() from functions_db.php to this code. * include/functions_network_profiles.php: Moved function get_networkprofile_name() from functions_db.php to this code. * include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y() from fucntions_db.php to this code. * include/functions_io.php: Moved function __() from functions_db.php to this code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
$incidents = db_get_all_rows_sql ($sql);
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incidents
FROM tincidencia
WHERE tincidencia.id_grupo = 0');
$incidents_all = db_get_value_sql($sql);
if ($incidents == false) {
$incidents = array();
}
foreach ($incidents as $incident) {
$data[$incident['nombre']] = $incident['n_incidents'];
}
if ($incidents_all > 0) {
$data[__('All')] = $incidents_all;
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, 320, 200,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
/**
* Print a graph with access data of agents
* @param integer id_agent Agent ID
* @param integer width pie graph width
* @param integer height pie graph height
* @param integer period time period
*/
function graphic_incident_user () {
global $config;
global $graphic_type;
$data = array ();
$max_items = 5;
switch ($config["dbtype"]) {
case 'mysql':
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incidents, id_usuario
FROM tincidencia
GROUP BY id_usuario
ORDER BY 1 DESC LIMIT %d', $max_items);
break;
case 'oracle':
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incidents, id_usuario
FROM tincidencia
WHERE rownum <= %d
GROUP BY id_usuario
ORDER BY 1 DESC', $max_items);
break;
}
* include/functions_graph.php include/functions_html.php include/functions_messages.php include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/ajax/skins.ajax.php include/ajax/reporting.ajax.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/config_process.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_incidents.php include/api.php include/functions_reports.php include/functions_ui_renders.php extensions/insert_data.php extensions/system_info.php extensions/extension_uploader.php extensions/pandora_logs.php extensions/agents_modules.php extensions/update_manager.php extensions/ssh_console.php extensions/dbmanager.php extensions/vnc_view.php extensions/resource_registration.php extensions/resource_exportation.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php extensions/update_manager/settings.php extensions/update_manager/main.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/incidents/incident_statistics.php operation/search_modules.php operation/visual_console/render_view.php operation/visual_console/index.php operation/extensions.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/agent_fields.php operation/agentes/tactical.php operation/agentes/group_view.php operation/agentes/networkmap.php operation/agentes/stat_win.php operation/servers/view_server.php operation/servers/view_server_detail.php operation/menu.php operation/search_agents.php operation/search_graphs.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/integria_incidents/incident.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident_statistics.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_validate.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/search_reports.php operation/search_maps.php operation/search_users.php extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php mobile/index.php general/error_authconfig.php general/links_menu.php general/logon_ok.php general/error_dbconfig.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/db/db_audit.php godmode/db/db_sanity.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_event.php godmode/db/db_purge.php godmode/extensions.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/configure_field.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/configure_alert_command.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/setup/file_manager.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/gis_step_2.php godmode/setup/links.php godmode/setup/setup.php godmode/setup/os.php godmode/setup/performance.php godmode/setup/setup_auth.php godmode/setup/gis.php godmode/setup/os.builder.php godmode/setup/setup_visuals.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/users/user_list.php godmode/users/configure_profile.php godmode/gis_maps/configure_gis_map.php godmode/gis_maps/index.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_operations.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/manage_network_components_form.php godmode/modules/manage_nc_groups_form.php godmode/modules/manage_network_templates.php godmode/modules/module_list.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components_form_network.php godmode/modules/manage_network_templates_form.php godmode/modules/manage_network_components_form_wmi.php godmode/modules/manage_network_components.php godmode/modules/manage_nc_groups.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/visual_console_builder.preview.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/reporting/graph_builder.preview.php include/functions_db.php: Added some includes and functions of this code have "db_" prefix. * include/functions.php: Moved function check_login(), check_acl(), dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php. * include/functions_groups.php: Moved functions get_childrens(), safe_acl_group() and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(), get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(), get_group_name(), get_group_users() from functions_db.php to this code. * include/functions_profile.php: New library with profile functions. Moved functions get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(), delete_profile() from functions_db.php to this code. Added new parameter in function get_profile() to retrieve profiles with filter conditions applied. * include/functions_users.php: New library with users functions. Moved functions get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(), get_user_first_group(), user_access_to_agent() from funtions_db.php to this code. * godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile(). * include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(), get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(), check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(), agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(), get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(), get_agent_group() from functions_db.php to this code. * include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(), get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(), get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(), get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(), get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(), get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(), get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(), give_modulecategory_name(), give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(), get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(), get_modulegroup_name() from functions_db.php to this code. * include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(), get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(), get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(), get_agentmodule_last_status() from functions_db.php to this code. * include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion() from functions_db.php to this code. * include/functions_events.php: Moved functions get_group_events(), get_agent_events(), get_module_events() from functions_db.php to this code. * include/functions_servers.php: Moved functions get_server_name(), show_server_type(), check_server_status(), server_status() from functions_db.php to this code. * include/functions_network_profiles.php: Moved function get_networkprofile_name() from functions_db.php to this code. * include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y() from fucntions_db.php to this code. * include/functions_io.php: Moved function __() from functions_db.php to this code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
$incidents = db_get_all_rows_sql ($sql);
if ($incidents == false) {
$incidents = array();
}
foreach ($incidents as $incident) {
if ($incident['id_usuario'] == false) {
$name = __('System');
}
else {
$name = $incident['id_usuario'];
}
$data[$name] = $incident['n_incidents'];
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, 320, 200,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
/**
* Print a pie graph with access data of incidents source
*
* @param integer width pie graph width
* @param integer height pie graph height
*/
function graphic_incident_source($width = 320, $height = 200) {
global $config;
global $graphic_type;
$data = array ();
$max_items = 5;
switch ($config["dbtype"]) {
case "mysql":
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incident, origen
FROM tincidencia
GROUP BY `origen`
ORDER BY 1 DESC LIMIT %d', $max_items);
break;
case "postgresql":
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incident, origen
FROM tincidencia
GROUP BY "origen"
ORDER BY 1 DESC LIMIT %d', $max_items);
break;
case "oracle":
$sql = sprintf ('SELECT COUNT(id_incidencia) n_incident, origen
FROM tincidencia
WHERE rownum <= %d
GROUP BY origen
ORDER BY 1 DESC', $max_items);
break;
}
* include/functions_graph.php include/functions_html.php include/functions_messages.php include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/ajax/skins.ajax.php include/ajax/reporting.ajax.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/config_process.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_incidents.php include/api.php include/functions_reports.php include/functions_ui_renders.php extensions/insert_data.php extensions/system_info.php extensions/extension_uploader.php extensions/pandora_logs.php extensions/agents_modules.php extensions/update_manager.php extensions/ssh_console.php extensions/dbmanager.php extensions/vnc_view.php extensions/resource_registration.php extensions/resource_exportation.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php extensions/update_manager/settings.php extensions/update_manager/main.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/incidents/incident_statistics.php operation/search_modules.php operation/visual_console/render_view.php operation/visual_console/index.php operation/extensions.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/agent_fields.php operation/agentes/tactical.php operation/agentes/group_view.php operation/agentes/networkmap.php operation/agentes/stat_win.php operation/servers/view_server.php operation/servers/view_server_detail.php operation/menu.php operation/search_agents.php operation/search_graphs.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/integria_incidents/incident.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident_statistics.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_validate.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/search_reports.php operation/search_maps.php operation/search_users.php extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php mobile/index.php general/error_authconfig.php general/links_menu.php general/logon_ok.php general/error_dbconfig.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/db/db_audit.php godmode/db/db_sanity.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_event.php godmode/db/db_purge.php godmode/extensions.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/configure_field.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/configure_alert_command.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/setup/file_manager.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/gis_step_2.php godmode/setup/links.php godmode/setup/setup.php godmode/setup/os.php godmode/setup/performance.php godmode/setup/setup_auth.php godmode/setup/gis.php godmode/setup/os.builder.php godmode/setup/setup_visuals.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/users/user_list.php godmode/users/configure_profile.php godmode/gis_maps/configure_gis_map.php godmode/gis_maps/index.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_operations.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/manage_network_components_form.php godmode/modules/manage_nc_groups_form.php godmode/modules/manage_network_templates.php godmode/modules/module_list.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components_form_network.php godmode/modules/manage_network_templates_form.php godmode/modules/manage_network_components_form_wmi.php godmode/modules/manage_network_components.php godmode/modules/manage_nc_groups.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/visual_console_builder.preview.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/reporting/graph_builder.preview.php include/functions_db.php: Added some includes and functions of this code have "db_" prefix. * include/functions.php: Moved function check_login(), check_acl(), dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php. * include/functions_groups.php: Moved functions get_childrens(), safe_acl_group() and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(), get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(), get_group_name(), get_group_users() from functions_db.php to this code. * include/functions_profile.php: New library with profile functions. Moved functions get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(), delete_profile() from functions_db.php to this code. Added new parameter in function get_profile() to retrieve profiles with filter conditions applied. * include/functions_users.php: New library with users functions. Moved functions get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(), get_user_first_group(), user_access_to_agent() from funtions_db.php to this code. * godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile(). * include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(), get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(), check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(), agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(), get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(), get_agent_group() from functions_db.php to this code. * include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(), get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(), get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(), get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(), get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(), get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(), get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(), give_modulecategory_name(), give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(), get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(), get_modulegroup_name() from functions_db.php to this code. * include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(), get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(), get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(), get_agentmodule_last_status() from functions_db.php to this code. * include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion() from functions_db.php to this code. * include/functions_events.php: Moved functions get_group_events(), get_agent_events(), get_module_events() from functions_db.php to this code. * include/functions_servers.php: Moved functions get_server_name(), show_server_type(), check_server_status(), server_status() from functions_db.php to this code. * include/functions_network_profiles.php: Moved function get_networkprofile_name() from functions_db.php to this code. * include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y() from fucntions_db.php to this code. * include/functions_io.php: Moved function __() from functions_db.php to this code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
$origins = db_get_all_rows_sql ($sql);
if ($origins == false) {
$origins = array();
}
foreach ($origins as $origin) {
$data[$origin['origen']] = $origin['n_incident'];
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
function graph_events_validated($width = 300, $height = 200, $extra_filters = array(), $meta = false, $history = false) {
global $config;
global $graphic_type;
$event_type = false;
if (array_key_exists('event_type', $extra_filters))
$event_type = $extra_filters['event_type'];
$event_severity = false;
if (array_key_exists('event_severity', $extra_filters))
$event_severity = $extra_filters['event_severity'];
$event_status = false;
if (array_key_exists('event_status', $extra_filters))
$event_status = $extra_filters['event_status'];
$event_filter_search = false;
if (array_key_exists('event_filter_search', $extra_filters))
$event_filter_search = $extra_filters['event_filter_search'];
2017-01-11 13:26:50 +01:00
$data_graph = events_get_count_events_validated(
array('id_group' => array_keys(users_get_groups())), null, null,
$event_severity, $event_type, $event_status, $event_filter_search);
$colors = array();
foreach ($data_graph as $k => $v) {
if ($k == __('Validated')) {
$colors[$k] = COL_NORMAL;
}
else {
$colors[$k] = COL_CRITICAL;
}
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
echo pie3d_graph(
true, $data_graph, $width, $height, __("other"), "",
$water_mark,
$config['fontpath'], $config['font_size'], 1, false, $colors);
}
/**
* Print a pie graph with events data of group
*
* @param integer width pie graph width
* @param integer height pie graph height
* @param string url
* @param bool if the graph required is or not for metaconsole
* @param bool if the graph required is or not for history table
*/
2015-04-15 09:45:13 +02:00
function grafico_eventos_grupo ($width = 300, $height = 200, $url = "", $meta = false, $history = false, $noWaterMark = true) {
global $config;
global $graphic_type;
//It was urlencoded, so we urldecode it
$url = html_entity_decode (rawurldecode ($url), ENT_QUOTES);
$data = array ();
$loop = 0;
define ('NUM_PIECES_PIE', 6);
//Hotfix for the id_agente_modulo
$url = str_replace(
'SELECT id_agente_modulo', 'SELECT_id_agente_modulo', $url);
$badstrings = array (";",
"SELECT ",
"DELETE ",
"UPDATE ",
"INSERT ",
"EXEC");
//remove bad strings from the query so queries like ; DELETE FROM don't pass
$url = str_ireplace ($badstrings, "", $url);
//Hotfix for the id_agente_modulo
$url = str_replace(
'SELECT_id_agente_modulo', 'SELECT id_agente_modulo', $url);
// Choose the table where search if metaconsole or not
if ($meta) {
if ($history) {
$event_table = 'tmetaconsole_event_history';
}
else {
$event_table = 'tmetaconsole_event';
}
$field_extra = ', agent_name';
$groupby_extra = ', server_id';
}
else {
$event_table = 'tevento';
$field_extra = '';
$groupby_extra = '';
}
// Add tags condition to filter
2015-01-23 08:59:42 +01:00
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
//This will give the distinct id_agente, give the id_grupo that goes
//with it and then the number of times it occured. GROUP BY statement
//is required if both DISTINCT() and COUNT() are in the statement
$sql = sprintf ('SELECT DISTINCT(id_agente) AS id_agente,
COUNT(id_agente) AS count'.$field_extra.'
FROM '.$event_table.' te LEFT JOIN tagent_secondary_group tasg
ON te.id_grupo = tasg.id_group
WHERE 1=1 %s %s
GROUP BY id_agente'.$groupby_extra.'
ORDER BY count DESC LIMIT 8', $url, $tags_condition);
$result = db_get_all_rows_sql ($sql, false, false);
if ($result === false) {
$result = array();
}
$system_events = 0;
$other_events = 0;
foreach ($result as $row) {
$row["id_grupo"] = agents_get_agent_group ($row["id_agente"]);
2012-12-28 Sergio Martin <sergio.martin@artica.es> * pandoradb_data.sql include/functions_users.php include/functions_visual_map.php include/ajax/skins.ajax.php include/ajax/events.php include/functions_custom_graphs.php include/functions.php include/functions_agents.php include/functions_graph.php include/functions_events.php include/functions_reporting.php include/functions_config.php include/functions_reports.php operation/visual_console/render_view.php operation/agentes/exportdata.php operation/menu.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/reporting/reporting_viewer.php pandoradb.data.postgreSQL.sql pandoradb.data.oracle.sql extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql general/main_menu.php godmode/menu.php godmode/events/event_edit_filter.php godmode/events/events.php godmode/events/event_filter.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/graph_builder.main.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/graphs.php: Change all the event and reporting acl control to new flags ER,EW,EM,RR,RW,RM git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7342 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-28 18:06:17 +01:00
if (!check_acl ($config["id_user"], $row["id_grupo"], "ER") == 1)
continue;
if ($loop >= NUM_PIECES_PIE) {
$other_events += $row["count"];
}
else {
if ($row["id_agente"] == 0) {
$system_events += $row["count"];
}
else {
if ($meta) {
2017-10-04 17:49:46 +02:00
$name = mb_substr (io_safe_output($row['agent_name']), 0, 25)." (".$row["count"].")";
}
else {
2017-02-22 16:43:28 +01:00
$alias = agents_get_alias($row["id_agente"]);
2017-10-04 17:49:46 +02:00
$name = mb_substr($alias, 0, 25)." #".$row["id_agente"]." (".$row["count"].")";
}
$data[$name] = $row["count"];
}
}
$loop++;
}
if ($system_events > 0) {
$name = __('SYSTEM')." (".$system_events.")";
$data[$name] = $system_events;
}
/*
if ($other_events > 0) {
$name = __('Other')." (".$other_events.")";
$data[$name] = $other_events;
}
*/
// Sort the data
arsort($data);
2015-04-15 09:45:13 +02:00
if ($noWaterMark) {
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
2015-07-14 15:59:39 +02:00
else
{
$water_mark = array();
}
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size'], 1, 'bottom');
}
function grafico_eventos_agente ($width = 300, $height = 200, $result = false, $meta = false, $history = false) {
global $config;
global $graphic_type;
//It was urlencoded, so we urldecode it
//$url = html_entity_decode (rawurldecode ($url), ENT_QUOTES);
$data = array ();
$loop = 0;
if ($result === false) {
$result = array();
}
$system_events = 0;
$other_events = 0;
$total = array();
$i = 0;
foreach ($result as $row) {
if ($meta) {
$count[] = $row["agent_name"];
}
else {
if ($row["id_agente"] == 0) {
$count[] = __('SYSTEM');
}
else
$count[] = agents_get_alias($row["id_agente"]) ;
}
}
$total = array_count_values($count);
foreach ($total as $key => $total) {
if ($meta) {
$name = $key." (".$total.")";
}
else {
$name = $key." (".$total.")";
}
$data[$name] = $total;
}
/*
if ($other_events > 0) {
$name = __('Other')." (".$other_events.")";
$data[$name] = $other_events;
}
*/
// Sort the data
arsort($data);
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Others'), '', $water_mark,
$config['fontpath'], $config['font_size'], 1, 'bottom');
}
/**
* Print a pie graph with events data in 320x200 size
*
* @param string filter Filter for query in DB
*/
2015-04-15 09:45:13 +02:00
function grafico_eventos_total($filter = "", $width = 320, $height = 200, $noWaterMark = true) {
global $config;
global $graphic_type;
$filter = str_replace ( "\\" , "", $filter);
// Add tags condition to filter
2015-01-23 08:59:42 +01:00
$tags_condition = tags_get_acl_tags($config['id_user'], 0, 'ER', 'event_condition', 'AND');
$filter .= $tags_condition;
$data = array ();
$legend = array ();
$total = 0;
$where = '';
if (!users_is_admin()) {
$where = 'WHERE event_type NOT IN (\'recon_host_detected\', \'system\',\'error\', \'new_agent\', \'configuration_change\')';
}
$sql = sprintf("SELECT criticity, COUNT(id_evento) events
FROM tevento %s
GROUP BY criticity ORDER BY events DESC", $where);
$criticities = db_get_all_rows_sql ($sql, false, false);
if (empty($criticities)) {
$criticities = array();
$colors = array();
}
foreach ($criticities as $cr) {
switch ($cr['criticity']) {
case EVENT_CRIT_MAINTENANCE:
$data[__('Maintenance')] = $cr['events'];
$colors[__('Maintenance')] = COL_MAINTENANCE;
break;
case EVENT_CRIT_INFORMATIONAL:
$data[__('Informational')] = $cr['events'];
$colors[__('Informational')] = COL_INFORMATIONAL;
break;
case EVENT_CRIT_NORMAL:
$data[__('Normal')] = $cr['events'];
$colors[__('Normal')] = COL_NORMAL;
break;
case EVENT_CRIT_MINOR:
$data[__('Minor')] = $cr['events'];
$colors[__('Minor')] = COL_MINOR;
break;
case EVENT_CRIT_WARNING:
$data[__('Warning')] = $cr['events'];
$colors[__('Warning')] = COL_WARNING;
break;
case EVENT_CRIT_MAJOR:
$data[__('Major')] = $cr['events'];
$colors[__('Major')] = COL_MAJOR;
break;
case EVENT_CRIT_CRITICAL:
$data[__('Critical')] = $cr['events'];
$colors[__('Critical')] = COL_CRITICAL;
break;
}
}
2015-04-15 09:45:13 +02:00
if ($noWaterMark) {
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("/images/logo_vertical_water.png", false, false, false));
}
2015-07-14 15:59:39 +02:00
else {
$water_mark = array();
}
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size'], 1, 'bottom', $colors);
}
/**
* Print a pie graph with events data of users
*
* @param integer height pie graph height
* @param integer period time period
*/
function grafico_eventos_usuario ($width, $height) {
global $config;
global $graphic_type;
$data = array ();
$max_items = 5;
$where = '';
if (!users_is_admin()) {
$where = 'WHERE event_type NOT IN (\'recon_host_detected\', \'system\',\'error\', \'new_agent\', \'configuration_change\')';
}
$sql = sprintf ('SELECT COUNT(id_evento) events, id_usuario
FROM tevento %s
GROUP BY id_usuario
ORDER BY 1 DESC LIMIT %d', $where, $max_items);
* include/functions_graph.php include/functions_html.php include/functions_messages.php include/db/postgresql.php include/db/mysql.php include/db/oracle.php include/functions_reporting.php include/functions_filemanager.php include/functions_gis.php include/auth/ldap.php include/auth/mysql.php include/functions_networkmap.php include/functions_network_components.php include/ajax/skins.ajax.php include/ajax/reporting.ajax.php include/ajax/visual_console_builder.ajax.php include/ajax/alert_list.ajax.php include/ajax/module.php include/functions_config.php include/functions_api.php include/help/en/help_timesource.php include/help/es/help_timesource.php include/help/ja/help_timesource.php include/config_process.php include/functions_ui.php include/functions_custom_graphs.php include/fgraph.php include/functions_incidents.php include/api.php include/functions_reports.php include/functions_ui_renders.php extensions/insert_data.php extensions/system_info.php extensions/extension_uploader.php extensions/pandora_logs.php extensions/agents_modules.php extensions/update_manager.php extensions/ssh_console.php extensions/dbmanager.php extensions/vnc_view.php extensions/resource_registration.php extensions/resource_exportation.php extensions/users_connected.php extensions/module_groups.php extensions/update_manager/load_updatemanager.php extensions/update_manager/lib/libupdate_manager_client.php extensions/update_manager/lib/libupdate_manager.php extensions/update_manager/lib/libupdate_manager_components.php extensions/update_manager/lib/libupdate_manager_updates.php extensions/update_manager/settings.php extensions/update_manager/main.php extensions/plugin_registration.php operation/incidents/incident.php operation/incidents/incident_detail.php operation/incidents/incident_statistics.php operation/search_modules.php operation/visual_console/render_view.php operation/visual_console/index.php operation/extensions.php operation/agentes/status_monitor.php operation/agentes/export_csv.php operation/agentes/estado_ultimopaquete.php operation/agentes/datos_agente.php operation/agentes/alerts_status.php operation/agentes/estado_generalagente.php operation/agentes/custom_fields.php operation/agentes/estado_agente.php operation/agentes/networkmap.topology.php operation/agentes/networkmap.groups.php operation/agentes/sla_view.php operation/agentes/exportdata.php operation/agentes/gis_view.php operation/agentes/estado_monitores.php operation/agentes/ver_agente.php operation/agentes/graphs.php operation/agentes/agent_fields.php operation/agentes/tactical.php operation/agentes/group_view.php operation/agentes/networkmap.php operation/agentes/stat_win.php operation/servers/view_server.php operation/servers/view_server_detail.php operation/menu.php operation/search_agents.php operation/search_graphs.php operation/snmpconsole/snmp_view.php operation/users/user_edit.php operation/gis_maps/render_view.php operation/gis_maps/ajax.php operation/integria_incidents/incident.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident_statistics.php operation/events/event_statistics.php operation/events/events_rss.php operation/events/export_csv.php operation/events/sound_events.php operation/events/events_validate.php operation/events/events_list.php operation/events/events_marquee.php operation/events/events.php operation/search_alerts.php operation/messages/message.php operation/reporting/reporting_xml.php operation/reporting/reporting_viewer.php operation/reporting/graph_viewer.php operation/search_reports.php operation/search_maps.php operation/search_users.php extras/pandora_diag.php mobile/operation/agents/monitor_status.php mobile/operation/agents/view_agents.php mobile/operation/agents/view_alerts.php mobile/operation/agents/group_view.php mobile/operation/events/events.php mobile/index.php general/error_authconfig.php general/links_menu.php general/logon_ok.php general/error_dbconfig.php general/ui/agents_list.php general/header.php godmode/groups/modu_group_list.php godmode/groups/configure_group.php godmode/groups/configure_modu_group.php godmode/groups/group_list.php godmode/admin_access_logs.php godmode/db/db_main.php godmode/db/db_audit.php godmode/db/db_sanity.php godmode/db/db_refine.php godmode/db/db_info.php godmode/db/db_event.php godmode/db/db_purge.php godmode/extensions.php godmode/agentes/agent_template.php godmode/agentes/module_manager_editor_common.php godmode/agentes/fields_manager.php godmode/agentes/agent_conf_gis.php godmode/agentes/module_manager_editor_prediction.php godmode/agentes/module_manager.php godmode/agentes/modificar_agente.php godmode/agentes/configurar_agente.php godmode/agentes/configure_field.php godmode/agentes/module_manager_editor.php godmode/agentes/planned_downtime.php godmode/agentes/manage_config_remote.php godmode/agentes/agent_manager.php godmode/servers/recon_script.php godmode/servers/plugin.php godmode/servers/manage_recontask.php godmode/servers/modificar_server.php godmode/servers/manage_recontask_form.php godmode/alerts/alert_list.list.php godmode/alerts/configure_alert_compound.php godmode/alerts/alert_compounds.php godmode/alerts/alert_list.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_templates.php godmode/alerts/configure_alert_action.php godmode/alerts/configure_alert_command.php godmode/alerts/alert_actions.php godmode/alerts/alert_list.builder.php godmode/alerts/alert_commands.php godmode/setup/file_manager.php godmode/setup/os.list.php godmode/setup/news.php godmode/setup/gis_step_2.php godmode/setup/links.php godmode/setup/setup.php godmode/setup/os.php godmode/setup/performance.php godmode/setup/setup_auth.php godmode/setup/gis.php godmode/setup/os.builder.php godmode/setup/setup_visuals.php godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_filters.php godmode/users/user_list.php godmode/users/configure_profile.php godmode/gis_maps/configure_gis_map.php godmode/gis_maps/index.php godmode/massive/massive_add_alerts.php godmode/massive/massive_copy_modules.php godmode/massive/massive_delete_agents.php godmode/massive/massive_enable_disable_alerts.php godmode/massive/massive_operations.php godmode/massive/massive_delete_profiles.php godmode/massive/massive_edit_agents.php godmode/massive/massive_delete_action_alerts.php godmode/massive/massive_delete_modules.php godmode/massive/massive_add_profiles.php godmode/massive/massive_delete_alerts.php godmode/massive/massive_edit_modules.php godmode/massive/massive_standby_alerts.php godmode/massive/massive_add_action_alerts.php godmode/modules/manage_network_components_form.php godmode/modules/manage_nc_groups_form.php godmode/modules/manage_network_templates.php godmode/modules/module_list.php godmode/modules/manage_network_components_form_common.php godmode/modules/manage_network_components_form_network.php godmode/modules/manage_network_templates_form.php godmode/modules/manage_network_components_form_wmi.php godmode/modules/manage_network_components.php godmode/modules/manage_nc_groups.php godmode/reporting/visual_console_builder.wizard.php godmode/reporting/graph_builder.main.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/visual_console_builder.php godmode/reporting/reporting_builder.preview.php godmode/reporting/reporting_builder.main.php godmode/reporting/visual_console_builder.data.php godmode/reporting/visual_console_builder.elements.php godmode/reporting/graph_builder.php godmode/reporting/visual_console_builder.preview.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.php godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php godmode/reporting/map_builder.php godmode/reporting/graphs.php godmode/reporting/graph_builder.preview.php include/functions_db.php: Added some includes and functions of this code have "db_" prefix. * include/functions.php: Moved function check_login(), check_acl(), dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php. * include/functions_groups.php: Moved functions get_childrens(), safe_acl_group() and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(), get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(), get_group_name(), get_group_users() from functions_db.php to this code. * include/functions_profile.php: New library with profile functions. Moved functions get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(), delete_profile() from functions_db.php to this code. Added new parameter in function get_profile() to retrieve profiles with filter conditions applied. * include/functions_users.php: New library with users functions. Moved functions get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(), get_user_first_group(), user_access_to_agent() from funtions_db.php to this code. * godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile(). * include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(), get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(), check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(), agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(), get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(), get_agent_group() from functions_db.php to this code. * include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(), get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(), get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(), get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(), get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(), get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(), get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(), give_modulecategory_name(), give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(), get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(), get_modulegroup_name() from functions_db.php to this code. * include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(), get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(), get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(), get_agentmodule_last_status() from functions_db.php to this code. * include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion() from functions_db.php to this code. * include/functions_events.php: Moved functions get_group_events(), get_agent_events(), get_module_events() from functions_db.php to this code. * include/functions_servers.php: Moved functions get_server_name(), show_server_type(), check_server_status(), server_status() from functions_db.php to this code. * include/functions_network_profiles.php: Moved function get_networkprofile_name() from functions_db.php to this code. * include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y() from fucntions_db.php to this code. * include/functions_io.php: Moved function __() from functions_db.php to this code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
$events = db_get_all_rows_sql ($sql);
if ($events === false) {
$events = array();
}
foreach($events as $event) {
if ($event['id_usuario'] == '0') {
$data[__('System')] = $event['events'];
}
elseif ($event['id_usuario'] == '') {
$data[__('System')] = $event['events'];
}
else {
$data[$event['id_usuario']] = $event['events'];
}
}
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("/images/logo_vertical_water.png", false, false, false));
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
/**
* Print a custom SQL-defined graph
*
* @param integer ID of report content, used to get SQL code to get information for graph
* @param integer height graph height
* @param integer width graph width
* @param integer Graph type 1 vbar, 2 hbar, 3 pie
*/
function graph_custom_sql_graph ($id, $width, $height,
$type = 'sql_graph_vbar', $only_image = false, $homeurl = '',
$ttl = 1, $max_num_elements = 8) {
global $config;
$SQL_GRAPH_MAX_LABEL_SIZE = 20;
$report_content = db_get_row ('treport_content', 'id_rc', $id);
if($id != null){
$historical_db = db_get_value_sql("SELECT historical_db from treport_content where id_rc =".$id);
}
else{
$historical_db = $content['historical_db'];
}
2015-06-08 11:05:19 +02:00
if ($report_content["external_source"] != "") {
$sql = io_safe_output ($report_content["external_source"]);
}
else {
$sql = db_get_row('treport_custom_sql', 'id', $report_content["treport_custom_sql_id"]);
$sql = io_safe_output($sql['sql']);
}
if (($config['metaconsole'] == 1) && defined('METACONSOLE')) {
$metaconsole_connection = enterprise_hook('metaconsole_get_connection', array($report_content['server_name']));
if ($metaconsole_connection === false) {
return false;
}
if (enterprise_hook('metaconsole_load_external_db', array($metaconsole_connection)) != NOERR) {
//ui_print_error_message ("Error connecting to ".$server_name);
return false;
}
}
2015-06-02 19:10:11 +02:00
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
break;
case "oracle":
$sql = str_replace(";", "", $sql);
break;
}
$data_result = db_get_all_rows_sql ($sql,$historical_db);
2015-06-02 19:10:11 +02:00
if (($config['metaconsole'] == 1) && defined('METACONSOLE'))
enterprise_hook('metaconsole_restore_db');
if ($data_result === false)
$data_result = array ();
$data = array ();
$count = 0;
foreach ($data_result as $data_item) {
$count++;
$value = 0;
if (!empty($data_item["value"])) {
$value = $data_item["value"];
}
if ($count <= $max_num_elements) {
$label = __('Data');
if (!empty($data_item["label"])) {
$label = io_safe_output($data_item["label"]);
if (strlen($label) > $SQL_GRAPH_MAX_LABEL_SIZE) {
$first_label = $label;
$label = substr($first_label, 0, floor($SQL_GRAPH_MAX_LABEL_SIZE/2));
$label .= '...';
$label .= substr($first_label, floor(-$SQL_GRAPH_MAX_LABEL_SIZE/2));
}
}
switch ($type) {
case 'sql_graph_vbar': // vertical bar
case 'sql_graph_hbar': // horizontal bar
$data[$label."_".$count]['g'] = $value;
break;
case 'sql_graph_pie': // Pie
$data[$label."_".$count] = $value;
break;
}
} else {
switch ($type) {
case 'sql_graph_vbar': // vertical bar
case 'sql_graph_hbar': // horizontal bar
if (!isset($data[__('Other')]['g'])) $data[__('Other')]['g'] = 0;
$data[__('Other')]['g'] += $value;
break;
case 'sql_graph_pie': // Pie
if (!isset($data[__('Other')])) $data[__('Other')] = 0;
$data[__('Other')] += $value;
break;
}
}
}
$flash_charts = $config['flash_charts'];
if ($only_image) {
$flash_charts = false;
}
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
switch ($type) {
case 'sql_graph_vbar': // vertical bar
2018-03-01 12:02:08 +01:00
return vbar_graph(
$flash_charts,
$data,
$width,
$height,
array(),
array(),
"",
"",
"",
"",
$water_mark,
$config['fontpath'],
$config['font_size'],
"",
$ttl,
2018-04-10 11:37:17 +02:00
$homeurl,
2018-03-01 12:02:08 +01:00
"white",
false,
false,
"c1c1c1"
2018-03-01 12:02:08 +01:00
);
break;
case 'sql_graph_hbar': // horizontal bar
return hbar_graph(
$flash_charts,
$data,
$width,
$height,
array(),
array(),
"",
"",
"",
"",
$water_mark,
$config['fontpath'],
$config['font_size'],
false,
$ttl,
2018-04-10 11:37:17 +02:00
$homeurl,
'white',
'c1c1c1'
);
break;
case 'sql_graph_pie': // Pie
return pie3d_graph($flash_charts, $data, $width, $height, __("other"), $homeurl,
$water_mark, $config['fontpath'], '', $ttl);
break;
}
}
/**
* Print a static graph with event data of agents
*
* @param integer id_agent Agent ID
* @param integer width pie graph width
* @param integer height pie graph height
* @param integer period time period
* @param string homeurl
* @param bool return or echo the result
*/
function graph_graphic_agentevents ($id_agent, $width, $height, $period = 0, $homeurl, $return = false, $from_agent_view = false) {
global $config;
global $graphic_type;
$data = array ();
2018-06-13 11:32:03 +02:00
//$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
$resolution = 5 * ($period * 2 / $width); // Number of "slices" we want in graph
$interval = (int) ($period / $resolution);
$date = get_system_time ();
$datelimit = $date - $period;
$periodtime = floor ($period / $interval);
$time = array ();
$data = array ();
$legend = array();
$full_legend = array();
$full_legend_date = array();
$cont = 0;
for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i);
if (! $graphic_type) {
if ($config['flash_charts']) {
$name = date('H:i', $bottom);
}
else {
$name = date('H\h', $bottom);
}
}
else {
$name = $bottom;
}
// Show less values in legend
if ($cont == 0 or $cont % 2)
$legend[$cont] = $name;
if ($from_agent_view) {
$full_date = date('Y/m/d', $bottom);
$full_legend_date[$cont] = $full_date;
}
$full_legend[$cont] = $name;
$top = $datelimit + ($periodtime * ($i + 1));
2017-07-13 16:57:53 +02:00
$event = db_get_row_filter ('tevento',
array ('id_agente' => $id_agent,
'utimestamp > '.$bottom,
'utimestamp < '.$top), 'criticity, utimestamp');
if (!empty($event['utimestamp'])) {
$data[$cont]['utimestamp'] = $periodtime;
switch ($event['criticity']) {
case EVENT_CRIT_WARNING:
$data[$cont]['data'] = 2;
break;
case EVENT_CRIT_CRITICAL:
$data[$cont]['data'] = 3;
break;
default:
$data[$cont]['data'] = 1;
break;
}
}
else {
$data[$cont]['utimestamp'] = $periodtime;
$data[$cont]['data'] = 1;
}
$cont++;
}
2017-07-13 16:57:53 +02:00
$colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN);
// Draw slicebar graph
if ($config['flash_charts']) {
$out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent, $full_legend_date);
2017-07-13 16:57:53 +02:00
}
else {
$out = slicesbar_graph($data, $period, $width, $height, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
// Draw legend
$out .= "<br>";
$out .= "&nbsp;";
foreach ($legend as $hour) {
$out .= "<span style='font-size: 6pt'>" . $hour . "</span>";
$out .= "&nbsp;";
}
}
if ($return) {
return $out;
}
else {
echo $out;
}
}
/**
* Print a static graph with event data of agents
*
* @param integer id_agent Agent ID
* @param integer width pie graph width
* @param integer height pie graph height
* @param integer period time period
* @param string homeurl
* @param bool return or echo the result
*/
function graph_graphic_moduleevents ($id_agent, $id_module, $width, $height, $period = 0, $homeurl, $return = false) {
global $config;
global $graphic_type;
2018-06-06 11:18:39 +02:00
2017-07-13 16:57:53 +02:00
$data = array ();
2018-06-06 11:18:39 +02:00
2018-06-13 11:32:03 +02:00
//$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
$resolution = 5 * ($period * 2 / $width); // Number of "slices" we want in graph
2017-07-13 16:57:53 +02:00
$interval = (int) ($period / $resolution);
$date = get_system_time ();
$datelimit = $date - $period;
$periodtime = floor ($period / $interval);
$time = array ();
$data = array ();
$legend = array();
$full_legend = array();
2018-06-06 11:18:39 +02:00
2017-07-13 16:57:53 +02:00
$cont = 0;
for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i);
if (! $graphic_type) {
if ($config['flash_charts']) {
$name = date('H:i:s', $bottom);
}
else {
$name = date('H\h', $bottom);
}
}
else {
2017-07-13 16:57:53 +02:00
$name = $bottom;
}
2018-06-06 11:18:39 +02:00
2017-07-13 16:57:53 +02:00
// Show less values in legend
if ($cont == 0 or $cont % 2)
$legend[$cont] = $name;
2018-06-06 11:18:39 +02:00
2017-07-13 16:57:53 +02:00
$full_legend[$cont] = $name;
2018-06-06 11:18:39 +02:00
2017-07-13 16:57:53 +02:00
$top = $datelimit + ($periodtime * ($i + 1));
$event_filter = array ('id_agente' => $id_agent,
'utimestamp > '.$bottom,
'utimestamp < '.$top);
if ((int)$id_module !== 0) {
$event_filter['id_agentmodule'] = $id_module;
}
$event = db_get_row_filter ('tevento', $event_filter, 'criticity, utimestamp');
2017-07-13 16:57:53 +02:00
if (!empty($event['utimestamp'])) {
$data[$cont]['utimestamp'] = $periodtime;
switch ($event['criticity']) {
case EVENT_CRIT_WARNING:
$data[$cont]['data'] = 2;
break;
case EVENT_CRIT_CRITICAL:
$data[$cont]['data'] = 3;
break;
default:
$data[$cont]['data'] = 1;
break;
}
}
else {
$data[$cont]['utimestamp'] = $periodtime;
$data[$cont]['data'] = 1;
}
$cont++;
}
2018-06-06 11:18:39 +02:00
$colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN);
2018-06-06 11:18:39 +02:00
// Draw slicebar graph
if ($config['flash_charts']) {
$out = flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent);
}
else {
$out = slicesbar_graph($data, $period, $width, $height, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
2018-06-06 11:18:39 +02:00
// Draw legend
$out .= "<br>";
$out .= "&nbsp;";
foreach ($legend as $hour) {
$out .= "<span style='font-size: 6pt'>" . $hour . "</span>";
$out .= "&nbsp;";
}
}
2018-02-27 16:28:00 +01:00
if ($return) {
return $out;
}
else {
echo $out;
}
}
// Prints an error image
function fs_error_image ($width = 300, $height = 110) {
global $config;
return graph_nodata_image($width, $height, 'area');
}
2018-02-27 16:28:00 +01:00
function fullscale_data (
$agent_module_id, $date_array,
$show_unknown = 0, $show_percentil = 0,
2018-06-06 11:18:39 +02:00
$series_suffix,
$compare = false,
$data_slice = false,
$type_mode_graph){
2018-02-21 11:54:24 +01:00
2018-02-16 13:41:31 +01:00
global $config;
2018-02-27 16:28:00 +01:00
$data_uncompress =
2018-02-16 13:41:31 +01:00
db_uncompress_module_data(
2018-02-27 16:28:00 +01:00
$agent_module_id,
$date_array['start_date'],
$date_array['final_date'],
$data_slice
2018-02-16 13:41:31 +01:00
);
$data = array();
$previous_data = 0;
//normal
$min_value_total = PHP_INT_MAX;
$max_value_total = -PHP_INT_MAX;
//max
$max_value_min = PHP_INT_MAX;
$max_value_max = -PHP_INT_MAX;
//min
$min_value_min = PHP_INT_MAX;
$min_value_max = -PHP_INT_MAX;
//avg
$avg_value_min = PHP_INT_MAX;
$avg_value_max = -PHP_INT_MAX;
2018-02-16 13:41:31 +01:00
$flag_unknown = 0;
$array_percentil = array();
if($data_slice){
foreach ($data_uncompress as $k) {
$sum_data = 0;
$count_data = 0;
$min_value = PHP_INT_MAX;
$max_value = -PHP_INT_MAX;
$flag_virtual_data = 0;
foreach ($k["data"] as $v) {
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
continue;
$flag_virtual_data = 1;
}
if($compare){ // * 1000 need js utimestam mlsecond
$real_date = ($v['utimestamp'] + $date_array['period']) * 1000;
}
else{
$real_date = $v['utimestamp'] * 1000;
}
if ($v["datos"] === NULL) {
// Unknown
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
}
else{
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
$flag_unknown = 1;
}
2018-06-06 17:23:32 +02:00
}
}
$v["datos"] = $previous_data;
}
else {
//normal
$previous_data = $v["datos"];
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
$flag_unknown = 0;
}
2018-06-06 17:23:32 +02:00
}
2018-02-21 11:54:24 +01:00
}
2018-02-16 13:41:31 +01:00
}
if(isset($v["datos"]) && $v["datos"]){
//max
if($v['datos'] >= $max_value){
$max_value = $v['datos'];
}
//min
if($v['datos'] <= $min_value){
$min_value = $v['datos'];
2018-02-21 11:54:24 +01:00
}
//avg sum
$sum_data += $v["datos"];
2018-02-16 13:41:31 +01:00
}
//avg count
$count_data++;
if($show_percentil && !$compare){
$array_percentil[] = $v["datos"];
}
$last_data = $v["datos"];
2018-02-16 13:41:31 +01:00
}
if(!$flag_virtual_data){
if($compare){ // * 1000 need js utimestam mlsecond
$real_date = ($k['data'][0]['utimestamp'] + $date_array['period']) * 1000;
2018-02-16 13:41:31 +01:00
}
else{
$real_date = $k['data'][0]['utimestamp'] * 1000;
}
$data["sum" . $series_suffix]['data'][] = array($real_date , $sum_data/$count_data);
if($type_mode_graph && !$params['baseline']){
if($min_value != PHP_INT_MAX) {
$data["min" . $series_suffix]['data'][] = array($real_date , $min_value);
}
if($max_value != -PHP_INT_MAX) {
$data["max" . $series_suffix]['data'][] = array($real_date , $max_value);
}
}
else{
if($min_value != PHP_INT_MAX) {
$data["sum" . $series_suffix]['slice_data'][$real_date]['min'] = $min_value;
}
$data["sum" . $series_suffix]['slice_data'][$real_date]['avg'] = $sum_data/$count_data;
if($max_value != -PHP_INT_MAX) {
$data["sum" . $series_suffix]['slice_data'][$real_date]['max'] = $max_value;
}
2018-02-16 13:41:31 +01:00
}
//max_total
if($max_value >= $max_value_total && $max_value != -PHP_INT_MAX){
$max_value_total = $max_value;
}
//min_total
if($min_value <= $min_value_total && $min_value != PHP_INT_MAX){
$min_value_total = $min_value;
}
//avg sum_total
$sum_data_total += $sum_data;
//avg count_total
$count_data_total++;
if($type_mode_graph && !$params['baseline']){
/*MIN*/
//max_min
if($min_value >= $min_value_max && $min_value != PHP_INT_MAX){
$min_value_max = $min_value;
}
//min_min
if($min_value <= $min_value_min && $min_value != PHP_INT_MAX){
$min_value_min = $min_value;
}
//avg sum_min
if ($min_value != PHP_INT_MAX) {
$sum_data_min += $min_value;
}
/*MAX*/
//max_max
if($max_value >= $max_value_max && $max_value != -PHP_INT_MAX){
$max_value_max = $max_value;
}
//min_max
if($max_value <= $max_value_min && $max_value != -PHP_INT_MAX){
$max_value_min = $max_value;
}
//avg sum_max
if ($max_value != -PHP_INT_MAX) {
$sum_data_max += $max_value;
}
/*AVG*/
//max_max
if(($sum_data/$count_data) >= $avg_value_max){
$avg_value_max = $sum_data/$count_data;
}
//min_max
if(($sum_data/$count_data) <= $avg_value_min){
$avg_value_min = $sum_data/$count_data;
}
//avg sum_max
$sum_data_avg += $sum_data/$count_data;
}
2018-02-16 13:41:31 +01:00
}
}
$data["sum" . $series_suffix]['min'] = $min_value_total;
$data["sum" . $series_suffix]['max'] = $max_value_total;
$data["sum" . $series_suffix]['avg'] = $sum_data_total/$count_data_total;
if($type_mode_graph && !$params['baseline']){
$data["min" . $series_suffix]['min'] = $min_value_min;
$data["min" . $series_suffix]['max'] = $min_value_max;
$data["min" . $series_suffix]['avg'] = $sum_data_min/$count_data_total;
$data["max" . $series_suffix]['min'] = $max_value_min;
$data["max" . $series_suffix]['max'] = $max_value_max;
$data["max" . $series_suffix]['avg'] = $sum_data_max/$count_data_total;
$data["sum" . $series_suffix]['min'] = $avg_value_min;
$data["sum" . $series_suffix]['max'] = $avg_value_max;
$data["sum" . $series_suffix]['avg'] = $sum_data_avg/$count_data_total;
}
}
else{
foreach ($data_uncompress as $k) {
foreach ($k["data"] as $v) {
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
continue;
}
if($compare){ // * 1000 need js utimestam mlsecond
$real_date = ($v['utimestamp'] + $date_array['period']) * 1000;
}
else{
$real_date = $v['utimestamp'] * 1000;
}
2018-02-16 13:41:31 +01:00
if ($v["datos"] === NULL) {
// Unknown
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
}
else{
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
$flag_unknown = 1;
}
}
}
$data["sum" . $series_suffix]['data'][] = array($real_date , $previous_data);
}
else {
//normal
$previous_data = $v["datos"];
$data["sum" . $series_suffix]['data'][] = array($real_date , $v["datos"]);
if($show_unknown){
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
$flag_unknown = 0;
}
}
}
}
if(isset($v["datos"]) && $v["datos"]){
//max
if($v['datos'] >= $max_value){
$max_value = $v['datos'];
}
//min
if($v['datos'] <= $min_value){
$min_value = $v['datos'];
}
//avg sum
$sum_data += $v["datos"];
}
//avg count
$count_data++;
if($show_percentil && !$compare){
$array_percentil[] = $v["datos"];
}
$last_data = $v["datos"];
}
2018-02-16 13:41:31 +01:00
}
$data["sum" . $series_suffix]['min'] = $min_value;
$data["sum" . $series_suffix]['max'] = $max_value;
$data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
2018-02-16 13:41:31 +01:00
}
2018-02-21 11:54:24 +01:00
if($show_percentil && !$compare){
2018-02-16 13:41:31 +01:00
$percentil_result = get_percentile($show_percentil, $array_percentil);
2018-02-21 11:54:24 +01:00
if($compare){
2018-02-27 16:28:00 +01:00
$data["percentil" . $series_suffix]['data'][] = array(
($date_array['start_date'] + $date_array['period']) * 1000,
$percentil_result
);
$data["percentil" . $series_suffix]['data'][] = array(
($date_array['final_date'] + $date_array['period']) * 1000,
$percentil_result
);
2018-02-21 11:54:24 +01:00
}
else{
2018-02-27 16:28:00 +01:00
$data["percentil" . $series_suffix]['data'][] = array(
$date_array['start_date'] * 1000,
$percentil_result
);
$data["percentil" . $series_suffix]['data'][] = array(
$date_array['final_date'] * 1000,
$percentil_result
);
2018-02-21 11:54:24 +01:00
}
2018-02-16 13:41:31 +01:00
}
// Add missed last data
2018-02-21 11:54:24 +01:00
if($compare){
2018-02-27 16:28:00 +01:00
$data["sum" . $series_suffix]['data'][] = array(
($date_array['final_date'] + $date_array['period']) * 1000,
$last_data
);
2018-02-21 11:54:24 +01:00
}
else{
2018-02-27 16:28:00 +01:00
$data["sum" . $series_suffix]['data'][] = array(
$date_array['final_date'] * 1000,
$last_data
);
if($data_slice){
if($type_mode_graph && !$params['baseline']){
$data["min" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $min_value);
$data["max" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $max_value);
}
else{
$data["sum" . $series_suffix]['slice_data'][$date_array['final_date'] * 1000]['min'] = $min_value;
$data["sum" . $series_suffix]['slice_data'][$date_array['final_date'] * 1000]['avg'] = $sum_data/$count_data;
$data["sum" . $series_suffix]['slice_data'][$date_array['final_date'] * 1000]['max'] = $max_value;
}
}
2018-02-21 11:54:24 +01:00
}
2018-02-27 16:28:00 +01:00
2018-02-16 13:41:31 +01:00
return $data;
}
2018-02-27 16:28:00 +01:00
/**
* Print an area graph with netflow aggregated
*/
function graph_netflow_aggregate_area ($data, $period, $width, $height, $unit = '', $ttl = 1, $only_image = false) {
2017-09-20 17:29:17 +02:00
global $config;
2018-02-27 16:28:00 +01:00
global $graphic_type;
if (empty ($data)) {
echo fs_error_image ();
return;
}
2018-02-27 16:28:00 +01:00
// Calculate source indexes
2018-06-06 11:18:39 +02:00
foreach ($data['sources'] as $key => $value) {
$i = 0;
foreach($data['data'] as $k => $v){
$chart['netflow_' . $key]['data'][$i][0] = $k * 1000;
$chart['netflow_' . $key]['data'][$i][1] = $v[$key];
$i++;
}
}
2018-06-06 11:18:39 +02:00
if ($config['homeurl'] != '') {
$homeurl = $config['homeurl'];
}
else {
$homeurl = '';
}
2018-06-06 11:18:39 +02:00
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
2018-06-06 11:18:39 +02:00
$water_mark = $config['homedir'] . "/images/logo_vertical_water.png";
}
2018-06-06 11:18:39 +02:00
if($ttl >= 2){
$only_image = true;
}
else{
$only_image = false;
}
$params =array(
'agent_module_id' => false,
'period' => $period,
'width' =>'90%',
'height' => 450,
'unit' => $unit,
'only_image' => $only_image,
'homeurl' => $homeurl,
'menu' => true,
'backgroundColor' => 'white',
'type_graph' => 'area',
'font' => $config['fontpath'],
2018-06-13 19:13:42 +02:00
'font_size' => $config['font_size'],
2018-06-06 11:18:39 +02:00
'array_data_create' => $chart
);
return grafico_modulo_sparse($params);
}
/**
* Print an area graph with netflow total
*/
function graph_netflow_total_area ($data, $period, $width, $height, $unit = '', $ttl = 1, $only_image = false) {
global $config;
global $graphic_type;
2018-06-06 11:18:39 +02:00
if (empty ($data)) {
echo fs_error_image ();
return;
}
2018-06-06 11:18:39 +02:00
// Calculate source indexes
$i=0;
foreach ($data as $key => $value) {
$chart['netflow']['data'][$i][0] = $key * 1000;
$chart['netflow']['data'][$i][1] = $value['data'];
$i++;
}
if ($config['homeurl'] != '') {
$homeurl = $config['homeurl'];
}
else {
$homeurl = '';
}
2018-06-06 11:18:39 +02:00
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
2018-06-06 11:18:39 +02:00
$water_mark = $config['homedir'] . "/images/logo_vertical_water.png";
}
2018-06-06 11:18:39 +02:00
if($ttl >= 2){
$only_image = true;
}
else{
$only_image = false;
}
$params =array(
'agent_module_id' => false,
'period' => $period,
'width' =>'90%',
'height' => 450,
'unit' => $unit,
'only_image' => $only_image,
'homeurl' => $homeurl,
'menu' => true,
'backgroundColor' => 'white',
'type_graph' => 'area',
'font' => $config['fontpath'],
2018-06-13 19:13:42 +02:00
'font_size' => $config['font_size'],
2018-06-06 11:18:39 +02:00
'array_data_create' => $chart
);
return grafico_modulo_sparse($params);
}
/**
* Print a pie graph with netflow aggregated
*/
function graph_netflow_aggregate_pie ($data, $aggregate, $ttl = 1, $only_image = false) {
global $config;
global $graphic_type;
2018-06-06 11:18:39 +02:00
if (empty ($data)) {
return fs_error_image ();
}
2018-06-06 11:18:39 +02:00
$date_array = array();
$date_array["period"] = 300;
$date_array["final_date"] = time();
$date_array["start_date"] = time() - 300;
$i = 0;
$values = array();
$agg = '';
while (isset ($data[$i])) {
$agg = $data[$i]['agg'];
if (!isset($values[$agg])) {
$values[$agg] = $data[$i]['data'];
}
else {
$values[$agg] += $data[$i]['data'];
}
$i++;
}
2018-06-06 11:18:39 +02:00
$flash_chart = $config['flash_charts'];
if ($only_image) {
$flash_chart = false;
}
2018-06-06 11:18:39 +02:00
if($config["fixed_graph"] == false){
$water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
}
2018-06-06 11:18:39 +02:00
return pie3d_graph($flash_chart, $values, 370, 200,
__('Other'), $config['homeurl'], $water_mark,
$config['fontpath'], $config['font_size'], $ttl);
}
/**
* Print a circular graph with the data transmitted between IPs
*/
function graph_netflow_circular_mesh ($data, $unit, $radius = 700) {
global $config;
if (empty($data) || empty($data['elements']) || empty($data['matrix'])) {
return fs_error_image ();
}
include_once($config['homedir'] . "/include/graphs/functions_d3.php");
return d3_relationship_graph ($data['elements'], $data['matrix'], $unit, $radius, true);
}
/**
* Print a rectangular graph with the traffic of the ports for each IP
*/
function graph_netflow_host_traffic ($data, $unit, $width = 700, $height = 700) {
global $config;
if (empty ($data)) {
return fs_error_image ();
}
include_once($config['homedir'] . "/include/graphs/functions_d3.php");
return d3_tree_map_graph ($data, $width, $height, true);
}
/**
2018-02-27 16:28:00 +01:00
* Print a graph with event data of module
*
2018-02-27 16:28:00 +01:00
* @param integer id_module Module ID
* @param integer width graph width
2018-02-27 16:28:00 +01:00
* @param integer height graph height
* @param integer period time period
* @param string homeurl Home url if the complete path is needed
* @param int Zoom factor over the graph
* @param string adaptation width and margin left key (could be adapter_[something] or adapted_[something])
* @param int date limit of the period
*/
2018-02-27 16:28:00 +01:00
function graphic_module_events ($id_module, $width, $height, $period = 0, $homeurl = '', $zoom = 0, $adapt_key = '', $date = false, $stat_win = false) {
global $config;
global $graphic_type;
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
$data = array ();
2018-05-10 08:43:09 +02:00
2018-06-13 11:32:03 +02:00
//$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
$resolution = 5 * ($period * 2 / $width); // Number of "slices" we want in graph
$interval = (int) ($period / $resolution);
2018-02-27 16:28:00 +01:00
if ($date === false) {
$date = get_system_time ();
}
2018-02-27 16:28:00 +01:00
$datelimit = $date - $period;
$periodtime = floor ($period / $interval);
$time = array ();
$data = array ();
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
// Set the title and time format
if ($period <= SECONDS_6HOURS) {
$time_format = 'H:i:s';
}
2018-02-27 16:28:00 +01:00
elseif ($period < SECONDS_1DAY) {
$time_format = 'H:i';
}
2018-02-27 16:28:00 +01:00
elseif ($period < SECONDS_15DAYS) {
$time_format = 'M d H:i';
}
2018-02-27 16:28:00 +01:00
elseif ($period < SECONDS_1MONTH) {
$time_format = 'M d H\h';
}
2018-02-27 16:28:00 +01:00
elseif ($period < SECONDS_6MONTHS) {
$time_format = "M d H\h";
}
else {
2018-02-27 16:28:00 +01:00
$time_format = "Y M d H\h";
}
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
$legend = array();
$cont = 0;
for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i);
if (! $graphic_type) {
$name = date($time_format, $bottom);
//$name = date('H\h', $bottom);
}
else {
2018-02-27 16:28:00 +01:00
$name = $bottom;
}
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
$top = $datelimit + ($periodtime * ($i + 1));
2018-05-10 08:43:09 +02:00
$events = db_get_all_rows_filter ('tevento',
2018-02-27 16:28:00 +01:00
array ('id_agentmodule' => $id_module,
'utimestamp > '.$bottom,
'utimestamp < '.$top),
'event_type, utimestamp');
if (!empty($events)) {
$status = 'normal';
foreach($events as $event) {
if (empty($event['utimestamp'])) {
continue;
}
switch($event['event_type']) {
case 'going_down_normal':
case 'going_up_normal':
// The default status is normal. Do nothing
break;
case 'going_unknown':
if ($status == 'normal') {
$status = 'unknown';
}
break;
case 'going_up_warning':
case 'going_down_warning':
if ($status == 'normal' || $status == 'unknown') {
$status = 'warning';
}
break;
case 'going_up_critical':
case 'going_down_critical':
$status = 'critical';
break;
}
}
}
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
$data[$cont]['utimestamp'] = $periodtime;
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
if (!empty($events)) {
switch ($status) {
case 'warning':
$data[$cont]['data'] = 2;
break;
case 'critical':
$data[$cont]['data'] = 3;
break;
case 'unknown':
$data[$cont]['data'] = 4;
break;
default:
$data[$cont]['data'] = 1;
break;
}
}
else {
2018-02-27 16:28:00 +01:00
$data[$cont]['data'] = 1;
}
2018-02-27 16:28:00 +01:00
$current_timestamp = $bottom;
2018-05-10 08:43:09 +02:00
$legend[] = date($time_format, $current_timestamp);
2018-02-27 16:28:00 +01:00
$cont++;
}
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($data);
if ($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
2018-02-27 16:28:00 +01:00
else {
$xdata_display = $max_xdata_display;
}
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
$step = round($ndata/$xdata_display);
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
$colors = array(1 => '#38B800', 2 => '#FFFF00', 3 => '#FF0000', 4 => '#C3C3C3');
2018-05-10 08:43:09 +02:00
2018-02-27 16:28:00 +01:00
// Draw slicebar graph
if ($config['flash_charts']) {
2018-05-10 08:43:09 +02:00
echo flot_slicesbar_graph($data, $period, $width, 50, $legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', $adapt_key, $stat_win);
}
2018-02-27 16:28:00 +01:00
else {
echo slicesbar_graph($data, $period, $width, 15, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
}
2018-02-27 16:28:00 +01:00
}
function graph_nodata_image($width = 300, $height = 110, $type = 'area', $text = '') {
$image = ui_get_full_url('images/image_problem_area_small.png',
false, false, false);
2018-02-27 16:28:00 +01:00
// if ($text == '') {
// $text = __('No data to show');
// }
2018-02-27 16:28:00 +01:00
$text_div = '<div class="nodata_text">' . $text . '</div>';
2018-02-27 16:28:00 +01:00
$image_div = '<div class="nodata_container" style="width:80%;height:80%;background-size: 80% 80%;background-image: url(\'' . $image . '\');">' .
$text_div . '</div>';
2018-02-27 16:28:00 +01:00
$div = '<div style="width:' . $width . 'px; height:' . $height . 'px; border: 1px dotted #ddd; background-color: white; margin: 0 auto;">' .
$image_div . '</div>';
2018-02-27 16:28:00 +01:00
return $div;
}
function get_criticity_pie_colors ($data_graph) {
$colors = array();
foreach (array_keys($data_graph) as $crit) {
switch ($crit) {
case __('Maintenance'):
$colors[$crit] = COL_MAINTENANCE;
break;
case __('Informational'):
$colors[$crit] = COL_INFORMATIONAL;
break;
case __('Normal'):
$colors[$crit] = COL_NORMAL;
break;
case __('Warning'):
$colors[$crit] = COL_WARNING;
break;
case __('Critical'):
$colors[$crit] = COL_CRITICAL;
break;
case __('Minor'):
$colors[$crit] = COL_MINOR;
break;
case __('Major'):
$colors[$crit] = COL_MAJOR;
break;
}
}
2018-02-27 16:28:00 +01:00
return $colors;
}
2018-02-27 16:28:00 +01:00
/**
2018-02-27 16:28:00 +01:00
* Print a rectangular graph with the snmptraps received
*/
2018-02-27 16:28:00 +01:00
function graph_snmp_traps_treemap ($data, $width = 700, $height = 700) {
global $config;
2018-02-27 16:28:00 +01:00
if (empty ($data)) {
return fs_error_image ();
}
2018-02-27 16:28:00 +01:00
include_once($config['homedir'] . "/include/graphs/functions_d3.php");
return d3_tree_map_graph ($data, $width, $height, true);
}
/**
* Print a solarburst graph with a representation of all the groups, agents, module groups and modules grouped
*/
function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
global $config;
include_once ($config['homedir'] . "/include/functions_users.php");
include_once ($config['homedir'] . "/include/functions_groups.php");
include_once ($config['homedir'] . "/include/functions_agents.php");
include_once ($config['homedir'] . "/include/functions_modules.php");
$graph_data = array();
$filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false;
if ($filter['group'] != 0) {
$filter_subgroups = "";
if (!$filter['dont_show_subgroups']) {
$filter_subgroups = " || parent = " . $filter['group'];
}
$groups = db_get_all_rows_sql ("SELECT * FROM tgrupo where id_grupo = " . $filter['group'] . $filter_subgroups);
$groups_ax = array();
foreach ($groups as $g) {
$groups_ax[$g['id_grupo']] = $g;
}
$groups = $groups_ax;
}
else {
2018-02-27 16:28:00 +01:00
$groups = users_get_groups(false, "AR", false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null));
}
2018-02-27 16:28:00 +01:00
$data_groups = array();
if (!empty($groups)) {
$groups_aux = $groups;
2018-02-27 16:28:00 +01:00
$childrens = array();
$data_groups = groups_get_tree_good($groups, false, $childrens);
// When i want only one group
if (count($data_groups) > 1) {
foreach ($childrens as $id_c) {
unset($data_groups[$id_c]);
}
}
$data_groups_keys = array();
groups_get_tree_keys($data_groups, $data_groups_keys);
$groups_aux = null;
}
if (!empty($data_groups)) {
$filter = array('id_grupo' => array_keys($data_groups_keys));
2017-10-04 17:49:46 +02:00
$fields = array('id_agente', 'id_parent', 'id_grupo', 'alias');
$agents = agents_get_agents($filter, $fields);
if (!empty($agents)) {
$agents_id = array();
$agents_aux = array();
foreach ($agents as $key => $agent) {
$agents_aux[$agent['id_agente']] = $agent;
}
$agents = $agents_aux;
$agents_aux = null;
$fields = array('id_agente_modulo', 'id_agente', 'id_module_group', 'nombre');
$module_groups = modules_get_modulegroups();
$module_groups[0] = __('Not assigned');
$modules = agents_get_modules(array_keys($agents), '*');
$data_agents = array();
if (!empty($modules)) {
foreach ($modules as $key => $module) {
$module_id = (int) $module['id_agente_modulo'];
$agent_id = (int) $module['id_agente'];
$module_group_id = (int) $module['id_module_group'];
$module_name = io_safe_output($module['nombre']);
$module_status = modules_get_agentmodule_status($module_id);
$module_value = modules_get_last_value($module_id);
if ($filter_module_group && $filter_module_group != $module_group_id)
continue;
if (!isset($data_agents[$agent_id])) {
$data_agents[$agent_id] = array();
$data_agents[$agent_id]['id'] = $agent_id;
2017-10-04 17:49:46 +02:00
$data_agents[$agent_id]['name'] = io_safe_output($agents[$agent_id]['alias']);
$data_agents[$agent_id]['group'] = (int) $agents[$agent_id]['id_grupo'];
$data_agents[$agent_id]['type'] = 'agent';
$data_agents[$agent_id]['size'] = 30;
$data_agents[$agent_id]['show_name'] = true;
$data_agents[$agent_id]['children'] = array();
$tooltip_content = __('Agent') . ": <b>" . $data_agents[$agent_id]['name'] . "</b>";
$data_agents[$agent_id]['tooltip_content'] = io_safe_output($tooltip_content);
$data_agents[$agent_id]['modules_critical'] = 0;
$data_agents[$agent_id]['modules_warning'] = 0;
$data_agents[$agent_id]['modules_normal'] = 0;
$data_agents[$agent_id]['modules_not_init'] = 0;
$data_agents[$agent_id]['modules_not_normal'] = 0;
$data_agents[$agent_id]['modules_unknown'] = 0;
$data_agents[$agent_id]['color'] = COL_UNKNOWN;
unset($agents[$agent_id]);
}
if (!isset($data_agents[$agent_id]['children'][$module_group_id])) {
$data_agents[$agent_id]['children'][$module_group_id] = array();
$data_agents[$agent_id]['children'][$module_group_id]['id'] = $module_group_id;
$data_agents[$agent_id]['children'][$module_group_id]['name'] = io_safe_output($module_groups[$module_group_id]);
$data_agents[$agent_id]['children'][$module_group_id]['type'] = 'module_group';
$data_agents[$agent_id]['children'][$module_group_id]['size'] = 10;
$data_agents[$agent_id]['children'][$module_group_id]['children'] = array();
$tooltip_content = __('Module group') . ": <b>" . $data_agents[$agent_id]['children'][$module_group_id]['name'] . "</b>";
$data_agents[$agent_id]['children'][$module_group_id]['tooltip_content'] = $tooltip_content;
$data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_warning'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_normal'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_not_init'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['modules_unknown'] = 0;
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_UNKNOWN;
}
switch ($module_status) {
case AGENT_MODULE_STATUS_CRITICAL_BAD:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
$data_agents[$agent_id]['modules_critical']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_critical']++;
break;
case AGENT_MODULE_STATUS_WARNING:
case AGENT_MODULE_STATUS_WARNING_ALERT:
$data_agents[$agent_id]['modules_warning']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_warning']++;
break;
case AGENT_MODULE_STATUS_NORMAL:
case AGENT_MODULE_STATUS_NORMAL_ALERT:
$data_agents[$agent_id]['modules_normal']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_normal']++;
break;
case AGENT_MODULE_STATUS_NOT_INIT:
$data_agents[$agent_id]['modules_not_init']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_not_init']++;
break;
case AGENT_MODULE_STATUS_NOT_NORMAL:
$data_agents[$agent_id]['modules_not_normal']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal']++;
break;
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_UNKNOWN:
$data_agents[$agent_id]['modules_unknown']++;
$data_agents[$agent_id]['children'][$module_group_id]['modules_unknown']++;
break;
}
if ($data_agents[$agent_id]['modules_critical'] > 0) {
$data_agents[$agent_id]['color'] = COL_CRITICAL;
}
else if ($data_agents[$agent_id]['modules_warning'] > 0) {
$data_agents[$agent_id]['color'] = COL_WARNING;
}
else if ($data_agents[$agent_id]['modules_not_normal'] > 0) {
$data_agents[$agent_id]['color'] = COL_WARNING;
}
else if ($data_agents[$agent_id]['modules_unknown'] > 0) {
$data_agents[$agent_id]['color'] = COL_UNKNOWN;
}
else if ($data_agents[$agent_id]['modules_normal'] > 0) {
$data_agents[$agent_id]['color'] = COL_NORMAL;
}
else {
$data_agents[$agent_id]['color'] = COL_NOTINIT;
}
if ($data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_CRITICAL;
}
else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_warning'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_WARNING;
}
else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_WARNING;
}
else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_unknown'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_UNKNOWN;
}
else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_normal'] > 0) {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_NORMAL;
}
else {
$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_NOTINIT;
}
$data_module = array();
$data_module['id'] = $module_id;
$data_module['name'] = $module_name;
$data_module['type'] = 'module';
$data_module['size'] = 10;
$data_module['link'] = ui_get_full_url("index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$agent_id");
$tooltip_content = __('Module') . ": <b>" . $module_name . "</b>";
if (isset($module_value) && $module_value !== false) {
$tooltip_content .= "<br>";
$tooltip_content .= __('Value') . ": <b>" . io_safe_output($module_value) . "</b>";
}
$data_module['tooltip_content'] = $tooltip_content;
switch ($module_status) {
case AGENT_MODULE_STATUS_CRITICAL_BAD:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
$data_module['color'] = COL_CRITICAL;
break;
case AGENT_MODULE_STATUS_WARNING:
case AGENT_MODULE_STATUS_WARNING_ALERT:
$data_module['color'] = COL_WARNING;
break;
case AGENT_MODULE_STATUS_NORMAL:
case AGENT_MODULE_STATUS_NORMAL_ALERT:
$data_module['color'] = COL_NORMAL;
break;
case AGENT_MODULE_STATUS_NOT_INIT:
$data_module['color'] = COL_NOTINIT;
break;
case AGENT_MODULE_STATUS_NOT_NORMAL:
$data_module['color'] = COL_WARNING;
break;
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_UNKNOWN:
default:
$data_module['color'] = COL_UNKNOWN;
break;
}
$data_agents[$agent_id]['children'][$module_group_id]['children'][] = $data_module;
unset($modules[$module_id]);
}
function order_module_group_keys ($value, $key) {
$value['children'] = array_merge($value['children']);
return $value;
}
$data_agents = array_map('order_module_group_keys', $data_agents);
}
foreach ($agents as $id => $agent) {
if (!isset($data_agents[$id])) {
$data_agents[$id] = array();
$data_agents[$id]['id'] = (int) $id;
2017-10-04 17:49:46 +02:00
$data_agents[$id]['name'] = io_safe_output($agent['alias']);
$data_agents[$id]['type'] = 'agent';
$data_agents[$id]['color'] = COL_NOTINIT;
$data_agents[$id]['show_name'] = true;
}
}
$agents = null;
}
}
function iterate_group_array ($groups, &$data_agents) {
$data = array();
foreach ($groups as $id => $group) {
$group_aux = array();
$group_aux['id'] = (int) $id;
$group_aux['name'] = io_safe_output($group['nombre']);
$group_aux['show_name'] = true;
$group_aux['parent'] = (int) $group['parent'];
$group_aux['type'] = 'group';
$group_aux['size'] = 100;
$group_aux['status'] = groups_get_status($id);
switch ($group_aux['status']) {
case AGENT_STATUS_CRITICAL:
$group_aux['color'] = COL_CRITICAL;
break;
case AGENT_STATUS_WARNING:
case AGENT_STATUS_ALERT_FIRED:
$group_aux['color'] = COL_WARNING;
break;
case AGENT_STATUS_NORMAL:
$group_aux['color'] = COL_NORMAL;
break;
case AGENT_STATUS_UNKNOWN:
default:
$group_aux['color'] = COL_UNKNOWN;
break;
}
$tooltip_content = html_print_image("images/groups_small/" . $group['icon'] . ".png", true) . "&nbsp;" . __('Group') . ": <b>" . $group_aux['name'] . "</b>";
$group_aux['tooltip_content'] = $tooltip_content;
$group_aux['children'] = array();
if (!empty($group['children']))
$group_aux['children'] = iterate_group_array($group['children'], $data_agents);
$agents = extract_agents_with_group_id($data_agents, (int) $id);
if (!empty($agents))
$group_aux['children'] = array_merge($group_aux['children'], $agents);
$data[] = $group_aux;
}
return $data;
}
function extract_agents_with_group_id (&$agents, $group_id) {
$valid_agents = array();
foreach ($agents as $id => $agent) {
if (isset($agent['group']) && $agent['group'] == $group_id) {
$valid_agents[$id] = $agent;
unset($agents[$id]);
}
}
if (!empty($valid_agents))
return $valid_agents;
else
return false;
}
$graph_data = array('name' => __('Main node'), 'type' => 'center_node', 'children' => iterate_group_array($data_groups, $data_agents), 'color' => '#3F3F3F');
if (empty($graph_data['children']))
return fs_error_image();
include_once($config['homedir'] . "/include/graphs/functions_d3.php");
return d3_sunburst_graph ($graph_data, $width, $height, true);
}
2018-02-27 16:28:00 +01:00
?>