2007-06-07 19:46:38 +02:00
< ? php
2009-06-08 20:26:14 +02:00
// Pandora FMS - http://pandorafms.com
// ==================================================
2011-03-02 22:56:48 +01:00
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
2009-06-08 20:26:14 +02:00
// Please see http://pandorafms.org for full contribution list
2008-04-23 22:01:37 +02:00
// This program is free software; you can redistribute it and/or
2011-03-22 23:11:57 +01:00
// modify it under the terms of the GNU Lesser General Public License
2009-06-08 20:26:14 +02:00
// as published by the Free Software Foundation; version 2
2008-04-23 22:01:37 +02:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
2011-03-22 23:11:57 +01:00
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2008-04-23 22:01:37 +02:00
// GNU General Public License for more details.
2007-06-07 19:46:38 +02:00
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php,
include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/FusionCharts/FusionCharts_Gen.php,
include/FusionCharts/FusionCharts.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/help/en/help_plugin_parameters.php,
include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php,
include/help/en/help_postprocess.php,
include/help/en/help_prediction_source_module.php,
include/help/en/help_date_format.php, include/help/en/help_recontask.php,
include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php,
include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php,
include/help/en/help_agent_status.php,
include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php,
include/help/en/help_alert_type.php,
include/help/en/help_network_component.php,
include/help/en/help_time_stamp-comparation.php,
include/help/en/help_eventview.php, include/help/en/help_timesource.php,
include/help/en/help_alert_validation.php,
include/help/en/help_map_builder.php,
include/help/en/help_alert_recovery.php,
include/help/en/help_module_type.php,
include/help/en/help_planned_downtime.php,
include/help/en/help_serverlag.php, include/help/en/help_alerts.php,
include/help/en/help_snmpwalk.php,
include/help/en/help_module_definition.php,
include/help/en/help_plugin_definition.php,
include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php
include/help/en/help_manageconfig.php,
include/help/es/help_alert_validation.php,
include/help/es/help_plugin_parameters.php,
include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php,
include/help/es/help_map_builder.php, include/help/es/help_postprocess.php,
include/help/es/help_date_format.php,
include/help/es/help_alert_recovery.php,
include/help/es/help_prediction_source_module.php,
include/help/es/help_module_type.php,
include/help/es/help_planned_downtime.php,
include/help/es/help_alert-matches.php, include/help/es/help_recontask.php,
include/help/es/help_alerts.php, include/help/es/help_serverlag.php,
include/help/es/help_snmpwalk.php,
include/help/es/help_module_definition.php,
include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php,
include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php,
include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php,
include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php,
include/help/es/help_wminamespace.php,
include/help/es/help_network_component.php,
include/help/es/help_time_stamp-comparation.php,
include/help/es/help_manageconfig.php, include/help/es/help_timesource.php,
include/config_process.php, include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change comments blocks for delete the
warnings to construct phpDoc Files, give a struct and order in the
phpDoc files.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-25 19:39:28 +02:00
/**
* @ package Include
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/ldap.php,
include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/config_process.php,
include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change or add the subpackage in phpdoc
comment blocks for to organize more the result phpdoc files. Start to
document undocument functions.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1882 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-26 17:37:47 +02:00
* @ subpackage Reporting
2009-08-24 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_menu.php, include/functions_html.php,
include/functions_events.php, include/functions_messages.php,
include/functions_modules.php, include/functions_exportserver.php,
include/functions_reporting.php, include/functions_filemanager.php,
include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php,
include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php,
include/functions_networkmap.php, include/functions_servers.php,
include/FusionCharts/FusionCharts_Gen.php,
include/FusionCharts/FusionCharts.php,
include/functions_network_profiles.php, include/gettext.php,
include/functions_network_components.php, include/functions_visual_map.php,
include/fgraph2.php, include/Image/image_functions.php,
include/functions_config.php, include/help/en/help_plugin_parameters.php,
include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php,
include/help/en/help_postprocess.php,
include/help/en/help_prediction_source_module.php,
include/help/en/help_date_format.php, include/help/en/help_recontask.php,
include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php,
include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php,
include/help/en/help_agent_status.php,
include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php,
include/help/en/help_alert_type.php,
include/help/en/help_network_component.php,
include/help/en/help_time_stamp-comparation.php,
include/help/en/help_eventview.php, include/help/en/help_timesource.php,
include/help/en/help_alert_validation.php,
include/help/en/help_map_builder.php,
include/help/en/help_alert_recovery.php,
include/help/en/help_module_type.php,
include/help/en/help_planned_downtime.php,
include/help/en/help_serverlag.php, include/help/en/help_alerts.php,
include/help/en/help_snmpwalk.php,
include/help/en/help_module_definition.php,
include/help/en/help_plugin_definition.php,
include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php
include/help/en/help_manageconfig.php,
include/help/es/help_alert_validation.php,
include/help/es/help_plugin_parameters.php,
include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php,
include/help/es/help_map_builder.php, include/help/es/help_postprocess.php,
include/help/es/help_date_format.php,
include/help/es/help_alert_recovery.php,
include/help/es/help_prediction_source_module.php,
include/help/es/help_module_type.php,
include/help/es/help_planned_downtime.php,
include/help/es/help_alert-matches.php, include/help/es/help_recontask.php,
include/help/es/help_alerts.php, include/help/es/help_serverlag.php,
include/help/es/help_snmpwalk.php,
include/help/es/help_module_definition.php,
include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php,
include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php,
include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php,
include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php,
include/help/es/help_wminamespace.php,
include/help/es/help_network_component.php,
include/help/es/help_time_stamp-comparation.php,
include/help/es/help_manageconfig.php, include/help/es/help_timesource.php,
include/config_process.php, include/functions_ui.php, include/htmlawed.php,
include/functions_custom_graphs.php, include/fgraph.php,
include/functions_incidents.php, include/functions.php,
include/functions_agents.php, include/functions_db.php,
include/functions_themes.php, include/streams.php,
include/functions_fsgraph.php, include/functions_alerts.php,
include/functions_reports.php, include/functions_extensions.php,
include/functions_ui_renders.php: change comments blocks for delete the
warnings to construct phpDoc Files, give a struct and order in the
phpDoc files.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-25 19:39:28 +02:00
*/
/**
* Include the usual functions
*/
2013-02-04 15:07:28 +01:00
require_once ( $config [ " homedir " ] . " /include/functions.php " );
require_once ( $config [ " homedir " ] . " /include/functions_db.php " );
require_once ( $config [ " homedir " ] . " /include/functions_agents.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_groups.php " );
2013-02-04 15:07:28 +01:00
require_once ( $config [ " homedir " ] . '/include/functions_graph.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_modules.php " );
include_once ( $config [ 'homedir' ] . " /include/functions_events.php " );
include_once ( $config [ 'homedir' ] . " /include/functions_alerts.php " );
include_once ( $config [ 'homedir' ] . '/include/functions_users.php' );
2013-02-04 15:07:28 +01:00
enterprise_include_once ( 'include/functions_metaconsole.php' );
enterprise_include_once ( 'include/functions_inventory.php' );
2011-10-26 17:18:51 +02:00
include_once ( $config [ 'homedir' ] . " /include/functions_forecast.php " );
2012-02-24 Miguel de Dios <miguel.dedios@artica.es>
* pandora_console/include/functions_ui.php: changed the source code into the
function "ui_get_full_url" for accept false for to return url with the home
url or with any string (as query) return url with the php file.
* pandora_console/include/functions_graph.php,
pandora_console/include/functions_html.php,
pandora_console/include/functions_events.php,
pandora_console/include/functions_reporting.php,
pandora_console/include/functions_api.php,
pandora_console/include/functions.php, pandora_console/index.php,
pandora_console/extensions/system_info.php,
pandora_console/operation/agentes/stat_win.php,
pandora_console/operation/menu.php,
pandora_console/operation/events/events_rss.php,
pandora_console/operation/events/events_marquee.php,
pandora_console/operation/events/events.php: change in more part of source
code to use "ui_get_full_url" instead the hard write method of $_SERVER
vars, now Pandora Console run fine (in all actions I hope) with web servers
in other ports instead the typical 80.
Merged from branch pandora_4.0
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5646 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-02-24 14:48:46 +01:00
include_once ( $config [ 'homedir' ] . " /include/functions_ui.php " );
2012-10-25 20:34:53 +02:00
include_once ( $config [ 'homedir' ] . " /include/functions_netflow.php " );
2015-03-30 17:07:57 +02:00
include_once ( $config [ 'homedir' ] . " /include/functions_os.php " );
2010-04-21 19:52:08 +02:00
2015-03-24 11:01:19 +01:00
function reporting_user_can_see_report ( $id_report , $id_user = null ) {
global $config ;
if ( empty ( $id_user )) {
$id_user = $config [ 'id_user' ];
}
// Get Report record (to get id_group)
$report = db_get_row ( 'treport' , 'id_report' , $id_report );
// Check ACL on the report to see if user has access to the report.
if ( empty ( $report ) || ! check_acl ( $config [ 'id_user' ], $report [ 'id_group' ], " RR " )) {
return false ;
}
return true ;
}
2015-03-23 11:08:58 +01:00
function reporting_get_type ( $content ) {
switch ( $content [ " type " ]) {
case REPORT_OLD_TYPE_SIMPLE_GRAPH :
$content [ " type " ] = 'simple_graph' ;
break ;
case REPORT_OLD_TYPE_CUSTOM_GRAPH :
$content [ " type " ] = 'custom_graph' ;
break ;
case REPORT_OLD_TYPE_MONITOR_REPORT :
$content [ " type " ] = 'monitor_report' ;
break ;
case REPORT_OLD_TYPE_SLA :
$content [ " type " ] = 'SLA' ;
break ;
case REPORT_OLD_TYPE_AVG_VALUE :
$content [ " type " ] = 'avg_value' ;
break ;
case REPORT_OLD_TYPE_MAX_VALUE :
$content [ " type " ] = 'max_value' ;
break ;
case REPORT_OLD_TYPE_MIN_VALUE :
$content [ " type " ] = 'min_value' ;
break ;
case REPORT_OLD_TYPE_SUMATORY :
$content [ " type " ] = 'sumatory' ;
break ;
}
return $content [ " type " ];
}
2015-03-24 17:52:57 +01:00
function reporting_get_description ( $id_report ) {
return db_get_value ( 'description' , 'treport' , 'id_report' , $id_report );
}
function reporting_get_name ( $id_report ) {
return db_get_value ( 'name' , 'treport' , 'id_report' , $id_report );
}
2015-03-24 11:01:19 +01:00
function reporting_make_reporting_data ( $id_report , $date , $time ,
$period = null , $type = 'dinamic' , $force_width_chart = null ,
$force_height_chart = null ) {
global $config ;
2015-03-18 13:51:14 +01:00
$return = array ();
2012-09-27 17:17:50 +02:00
2015-03-24 11:01:19 +01:00
$report = db_get_row ( 'treport' , 'id_report' , $id_report );
2015-03-18 13:51:14 +01:00
switch ( $config [ " dbtype " ]) {
case " mysql " :
$contents = db_get_all_rows_field_filter ( " treport_content " ,
" id_report " , $id_report , " `order` " );
break ;
case " postgresql " :
$contents = db_get_all_rows_field_filter ( " treport_content " ,
" id_report " , $id_report , '"order"' );
break ;
case " oracle " :
$contents = db_get_all_rows_field_filter ( " treport_content " ,
" id_report " , $id_report , '"order"' );
break ;
2011-03-08 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php, include/functions_messages.php,
include/functions_exportserver.php, include/functions_reporting.php,
include/functions_gis.php, include/functions_networkmap.php,
include/functions_servers.php, include/functions_api.php,
include/fgraph.php, include/functions_agents.php, include/functions_db.php,
include/functions_alerts.php, extensions/module_groups.php,
operation/incidents/incident.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/alerts_status.php, operation/agentes/estado_agente.php,
operation/agentes/sla_view.php, operation/agentes/ver_agente.php,
operation/servers/view_server_detail.php, operation/menu.php,
operation/search_graphs.php, operation/snmpconsole/snmp_view.php,
operation/gis_maps/ajax.php, operation/events/events_rss.php,
operation/events/events_list.php, operation/search_alerts.php,
operation/search_reports.php, operation/reporting/reporting_xml.php,
operation/reporting/graph_viewer.php, operation/search_maps.php,
operation/search_users.php, mobile/operation/agents/view_agents.php,
mobile/operation/events/events.php, godmode/groups/modu_group_list.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/db/db_main.php, godmode/db/db_purge.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/planned_downtime.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/alert_list.list.php, godmode/users/configure_user.php,
godmode/massive/massive_edit_modules.php,
godmode/modules/manage_network_templates_form.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/reporting/visual_console_builder.php,
godmode/reporting/reporting_builder.item_editor.php: changed or added in
some cases the SQL queries for to be PostgreSQL standard, and cleaned source
style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4074 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-03-09 15:26:36 +01:00
}
2015-03-18 13:51:14 +01:00
if ( $contents === false ) {
return $return ;
2010-04-29 17:31:14 +02:00
}
2012-09-27 17:17:50 +02:00
2015-03-30 17:07:57 +02:00
$report [ " group " ] = $report [ 'id_group' ];
2015-03-18 13:51:14 +01:00
$report [ " group_name " ] = groups_get_name ( $report [ 'id_group' ]);
2012-09-27 17:17:50 +02:00
2015-03-23 11:08:58 +01:00
$datetime = strtotime ( $date . ' ' . $time );
$report [ " datetime " ] = $datetime ;
$report [ 'contents' ] = array ();
foreach ( $contents as $content ) {
2015-03-24 11:01:19 +01:00
if ( ! empty ( $period )) {
$content [ 'period' ] = $period ;
2015-03-23 11:08:58 +01:00
}
2015-03-24 11:01:19 +01:00
$content [ 'style' ] = json_decode (
io_safe_output ( $content [ 'style' ]), true );
2015-03-23 11:08:58 +01:00
switch ( reporting_get_type ( $content )) {
case 'simple_graph' :
$report [ 'contents' ][] =
reporting_simple_graph (
2015-03-24 11:01:19 +01:00
$report ,
$content ,
$type ,
$force_width_chart ,
$force_height_chart );
break ;
case 'general' :
$report [ 'contents' ][] =
reporting_general (
2015-03-23 11:08:58 +01:00
$report ,
2015-03-24 15:06:10 +01:00
$content );
break ;
2015-04-10 00:58:24 +02:00
case 'availability' :
$report [ 'contents' ][] =
reporting_availability (
$report ,
$content );
break ;
2015-03-24 15:06:10 +01:00
case 'sql' :
$report [ 'contents' ][] = reporting_sql (
$report ,
$content );
2015-03-23 11:08:58 +01:00
break ;
2015-03-25 16:44:39 +01:00
case 'custom_graph' :
case 'automatic_custom_graph' :
$report [ 'contents' ][] =
reporting_custom_graph (
$report ,
$content ,
$type ,
$force_width_chart ,
$force_height_chart );
break ;
2015-03-25 16:58:53 +01:00
case 'text' :
$report [ 'contents' ][] = reporting_text (
$report ,
$content );
break ;
2015-03-25 17:19:13 +01:00
case 'url' :
$report [ 'contents' ][] = reporting_url (
$report ,
$content ,
$type );
break ;
2015-03-25 18:14:05 +01:00
case 'max_value' :
2015-03-25 18:28:58 +01:00
$report [ 'contents' ][] = reporting_value (
2015-03-25 18:14:05 +01:00
$report ,
2015-03-25 18:28:58 +01:00
$content ,
'max' );
break ;
case 'avg_value' :
$report [ 'contents' ][] = reporting_value (
$report ,
$content ,
'avg' );
break ;
case 'min_value' :
$report [ 'contents' ][] = reporting_value (
$report ,
$content ,
'min' );
2015-03-25 18:14:05 +01:00
break ;
2015-03-26 11:29:10 +01:00
case 'sumatory' :
$report [ 'contents' ][] = reporting_value (
$report ,
$content ,
'sum' );
break ;
2015-03-27 10:24:44 +01:00
case 'MTTR' :
$report [ 'contents' ][] = reporting_value (
$report ,
$content ,
'MTTR' );
break ;
case 'MTBF' :
$report [ 'contents' ][] = reporting_value (
$report ,
$content ,
'MTBF' );
break ;
case 'TTO' :
$report [ 'contents' ][] = reporting_value (
$report ,
$content ,
'TTO' );
break ;
2015-03-27 13:03:15 +01:00
case 'TTRT' :
$report [ 'contents' ][] = reporting_value (
$report ,
$content ,
'TTRT' );
break ;
2015-03-30 17:07:57 +02:00
case 'agent_configuration' :
$report [ 'contents' ][] = reporting_agent_configuration (
$report ,
$content );
break ;
2015-04-13 16:37:10 +02:00
case 'projection_graph' :
$report [ 'contents' ][] = reporting_projection_graph (
$report ,
$content ,
$type ,
$force_width_chart ,
$force_height_chart );
break ;
2015-04-13 18:15:02 +02:00
case 'prediction_date' :
$report [ 'contents' ][] = reporting_prediction_date (
$report ,
$content );
break ;
2015-04-13 18:42:35 +02:00
case 'simple_baseline_graph' :
$report [ 'contents' ][] = reporting_simple_baseline_graph (
$report ,
$content ,
$type ,
$force_width_chart ,
$force_height_chart );
break ;
2015-04-14 12:58:26 +02:00
case 'netflow_area' :
$report [ 'contents' ][] = reporting_simple_baseline_graph (
$report ,
$content ,
$type ,
$force_width_chart ,
$force_height_chart );
break ;
case 'netflow_pie' :
$report [ 'contents' ][] = reporting_netflow_pie (
$report ,
$content ,
$type ,
$force_width_chart ,
$force_height_chart );
break ;
case 'netflow_data' :
$report [ 'contents' ][] = reporting_netflow_data (
$report ,
$content ,
$type ,
$force_width_chart ,
$force_height_chart );
break ;
case 'netflow_statistics' :
$report [ 'contents' ][] = reporting_netflow_statistics (
$report ,
$content ,
$type ,
$force_width_chart ,
$force_height_chart );
break ;
case 'netflow_summary' :
$report [ 'contents' ][] = reporting_netflow_summary (
$report ,
$content ,
$type ,
$force_width_chart ,
$force_height_chart );
break ;
2015-04-14 16:21:44 +02:00
case 'monitor_report' :
$report [ 'contents' ][] = reporting_monitor_report (
$report ,
$content );
break ;
2015-03-23 11:08:58 +01:00
}
}
2015-03-24 11:01:19 +01:00
return reporting_check_structure_report ( $report );
2010-04-21 19:52:08 +02:00
}
2015-04-14 16:21:44 +02:00
function reporting_monitor_report ( $report , $content ) {
global $config ;
$return [ 'type' ] = 'monitor_report' ;
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'Monitor Report' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text ( $report , $content );
$value = reporting_get_agentmodule_sla (
$content [ 'id_agent_module' ],
$content [ 'period' ],
1 ,
false ,
$report [ " datetime " ]);
if ( $value === __ ( 'Unknown' )) {
$return [ 'data' ][ 'unknown' ] = 1 ;
}
else {
$return [ 'data' ][ 'unknown' ] = 0 ;
$return [ " data " ][ " ok " ][ " value " ] = $value ;
$return [ " data " ][ " ok " ][ " formated_value " ] = format_numeric ( $value , 2 );
$return [ " data " ][ " fail " ][ " value " ] = 100 - $return [ " data " ][ " ok " ][ " value " ];
$return [ " data " ][ " fail " ][ " formated_value " ] = ( 100 - $return [ " data " ][ " ok " ][ " formated_value " ]);
}
return reporting_check_structure_content ( $return );
}
2015-04-14 12:58:26 +02:00
function reporting_netflow ( $report , $content , $type ,
$force_width_chart , $force_height_chart , $type_netflow = null ) {
global $config ;
switch ( $type_netflow ) {
case 'netflow_area' :
$return [ 'type' ] = 'netflow_area' ;
break ;
case 'netflow_pie' :
$return [ 'type' ] = 'netflow_pie' ;
break ;
case 'netflow_data' :
$return [ 'type' ] = 'netflow_data' ;
break ;
case 'netflow_statistics' :
$return [ 'type' ] = 'netflow_statistics' ;
break ;
case 'netflow_summary' :
$return [ 'type' ] = 'netflow_summary' ;
break ;
}
if ( empty ( $content [ 'name' ])) {
switch ( $type_netflow ) {
case 'netflow_area' :
$return [ 'name' ] = __ ( 'Netflow Area' );
break ;
case 'netflow_pie' :
$return [ 'name' ] = __ ( 'Netflow Pie' );
break ;
case 'netflow_data' :
$return [ 'name' ] = __ ( 'Netflow Data' );
break ;
case 'netflow_statistics' :
$return [ 'name' ] = __ ( 'Netflow Statistics' );
break ;
case 'netflow_summary' :
$return [ 'name' ] = __ ( 'Netflow Summary' );
break ;
}
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text ( $report , $content );
// Get chart
reporting_set_conf_charts ( $width , $height , $only_image , $type , $content );
if ( ! empty ( $force_width_chart )) {
$width = $force_width_chart ;
}
if ( ! empty ( $force_height_chart )) {
$height = $force_height_chart ;
}
// Get item filters
$filter = db_get_row_sql ( " SELECT *
FROM tnetflow_filter
WHERE id_sg = '" . (int)$content[' text '] . "' " , false, true);
switch ( $type ) {
case 'dinamic' :
case 'static' :
$return [ 'chart' ] = netflow_draw_item (
$report [ 'datetime' ] - $content [ 'period' ],
$report [ 'datetime' ],
$content [ 'top_n' ],
$type_netflow ,
$filter ,
$content [ 'top_n_value' ],
$content [ 'server_name' ],
'HTML' );
break ;
case 'data' :
break ;
}
return reporting_check_structure_content ( $return );
}
2015-04-13 18:42:35 +02:00
function reporting_simple_baseline_graph ( $report , $content ,
$type = 'dinamic' , $force_width_chart = null ,
$force_height_chart = null ) {
global $config ;
$return [ 'type' ] = 'simple_baseline_graph' ;
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'Simple baseline graph' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text ( $report , $content );
// Get chart
reporting_set_conf_charts ( $width , $height , $only_image , $type , $content );
if ( ! empty ( $force_width_chart )) {
$width = $force_width_chart ;
}
if ( ! empty ( $force_height_chart )) {
$height = $force_height_chart ;
}
switch ( $type ) {
case 'dinamic' :
case 'static' :
$return [ 'chart' ] = grafico_modulo_sparse (
$content [ 'id_agent_module' ],
$content [ 'period' ],
false ,
$width ,
$height ,
'' ,
'' ,
false ,
true ,
true ,
$report [ " datetime " ],
'' ,
true ,
0 ,
true ,
false ,
ui_get_full_url ( false , false , false , false ));
break ;
case 'data' :
break ;
}
return reporting_check_structure_content ( $return );
}
2015-04-13 18:15:02 +02:00
function reporting_prediction_date ( $report , $content ) {
global $config ;
$return [ 'type' ] = 'prediction_date' ;
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'Prediction Date' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text ( $report , $content );
set_time_limit ( 500 );
$intervals_text = $content [ 'text' ];
$max_interval = substr ( $intervals_text , 0 , strpos ( $intervals_text , ';' ));
$min_interval = substr ( $intervals_text , strpos ( $intervals_text , ';' ) + 1 );
$value = forecast_prediction_date ( $content [ 'id_agent_module' ], $content [ 'period' ], $max_interval , $min_interval );
if ( $value === false ) {
$return [ " data " ][ 'value' ] = __ ( 'Unknown' );
}
else {
$return [ " data " ][ 'value' ] = date ( 'd M Y H:i:s' , $value );
}
return reporting_check_structure_content ( $return );
}
2015-04-13 16:37:10 +02:00
function reporting_projection_graph ( $report , $content ,
$type = 'dinamic' , $force_width_chart = null ,
$force_height_chart = null ) {
global $config ;
$return [ 'type' ] = 'projection_graph' ;
if ( empty ( $content [ 'name' ])) {
2015-04-13 18:15:02 +02:00
$content [ 'name' ] = __ ( 'Projection Graph' );
2015-04-13 16:37:10 +02:00
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text ( $report , $content );
set_time_limit ( 500 );
$output_projection = forecast_projection_graph (
$content [ 'id_agent_module' ], $content [ 'period' ], $content [ 'top_n_value' ]);
// If projection doesn't have data then don't draw graph
if ( $output_projection == NULL ) {
$output_projection = false ;
}
// Get chart
reporting_set_conf_charts ( $width , $height , $only_image , $type , $content );
if ( ! empty ( $force_width_chart )) {
$width = $force_width_chart ;
}
if ( ! empty ( $force_height_chart )) {
$height = $force_height_chart ;
}
switch ( $type ) {
case 'dinamic' :
case 'static' :
$return [ 'chart' ] = graphic_combined_module (
array ( $content [ 'id_agent_module' ]),
array (),
$content [ 'period' ],
$width ,
$height ,
'Projection%20Sample%20Graph' ,
'' ,
0 ,
0 ,
0 ,
0 ,
$report [ " datetime " ],
true ,
ui_get_full_url ( false , false , false , false ) . '/' ,
1 ,
// Important parameter, this tell to graphic_combined_module function that is a projection graph
$output_projection ,
$content [ 'top_n_value' ]
);
break ;
case 'data' :
break ;
}
return reporting_check_structure_content ( $return );
}
2015-03-30 17:07:57 +02:00
function reporting_agent_configuration ( $report , $content ) {
global $config ;
$return [ 'type' ] = 'agent_configuration' ;
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'Agent configuration' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text ( $report , $content );
$sql = "
SELECT *
FROM tagente
WHERE id_agente = " . $content['id_agent'] ;
$agent_data = db_get_row_sql ( $sql );
$agent_configuration = array ();
$agent_configuration [ 'name' ] = $agent_data [ 'nombre' ];
$agent_configuration [ 'group' ] = groups_get_name ( $agent_data [ 'id_grupo' ]);
$agent_configuration [ 'group_icon' ] =
ui_print_group_icon ( $agent_data [ 'id_grupo' ], true , '' , '' , false );
$agent_configuration [ 'os' ] = os_get_name ( $agent_data [ " id_os " ]);
$agent_configuration [ 'os_icon' ] = ui_print_os_icon ( $agent_data [ " id_os " ], true , true );
$agent_configuration [ 'address' ] = $agent_data [ 'direccion' ];
$agent_configuration [ 'description' ] =
strip_tags ( ui_bbcode_to_html ( $agent_data [ 'comentarios' ]));
$agent_configuration [ 'enabled' ] = ( int ) ! $agent_data [ 'disabled' ];
$agent_configuration [ 'group' ] = $report [ " group " ];
$modules = agents_get_modules ( $content [ 'id_agent' ]);
$agent_configuration [ 'modules' ] = array ();
//Agent's modules
if ( ! empty ( $modules )) {
foreach ( $modules as $id_agent_module => $module ) {
$sql = "
SELECT *
FROM tagente_modulo
WHERE id_agente_modulo = $id_agent_module " ;
$module_db = db_get_row_sql ( $sql );
$data_module = array ();
$data_module [ 'name' ] = $module_db [ 'nombre' ];
if ( $module_db [ 'disabled' ]) {
$data_module [ 'name' ] .= " ( " . __ ( 'Disabled' ) . " ) " ;
}
$data_module [ 'type_icon' ] =
ui_print_moduletype_icon ( $module_db [ 'id_tipo_modulo' ], true );
$data_module [ 'type' ] =
modules_get_type_name ( $module_db [ 'id_tipo_modulo' ]);
$data_module [ 'max_warning' ] =
$module_db [ 'max_warning' ];
$data_module [ 'min_warning' ] =
$module_db [ 'min_warning' ];
$data_module [ 'max_critical' ] =
$module_db [ 'max_critical' ];
$data_module [ 'min_critical' ] =
$module_db [ 'min_critical' ];
$data_module [ 'threshold' ] = $module_db [ 'module_ff_interval' ];
$data_module [ 'description' ] = $module_db [ 'descripcion' ];
if (( $module_db [ 'module_interval' ] == 0 ) ||
( $module_db [ 'module_interval' ] == '' )) {
$data_module [ 'interval' ] = db_get_value ( 'intervalo' ,
'tagente' , 'id_agente' , $content [ 'id_agent' ]);
}
else {
$data_module [ 'interval' ] = $module_db [ 'module_interval' ];
}
$data_module [ 'unit' ] = $module_db [ 'unit' ];
$module_status = db_get_row (
'tagente_estado' , 'id_agente_modulo' , $id_agent_module );
modules_get_status ( $id_agent_module ,
$module_status [ 'estado' ],
$module_status [ 'datos' ], $status , $title );
$data_module [ 'status_icon' ] =
ui_print_status_image ( $status , $title , true );
$data_module [ 'status' ] = $title ;
$sql_tag = "
SELECT name
FROM ttag
WHERE id_tag IN (
SELECT id_tag
FROM ttag_module
WHERE id_agente_modulo = $id_agent_module ) " ;
$tags = db_get_all_rows_sql ( $sql_tag );
if ( $tags === false )
$data_module [ 'tags' ] = array ();
else
$data_module [ 'tags' ] = $tags ;
$agent_configuration [ 'modules' ][] = $data_module ;
}
}
$return [ 'data' ] = $agent_configuration ;
return reporting_check_structure_content ( $return );
}
2015-03-25 18:28:58 +01:00
function reporting_value ( $report , $content , $type ) {
2015-03-25 18:14:05 +01:00
global $config ;
$return = array ();
2015-03-25 18:28:58 +01:00
switch ( $type ) {
case 'max' :
$return [ 'type' ] = 'max_value' ;
break ;
case 'min' :
$return [ 'type' ] = 'min_value' ;
break ;
case 'avg' :
$return [ 'type' ] = 'avg_value' ;
break ;
2015-03-26 11:29:10 +01:00
case 'sum' :
$return [ 'type' ] = 'sumatory' ;
break ;
2015-03-27 10:24:44 +01:00
case 'MTTR' :
$return [ 'type' ] = 'MTTR' ;
break ;
case 'MTBF' :
$return [ 'type' ] = 'MTBF' ;
break ;
case 'TTO' :
$return [ 'type' ] = 'TTO' ;
break ;
2015-03-27 13:03:15 +01:00
case 'TTRT' :
$return [ 'type' ] = 'TTRT' ;
break ;
2015-03-25 18:28:58 +01:00
}
2015-03-25 18:14:05 +01:00
if ( empty ( $content [ 'name' ])) {
2015-03-25 18:28:58 +01:00
switch ( $type ) {
case 'max' :
$content [ 'name' ] = __ ( 'Max. Value' );
break ;
case 'min' :
$content [ 'name' ] = __ ( 'Min. Value' );
break ;
case 'avg' :
$content [ 'name' ] = __ ( 'AVG. Value' );
break ;
2015-03-26 11:29:10 +01:00
case 'sum' :
$content [ 'name' ] = __ ( 'Summatory' );
break ;
2015-03-27 10:24:44 +01:00
case 'MTTR' :
$content [ 'name' ] = __ ( 'MTTR' );
break ;
case 'MTBF' :
$content [ 'name' ] = __ ( 'MTBF' );
break ;
case 'TTO' :
$content [ 'name' ] = __ ( 'TTO' );
break ;
2015-03-27 13:03:15 +01:00
case 'TTRT' :
$return [ 'type' ] = __ ( 'TTRT' );
break ;
2015-03-25 18:28:58 +01:00
}
2015-03-25 18:14:05 +01:00
}
2015-03-25 18:28:58 +01:00
$module_name = io_safe_output (
modules_get_agentmodule_name ( $content [ 'id_agent_module' ]));
$agent_name = io_safe_output (
modules_get_agentmodule_agent_name ( $content [ 'id_agent_module' ]));
2015-03-27 10:24:44 +01:00
$unit = db_get_value ( 'unit' , 'tagente_modulo' , 'id_agente_modulo' ,
$content [ 'id_agent_module' ]);
2015-03-25 18:28:58 +01:00
2015-03-25 18:14:05 +01:00
$return [ 'title' ] = $content [ 'name' ];
2015-03-25 18:28:58 +01:00
$return [ 'subtitle' ] = $agent_name . " - " . $module_name ;
2015-03-25 18:14:05 +01:00
$return [ " description " ] = $content [ " description " ];
2015-03-25 18:28:58 +01:00
$return [ " date " ] = reporting_get_date_text ( $report , $content );
2015-03-25 18:14:05 +01:00
2015-03-25 18:28:58 +01:00
switch ( $type ) {
case 'max' :
$value = reporting_get_agentmodule_data_max (
$content [ 'id_agent_module' ], $content [ 'period' ], $report [ " datetime " ]);
2015-03-27 10:24:44 +01:00
$formated_value = format_for_graph ( $value , 2 ) . " " . $unit ;
2015-03-25 18:28:58 +01:00
break ;
case 'min' :
$value = reporting_get_agentmodule_data_min (
$content [ 'id_agent_module' ], $content [ 'period' ], $report [ " datetime " ]);
2015-03-27 10:24:44 +01:00
$formated_value = format_for_graph ( $value , 2 ) . " " . $unit ;
2015-03-25 18:28:58 +01:00
break ;
case 'avg' :
$value = reporting_get_agentmodule_data_average (
$content [ 'id_agent_module' ], $content [ 'period' ], $report [ " datetime " ]);
2015-03-27 10:24:44 +01:00
$formated_value = format_for_graph ( $value , 2 ) . " " . $unit ;
2015-03-25 18:28:58 +01:00
break ;
2015-03-26 11:29:10 +01:00
case 'sum' :
$value = reporting_get_agentmodule_data_sum (
$content [ 'id_agent_module' ], $content [ 'period' ], $report [ " datetime " ]);
2015-03-27 10:24:44 +01:00
$formated_value = format_for_graph ( $value , 2 ) . " " . $unit ;
break ;
case 'MTTR' :
$value = reporting_get_agentmodule_mttr (
$content [ 'id_agent_module' ], $content [ 'period' ], $report [ " datetime " ]);
$formated_value = null ;
break ;
case 'MTBF' :
$value = reporting_get_agentmodule_mtbf (
$content [ 'id_agent_module' ], $content [ 'period' ], $report [ " datetime " ]);
$formated_value = null ;
break ;
case 'TTO' :
$value = reporting_get_agentmodule_tto (
$content [ 'id_agent_module' ], $content [ 'period' ], $report [ " datetime " ]);
if ( $value == 0 ) {
$formated_value = null ;
}
else {
$formated_value = human_time_description_raw ( $value );
}
2015-03-26 11:29:10 +01:00
break ;
2015-03-27 13:03:15 +01:00
case 'TTRT' :
$value = reporting_get_agentmodule_ttr (
$content [ 'id_agent_module' ], $content [ 'period' ], $report [ " datetime " ]);
if ( $value == 0 ) {
$formated_value = null ;
}
else {
$formated_value = human_time_description_raw ( $value );
}
break ;
2015-03-25 18:28:58 +01:00
}
2015-03-25 18:14:05 +01:00
$return [ 'data' ] = array (
'value' => $value ,
2015-03-27 10:24:44 +01:00
'formated_value' => $formated_value );
2015-03-25 18:14:05 +01:00
return reporting_check_structure_content ( $return );
}
2015-03-25 17:19:13 +01:00
function reporting_url ( $report , $content , $type = 'dinamic' ) {
global $config ;
$return = array ();
$return [ 'type' ] = 'url' ;
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'Url' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text ();
$return [ " url " ] = $content [ " external_source " ];
switch ( $type ) {
case 'dinamic' :
$return [ " data " ] = null ;
break ;
case 'data' :
case 'static' :
$curlObj = curl_init ();
curl_setopt ( $curlObj , CURLOPT_URL , $content [ 'external_source' ]);
curl_setopt ( $curlObj , CURLOPT_RETURNTRANSFER , 1 );
$output = curl_exec ( $curlObj );
curl_close ( $curlObj );
$return [ " data " ] = $output ;
break ;
}
return reporting_check_structure_content ( $return );
}
2015-03-25 16:58:53 +01:00
function reporting_text ( $report , $content ) {
global $config ;
$return = array ();
$return [ 'type' ] = 'text' ;
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'Text' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text ();
$return [ " data " ] = html_entity_decode ( $content [ 'text' ]);
return reporting_check_structure_content ( $return );
}
2015-03-24 15:06:10 +01:00
function reporting_sql ( $report , $content ) {
global $config ;
$return = array ();
2015-03-24 17:52:57 +01:00
$return [ 'type' ] = 'sql' ;
2015-03-24 15:06:10 +01:00
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'SQL' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
2015-03-24 17:52:57 +01:00
$return [ " date " ] = reporting_get_date_text ();
2015-03-24 15:06:10 +01:00
if ( $content [ 'treport_custom_sql_id' ] != 0 ) {
switch ( $config [ " dbtype " ]) {
case " mysql " :
$sql = io_safe_output ( db_get_value_filter ( '`sql`' , 'treport_custom_sql' , array ( 'id' => $content [ 'treport_custom_sql_id' ])));
break ;
case " postgresql " :
$sql = io_safe_output ( db_get_value_filter ( '"sql"' , 'treport_custom_sql' , array ( 'id' => $content [ 'treport_custom_sql_id' ])));
break ;
case " oracle " :
$sql = io_safe_output ( db_get_value_filter ( 'sql' , 'treport_custom_sql' , array ( 'id' => $content [ 'treport_custom_sql_id' ])));
break ;
}
}
else {
$sql = io_safe_output ( $content [ 'external_source' ]);
}
// Do a security check on SQL coming from the user
$sql = check_sql ( $sql );
$return [ 'sql' ] = $sql ;
$return [ 'correct' ] = 1 ;
$return [ 'error' ] = " " ;
$return [ 'data' ] = array ();
if ( $sql != '' ) {
$header = array ();
if ( $content [ 'header_definition' ] != '' ) {
$header = explode ( '|' , $content [ 'header_definition' ]);
}
$result = db_get_all_rows_sql ( $sql );
if ( $result !== false ) {
foreach ( $result as $row ) {
$data_row = array ();
$i = 0 ;
foreach ( $row as $dbkey => $field ) {
if ( isset ( $header [ $i ])) {
$key = $header [ $i ];
}
else {
$key = $dbkey ;
}
$data_row [ $key ] = $field ;
$i ++ ;
}
$return [ 'data' ][] = $data_row ;
}
}
}
else {
$return [ 'correct' ] = 0 ;
$return [ 'error' ] = __ ( 'Illegal query: Due security restrictions, there are some tokens or words you cannot use: *, delete, drop, alter, modify, union, password, pass, insert or update.' );
}
return reporting_check_structure_content ( $return );
}
2015-04-10 00:58:24 +02:00
function reporting_availability ( $report , $content ) {
global $config ;
$return = array ();
$return [ 'type' ] = 'availability' ;
$return [ 'subtype' ] = $content [ 'group_by_agent' ];
$return [ 'resume' ] = $content [ 'show_resume' ];
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'Availability' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text (
$report ,
$content );
if ( $content [ 'show_graph' ]) {
$return [ 'kind_availability' ] = " address " ;
}
else {
$return [ 'kind_availability' ] = " module " ;
}
$sql = sprintf ( "
SELECT id_agent_module ,
server_name , operation
FROM treport_content_item
WHERE id_report_content = % d " ,
$content [ 'id_rc' ]);
$items = db_process_sql ( $sql );
$data = array ();
$avg = 0 ;
$min = null ;
$min_text = " " ;
$max = null ;
$max_text = " " ;
$count = 0 ;
foreach ( $items as $item ) {
//aaMetaconsole connection
$server_name = $item [ 'server_name' ];
if (( $config [ 'metaconsole' ] == 1 ) && $server_name != '' && defined ( 'METACONSOLE' )) {
$connection = metaconsole_get_connection ( $server_name );
if ( metaconsole_load_external_db ( $connection ) != NOERR ) {
//ui_print_error_message ("Error connecting to ".$server_name);
continue ;
}
}
if ( modules_is_disable_agent ( $item [ 'id_agent_module' ])) {
continue ;
}
$row = array ();
$text = " " ;
// HACK it is saved in show_graph field.
// Show interfaces instead the modules
if ( $content [ 'show_graph' ]) {
$text = $row [ 'availability_item' ] = agents_get_address (
modules_get_agentmodule_agent ( $item [ 'id_agent_module' ]));
if ( empty ( $text )) {
$text = $row [ 'availability_item' ] = __ ( 'No Address' );
}
}
else {
$text = $row [ 'availability_item' ] = modules_get_agentmodule_name (
$item [ 'id_agent_module' ]);
}
$row [ 'agent' ] = modules_get_agentmodule_agent_name (
$item [ 'id_agent_module' ]);
$text = $row [ 'agent' ] . " ( " . $text . " ) " ;
$count_checks = modules_get_count_datas (
$item [ 'id_agent_module' ],
$report [ " datetime " ] - $content [ 'period' ],
$report [ " datetime " ]);
if ( empty ( $count_checks )) {
$row [ 'checks' ] = __ ( 'Unknown' );
$row [ 'failed' ] = __ ( 'Unknown' );
$row [ 'fail' ] = __ ( 'Unknown' );
$row [ 'poling_time' ] = __ ( 'Unknown' );
$row [ 'time_unavaliable' ] = __ ( 'Unknown' );
$row [ 'ok' ] = __ ( 'Unknown' );
$percent_ok = 0 ;
}
else {
$count_fails = count (
modules_get_data_with_value (
$item [ 'id_agent_module' ],
$report [ " datetime " ] - $content [ 'period' ],
$report [ " datetime " ],
0 , true ));
$percent_ok = (( $count_checks - $count_fails ) * 100 ) / $count_checks ;
$percent_fail = 100 - $percent_ok ;
$row [ 'ok' ] = format_numeric ( $percent_ok , 2 ) . " % " ;
$row [ 'fail' ] = format_numeric ( $percent_fail , 2 ) . " % " ;
$row [ 'checks' ] = format_numeric ( $count_checks , 2 );
$row [ 'failed' ] = format_numeric ( $count_fails , 2 );
$row [ 'poling_time' ] = human_time_description_raw (
( $count_checks - $count_fails ) * modules_get_interval ( $item [ 'id_agent_module' ]),
true );
$row [ 'time_unavaliable' ] = " - " ;
if ( $count_fails > 0 ) {
$row [ 'time_unavaliable' ] = human_time_description_raw (
$count_fails * modules_get_interval ( $item [ 'id_agent_module' ]),
true );
}
}
$data [] = $row ;
$avg = (( $avg * $count ) + $percent_ok ) / ( $count + 1 );
if ( is_null ( $min )) {
$min = $percent_ok ;
$min_text = $text ;
}
else {
if ( $min > $percent_ok ) {
$min = $percent_ok ;
$min_text = $text ;
}
}
if ( is_null ( $max )) {
$max = $percent_ok ;
$max_text = $text ;
}
else {
if ( $max < $percent_ok ) {
$max = $percent_ok ;
$max_text = $text ;
}
}
//Restore dbconnection
if (( $config [ 'metaconsole' ] == 1 ) && $server_name != '' && defined ( 'METACONSOLE' )) {
metaconsole_restore_db ();
}
$count ++ ;
}
switch ( $content [ 'order_uptodown' ]) {
case REPORT_ITEM_ORDER_BY_AGENT_NAME :
$temp = array ();
foreach ( $data as $row ) {
$i = 0 ;
foreach ( $temp as $t_row ) {
if ( strcmp ( $row [ 'agent' ], $t_row [ 'agent' ]) < 0 ) {
break ;
}
$i ++ ;
}
array_splice ( $temp , $i , 0 , array ( $row ));
}
$data = $temp ;
break ;
case REPORT_ITEM_ORDER_BY_ASCENDING :
$temp = array ();
foreach ( $data as $row ) {
$i = 0 ;
foreach ( $temp as $t_row ) {
if ( strcmp ( $row [ 'availability_item' ], $t_row [ 'availability_item' ]) < 0 ) {
break ;
}
$i ++ ;
}
array_splice ( $temp , $i , 0 , array ( $row ));
}
$data = $temp ;
break ;
case REPORT_ITEM_ORDER_BY_DESCENDING :
$temp = array ();
foreach ( $data as $row ) {
$i = 0 ;
foreach ( $temp as $t_row ) {
if ( strcmp ( $row [ 'availability_item' ], $t_row [ 'availability_item' ]) > 0 ) {
break ;
}
$i ++ ;
}
array_splice ( $temp , $i , 0 , array ( $row ));
}
$data = $temp ;
break ;
}
$return [ " data " ] = $data ;
$return [ " resume " ] = array ();
$return [ " resume " ][ 'min_text' ] = $min_text ;
$return [ " resume " ][ 'min' ] = $min ;
$return [ " resume " ][ 'avg' ] = $avg ;
$return [ " resume " ][ 'max_text' ] = $max_text ;
$return [ " resume " ][ 'max' ] = $max ;
return reporting_check_structure_content ( $return );
}
2015-03-24 15:06:10 +01:00
function reporting_general ( $report , $content ) {
2015-03-24 11:01:19 +01:00
2012-02-20 17:15:34 +01:00
global $config ;
2015-03-24 11:01:19 +01:00
$return = array ();
2015-03-24 17:52:57 +01:00
$return [ 'type' ] = 'general' ;
2015-03-25 13:04:11 +01:00
$return [ 'subtype' ] = $content [ 'group_by_agent' ];
$return [ 'resume' ] = $content [ 'show_resume' ];
2015-03-24 11:01:19 +01:00
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'General' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text (
$report ,
$content );
2015-03-24 15:06:10 +01:00
$return [ " data " ] = array ();
$return [ " avg_value " ] = 0 ;
$return [ " min " ] = array ();
$return [ " min " ][ " value " ] = null ;
$return [ " min " ][ " formated_value " ] = null ;
$return [ " min " ][ " agent " ] = null ;
$return [ " min " ][ " module " ] = null ;
$return [ " max " ] = array ();
$return [ " max " ][ " value " ] = null ;
$return [ " max " ][ " formated_value " ] = null ;
$return [ " max " ][ " agent " ] = null ;
$return [ " max " ][ " module " ] = null ;
2015-03-24 11:47:39 +01:00
$generals = db_get_all_rows_filter (
'treport_content_item' ,
array ( 'id_report_content' => $content [ 'id_rc' ]));
if ( empty ( $generals )) {
$generals = array ();
}
2015-03-24 15:06:10 +01:00
$i = 0 ;
foreach ( $generals as $key => $row ) {
//Metaconsole connection
$server_name = $row [ 'server_name' ];
if (( $config [ 'metaconsole' ] == 1 ) && $server_name != '' && defined ( 'METACONSOLE' )) {
$connection = metaconsole_get_connection ( $server_name );
if ( metaconsole_load_external_db ( $connection ) != NOERR ) {
//ui_print_error_message ("Error connecting to ".$server_name);
continue ;
}
}
if ( modules_is_disable_agent ( $row [ 'id_agent_module' ])) {
continue ;
}
$mod_name = modules_get_agentmodule_name ( $row [ 'id_agent_module' ]);
$ag_name = modules_get_agentmodule_agent_name ( $row [ 'id_agent_module' ]);
$unit = db_get_value ( 'unit' , 'tagente_modulo' ,
'id_agente_modulo' ,
$row [ 'id_agent_module' ]);
if ( $content [ 'period' ] == 0 ) {
$data_res [ $key ] =
modules_get_last_value ( $row [ 'id_agent_module' ]);
}
else {
switch ( $row [ 'operation' ]) {
case 'sum' :
2015-03-24 11:01:19 +01:00
$data_res [ $key ] =
2015-03-24 15:06:10 +01:00
reporting_get_agentmodule_data_sum (
$row [ 'id_agent_module' ], $content [ 'period' ], $report [ " datetime " ]);
break ;
case 'max' :
$data_res [ $key ] =
reporting_get_agentmodule_data_max (
$row [ 'id_agent_module' ], $content [ 'period' ]);
break ;
case 'min' :
$data_res [ $key ] =
reporting_get_agentmodule_data_min (
$row [ 'id_agent_module' ], $content [ 'period' ]);
break ;
case 'avg' :
default :
$data_res [ $key ] =
reporting_get_agentmodule_data_average (
$row [ 'id_agent_module' ], $content [ 'period' ]);
break ;
}
}
switch ( $content [ 'group_by_agent' ]) {
case REPORT_GENERAL_NOT_GROUP_BY_AGENT :
2015-03-24 11:01:19 +01:00
$id_agent_module [ $key ] = $row [ 'id_agent_module' ];
$agent_name [ $key ] = $ag_name ;
$module_name [ $key ] = $mod_name ;
$units [ $key ] = $unit ;
$operations [ $key ] = $row [ 'operation' ];
2015-03-24 15:06:10 +01:00
break ;
case REPORT_GENERAL_GROUP_BY_AGENT :
if ( $data_res [ $key ] === false ) {
$return [ " data " ][ $ag_name ][ $mod_name ] = null ;
}
else {
2015-03-25 13:04:11 +01:00
if ( ! is_numeric ( $data_res [ $key ])) {
2015-03-24 15:06:10 +01:00
$return [ " data " ][ $ag_name ][ $mod_name ] = $data_res [ $key ];
}
else {
$return [ " data " ][ $ag_name ][ $mod_name ] =
format_for_graph ( $data_res [ $key ], 2 ) . " " . $unit ;
}
}
break ;
}
// Calculate the avg, min and max
if ( is_numeric ( $data_res [ $key ])) {
$change_min = false ;
if ( is_null ( $return [ " min " ][ " value " ])) {
$change_min = true ;
}
else {
if ( $return [ " min " ][ " value " ] > $data_res [ $key ]) {
$change_min = true ;
2015-03-24 11:01:19 +01:00
}
}
2015-03-24 15:06:10 +01:00
if ( $change_min ) {
$return [ " min " ][ " value " ] = $data_res [ $key ];
$return [ " min " ][ " formated_value " ] =
format_for_graph ( $data_res [ $key ], 2 ) . " " . $unit ;
$return [ " min " ][ " agent " ] = $ag_name ;
$return [ " min " ][ " module " ] = $mod_name ;
}
2015-03-24 11:01:19 +01:00
2015-03-24 15:06:10 +01:00
$change_max = false ;
if ( is_null ( $return [ " max " ][ " value " ])) {
$change_max = true ;
}
else {
if ( $return [ " max " ][ " value " ] < $data_res [ $key ]) {
$change_max = true ;
}
}
2015-03-24 11:01:19 +01:00
2015-03-24 15:06:10 +01:00
if ( $change_max ) {
$return [ " max " ][ " value " ] = $data_res [ $key ];
$return [ " max " ][ " formated_value " ] =
format_for_graph ( $data_res [ $key ], 2 ) . " " . $unit ;
$return [ " max " ][ " agent " ] = $ag_name ;
$return [ " max " ][ " module " ] = $mod_name ;
}
2015-03-24 11:01:19 +01:00
2015-03-24 15:06:10 +01:00
if ( $i == 0 ) {
$return [ " avg_value " ] = $data_res [ $key ];
}
else {
$return [ " avg_value " ] =
(( $return [ " avg_value " ] * $i ) / ( $i + 1 ))
+
( $data_res [ $key ] / ( $i + 1 ));
}
}
$i ++ ;
//Restore dbconnection
if (( $config [ 'metaconsole' ] == 1 ) && $server_name != '' && defined ( 'METACONSOLE' )) {
metaconsole_restore_db ();
}
}
switch ( $content [ 'group_by_agent' ]) {
case REPORT_GENERAL_NOT_GROUP_BY_AGENT :
2015-03-24 11:01:19 +01:00
switch ( $content [ 'order_uptodown' ]) {
case REPORT_ITEM_ORDER_BY_AGENT_NAME :
array_multisort ( $agent_name , SORT_ASC ,
$data_res , SORT_ASC , $module_name , SORT_ASC ,
$id_agent_module , SORT_ASC , $operations ,
SORT_ASC );
break ;
case REPORT_ITEM_ORDER_BY_ASCENDING :
array_multisort ( $data_res , SORT_ASC ,
$agent_name , SORT_ASC , $module_name ,
SORT_ASC , $id_agent_module ,
SORT_ASC , $operations , SORT_ASC );
break ;
case REPORT_ITEM_ORDER_BY_DESCENDING :
array_multisort ( $data_res , SORT_DESC ,
$agent_name , SORT_ASC , $module_name ,
SORT_ASC , $id_agent_module ,
SORT_ASC , $operations , SORT_ASC );
break ;
case REPORT_ITEM_ORDER_BY_UNSORT :
break ;
}
2015-03-24 15:06:10 +01:00
2015-03-24 11:01:19 +01:00
$i = 0 ;
foreach ( $data_res as $d ) {
$data = array ();
$data [ 'agent' ] = $agent_name [ $i ];
$data [ 'module' ] = $module_name [ $i ];
$data [ 'operator' ] = " " ;
if ( $content [ 'period' ] != 0 ) {
switch ( $operations [ $i ]) {
case 'sum' :
$data [ 'operator' ] = __ ( 'Summatory' );
break ;
case 'min' :
$data [ 'operator' ] = __ ( 'Minimal' );
break ;
case 'max' :
$data [ 'operator' ] = __ ( 'Maximun' );
break ;
case 'avg' :
default :
$data [ 'operator' ] = __ ( 'Rate' );
break ;
}
}
if ( $d === false ) {
2015-03-24 15:06:10 +01:00
$data [ 'value' ] = null ;
2015-03-24 11:01:19 +01:00
}
else {
if ( ! is_numeric ( $d )) {
$data [ 'value' ] = $d ;
}
else {
$data [ 'value' ] = format_for_graph ( $d , 2 ) . " " .
$units [ $i ];
}
}
$return [ " data " ][] = $data ;
$i ++ ;
}
break ;
}
return reporting_check_structure_content ( $return );
}
2015-03-25 16:44:39 +01:00
function reporting_custom_graph ( $report , $content , $type = 'dinamic' ,
$force_width_chart = null , $force_height_chart = null ) {
global $config ;
require_once ( $config [ " homedir " ] . '/include/functions_graph.php' );
$graph = db_get_row ( " tgraph " , " id_graph " , $content [ 'id_gs' ]);
$return = array ();
$return [ 'type' ] = 'custom_graph' ;
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'Simple graph' );
}
$return [ 'title' ] = $content [ 'name' ];
$return [ 'subtitle' ] = $graph [ 'name' ];
$return [ " description " ] = $content [ " description " ];
$return [ " date " ] = reporting_get_date_text (
$report ,
$content );
$graphs = db_get_all_rows_field_filter ( " tgraph_source " ,
" id_graph " , $content [ 'id_gs' ]);
$modules = array ();
$weights = array ();
if ( $graphs === false )
$graphs = array ();
foreach ( $graphs as $graph_item ) {
array_push ( $modules , $graph_item [ 'id_agent_module' ]);
array_push ( $weights , $graph_item [ " weight " ]);
}
$return [ 'chart' ] = '' ;
// Get chart
reporting_set_conf_charts ( $width , $height , $only_image , $type , $content );
$height += count ( $modules ) * REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE ;
switch ( $type ) {
case 'dinamic' :
case 'static' :
$return [ 'chart' ] = graphic_combined_module (
$modules ,
$weights ,
$content [ 'period' ],
$width , $height ,
'Combined%20Sample%20Graph' ,
'' ,
0 ,
0 ,
0 ,
$graph [ " stacked " ],
$report [ " datetime " ],
$only_image ,
ui_get_full_url ( false , false , false , false ));
break ;
case 'data' :
break ;
}
return reporting_check_structure_content ( $return );
}
2015-03-24 11:01:19 +01:00
function reporting_simple_graph ( $report , $content , $type = 'dinamic' ,
$force_width_chart = null , $force_height_chart = null ) {
global $config ;
2015-03-23 11:08:58 +01:00
2015-03-18 13:51:14 +01:00
$return = array ();
2015-03-24 17:52:57 +01:00
$return [ 'type' ] = 'simple_graph' ;
2013-01-03 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php,
extensions/resource_exportation.php,
operation/events/event_statistics.php,
operation/events/events_list.php,
operation/reporting/reporting_viewer.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php,
include/functions_alerts.php, include/functions_reports.php,
include/functions_events.php, include/graphs/fgraph.php,
include/functions_graph.php, include/styles/pandora.css,
include/functions_reporting.php, include/functions_agents.php: a lot
of changes and fixes from the branch for the reports.
MERGED FROM PANDORA_4.0
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7351 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-01-03 19:52:21 +01:00
2015-03-18 13:51:14 +01:00
if ( empty ( $content [ 'name' ])) {
$content [ 'name' ] = __ ( 'Simple graph' );
2013-01-03 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php,
extensions/resource_exportation.php,
operation/events/event_statistics.php,
operation/events/events_list.php,
operation/reporting/reporting_viewer.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php,
include/functions_alerts.php, include/functions_reports.php,
include/functions_events.php, include/graphs/fgraph.php,
include/functions_graph.php, include/styles/pandora.css,
include/functions_reporting.php, include/functions_agents.php: a lot
of changes and fixes from the branch for the reports.
MERGED FROM PANDORA_4.0
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7351 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-01-03 19:52:21 +01:00
}
2015-03-18 13:51:14 +01:00
$module_name = io_safe_output (
modules_get_agentmodule_name ( $content [ 'id_agent_module' ]));
$agent_name = io_safe_output (
modules_get_agentmodule_agent_name ( $content [ 'id_agent_module' ]));
2013-01-03 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php,
extensions/resource_exportation.php,
operation/events/event_statistics.php,
operation/events/events_list.php,
operation/reporting/reporting_viewer.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.item_editor.php,
include/functions_alerts.php, include/functions_reports.php,
include/functions_events.php, include/graphs/fgraph.php,
include/functions_graph.php, include/styles/pandora.css,
include/functions_reporting.php, include/functions_agents.php: a lot
of changes and fixes from the branch for the reports.
MERGED FROM PANDORA_4.0
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7351 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-01-03 19:52:21 +01:00
2015-03-18 13:51:14 +01:00
$return [ 'title' ] = $content [ 'name' ];
$return [ 'subtitle' ] = $agent_name . " - " . $module_name ;
$return [ " description " ] = $content [ " description " ];
2015-03-23 11:08:58 +01:00
$return [ " date " ] = reporting_get_date_text (
2015-03-24 11:01:19 +01:00
$report ,
$content );
2015-03-23 11:08:58 +01:00
$only_avg = true ;
// Due to database compatibility problems, the 'only_avg' value
// is stored into the json contained into the 'style' column.
2015-03-24 11:01:19 +01:00
if ( isset ( $style [ 'only_avg' ])) {
$only_avg = ( bool ) $style [ 'only_avg' ];
2015-03-23 11:08:58 +01:00
}
$moduletype_name = modules_get_moduletype_name (
modules_get_agentmodule_type (
$content [ 'id_agent_module' ]));
2013-03-04 13:51:22 +01:00
2015-03-23 11:08:58 +01:00
$return [ 'chart' ] = '' ;
2015-03-18 13:51:14 +01:00
// Get chart
2015-03-25 16:44:39 +01:00
reporting_set_conf_charts ( $width , $height , $only_image , $type , $content );
2015-03-23 11:08:58 +01:00
2015-03-24 11:01:19 +01:00
if ( ! empty ( $force_width_chart )) {
$width = $force_width_chart ;
}
if ( ! empty ( $force_height_chart )) {
$height = $force_height_chart ;
}
2015-03-23 11:08:58 +01:00
switch ( $type ) {
case 'dinamic' :
case 'static' :
if ( preg_match ( " /string/ " , $moduletype_name )) {
$urlImage = ui_get_full_url ( false , false , false , false );
$return [ 'chart' ] = grafico_modulo_string (
$content [ 'id_agent_module' ],
$content [ 'period' ],
false ,
2015-03-24 11:01:19 +01:00
$width ,
$height ,
2015-03-23 11:08:58 +01:00
'' ,
'' ,
false ,
$only_avg ,
false ,
$report [ " datetime " ], $only_image , $urlImage );
}
else {
2015-04-10 00:58:24 +02:00
// HACK it is saved in show_graph field.
$time_compare_overlapped = false ;
if ( $content [ 'show_graph' ]) {
$time_compare_overlapped = 'overlapped' ;
}
2015-03-24 11:01:19 +01:00
$return [ 'chart' ] = grafico_modulo_sparse (
2015-03-23 11:08:58 +01:00
$content [ 'id_agent_module' ],
$content [ 'period' ],
false ,
2015-03-24 11:01:19 +01:00
$width ,
$height ,
2015-03-23 11:08:58 +01:00
'' ,
'' ,
false ,
$only_avg ,
true ,
$report [ " datetime " ],
'' ,
0 ,
0 ,
true ,
$only_image ,
ui_get_full_url ( false , false , false , false ),
1 ,
false ,
'' ,
2015-04-10 00:58:24 +02:00
$time_compare_overlapped ,
2015-03-23 11:08:58 +01:00
true );
}
2013-03-04 13:51:22 +01:00
break ;
2015-03-18 13:51:14 +01:00
case 'data' :
2013-03-04 13:51:22 +01:00
break ;
}
2015-03-18 13:51:14 +01:00
return reporting_check_structure_content ( $return );
2015-01-15 18:08:58 +01:00
}
2015-03-24 17:52:57 +01:00
function reporting_get_date_text ( $report = null , $content = null ) {
2015-01-15 18:08:58 +01:00
global $config ;
2015-03-18 13:51:14 +01:00
$return = array ();
2015-03-24 17:52:57 +01:00
$return [ 'date' ] = null ;
$return [ 'period' ] = null ;
$return [ 'from' ] = null ;
$return [ 'to' ] = null ;
if ( ! empty ( $report ) && ! empty ( $content )) {
if ( $content [ 'period' ] == 0 ) {
$es = json_decode ( $content [ 'external_source' ], true );
if ( $es [ 'date' ] == 0 ) {
$return [ 'period' ] = 0 ;
}
else {
$return [ 'date' ] = $es [ 'date' ];
}
2015-03-11 11:31:46 +01:00
}
2015-03-18 13:51:14 +01:00
else {
2015-03-24 17:52:57 +01:00
$return [ 'period' ] = $content [ 'period' ];
$return [ 'from' ] = $report [ " datetime " ] - $content [ 'period' ];
$return [ 'to' ] = $report [ " datetime " ];
2015-01-15 18:08:58 +01:00
}
2015-03-18 13:51:14 +01:00
}
2015-03-09 09:52:36 +01:00
2015-03-18 13:51:14 +01:00
return $return ;
2015-01-15 18:08:58 +01:00
}
2015-03-23 11:08:58 +01:00
/**
* Check the common items exits
*/
function reporting_check_structure_report ( $return ) {
if ( ! isset ( $return [ 'group_name' ]))
$return [ 'group_name' ] = " " ;
if ( ! isset ( $return [ 'title' ]))
$return [ 'title' ] = " " ;
if ( ! isset ( $return [ 'datetime' ]))
$return [ 'datetime' ] = " " ;
if ( ! isset ( $return [ 'period' ]))
$return [ 'period' ] = " " ;
return $return ;
}
2015-03-18 13:51:14 +01:00
/**
* Check the common items exits
*/
2015-03-24 11:01:19 +01:00
function reporting_check_structure_content ( $report ) {
if ( ! isset ( $report [ 'title' ]))
$report [ 'title' ] = " " ;
if ( ! isset ( $report [ 'subtitle' ]))
$report [ 'subtitle' ] = " " ;
if ( ! isset ( $report [ 'description' ]))
$report [ 'description' ] = " " ;
if ( ! isset ( $report [ " date " ])) {
$report [ " date " ][ 'date' ] = " " ;
$report [ " date " ][ 'period' ] = " " ;
$report [ " date " ][ 'from' ] = " " ;
$report [ " date " ][ 'to' ] = " " ;
2015-01-15 18:08:58 +01:00
}
2015-03-24 11:01:19 +01:00
return $report ;
2015-01-15 18:08:58 +01:00
}
2015-03-23 11:08:58 +01:00
2015-03-25 16:44:39 +01:00
function reporting_set_conf_charts ( & $width , & $height , & $only_image , $type , $content ) {
switch ( $type ) {
case 'dinamic' :
$only_image = false ;
$width = 900 ;
$height = 230 ;
break ;
case 'static' :
$only_image = true ;
if ( $content [ 'style' ][ 'show_in_landscape' ]) {
$height = 1100 ;
$width = 1700 ;
}
else {
$height = 360 ;
$width = 780 ;
}
break ;
case 'data' :
break ;
}
}
////////////////////////////////////////////////////////////////////////
// MAYBE MOVE THE NEXT FUNCTIONS TO A FILE NAMED AS FUNCTION_REPORTING.UTILS.PHP //
////////////////////////////////////////////////////////////////////////
2015-03-24 11:01:19 +01:00
////////////////////////////////////////////////////////////////////////
2015-03-23 11:08:58 +01:00
/**
* Get general statistical info on a group
*
* @ param int Group Id to get info from . 0 = all
*
* @ return array Group statistics
*/
function reporting_get_group_stats ( $id_group = 0 , $access = 'AR' ) {
global $config ;
$data = array ();
$data [ " monitor_checks " ] = 0 ;
$data [ " monitor_not_init " ] = 0 ;
$data [ " monitor_unknown " ] = 0 ;
$data [ " monitor_ok " ] = 0 ;
$data [ " monitor_bad " ] = 0 ; // Critical + Unknown + Warning
$data [ " monitor_warning " ] = 0 ;
$data [ " monitor_critical " ] = 0 ;
$data [ " monitor_not_normal " ] = 0 ;
$data [ " monitor_alerts " ] = 0 ;
$data [ " monitor_alerts_fired " ] = 0 ;
$data [ " monitor_alerts_fire_count " ] = 0 ;
$data [ " total_agents " ] = 0 ;
$data [ " total_alerts " ] = 0 ;
$data [ " total_checks " ] = 0 ;
$data [ " alerts " ] = 0 ;
$data [ " agents_unknown " ] = 0 ;
$data [ " monitor_health " ] = 100 ;
$data [ " alert_level " ] = 100 ;
$data [ " module_sanity " ] = 100 ;
$data [ " server_sanity " ] = 100 ;
$data [ " total_not_init " ] = 0 ;
$data [ " monitor_non_init " ] = 0 ;
$data [ " agent_ok " ] = 0 ;
$data [ " agent_warning " ] = 0 ;
$data [ " agent_critical " ] = 0 ;
$data [ " agent_unknown " ] = 0 ;
$data [ " agent_not_init " ] = 0 ;
$cur_time = get_system_time ();
//Check for access credentials using check_acl. More overhead, much safer
if ( ! check_acl ( $config [ " id_user " ], $id_group , $access )) {
return $data ;
}
if ( $id_group == 0 ) {
$id_group = array_keys (
users_get_groups ( $config [ 'id_user' ], $access , false ));
}
// -----------------------------------------------------------------
// Server processed stats. NOT realtime (taken from tgroup_stat)
// -----------------------------------------------------------------
if ( $config [ " realtimestats " ] == 0 ) {
if ( ! is_array ( $id_group )){
$my_group = $id_group ;
$id_group = array ();
$id_group [ 0 ] = $my_group ;
}
foreach ( $id_group as $group ) {
$group_stat = db_get_all_rows_sql ( " SELECT *
FROM tgroup_stat , tgrupo
WHERE tgrupo . id_grupo = tgroup_stat . id_group
AND tgroup_stat . id_group = $group
ORDER BY nombre " );
$data [ " monitor_checks " ] += $group_stat [ 0 ][ " modules " ];
$data [ " agent_not_init " ] += $group_stat [ 0 ][ " non-init " ];
$data [ " agent_unknown " ] += $group_stat [ 0 ][ " unknown " ];
$data [ " agent_ok " ] += $group_stat [ 0 ][ " normal " ];
$data [ " agent_warning " ] += $group_stat [ 0 ][ " warning " ];
$data [ " agent_critical " ] += $group_stat [ 0 ][ " critical " ];
$data [ " monitor_alerts " ] += $group_stat [ 0 ][ " alerts " ];
$data [ " monitor_alerts_fired " ] += $group_stat [ 0 ][ " alerts_fired " ];
$data [ " monitor_alerts_fire_count " ] += $group_stat [ 0 ][ " alerts_fired " ];
$data [ " total_checks " ] += $group_stat [ 0 ][ " modules " ];
$data [ " total_alerts " ] += $group_stat [ 0 ][ " alerts " ];
$data [ " total_agents " ] += $group_stat [ 0 ][ " agents " ];
$data [ " agents_unknown " ] += $group_stat [ 0 ][ " agents_unknown " ];
$data [ " utimestamp " ] = $group_stat [ 0 ][ " utimestamp " ];
// This fields are not in database
$data [ " monitor_ok " ] += ( int ) groups_get_normal_monitors ( $group );
$data [ " monitor_warning " ] += ( int ) groups_get_warning_monitors ( $group );
$data [ " monitor_critical " ] += ( int ) groups_get_critical_monitors ( $group );
$data [ " monitor_unknown " ] += ( int ) groups_get_unknown_monitors ( $group );
$data [ " monitor_not_init " ] += ( int ) groups_get_not_init_monitors ( $group );
}
// -------------------------------------------------------------------
// Realtime stats, done by PHP Console
// -------------------------------------------------------------------
}
else {
if ( ! is_array ( $id_group )) {
$my_group = $id_group ;
$id_group = array ();
$id_group [ 0 ] = $my_group ;
}
// Store the groups where we are quering
$covered_groups = array ();
$group_array = array ();
foreach ( $id_group as $group ) {
$children = groups_get_childrens ( $group );
//Show empty groups only if they have children with agents
//$group_array = array();
foreach ( $children as $sub ) {
// If the group is quering previously, we ingore it
if ( ! in_array ( $sub [ 'id_grupo' ], $covered_groups )) {
array_push ( $covered_groups , $sub [ 'id_grupo' ]);
array_push ( $group_array , $sub [ 'id_grupo' ]);
}
}
// Add id of this group to create the clause
// If the group is quering previously, we ingore it
if ( ! in_array ( $group , $covered_groups )) {
array_push ( $covered_groups , $group );
array_push ( $group_array , $group );
}
// If there are not groups to query, we jump to nextone
if ( empty ( $group_array )) {
continue ;
}
}
if ( ! empty ( $group_array )) {
// FOR THE FUTURE: Split the groups into groups with tags restrictions and groups without it
// To calculate in the light way the non tag restricted and in the heavy way the others
/*
$group_restricted_data = tags_get_acl_tags ( $config [ 'id_user' ], $group_array , $access , 'data' );
$tags_restricted_groups = array_keys ( $group_restricted_data );
$no_tags_restricted_groups = $group_array ;
foreach ( $no_tags_restricted_groups as $k => $v ) {
if ( in_array ( $v , $tags_restricted_groups )) {
unset ( $no_tags_restricted_groups [ $k ]);
}
}
*/
if ( ! empty ( $group_array )) {
// Get monitor NOT INIT, except disabled AND async modules
$data [ " monitor_not_init " ] += ( int ) groups_get_not_init_monitors ( $group_array , array (), array (), false , false , true );
// Get monitor OK, except disabled and non-init
$data [ " monitor_ok " ] += ( int ) groups_get_normal_monitors ( $group_array , array (), array (), false , false , true );
// Get monitor CRITICAL, except disabled and non-init
$data [ " monitor_critical " ] += ( int ) groups_get_critical_monitors ( $group_array , array (), array (), false , false , true );
// Get monitor WARNING, except disabled and non-init
$data [ " monitor_warning " ] += ( int ) groups_get_warning_monitors ( $group_array , array (), array (), false , false , true );
// Get monitor UNKNOWN, except disabled and non-init
$data [ " monitor_unknown " ] += ( int ) groups_get_unknown_monitors ( $group_array , array (), array (), false , false , true );
// Get alerts configured, except disabled
$data [ " monitor_alerts " ] += groups_monitor_alerts ( $group_array ) ;
// Get alert configured currently FIRED, except disabled
$data [ " monitor_alerts_fired " ] += groups_monitor_fired_alerts ( $group_array );
// Calculate totals using partial counts from above
// Get TOTAL non-init modules, except disabled ones and async modules
$data [ " total_not_init " ] += $data [ " monitor_not_init " ];
// Get TOTAL agents in a group
$data [ " total_agents " ] += ( int ) groups_get_total_agents ( $group_array , array (), array (), false , false , true );
// Get Agents OK
$data [ " agent_ok " ] += ( int ) groups_get_normal_agents ( $group_array , array (), array (), false , false , true );
// Get Agents Warning
$data [ " agent_warning " ] += ( int ) groups_get_warning_agents ( $group_array , array (), array (), false , false , true );
// Get Agents Critical
$data [ " agent_critical " ] += ( int ) groups_get_critical_agents ( $group_array , array (), array (), false , false , true );
// Get Agents Unknown
$data [ " agent_unknown " ] += ( int ) groups_get_unknown_agents ( $group_array , array (), array (), false , false , true );
// Get Agents Not init
$data [ " agent_not_init " ] += ( int ) groups_get_not_init_agents ( $group_array , array (), array (), false , false , true );
}
// Get total count of monitors for this group, except disabled.
$data [ " monitor_checks " ] = $data [ " monitor_not_init " ] + $data [ " monitor_unknown " ] + $data [ " monitor_warning " ] + $data [ " monitor_critical " ] + $data [ " monitor_ok " ];
// Calculate not_normal monitors
$data [ " monitor_not_normal " ] += $data [ " monitor_checks " ] - $data [ " monitor_ok " ];
}
// Get total count of monitors for this group, except disabled.
$data [ " monitor_checks " ] = $data [ " monitor_not_init " ] + $data [ " monitor_unknown " ] + $data [ " monitor_warning " ] + $data [ " monitor_critical " ] + $data [ " monitor_ok " ];
/*
Monitor health ( percentage )
Data health ( percentage )
Global health ( percentage )
Module sanity ( percentage )
Alert level ( percentage )
Server Sanity 0 % Uninitialized modules
*/
}
if ( $data [ " monitor_unknown " ] > 0 && $data [ " monitor_checks " ] > 0 ) {
$data [ " monitor_health " ] = format_numeric ( 100 - ( $data [ " monitor_not_normal " ] / ( $data [ " monitor_checks " ] / 100 )), 1 );
}
else {
$data [ " monitor_health " ] = 100 ;
}
if ( $data [ " monitor_not_init " ] > 0 && $data [ " monitor_checks " ] > 0 ) {
$data [ " module_sanity " ] = format_numeric ( 100 - ( $data [ " monitor_not_init " ] / ( $data [ " monitor_checks " ] / 100 )), 1 );
}
else {
$data [ " module_sanity " ] = 100 ;
}
if ( isset ( $data [ " alerts " ])) {
if ( $data [ " monitor_alerts_fired " ] > 0 && $data [ " alerts " ] > 0 ) {
$data [ " alert_level " ] = format_numeric ( 100 - ( $data [ " monitor_alerts_fired " ] / ( $data [ " alerts " ] / 100 )), 1 );
}
else {
$data [ " alert_level " ] = 100 ;
}
}
else {
$data [ " alert_level " ] = 100 ;
$data [ " alerts " ] = 0 ;
}
$data [ " monitor_bad " ] = $data [ " monitor_critical " ] + $data [ " monitor_warning " ];
if ( $data [ " monitor_bad " ] > 0 && $data [ " monitor_checks " ] > 0 ) {
$data [ " global_health " ] = format_numeric ( 100 - ( $data [ " monitor_bad " ] / ( $data [ " monitor_checks " ] / 100 )), 1 );
}
else {
$data [ " global_health " ] = 100 ;
}
$data [ " server_sanity " ] = format_numeric ( 100 - $data [ " module_sanity " ], 1 );
$data [ 'alert_fired' ] = 0 ;
if ( $data [ " monitor_alerts_fired " ] > 0 ) {
$data [ 'alert_fired' ] = 1 ;
}
if ( $data [ " monitor_critical " ] > 0 ) {
$data [ 'status' ] = 'critical' ;
}
elseif ( $data [ " monitor_warning " ] > 0 ) {
$data [ 'status' ] = 'warning' ;
}
elseif (( $data [ " monitor_unknown " ] > 0 ) || ( $data [ " agents_unknown " ] > 0 )) {
$data [ 'status' ] = 'unknown' ;
}
elseif ( $data [ " monitor_ok " ] > 0 ) {
$data [ 'status' ] = 'ok' ;
}
elseif ( $data [ " agent_not_init " ] > 0 ) {
$data [ 'status' ] = 'not_init' ;
}
else {
$data [ 'status' ] = 'none' ;
}
return ( $data );
}
function reporting_get_stats_indicators ( $data , $width = 280 , $height = 20 , $html = true ) {
$table_ind = html_get_predefined_table ();
$servers = array ();
$servers [ " all " ] = ( int ) db_get_value ( 'COUNT(id_server)' , 'tserver' );
$servers [ " up " ] = ( int ) servers_check_status ();
$servers [ " down " ] = $servers [ " all " ] - $servers [ " up " ];
if ( $servers [ " all " ] == 0 ) {
$servers [ " health " ] = 0 ;
}
else {
$servers [ " health " ] = $servers [ " up " ] / ( $servers [ " all " ] / 100 );
}
if ( $html ) {
$tdata [ 0 ] = ' < fieldset class = " databox tactical_set " >
< legend > ' .
__ ( 'Server health' ) . ui_print_help_tip ( sprintf ( __ ( '%d Downed servers' ), $servers [ " down " ]), true ) .
'</legend>' .
progress_bar ( $servers [ " health " ], $width , $height , '' , 0 ) . '</fieldset>' ;
$table_ind -> rowclass [] = '' ;
$table_ind -> data [] = $tdata ;
$tdata [ 0 ] = ' < fieldset class = " databox tactical_set " >
< legend > ' .
__ ( 'Monitor health' ) . ui_print_help_tip ( sprintf ( __ ( '%d Not Normal monitors' ), $data [ " monitor_not_normal " ]), true ) .
'</legend>' .
progress_bar ( $data [ " monitor_health " ], $width , $height , $data [ " monitor_health " ] . '% ' . __ ( 'of monitors up' ), 0 ) . '</fieldset>' ;
$table_ind -> rowclass [] = '' ;
$table_ind -> data [] = $tdata ;
$tdata [ 0 ] = ' < fieldset class = " databox tactical_set " >
< legend > ' .
__ ( 'Module sanity' ) . ui_print_help_tip ( sprintf ( __ ( '%d Not inited monitors' ), $data [ " monitor_not_init " ]), true ) .
'</legend>' .
progress_bar ( $data [ " module_sanity " ], $width , $height , $data [ " module_sanity " ] . '% ' . __ ( 'of total modules inited' ), 0 ) . '</fieldset>' ;
$table_ind -> rowclass [] = '' ;
$table_ind -> data [] = $tdata ;
$tdata [ 0 ] = ' < fieldset class = " databox tactical_set " >
< legend > ' .
__ ( 'Alert level' ) . ui_print_help_tip ( sprintf ( __ ( '%d Fired alerts' ), $data [ " monitor_alerts_fired " ]), true ) .
'</legend>' .
progress_bar ( $data [ " alert_level " ], $width , $height , $data [ " alert_level " ] . '% ' . __ ( 'of defined alerts not fired' ), 0 ) . '</fieldset>' ;
$table_ind -> rowclass [] = '' ;
$table_ind -> data [] = $tdata ;
return html_print_table ( $table_ind , true );
}
else {
$return = array ();
$return [ 'server_health' ] = array (
'title' => __ ( 'Server health' ),
'graph' => progress_bar ( $servers [ " health " ], $width , $height , '' , 0 ));
$return [ 'monitor_health' ] = array (
'title' => __ ( 'Monitor health' ),
'graph' => progress_bar ( $data [ " monitor_health " ], $width , $height , $data [ " monitor_health " ] . '% ' . __ ( 'of monitors up' ), 0 ));
$return [ 'module_sanity' ] = array (
'title' => __ ( 'Module sanity' ),
'graph' => progress_bar ( $data [ " module_sanity " ], $width , $height , $data [ " module_sanity " ] . '% ' . __ ( 'of total modules inited' ), 0 ));
$return [ 'alert_level' ] = array (
'title' => __ ( 'Alert level' ),
'graph' => progress_bar ( $data [ " alert_level " ], $width , $height , $data [ " alert_level " ] . '% ' . __ ( 'of defined alerts not fired' ), 0 ));
return $return ;
}
}
function reporting_get_stats_alerts ( $data , $links = false ) {
global $config ;
// Link URLS
$mobile = false ;
if ( isset ( $data [ 'mobile' ])) {
if ( $data [ 'mobile' ]) {
$mobile = true ;
}
}
if ( $mobile ) {
$urls = array ();
$urls [ 'monitor_alerts' ] = " index.php?page=alerts&status=all_enabled " ;
$urls [ 'monitor_alerts_fired' ] = " index.php?page=alerts&status=fired " ;
}
else {
$urls = array ();
if ( $links ) {
$urls [ 'monitor_alerts' ] = " index.php?sec=estado&sec2=operation/agentes/alerts_status&pure= " . $config [ 'pure' ];
$urls [ 'monitor_alerts_fired' ] = " index.php?sec=estado&sec2=operation/agentes/alerts_status&filter=fired&pure= " . $config [ 'pure' ];
} else {
$urls [ 'monitor_alerts' ] = " index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60 " ;
$urls [ 'monitor_alerts_fired' ] = " index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&filter=fired " ;
}
}
2015-03-24 11:36:40 +01:00
// Alerts table
$table_al = html_get_predefined_table ();
2015-03-23 11:08:58 +01:00
$tdata = array ();
$tdata [ 0 ] = html_print_image ( 'images/bell.png' , true , array ( 'title' => __ ( 'Defined alerts' )));
$tdata [ 1 ] = $data [ " monitor_alerts " ] <= 0 ? '-' : $data [ " monitor_alerts " ];
$tdata [ 1 ] = '<a class="big_data" href="' . $urls [ " monitor_alerts " ] . '">' . $tdata [ 1 ] . '</a>' ;
$tdata [ 2 ] = html_print_image ( 'images/bell_error.png' , true , array ( 'title' => __ ( 'Fired alerts' )));
$tdata [ 3 ] = $data [ " monitor_alerts_fired " ] <= 0 ? '-' : $data [ " monitor_alerts_fired " ];
$tdata [ 3 ] = '<a style="color: ' . COL_ALERTFIRED . ';" class="big_data" href="' . $urls [ " monitor_alerts_fired " ] . '">' . $tdata [ 3 ] . '</a>' ;
$table_al -> rowclass [] = '' ;
$table_al -> data [] = $tdata ;
2015-03-24 11:36:40 +01:00
if ( ! defined ( 'METACONSOLE' )){
2015-03-23 11:08:58 +01:00
$output = ' < fieldset class = " databox tactical_set " >
< legend > ' .
__ ( 'Defined and fired alerts' ) .
'</legend>' .
html_print_table ( $table_al , true ) . '</fieldset>' ;
2015-03-24 11:36:40 +01:00
} else {
2015-03-23 11:08:58 +01:00
$table_al -> class = " tactical_view " ;
$table_al -> style = array ();
$output = ' < fieldset class = " tactical_set " >
< legend > ' .
__ ( 'Defined and fired alerts' ) .
'</legend>' .
html_print_table ( $table_al , true ) . '</fieldset>' ;
}
return $output ;
}
function reporting_get_stats_modules_status ( $data , $graph_width = 250 , $graph_height = 150 , $links = false , $data_agents = false ) {
global $config ;
2015-03-24 11:36:40 +01:00
// Link URLS
if ( $links === false ) {
$urls = array ();
$urls [ 'monitor_critical' ] = " index.php? " .
" sec=estado&sec2=operation/agentes/status_monitor& " .
" refr=60&status= " . AGENT_MODULE_STATUS_CRITICAL_BAD . " &pure= " . $config [ 'pure' ];
$urls [ 'monitor_warning' ] = " index.php? " .
" sec=estado&sec2=operation/agentes/status_monitor& " .
" refr=60&status= " . AGENT_MODULE_STATUS_WARNING . " &pure= " . $config [ 'pure' ];
$urls [ 'monitor_ok' ] = " index.php? " .
" sec=estado&sec2=operation/agentes/status_monitor& " .
" refr=60&status= " . AGENT_MODULE_STATUS_NORMAL . " &pure= " . $config [ 'pure' ];
$urls [ 'monitor_unknown' ] = " index.php? " .
" sec=estado&sec2=operation/agentes/status_monitor& " .
" refr=60&status= " . AGENT_MODULE_STATUS_UNKNOWN . " &pure= " . $config [ 'pure' ];
$urls [ 'monitor_not_init' ] = " index.php? " .
" sec=estado&sec2=operation/agentes/status_monitor& " .
" refr=60&status= " . AGENT_MODULE_STATUS_NOT_INIT . " &pure= " . $config [ 'pure' ];
}
else {
$urls = array ();
$urls [ 'monitor_critical' ] = $links [ 'monitor_critical' ];
$urls [ 'monitor_warning' ] = $links [ 'monitor_warning' ];
$urls [ 'monitor_ok' ] = $links [ 'monitor_ok' ];
$urls [ 'monitor_unknown' ] = $links [ 'monitor_unknown' ];
$urls [ 'monitor_not_init' ] = $links [ 'monitor_not_init' ];
2015-03-23 11:08:58 +01:00
}
// Modules by status table
$table_mbs = html_get_predefined_table ();
2015-03-24 11:36:40 +01:00
$tdata = array ();
$tdata [ 0 ] = html_print_image ( 'images/module_critical.png' , true , array ( 'title' => __ ( 'Monitor critical' )));
$tdata [ 1 ] = $data [ " monitor_critical " ] <= 0 ? '-' : $data [ " monitor_critical " ];
$tdata [ 1 ] = '<a style="color: ' . COL_CRITICAL . ';" class="big_data" href="' . $urls [ 'monitor_critical' ] . '">' . $tdata [ 1 ] . '</a>' ;
$tdata [ 2 ] = html_print_image ( 'images/module_warning.png' , true , array ( 'title' => __ ( 'Monitor warning' )));
$tdata [ 3 ] = $data [ " monitor_warning " ] <= 0 ? '-' : $data [ " monitor_warning " ];
$tdata [ 3 ] = '<a style="color: ' . COL_WARNING_DARK . ';" class="big_data" href="' . $urls [ 'monitor_warning' ] . '">' . $tdata [ 3 ] . '</a>' ;
$table_mbs -> rowclass [] = '' ;
$table_mbs -> data [] = $tdata ;
$tdata = array ();
$tdata [ 0 ] = html_print_image ( 'images/module_ok.png' , true , array ( 'title' => __ ( 'Monitor normal' )));
$tdata [ 1 ] = $data [ " monitor_ok " ] <= 0 ? '-' : $data [ " monitor_ok " ];
$tdata [ 1 ] = '<a style="color: ' . COL_NORMAL . ';" class="big_data" href="' . $urls [ " monitor_ok " ] . '">' . $tdata [ 1 ] . '</a>' ;
$tdata [ 2 ] = html_print_image ( 'images/module_unknown.png' , true , array ( 'title' => __ ( 'Monitor unknown' )));
$tdata [ 3 ] = $data [ " monitor_unknown " ] <= 0 ? '-' : $data [ " monitor_unknown " ];
$tdata [ 3 ] = '<a style="color: ' . COL_UNKNOWN . ';" class="big_data" href="' . $urls [ " monitor_unknown " ] . '">' . $tdata [ 3 ] . '</a>' ;
$table_mbs -> rowclass [] = '' ;
$table_mbs -> data [] = $tdata ;
$tdata = array ();
$tdata [ 0 ] = html_print_image ( 'images/module_notinit.png' , true , array ( 'title' => __ ( 'Monitor not init' )));
$tdata [ 1 ] = $data [ " monitor_not_init " ] <= 0 ? '-' : $data [ " monitor_not_init " ];
$tdata [ 1 ] = '<a style="color: ' . COL_NOTINIT . ';" class="big_data" href="' . $urls [ " monitor_not_init " ] . '">' . $tdata [ 1 ] . '</a>' ;
$tdata [ 2 ] = $tdata [ 3 ] = '' ;
$table_mbs -> rowclass [] = '' ;
$table_mbs -> data [] = $tdata ;
2015-03-11 11:31:46 +01:00
2015-03-24 11:36:40 +01:00
if ( $data [ " monitor_checks " ] > 0 ) {
$tdata = array ();
$table_mbs -> colspan [ count ( $table_mbs -> data )][ 0 ] = 4 ;
$table_mbs -> cellstyle [ count ( $table_mbs -> data )][ 0 ] = 'text-align: center;' ;
$tdata [ 0 ] = '<div id="outter_status_pie" style="height: ' . $graph_height . 'px">' .
'<div id="status_pie" style="margin: auto; width: ' . $graph_width . 'px;">' .
graph_agent_status ( false , $graph_width , $graph_height , true , true , $data_agents ) .
'</div></div>' ;
$table_mbs -> rowclass [] = '' ;
$table_mbs -> data [] = $tdata ;
2015-03-23 11:08:58 +01:00
}
2015-03-24 11:36:40 +01:00
if ( ! defined ( " METACONSOLE " )){
2015-03-23 11:08:58 +01:00
$output = '
< fieldset class = " databox tactical_set " >
< legend > ' .
__ ( 'Monitors by status' ) .
'</legend>' .
html_print_table ( $table_mbs , true ) .
'</fieldset>' ;
}
2015-03-24 11:36:40 +01:00
else {
2015-03-23 11:08:58 +01:00
$table_mbs -> class = " tactical_view " ;
$table_mbs -> style = array ();
$output = '
< fieldset class = " tactical_set " >
< legend > ' .
__ ( 'Monitors by status' ) .
'</legend>' .
html_print_table ( $table_mbs , true ) .
'</fieldset>' ;
}
return $output ;
}
function reporting_get_stats_agents_monitors ( $data ) {
global $config ;
// Link URLS
$mobile = false ;
if ( isset ( $data [ 'mobile' ])) {
if ( $data [ 'mobile' ]) {
$mobile = true ;
}
}
if ( $mobile ) {
$urls = array ();
$urls [ 'total_agents' ] = " index.php?page=agents " ;
$urls [ 'monitor_checks' ] = " index.php?page=modules " ;
}
else {
$urls = array ();
$urls [ 'total_agents' ] = " index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60 " ;
$urls [ 'monitor_checks' ] = " index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&status=-1 " ;
}
// Agents and modules table
$table_am = html_get_predefined_table ();
$tdata = array ();
$tdata [ 0 ] = html_print_image ( 'images/agent.png' , true , array ( 'title' => __ ( 'Total agents' )));
$tdata [ 1 ] = $data [ " total_agents " ] <= 0 ? '-' : $data [ " total_agents " ];
$tdata [ 1 ] = '<a class="big_data" href="' . $urls [ 'total_agents' ] . '">' . $tdata [ 1 ] . '</a>' ;
$tdata [ 2 ] = html_print_image ( 'images/module.png' , true , array ( 'title' => __ ( 'Monitor checks' )));
$tdata [ 3 ] = $data [ " monitor_checks " ] <= 0 ? '-' : $data [ " monitor_checks " ];
$tdata [ 3 ] = '<a class="big_data" href="' . $urls [ 'monitor_checks' ] . '">' . $tdata [ 3 ] . '</a>' ;
$table_am -> rowclass [] = '' ;
$table_am -> data [] = $tdata ;
$output = ' < fieldset class = " databox tactical_set " >
< legend > ' .
__ ( 'Total agents and monitors' ) .
'</legend>' .
html_print_table ( $table_am , true ) . '</fieldset>' ;
return $output ;
}
function reporting_get_stats_users ( $data ) {
global $config ;
// Link URLS
$urls = array ();
if ( check_acl ( $config [ 'id_user' ], 0 , " UM " )) {
$urls [ 'defined_users' ] = " index.php?sec=gusuarios&sec2=godmode/users/user_list " ;
}
else {
$urls [ 'defined_users' ] = 'javascript:' ;
}
// Users table
$table_us = html_get_predefined_table ();
$tdata = array ();
$tdata [ 0 ] = html_print_image ( 'images/user_green.png' , true , array ( 'title' => __ ( 'Defined users' )));
$tdata [ 1 ] = count ( get_users ());
$tdata [ 1 ] = '<a class="big_data" href="' . $urls [ " defined_users " ] . '">' . $tdata [ 1 ] . '</a>' ;
$tdata [ 2 ] = $tdata [ 3 ] = ' ' ;
$table_us -> rowclass [] = '' ;
$table_us -> data [] = $tdata ;
$output = ' < fieldset class = " databox tactical_set " >
< legend > ' .
__ ( 'Users' ) .
'</legend>' .
html_print_table ( $table_us , true ) . '</fieldset>' ;
return $output ;
}
2015-03-25 16:44:39 +01:00
/**
* Get the average value of an agent module in a period of time .
*
* @ param int Agent module id
* @ param int Period of time to check ( in seconds )
* @ param int Top date to check the values . Default current time .
*
* @ return float The average module value in the interval .
*/
function reporting_get_agentmodule_data_average ( $id_agent_module , $period = 0 , $date = 0 ) {
global $config ;
// Initialize variables
if ( empty ( $date )) $date = get_system_time ();
$datelimit = $date - $period ;
$search_in_history_db = db_search_in_history_db ( $datelimit );
$id_module_type = modules_get_agentmodule_type ( $id_agent_module );
$module_type = modules_get_moduletype_name ( $id_module_type );
$uncompressed_module = is_module_uncompressed ( $module_type );
// Get module data
$interval_data = db_get_all_rows_sql ( ' SELECT *
FROM tagente_datos
WHERE id_agente_modulo = ' . ( int ) $id_agent_module .
' AND utimestamp > ' . ( int ) $datelimit .
' AND utimestamp < ' . ( int ) $date .
' ORDER BY utimestamp ASC' , $search_in_history_db );
if ( $interval_data === false ) $interval_data = array ();
// Uncompressed module data
if ( $uncompressed_module ) {
$min_necessary = 1 ;
// Compressed module data
}
else {
// Get previous data
$previous_data = modules_get_previous_data ( $id_agent_module , $datelimit );
if ( $previous_data !== false ) {
$previous_data [ 'utimestamp' ] = $datelimit ;
array_unshift ( $interval_data , $previous_data );
}
// Get next data
$next_data = modules_get_next_data ( $id_agent_module , $date );
if ( $next_data !== false ) {
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
else if ( count ( $interval_data ) > 0 ) {
// Propagate the last known data to the end of the interval
$next_data = array_pop ( $interval_data );
array_push ( $interval_data , $next_data );
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
$min_necessary = 2 ;
}
if ( count ( $interval_data ) < $min_necessary ) {
return false ;
}
// Set initial conditions
$total = 0 ;
$count = 0 ;
if ( ! $uncompressed_module ) {
$previous_data = array_shift ( $interval_data );
// Do not count the empty start of an interval as 0
if ( $previous_data [ 'utimestamp' ] != $datelimit ) {
$period = $date - $previous_data [ 'utimestamp' ];
}
}
foreach ( $interval_data as $data ) {
if ( ! $uncompressed_module ) {
$total += $previous_data [ 'datos' ] * ( $data [ 'utimestamp' ] - $previous_data [ 'utimestamp' ]);
$previous_data = $data ;
}
else {
$total += $data [ 'datos' ];
$count ++ ;
}
}
// Compressed module data
if ( ! $uncompressed_module ) {
if ( $period == 0 ) {
return 0 ;
}
return $total / $period ;
}
// Uncompressed module data
if ( $count == 0 ) {
return 0 ;
}
return $total / $count ;
}
2015-03-27 13:03:15 +01:00
/**
* Get the MTTR value of an agent module in a period of time . See
* http :// en . wikipedia . org / wiki / Mean_time_to_recovery
*
* @ param int Agent module id
* @ param int Period of time to check ( in seconds )
* @ param int Top date to check the values . Default current time .
*
* @ return float The MTTR value in the interval .
*/
function reporting_get_agentmodule_mttr ( $id_agent_module , $period = 0 , $date = 0 ) {
// Initialize variables
if ( empty ( $date )) $date = get_system_time ();
// Read module configuration
$datelimit = $date - $period ;
$search_in_history_db = db_search_in_history_db ( $datelimit );
$module = db_get_row_sql ( ' SELECT max_critical , min_critical , id_tipo_modulo
FROM tagente_modulo
WHERE id_agente_modulo = ' . ( int ) $id_agent_module );
if ( $module === false ) {
return false ;
}
$critical_min = $module [ 'min_critical' ];
$critical_max = $module [ 'max_critical' ];
$module_type = $module [ 'id_tipo_modulo' ];
// Set critical_min and critical for proc modules
$module_type_str = modules_get_type_name ( $module_type );
if ( strstr ( $module_type_str , 'proc' ) !== false &&
( $critical_min == 0 && $critical_max == 0 )) {
$critical_min = 1 ;
}
// Get module data
$interval_data = db_get_all_rows_sql ( ' SELECT * FROM tagente_datos
WHERE id_agente_modulo = ' . ( int ) $id_agent_module .
' AND utimestamp > ' . ( int ) $datelimit .
' AND utimestamp < ' . ( int ) $date .
' ORDER BY utimestamp ASC' , $search_in_history_db );
if ( $interval_data === false ) $interval_data = array ();
// Get previous data
$previous_data = modules_get_previous_data ( $id_agent_module , $datelimit );
if ( $previous_data !== false ) {
$previous_data [ 'utimestamp' ] = $datelimit ;
array_unshift ( $interval_data , $previous_data );
}
// Get next data
$next_data = modules_get_next_data ( $id_agent_module , $date );
if ( $next_data !== false ) {
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
else if ( count ( $interval_data ) > 0 ) {
// Propagate the last known data to the end of the interval
$next_data = array_pop ( $interval_data );
array_push ( $interval_data , $next_data );
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
if ( count ( $interval_data ) < 2 ) {
return false ;
}
// Set initial conditions
$critical_period = 0 ;
$first_data = array_shift ( $interval_data );
$previous_utimestamp = $first_data [ 'utimestamp' ];
if ((( $critical_max > $critical_min AND ( $first_data [ 'datos' ] > $critical_max OR $first_data [ 'datos' ] < $critical_min ))) OR
( $critical_max <= $critical_min AND $first_data [ 'datos' ] < $critical_min )) {
$previous_status = 1 ;
$critical_count = 1 ;
}
else {
$previous_status = 0 ;
$critical_count = 0 ;
}
foreach ( $interval_data as $data ) {
// Previous status was critical
if ( $previous_status == 1 ) {
$critical_period += $data [ 'utimestamp' ] - $previous_utimestamp ;
}
// Re-calculate previous status for the next data
if ((( $critical_max > $critical_min AND ( $data [ 'datos' ] > $critical_max OR $data [ 'datos' ] < $critical_min ))) OR
( $critical_max <= $critical_min AND $data [ 'datos' ] < $critical_min )) {
if ( $previous_status == 0 ) {
$critical_count ++ ;
}
$previous_status = 1 ;
}
else {
$previous_status = 0 ;
}
$previous_utimestamp = $data [ 'utimestamp' ];
}
if ( $critical_count == 0 ) {
return 0 ;
}
return $critical_period / $critical_count ;
}
/**
* Get the MTBF value of an agent module in a period of time . See
* http :// en . wikipedia . org / wiki / Mean_time_between_failures
*
* @ param int Agent module id
* @ param int Period of time to check ( in seconds )
* @ param int Top date to check the values . Default current time .
*
* @ return float The MTBF value in the interval .
*/
function reporting_get_agentmodule_mtbf ( $id_agent_module , $period = 0 , $date = 0 ) {
// Initialize variables
if ( empty ( $date )) $date = get_system_time ();
// Read module configuration
$datelimit = $date - $period ;
$search_in_history_db = db_search_in_history_db ( $datelimit );
$module = db_get_row_sql ( ' SELECT max_critical , min_critical , id_tipo_modulo
FROM tagente_modulo
WHERE id_agente_modulo = ' . ( int ) $id_agent_module );
if ( $module === false ) {
return false ;
}
$critical_min = $module [ 'min_critical' ];
$critical_max = $module [ 'max_critical' ];
$module_type = $module [ 'id_tipo_modulo' ];
// Set critical_min and critical for proc modules
$module_type_str = modules_get_type_name ( $module_type );
if ( strstr ( $module_type_str , 'proc' ) !== false &&
( $critical_min == 0 && $critical_max == 0 )) {
$critical_min = 1 ;
}
// Get module data
$interval_data = db_get_all_rows_sql ( ' SELECT * FROM tagente_datos
WHERE id_agente_modulo = ' . ( int ) $id_agent_module .
' AND utimestamp > ' . ( int ) $datelimit .
' AND utimestamp < ' . ( int ) $date .
' ORDER BY utimestamp ASC' , $search_in_history_db );
if ( $interval_data === false ) $interval_data = array ();
// Get previous data
$previous_data = modules_get_previous_data ( $id_agent_module , $datelimit );
if ( $previous_data !== false ) {
$previous_data [ 'utimestamp' ] = $datelimit ;
array_unshift ( $interval_data , $previous_data );
}
// Get next data
$next_data = modules_get_next_data ( $id_agent_module , $date );
if ( $next_data !== false ) {
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
else if ( count ( $interval_data ) > 0 ) {
// Propagate the last known data to the end of the interval
$next_data = array_pop ( $interval_data );
array_push ( $interval_data , $next_data );
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
if ( count ( $interval_data ) < 2 ) {
return false ;
}
// Set initial conditions
$critical_period = 0 ;
$first_data = array_shift ( $interval_data );
$previous_utimestamp = $first_data [ 'utimestamp' ];
if ((( $critical_max > $critical_min AND ( $first_data [ 'datos' ] > $critical_max OR $first_data [ 'datos' ] < $critical_min ))) OR
( $critical_max <= $critical_min AND $first_data [ 'datos' ] < $critical_min )) {
$previous_status = 1 ;
$critical_count = 1 ;
}
else {
$previous_status = 0 ;
$critical_count = 0 ;
}
foreach ( $interval_data as $data ) {
// Previous status was critical
if ( $previous_status == 1 ) {
$critical_period += $data [ 'utimestamp' ] - $previous_utimestamp ;
}
// Re-calculate previous status for the next data
if ((( $critical_max > $critical_min AND ( $data [ 'datos' ] > $critical_max OR $data [ 'datos' ] < $critical_min ))) OR
( $critical_max <= $critical_min AND $data [ 'datos' ] < $critical_min )) {
if ( $previous_status == 0 ) {
$critical_count ++ ;
}
$previous_status = 1 ;
}
else {
$previous_status = 0 ;
}
$previous_utimestamp = $data [ 'utimestamp' ];
}
if ( $critical_count == 0 ) {
return 0 ;
}
return ( $period - $critical_period ) / $critical_count ;
}
/**
* Get the TTO value of an agent module in a period of time .
*
* @ param int Agent module id
* @ param int Period of time to check ( in seconds )
* @ param int Top date to check the values . Default current time .
*
* @ return float The TTO value in the interval .
*/
function reporting_get_agentmodule_tto ( $id_agent_module , $period = 0 , $date = 0 ) {
// Initialize variables
if ( empty ( $date )) $date = get_system_time ();
// Read module configuration
$datelimit = $date - $period ;
$search_in_history_db = db_search_in_history_db ( $datelimit );
$module = db_get_row_sql ( ' SELECT max_critical , min_critical , id_tipo_modulo
FROM tagente_modulo
WHERE id_agente_modulo = ' . ( int ) $id_agent_module );
if ( $module === false ) {
return false ;
}
$critical_min = $module [ 'min_critical' ];
$critical_max = $module [ 'max_critical' ];
$module_type = $module [ 'id_tipo_modulo' ];
// Set critical_min and critical for proc modules
$module_type_str = modules_get_type_name ( $module_type );
if ( strstr ( $module_type_str , 'proc' ) !== false &&
( $critical_min == 0 && $critical_max == 0 )) {
$critical_min = 1 ;
}
// Get module data
$interval_data = db_get_all_rows_sql ( ' SELECT * FROM tagente_datos
WHERE id_agente_modulo = ' . ( int ) $id_agent_module .
' AND utimestamp > ' . ( int ) $datelimit .
' AND utimestamp < ' . ( int ) $date .
' ORDER BY utimestamp ASC' , $search_in_history_db );
if ( $interval_data === false ) $interval_data = array ();
// Get previous data
$previous_data = modules_get_previous_data ( $id_agent_module , $datelimit );
if ( $previous_data !== false ) {
$previous_data [ 'utimestamp' ] = $datelimit ;
array_unshift ( $interval_data , $previous_data );
}
// Get next data
$next_data = modules_get_next_data ( $id_agent_module , $date );
if ( $next_data !== false ) {
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
else if ( count ( $interval_data ) > 0 ) {
// Propagate the last known data to the end of the interval
$next_data = array_pop ( $interval_data );
array_push ( $interval_data , $next_data );
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
if ( count ( $interval_data ) < 2 ) {
return false ;
}
// Set initial conditions
$critical_period = 0 ;
$first_data = array_shift ( $interval_data );
$previous_utimestamp = $first_data [ 'utimestamp' ];
if ((( $critical_max > $critical_min AND ( $first_data [ 'datos' ] > $critical_max OR $first_data [ 'datos' ] < $critical_min ))) OR
( $critical_max <= $critical_min AND $first_data [ 'datos' ] < $critical_min )) {
$previous_status = 1 ;
}
else {
$previous_status = 0 ;
}
foreach ( $interval_data as $data ) {
// Previous status was critical
if ( $previous_status == 1 ) {
$critical_period += $data [ 'utimestamp' ] - $previous_utimestamp ;
}
// Re-calculate previous status for the next data
if ((( $critical_max > $critical_min AND ( $data [ 'datos' ] > $critical_max OR $data [ 'datos' ] < $critical_min ))) OR
( $critical_max <= $critical_min AND $data [ 'datos' ] < $critical_min )) {
$previous_status = 1 ;
}
else {
$previous_status = 0 ;
}
$previous_utimestamp = $data [ 'utimestamp' ];
}
return $period - $critical_period ;
}
/**
* Get the TTR value of an agent module in a period of time .
*
* @ param int Agent module id
* @ param int Period of time to check ( in seconds )
* @ param int Top date to check the values . Default current time .
*
* @ return float The TTR value in the interval .
*/
function reporting_get_agentmodule_ttr ( $id_agent_module , $period = 0 , $date = 0 ) {
// Initialize variables
if ( empty ( $date )) $date = get_system_time ();
// Read module configuration
$datelimit = $date - $period ;
$search_in_history_db = db_search_in_history_db ( $datelimit );
$module = db_get_row_sql ( ' SELECT max_critical , min_critical , id_tipo_modulo
FROM tagente_modulo
WHERE id_agente_modulo = ' . ( int ) $id_agent_module );
if ( $module === false ) {
return false ;
}
$critical_min = $module [ 'min_critical' ];
$critical_max = $module [ 'max_critical' ];
$module_type = $module [ 'id_tipo_modulo' ];
// Set critical_min and critical for proc modules
$module_type_str = modules_get_type_name ( $module_type );
if ( strstr ( $module_type_str , 'proc' ) !== false &&
( $critical_min == 0 && $critical_max == 0 )) {
$critical_min = 1 ;
}
// Get module data
$interval_data = db_get_all_rows_sql ( ' SELECT * FROM tagente_datos
WHERE id_agente_modulo = ' . ( int ) $id_agent_module .
' AND utimestamp > ' . ( int ) $datelimit .
' AND utimestamp < ' . ( int ) $date .
' ORDER BY utimestamp ASC' , $search_in_history_db );
if ( $interval_data === false ) $interval_data = array ();
// Get previous data
$previous_data = modules_get_previous_data ( $id_agent_module , $datelimit );
if ( $previous_data !== false ) {
$previous_data [ 'utimestamp' ] = $datelimit ;
array_unshift ( $interval_data , $previous_data );
}
// Get next data
$next_data = modules_get_next_data ( $id_agent_module , $date );
if ( $next_data !== false ) {
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
else if ( count ( $interval_data ) > 0 ) {
// Propagate the last known data to the end of the interval
$next_data = array_pop ( $interval_data );
array_push ( $interval_data , $next_data );
$next_data [ 'utimestamp' ] = $date ;
array_push ( $interval_data , $next_data );
}
if ( count ( $interval_data ) < 2 ) {
return false ;
}
// Set initial conditions
$critical_period = 0 ;
$first_data = array_shift ( $interval_data );
$previous_utimestamp = $first_data [ 'utimestamp' ];
if ((( $critical_max > $critical_min AND ( $first_data [ 'datos' ] > $critical_max OR $first_data [ 'datos' ] < $critical_min ))) OR
( $critical_max <= $critical_min AND $first_data [ 'datos' ] < $critical_min )) {
$previous_status = 1 ;
}
else {
$previous_status = 0 ;
}
foreach ( $interval_data as $data ) {
// Previous status was critical
if ( $previous_status == 1 ) {
$critical_period += $data [ 'utimestamp' ] - $previous_utimestamp ;
}
// Re-calculate previous status for the next data
if ((( $critical_max > $critical_min AND ( $data [ 'datos' ] > $critical_max OR $data [ 'datos' ] < $critical_min ))) OR
( $critical_max <= $critical_min AND $data [ 'datos' ] < $critical_min )) {
$previous_status = 1 ;
}
else {
$previous_status = 0 ;
}
$previous_utimestamp = $data [ 'utimestamp' ];
}
return $critical_period ;
}
2015-03-27 10:24:44 +01:00
?>