2008-08-22 20:07:32 +02:00
< ? php
2020-10-05 17:03:30 +02:00
/**
* Combined graph
*
* @ category Combined graph
* @ package Pandora FMS
* @ subpackage Community
* @ version 1.0 . 0
* @ license See below
*
* ______ ___ _______ _______ ________
2023-06-08 12:42:10 +02:00
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
2020-10-05 17:03:30 +02:00
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
2023-06-08 11:53:13 +02:00
* Copyright ( c ) 2005 - 2023 Pandora FMS
2023-06-08 13:19:01 +02:00
* Please see https :// pandorafms . com / community / for full contribution list
2020-10-05 17:03:30 +02:00
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* ============================================================================
*/
2008-08-22 20:07:32 +02:00
2021-04-30 13:24:55 +02:00
// Begin.
2010-03-03 18:10:37 +01:00
global $config ;
2019-01-30 16:18:44 +01:00
if ( is_ajax ()) {
$search_agents = ( bool ) get_parameter ( 'search_agents' );
if ( $search_agents ) {
include_once 'include/functions_agents.php' ;
$id_agent = ( int ) get_parameter ( 'id_agent' );
$string = ( string ) get_parameter ( 'q' );
2020-10-05 17:03:30 +02:00
// Q is what autocomplete plugin gives.
2019-01-30 16:18:44 +01:00
$id_group = ( int ) get_parameter ( 'id_group' );
$filter = [];
2022-02-01 15:18:45 +01:00
$filter [] = '(nombre LIKE "%' . $string . '%" OR direccion LIKE "%' . $string . '%" OR comentarios LIKE "%' . $string . '%")' ;
2019-01-30 16:18:44 +01:00
$filter [ 'id_grupo' ] = $id_group ;
$agents = agents_get_agents ( $filter , [ 'nombre' , 'direccion' ]);
if ( $agents === false ) {
return ;
}
foreach ( $agents as $agent ) {
echo $agent [ 'nombre' ] . '|' . $agent [ 'direccion' ] . " \n " ;
}
return ;
}
return ;
2009-08-14 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/agent_manager.php, godmode/agentes/massive_config.php,
godmode/alerts/alert_list.php, godmode/reporting/graph_builder.php,
godmode/reporting/map_builder.php, include/functions_db.php,
include/functions_html.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php: very changes for add input text
autocomplete with ajax jquery for agent input in several forms. Add to form
this exportdata, graph_builder, map_builder.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1849 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-08-14 18:38:57 +02:00
}
2019-01-30 16:18:44 +01:00
check_login ();
2008-08-11 Esteban Sanchez <estebans@artica.es>
* include/functions_db.php: Added __ as an alias of lang_string().
* include/functions_reporting_pdf.php,
include/functions_reporting.php, include/functions.php,
include/functions_visual_map.php, index.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/incidents/incident_note.php,
operation/incidents/incident_search.php,
operation/incidents/incident_statistics.php,
operation/snmpconsole/snmp_alert.php,
operation/snmpconsole/snmp_view.php, operation/users/user.php,
operation/users/user_edit.php, operation/users/user_statistics.php,
operation/events/event_statistics.php, operation/events/events.php,
operation/visual_console/render_view.php,
operation/visual_console/index.php, operation/extensions.php,
operation/agentes/estado_alertas.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_grupo.php, operation/agentes/export_csv.php,
operation/agentes/datos_agente.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/bulbs.php,
operation/agentes/status_events.php, operation/agentes/sla_view.php,
operation/agentes/exportdata.php,
operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php, operation/agentes/estadisticas.php,
operation/agentes/tactical.php, operation/agentes/networkmap.php,
operation/messages/message.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php,
operation/reporting/custom_reporting.php,
operation/servers/view_server.php,
operation/servers/view_server_detail.php, operation/menu.php,
reporting/fgraph.php, reporting/stat_win.php, ajax.php,
general/logoff.php, general/pandora_help.php, general/footer.php,
general/noaccess.php, general/logon_failed.php,
general/links_menu.php, general/login_page.php, general/logon_ok.php,
general/header.php, general/main_menu.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/setup/news.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/users/user_list.php,
godmode/users/configure_user.php, godmode/profiles/profile_list.php,
godmode/admin_access_logs.php, godmode/db/db_info_data.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_network.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/alert_manager.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/alert_manager_editor.php,
godmode/agentes/manage_config.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/agent_disk_conf_editor.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php,
godmode/agentes/agent_manager.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_templates_form.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/map_builder.php,
godmode/reporting/graph_builder.php, godmode/servers/plugin.php,
godmode/servers/manage_recontask.php,
godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/modify_alert.php, godmode/alerts/configure_alert.php,
godmode/menu.php: Replaced $id_user with $config['id_user']. Use __a
instead of $lang_label to future use of gettext. Style
corrections.
* godmode/agentes/planned_downtime.php: Rewritten to use Pandora
functions and adopt the UI style. Replaced lang_string with __().
* pandoradb.sql: Fields in tplanned_downtime renamed to fit
guidelines.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1005 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-08-11 12:59:07 +02:00
2020-10-05 17:03:30 +02:00
if ( ! check_acl ( $config [ 'id_user' ], 0 , 'RW' )
&& ! check_acl ( $config [ 'id_user' ], 0 , 'RM' )
) {
2019-01-30 16:18:44 +01:00
db_pandora_audit (
2022-01-20 10:55:23 +01:00
AUDIT_LOG_ACL_VIOLATION ,
2019-01-30 16:18:44 +01:00
'Trying to access graph builder'
);
include 'general/noaccess.php' ;
exit ;
2008-08-11 Esteban Sanchez <estebans@artica.es>
* include/functions_db.php: Added __ as an alias of lang_string().
* include/functions_reporting_pdf.php,
include/functions_reporting.php, include/functions.php,
include/functions_visual_map.php, index.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/incidents/incident_note.php,
operation/incidents/incident_search.php,
operation/incidents/incident_statistics.php,
operation/snmpconsole/snmp_alert.php,
operation/snmpconsole/snmp_view.php, operation/users/user.php,
operation/users/user_edit.php, operation/users/user_statistics.php,
operation/events/event_statistics.php, operation/events/events.php,
operation/visual_console/render_view.php,
operation/visual_console/index.php, operation/extensions.php,
operation/agentes/estado_alertas.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_grupo.php, operation/agentes/export_csv.php,
operation/agentes/datos_agente.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/bulbs.php,
operation/agentes/status_events.php, operation/agentes/sla_view.php,
operation/agentes/exportdata.php,
operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php, operation/agentes/estadisticas.php,
operation/agentes/tactical.php, operation/agentes/networkmap.php,
operation/messages/message.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php,
operation/reporting/custom_reporting.php,
operation/servers/view_server.php,
operation/servers/view_server_detail.php, operation/menu.php,
reporting/fgraph.php, reporting/stat_win.php, ajax.php,
general/logoff.php, general/pandora_help.php, general/footer.php,
general/noaccess.php, general/logon_failed.php,
general/links_menu.php, general/login_page.php, general/logon_ok.php,
general/header.php, general/main_menu.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/setup/news.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/users/user_list.php,
godmode/users/configure_user.php, godmode/profiles/profile_list.php,
godmode/admin_access_logs.php, godmode/db/db_info_data.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_network.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/alert_manager.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/alert_manager_editor.php,
godmode/agentes/manage_config.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/agent_disk_conf_editor.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php,
godmode/agentes/agent_manager.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_templates_form.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/map_builder.php,
godmode/reporting/graph_builder.php, godmode/servers/plugin.php,
godmode/servers/manage_recontask.php,
godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/modify_alert.php, godmode/alerts/configure_alert.php,
godmode/menu.php: Replaced $id_user with $config['id_user']. Use __a
instead of $lang_label to future use of gettext. Style
corrections.
* godmode/agentes/planned_downtime.php: Rewritten to use Pandora
functions and adopt the UI style. Replaced lang_string with __().
* pandoradb.sql: Fields in tplanned_downtime renamed to fit
guidelines.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1005 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-08-11 12:59:07 +02:00
}
2013-01-07 10:59:56 +01:00
unset ( $name );
2019-01-30 16:18:44 +01:00
$add_module = ( bool ) get_parameter ( 'add_module' , false );
$delete_module = ( bool ) get_parameter ( 'delete_module' , false );
2010-06-21 17:59:37 +02:00
$edit_graph = ( bool ) get_parameter ( 'edit_graph' , false );
$active_tab = get_parameter ( 'tab' , 'main' );
$add_graph = ( bool ) get_parameter ( 'add_graph' , false );
$update_graph = ( bool ) get_parameter ( 'update_graph' , false );
$change_weight = ( bool ) get_parameter ( 'change_weight' , false );
2015-11-04 17:42:45 +01:00
$change_label = ( bool ) get_parameter ( 'change_label' , false );
2010-06-21 17:59:37 +02:00
$id_graph = ( int ) get_parameter ( 'id' , 0 );
2020-10-22 12:00:44 +02:00
if ( $id_graph > 0 ) {
$graph_group = db_get_value ( 'id_group' , 'tgraph' , 'id_graph' , $id_graph );
if ( ! check_acl_restricted_all ( $config [ 'id_user' ], $graph_group , 'RW' )
&& ! check_acl_restricted_all ( $config [ 'id_user' ], $graph_group , 'RM' )
) {
db_pandora_audit (
2022-01-20 10:55:23 +01:00
AUDIT_LOG_ACL_VIOLATION ,
2020-10-22 12:00:44 +02:00
'Trying to access graph builder'
);
include 'general/noaccess.php' ;
exit ;
}
}
2019-01-30 16:18:44 +01:00
if ( $id_graph !== 0 ) {
$sql = " SELECT * FROM tgraph
WHERE ( private = 0 OR ( private = 1 AND id_user = '".$config[' id_user ']."' ))
2017-04-11 15:30:32 +02:00
AND id_graph = " . $id_graph ;
2019-01-30 16:18:44 +01:00
$control = db_process_sql ( $sql );
if ( ! $control ) {
header ( 'Location: index.php?sec=reporting&sec2=godmode/reporting/graphs' );
}
2017-04-11 15:30:32 +02:00
}
2021-06-03 15:37:11 +02:00
if ( $add_graph === true ) {
2019-01-30 16:18:44 +01:00
$name = get_parameter_post ( 'name' );
$description = get_parameter_post ( 'description' );
$module_number = get_parameter_post ( 'module_number' );
$idGroup = get_parameter_post ( 'graph_id_group' );
$stacked = get_parameter ( 'stacked' , 0 );
$period = get_parameter_post ( 'period' );
$threshold = get_parameter ( 'threshold' );
$percentil = get_parameter ( 'percentil' , 0 );
$summatory_series = get_parameter ( 'summatory_series' , 0 );
$average_series = get_parameter ( 'average_series' , 0 );
$modules_series = get_parameter ( 'modules_series' , 0 );
$fullscale = get_parameter ( 'fullscale' , 0 );
if ( $threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD ) {
$stacked = $threshold ;
}
2020-10-05 17:03:30 +02:00
// Create graph.
2019-01-30 16:18:44 +01:00
$values = [
'id_user' => $config [ 'id_user' ],
'name' => $name ,
'description' => $description ,
'period' => $period ,
'private' => 0 ,
'id_group' => $idGroup ,
'stacked' => $stacked ,
'percentil' => $percentil ,
'summatory_series' => $summatory_series ,
'average_series' => $average_series ,
'modules_series' => $modules_series ,
'fullscale' => $fullscale ,
];
if ( trim ( $name ) != '' ) {
$id_graph = db_process_sql_insert ( 'tgraph' , $values );
2022-02-01 13:39:18 +01:00
$auditMessage = ( $id_graph !== false ) ? sprintf ( 'Create graph #%s' , $id_graph ) : 'Fail try to create graph' ;
db_pandora_audit (
AUDIT_LOG_REPORT_MANAGEMENT ,
$auditMessage
);
2019-01-30 16:18:44 +01:00
} else {
$id_graph = false ;
}
if ( ! $id_graph ) {
$edit_graph = false ;
}
2010-06-21 17:59:37 +02:00
}
2008-06-17 Esteban Sanchez <estebans@artica.es>
* ajax.php: Added to repository. AJAX interface for Pandora. A new
time is coming...
* pandoradb.sql: Added id_group to treport. A report is now assigned
to a group of agents. Changes in treport_content to add an order
field, drop sla fields and use an enum for the type. NOTE: This will
break all your current defined reports, update under your
responsabillity. Added table treport_content_sla_combined to define
SLAs in the SLA types reports.
* godmode/reporting/graph_builder.php: Use Pandora functions. Adde
javascript code to display the module icon when changing from the
dropdown menu.
* godmode/reporting/reporting_builder.php: Almost complet rewritten to
use Pandora HTML functions. Style correction.
* include/functions.php: Added new report types. Style correction.
* include/functions_db.php: Use Pandora database functions to get
simple values. Added functions get_agents_in_group(),
get_modules_in_agent(), get_simple_alerts_in_agent(),
get_combined_alerts_in_agent(), get_alerts_in_agent(),
get_monitor_downs_in_period(),
get_monitor_last_down_timestamp_in_period(),
get_alert_fires_in_period(),
get_alert_last_fire_timestamp_in_period(). Deleted debug output and
fixed calling to an inexistent function in
return_moduledata_sum_value().
* include/functions_html.php: Tab style correction. Thanks to Ramon
for the advice. Fixed some errors on print_table that was causing not
to work fine if rowclass or colspan was defined.
* include/functions_reporting.php: Adde date support to
return_module_SLA(), event_reporting(). Added alert_reporting(),
monitor_health_reporting(), general_group_reporting() and
agents_detailed_reporting() to implement new report types. Style
correction.
* include/javascript/pandora.js: Added html_entity_decode() function
to decode some AJAX results.
* javascript/jquery.js: Added to repository. jQuery version 1.2.4a
* include/javascript/jquery.timeentry.js: jQuery plugin to manage time
inputs.
* include/javascript/jquery.ui.datepicker.js: jQuery plugin to manage
date inputs in a dropdown calendar.
* include/languages/date_*.js, include/languages/time_*.js: Added to
repository. Translation of date and time strings for the new calendar
javascript support.
* include/languages/language_en.php: Added new strings relatives to
reports.
* include/languages/language_de.php,
include/languages/language_fr.php, include/languages/language_gl.php,
include/languages/language_pt_br.php: Fixed a variable name.
* godmode/groups/group_list.php: Avoid the use of an extra indentation
by returning if no success on comprueba_login().
* include/styles/pandora.css: Add some classes. Tab style correction.
* operation/agentes/ver_agente.php: Added AJAX support to agent
operations.
* operation/reporting/graph_viewer.php: Period dropdown selection
improved and printed with Pandora functions.
* operation/reporting/reporting_viewer.php: Massive rewritten.
Implemented date and time support, added new report types, use Pandora
functions...
* reporting/fgraph.php: Documentation fix. Added a new graphic to show
monitors health.
* godmode/agentes/agent_manager.php,
operation/reporting/custom_reporting.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@869 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-17 16:30:44 +02:00
2010-06-21 17:59:37 +02:00
if ( $update_graph ) {
2019-01-30 16:18:44 +01:00
$id_graph = get_parameter ( 'id' );
$name = get_parameter ( 'name' );
$id_group = get_parameter ( 'graph_id_group' );
$description = get_parameter ( 'description' );
$period = get_parameter ( 'period' );
$stacked = get_parameter ( 'stacked' );
$percentil = get_parameter ( 'percentil' );
$summatory_series = get_parameter ( 'summatory_series' );
$average_series = get_parameter ( 'average_series' );
$modules_series = get_parameter ( 'modules_series' );
$alerts = get_parameter ( 'alerts' );
$threshold = get_parameter ( 'threshold' );
$fullscale = get_parameter ( 'fullscale' );
if ( $threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD ) {
$stacked = $threshold ;
}
2021-06-03 15:37:11 +02:00
if ( empty ( trim ( $name )) === false ) {
2019-01-30 16:18:44 +01:00
$success = db_process_sql_update (
'tgraph' ,
[
'name' => $name ,
'id_group' => $id_group ,
'description' => $description ,
'width' => $width ,
'height' => $height ,
'period' => $period ,
'stacked' => $stacked ,
'percentil' => $percentil ,
'summatory_series' => $summatory_series ,
'average_series' => $average_series ,
'modules_series' => $modules_series ,
'fullscale' => $fullscale ,
],
[ 'id_graph' => $id_graph ]
);
2022-02-01 13:39:18 +01:00
$auditMessage = ( $success !== false ) ? 'Update graph' : 'Fail try to update graph' ;
db_pandora_audit (
AUDIT_LOG_REPORT_MANAGEMENT ,
sprintf (
'%s #%s' ,
$auditMessage ,
$id_graph
)
);
2019-01-30 16:18:44 +01:00
} else {
$success = false ;
}
2007-03-28 18:07:29 +02:00
}
2019-01-30 16:18:44 +01:00
2010-06-21 17:59:37 +02:00
function add_quotes ( $item )
{
2019-01-30 16:18:44 +01:00
return " ' $item ' " ;
2007-03-28 18:07:29 +02:00
}
2019-01-30 16:18:44 +01:00
2021-06-03 15:37:11 +02:00
if ( $add_module === true ) {
2019-01-30 16:18:44 +01:00
$id_graph = get_parameter ( 'id' );
2022-01-26 11:52:49 +01:00
$id_modules = explode ( ',' , get_parameter ( 'id_modules' ));
2022-01-21 12:56:14 +01:00
$id_agents = explode ( ',' , get_parameter ( 'id_agents' ));
2019-01-30 16:18:44 +01:00
$weight = get_parameter ( 'weight' );
2020-10-05 17:03:30 +02:00
// Id modules has double entities conversion.
// Safe output remove all entities.
2019-01-30 16:18:44 +01:00
io_safe_output_array ( $id_modules , '' );
2022-12-05 09:44:35 +01:00
$id_modules = array_map (
function ( $mod ) {
2022-11-18 14:21:31 +01:00
return io_safe_input ( $mod );
},
$id_modules
);
2022-01-21 12:56:14 +01:00
2022-01-26 11:52:49 +01:00
$id_agent_modules = db_get_all_rows_sql (
2023-12-15 10:41:21 +01:00
'SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN (' . implode ( ',' , $id_agents ) . " ) AND id_agente_modulo IN (' " . implode ( " ',' " , $id_modules ) . " ') "
2022-01-26 11:52:49 +01:00
);
2019-01-30 16:18:44 +01:00
if ( count ( $id_agent_modules ) > 0 && $id_agent_modules != '' ) {
$order = db_get_row_sql ( " SELECT `field_order` from tgraph_source WHERE id_graph= $id_graph ORDER BY `field_order` DESC " );
$order = $order [ 'field_order' ];
foreach ( $id_agent_modules as $id_agent_module ) {
$order ++ ;
2022-01-26 11:52:49 +01:00
$result = db_process_sql_insert ( 'tgraph_source' , [ 'id_graph' => $id_graph , 'id_agent_module' => $id_agent_module [ 'id_agente_modulo' ], 'weight' => $weight , 'field_order' => $order ]);
2019-01-30 16:18:44 +01:00
}
} else {
$result = false ;
}
2010-06-21 17:59:37 +02:00
}
2021-06-03 15:37:11 +02:00
if ( $delete_module === true ) {
2019-01-30 16:18:44 +01:00
$id_graph = get_parameter ( 'id' );
2018-09-19 10:06:57 +02:00
2019-01-30 16:18:44 +01:00
$deleteGraph = get_parameter ( 'delete' );
$order_val = db_get_value ( 'field_order' , 'tgraph_source' , 'id_gs' , $deleteGraph );
$result = db_process_sql_delete ( 'tgraph_source' , [ 'id_gs' => $deleteGraph ]);
db_process_sql ( 'UPDATE tgraph_source SET field_order=field_order-1 WHERE id_graph=' . $id_graph . ' AND field_order>' . $order_val );
2010-06-21 17:59:37 +02:00
}
2021-06-03 15:37:11 +02:00
if ( $change_weight === true ) {
2019-01-30 16:18:44 +01:00
$weight = get_parameter ( 'weight' );
$id_gs = get_parameter ( 'graph' );
db_process_sql_update (
'tgraph_source' ,
[ 'weight' => $weight ],
[ 'id_gs' => $id_gs ]
);
2010-06-21 17:59:37 +02:00
}
2019-01-30 16:18:44 +01:00
2015-11-04 17:42:45 +01:00
if ( $change_label ) {
2019-01-30 16:18:44 +01:00
$label = get_parameter ( 'label' );
$id_gs = get_parameter ( 'graph' );
db_process_sql_update (
'tgraph_source' ,
[ 'label' => $label ],
[ 'id_gs' => $id_gs ]
);
2015-11-04 17:42:45 +01:00
}
2010-06-21 17:59:37 +02:00
2021-06-03 15:37:11 +02:00
if ( $edit_graph === true ) {
2019-01-30 16:18:44 +01:00
$buttons = [
'graph_list' => [
'active' => false ,
2021-03-11 15:40:23 +01:00
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/graphs">' . html_print_image (
2023-03-03 14:50:47 +01:00
'images/logs@svg.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'Graph list' ),
2023-03-03 14:50:47 +01:00
'class' => 'main_menu_icon invert_filter' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ,
2019-01-30 16:18:44 +01:00
],
'main' => [
'active' => false ,
2021-03-11 15:40:23 +01:00
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/graph_builder&tab=main&edit_graph=1&id=' . $id_graph . '">' . html_print_image (
2023-03-03 14:50:47 +01:00
'images/graph@svg.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'Main data' ),
2023-03-03 14:50:47 +01:00
'class' => 'main_menu_icon invert_filter' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ,
2019-01-30 16:18:44 +01:00
],
'graph_editor' => [
'active' => false ,
2021-03-11 15:40:23 +01:00
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/graph_builder&tab=graph_editor&edit_graph=1&id=' . $id_graph . '">' . html_print_image (
2023-04-19 10:53:52 +02:00
'images/builder@svg.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'Graph editor' ),
2023-03-03 14:50:47 +01:00
'class' => 'main_menu_icon invert_filter' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ,
2019-01-30 16:18:44 +01:00
],
'view' => [
'active' => false ,
2021-03-11 15:40:23 +01:00
'text' => '<a href="index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=' . $id_graph . '">' . html_print_image (
2023-03-03 14:50:47 +01:00
'images/enable.svg' ,
2021-03-11 15:40:23 +01:00
true ,
[
'title' => __ ( 'View graph' ),
2023-03-03 14:50:47 +01:00
'class' => 'main_menu_icon invert_filter' ,
2021-03-11 15:40:23 +01:00
]
) . '</a>' ,
2019-01-30 16:18:44 +01:00
],
];
$buttons [ $active_tab ][ 'active' ] = true ;
$graphInTgraph = db_get_row_sql ( 'SELECT name FROM tgraph WHERE id_graph = ' . $id_graph );
$name = $graphInTgraph [ 'name' ];
} else {
2021-06-03 15:37:11 +02:00
$buttons = [];
2010-06-21 17:59:37 +02:00
}
$head = __ ( 'Graph builder' );
2021-04-30 13:24:55 +02:00
if ( isset ( $name ) === true ) {
$head .= ' » ' . $name ;
2019-01-30 16:18:44 +01:00
}
2010-06-21 17:59:37 +02:00
2019-04-24 13:53:18 +02:00
// Header.
2021-04-30 13:24:55 +02:00
$tab = get_parameter ( 'tab' );
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* install.php, operation/reporting/reporting_xml.php,
operation/netflow/nf_live_view.php, operation/netflow/nf_view.php,
operation/tree.php, operation/agentes/gis_view.php,
operation/agentes/estado_monitores.php,
operation/agentes/networkmap.php,
operation/agentes/datos_agente.php,
operation/agentes/alerts_status.php, operation/menu.php,
operation/snmpconsole/snmp_view.php, operation/users/user_edit.php,
godmode/groups/configure_group.php,
godmode/groups/configure_modu_group.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/servers/manage_recontask.php,
godmode/alerts/alert_compounds.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_special_days.php, godmode/setup/links.php,
godmode/setup/os.php, godmode/users/configure_profile.php,
godmode/events/events.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_edit_modules.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_add_action_alerts.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_operations.php,
godmode/massive/massive_delete_profiles.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/graph_builder.php,
godmode/reporting/reporting_builder.item_editor.php,
include/functions_menu.php, include/functions_visual_map.php,
include/functions_db.php: cleaned source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6759 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-10 12:38:02 +02:00
switch ( $tab ) {
2021-04-30 13:24:55 +02:00
case 'graph_editor' :
$headerHelp = '' ;
2019-01-30 16:18:44 +01:00
break ;
2021-04-30 13:24:55 +02:00
case 'main' :
default :
$headerHelp = 'graph_builder' ;
2019-01-30 16:18:44 +01:00
break ;
2011-09-15 20:52:54 +02:00
}
2021-04-30 13:24:55 +02:00
// Header.
ui_print_standard_header (
$head ,
'images/chart.png' ,
false ,
$headerHelp ,
false ,
2021-06-03 15:37:11 +02:00
$buttons ,
2021-04-30 13:24:55 +02:00
[
[
'link' => '' ,
'label' => __ ( 'Reporting' ),
],
[
'link' => '' ,
'label' => __ ( 'Custom graphs' ),
],
]
);
2019-01-30 16:18:44 +01:00
if ( $add_graph ) {
2020-10-05 17:03:30 +02:00
ui_print_result_message (
$id_graph ,
__ ( 'Graph stored successfully' ),
__ ( 'There was a problem storing Graph' )
);
2019-01-30 16:18:44 +01:00
}
2010-06-22 18:16:28 +02:00
2019-01-30 16:18:44 +01:00
if ( $add_module ) {
2020-10-05 17:03:30 +02:00
ui_print_result_message (
$result ,
__ ( 'Module added successfully' ),
__ ( 'There was a problem adding Module' )
);
2019-01-30 16:18:44 +01:00
}
2010-06-21 17:59:37 +02:00
2019-01-30 16:18:44 +01:00
if ( $update_graph ) {
2020-10-05 17:03:30 +02:00
ui_print_result_message (
$success ,
__ ( 'Update the graph' ),
__ ( 'Bad update the graph' )
);
2019-01-30 16:18:44 +01:00
}
2010-06-21 17:59:37 +02:00
if ( $delete_module ) {
2020-10-05 17:03:30 +02:00
ui_print_result_message (
$result ,
__ ( 'Graph deleted successfully' ),
__ ( 'There was a problem deleting Graph' )
);
2007-03-28 18:07:29 +02:00
}
2008-07-07 15:16:13 +02:00
2020-10-05 17:03:30 +02:00
// Parse CHUNK information into showable information.
// Split id to get all parameters.
2021-06-03 15:37:11 +02:00
if ( $delete_module === false ) {
if ( isset ( $_POST [ 'period' ]) === true ) {
2019-01-30 16:18:44 +01:00
$period = $_POST [ 'period' ];
}
2021-06-03 15:37:11 +02:00
if (( isset ( $chunkdata ) === true ) && ( empty ( $chunkdata ) === false )) {
2019-01-30 16:18:44 +01:00
$module_array = [];
$weight_array = [];
$agent_array = [];
$chunk1 = [];
$chunk1 = explode ( '|' , $chunkdata );
$modules = '' ;
$weights = '' ;
2021-04-30 13:24:55 +02:00
$chunkCount = count ( $chunk1 );
for ( $a = 0 ; $a < $chunkCount ; $a ++ ) {
2019-01-30 16:18:44 +01:00
$chunk2 [ $a ] = [];
$chunk2 [ $a ] = explode ( ',' , $chunk1 [ $a ]);
if ( strpos ( $modules , $chunk2 [ $a ][ 1 ]) == 0 ) {
// Skip dupes
$module_array [] = $chunk2 [ $a ][ 1 ];
$agent_array [] = $chunk2 [ $a ][ 0 ];
$weight_array [] = $chunk2 [ $a ][ 2 ];
if ( $modules != '' ) {
$modules = $modules . ',' . $chunk2 [ $a ][ 1 ];
} else {
$modules = $chunk2 [ $a ][ 1 ];
}
if ( $weights != '' ) {
$weights = $weights . ',' . $chunk2 [ $a ][ 2 ];
} else {
$weights = $chunk2 [ $a ][ 2 ];
}
}
}
}
2007-03-28 18:07:29 +02:00
}
2010-06-21 17:59:37 +02:00
switch ( $active_tab ) {
2019-01-30 16:18:44 +01:00
case 'main' :
include_once 'godmode/reporting/graph_builder.main.php' ;
break ;
case 'graph_editor' :
include_once 'godmode/reporting/graph_builder.graph_editor.php' ;
break ;
2021-04-30 13:24:55 +02:00
default :
// Nothing to do.
break ;
2007-04-19 20:50:07 +02:00
}