2006-03-27 05:37:27 +02:00
< ? php
2021-01-14 19:08:01 +01:00
/**
* Alerts Status
*
* @ category Alerts
* @ package Pandora FMS
* @ subpackage Alert Status View
* @ version 1.0 . 0
* @ license See below
*
* ______ ___ _______ _______ ________
2023-06-08 12:42:10 +02:00
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
2021-01-14 19:08:01 +01:00
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
2023-06-08 11:53:13 +02:00
* Copyright ( c ) 2005 - 2023 Pandora FMS
2023-06-08 13:19:01 +02:00
* Please see https :// pandorafms . com / community / for full contribution list
2021-01-14 19:08:01 +01:00
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* ============================================================================
*/
2008-08-22 20:07:32 +02:00
2010-04-05 17:54:17 +02:00
global $config ;
2006-03-27 05:37:27 +02:00
2022-10-03 10:16:00 +02:00
// Login check.
2019-01-30 16:18:44 +01:00
check_login ();
2007-04-19 20:50:07 +02:00
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
if ( is_ajax ()) {
2019-01-30 16:18:44 +01:00
include_once 'include/functions_reporting.php' ;
$get_alert_fired = get_parameter ( 'get_alert_fired' , 0 );
if ( $get_alert_fired ) {
2022-10-03 10:16:00 +02:00
// Calculate alerts fired.
2019-01-30 16:18:44 +01:00
$data_reporting = reporting_get_group_stats ();
echo $data_reporting [ 'monitor_alerts_fired' ];
}
return ;
2012-02-01 11:57:43 +01:00
}
2019-01-30 16:18:44 +01:00
require_once $config [ 'homedir' ] . '/include/functions_agents.php' ;
require_once $config [ 'homedir' ] . '/operation/agentes/alerts_status.functions.php' ;
require_once $config [ 'homedir' ] . '/include/functions_users.php' ;
2010-04-05 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_ui.php: changed some parts of source code in the
functions "format_alert_row" for show column modules in general view. In the
function "pagination" added the parameter $offset_name with default value
'offset' for to use several paginations in one page.
* include/functions_agents.php: added the parameters $limit, $idGroup,
$count in the function "get_agent_alerts_simple", and now you can limit the
rows, search by id group and return the count of rows (without limit). And
in the function "get_agent_alerts_compound" added the same parameters to
another function $idGroup, $limit, $count for similar uses.
* operation/agentes/alerts_status.php: cleaned more parts of source code,
fixed the mad array_merge of alerts, fixed SQL with the searchs IN
(large large list ids), fixed the pagination before loop all rows, now
only loop the block page rows.
* operation/agentes/alerts_status.functions.php: new file with the functions
"forceExecution", "validateAlert", and "printFormFilterAlert".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2542 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-04-06 14:46:34 +02:00
2019-01-30 16:18:44 +01:00
$isFunctionPolicies = enterprise_include_once ( 'include/functions_policies.php' );
2009-01-15 11:21:38 +01:00
2015-01-15 18:08:58 +01:00
$strict_user = db_get_value ( 'strict_acl' , 'tusuario' , 'id_user' , $config [ 'id_user' ]);
2023-01-31 11:51:00 +01:00
$disabled = get_parameter ( 'disabled' , 'all_enabled' );
2022-07-15 12:15:37 +02:00
$filter_standby = get_parameter ( 'standby' , 'all' );
2019-01-30 16:18:44 +01:00
$id_group = ( int ) get_parameter ( 'ag_group' , 0 );
// 0 is the All group (selects all groups)
$free_search = get_parameter ( 'free_search' , '' );
2023-09-19 13:50:06 +02:00
$search_sg = get_parameter ( 'search_sg' , 0 );
2019-01-30 16:18:44 +01:00
$user_tag_array = tags_get_user_tags ( $config [ 'id_user' ], 'AR' , true );
2017-12-11 16:07:39 +01:00
2018-02-26 13:42:28 +01:00
if ( $user_tag_array ) {
2019-01-30 16:18:44 +01:00
$user_tag_array = array_values ( array_keys ( $user_tag_array ));
$user_tag = '' ;
foreach ( $user_tag_array as $key => $value ) {
if ( $value === end ( $user_tag_array )) {
$user_tag .= $value ;
} else {
$user_tag .= $value . ',' ;
}
}
$tag_filter = get_parameter ( 'tag_filter' , $user_tag );
$tag_param_validate = explode ( ',' , $tag_filter );
foreach ( $tag_param_validate as $key => $value ) {
if ( ! in_array ( $value , $user_tag_array )) {
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 Alert view'
);
include 'general/noaccess.php' ;
exit ;
}
}
2018-02-26 13:42:28 +01:00
} else {
2019-01-30 16:18:44 +01:00
$tag_filter = get_parameter ( 'tag_filter' , 0 );
2017-12-11 16:07:39 +01:00
}
2015-01-15 18:08:58 +01:00
if ( $tag_filter ) {
2019-01-30 16:18:44 +01:00
if ( $id_group && $strict_user ) {
$tag_filter = 0 ;
}
2015-01-15 18:08:58 +01:00
}
2007-04-19 20:50:07 +02:00
2022-07-15 12:15:37 +02:00
$action_filter = get_parameter ( 'action' , 0 );
2016-06-28 14:55:13 +02:00
2019-01-30 16:18:44 +01:00
$sec2 = get_parameter_get ( 'sec2' );
$sec2 = safe_url_extraclean ( $sec2 );
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
2019-01-30 16:18:44 +01:00
$sec = get_parameter_get ( 'sec' );
$sec = safe_url_extraclean ( $sec );
2009-01-05 19:41:14 +01:00
2019-01-30 16:18:44 +01:00
$flag_alert = ( bool ) get_parameter ( 'force_execution' , 0 );
$alert_validate = ( bool ) get_parameter ( 'alert_validate' , 0 );
$tab = get_parameter_get ( 'tab' , null );
2023-09-21 10:21:45 +02:00
$op = get_parameter ( 'op' , null );
2009-03-27 13:03:41 +01:00
2019-01-30 16:18:44 +01:00
$refr = ( int ) get_parameter ( 'refr' , 0 );
2013-11-12 13:42:46 +01:00
$pure = get_parameter ( 'pure' , 0 );
2015-01-15 18:08:58 +01:00
2023-01-31 11:51:00 +01:00
$url = 'index.php?sec=' . $sec . '&sec2=' . $sec2 . '&refr=' . $refr . '&disabled=' . $disabled . '&filter_standby=' . $filter_standby . '&ag_group=' . $id_group . '&tag_filter=' . $tag_filter . '&action_filter=' . $action_filter ;
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql, pandoradb.postgreSQL.sql,
extras/pandoradb_migrate_v3.2_to_v4.0.sql: changed the default value for
zero/null date "0000-00-00 00:00:00" to "01-01-1970 00:00:00".
* include/functions_graph.php,include/db/postgresql.php,
include/functions_modules.php, include/functions_agents.php,
operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php, operation/servers/view_server.php,
operation/gis_maps/ajax.php, godmode/db/db_sanity.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/configurar_agente.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_alert.php: small fixeds for the support the
PostgreSQL engine.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4306 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-05 17:20:49 +02:00
2019-01-30 16:18:44 +01:00
if ( $flag_alert == 1 && check_acl ( $config [ 'id_user' ], $id_group , 'AW' )) {
forceExecution ( $id_group );
2009-01-15 11:21:38 +01:00
}
2009-03-27 13:03:41 +01:00
2023-09-21 10:21:45 +02:00
if ( isset ( $id_agente ) === false || empty ( $id_agente ) === true ) {
$idAgent = get_parameter_get ( 'id_agente' , 0 );
} else {
$idAgent = $id_agente ;
}
2010-04-05 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_ui.php: changed some parts of source code in the
functions "format_alert_row" for show column modules in general view. In the
function "pagination" added the parameter $offset_name with default value
'offset' for to use several paginations in one page.
* include/functions_agents.php: added the parameters $limit, $idGroup,
$count in the function "get_agent_alerts_simple", and now you can limit the
rows, search by id group and return the count of rows (without limit). And
in the function "get_agent_alerts_compound" added the same parameters to
another function $idGroup, $limit, $count for similar uses.
* operation/agentes/alerts_status.php: cleaned more parts of source code,
fixed the mad array_merge of alerts, fixed SQL with the searchs IN
(large large list ids), fixed the pagination before loop all rows, now
only loop the block page rows.
* operation/agentes/alerts_status.functions.php: new file with the functions
"forceExecution", "validateAlert", and "printFormFilterAlert".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2542 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-04-06 14:46:34 +02:00
2022-11-02 09:41:07 +01:00
// Show alerts for specific agent.
2010-04-05 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_ui.php: changed some parts of source code in the
functions "format_alert_row" for show column modules in general view. In the
function "pagination" added the parameter $offset_name with default value
'offset' for to use several paginations in one page.
* include/functions_agents.php: added the parameters $limit, $idGroup,
$count in the function "get_agent_alerts_simple", and now you can limit the
rows, search by id group and return the count of rows (without limit). And
in the function "get_agent_alerts_compound" added the same parameters to
another function $idGroup, $limit, $count for similar uses.
* operation/agentes/alerts_status.php: cleaned more parts of source code,
fixed the mad array_merge of alerts, fixed SQL with the searchs IN
(large large list ids), fixed the pagination before loop all rows, now
only loop the block page rows.
* operation/agentes/alerts_status.functions.php: new file with the functions
"forceExecution", "validateAlert", and "printFormFilterAlert".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2542 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-04-06 14:46:34 +02:00
if ( $idAgent != 0 ) {
2019-01-30 16:18:44 +01:00
$url = $url . '&id_agente=' . $idAgent ;
$id_group = agents_get_agent_group ( $idAgent );
2021-06-10 08:45:50 +02:00
// All groups is calculated in ver_agente.php. Avoid to calculate it again.
2019-01-30 16:18:44 +01:00
if ( ! isset ( $all_groups )) {
$all_groups = agents_get_all_groups_agent ( $idAgent , $id_group );
}
2021-06-10 08:45:50 +02:00
if ( ! check_acl_one_of_groups ( $config [ 'id_user' ], $all_groups , 'AR' ) && ! check_acl_one_of_groups ( $config [ 'id_user' ], $id_group , 'AW' )) {
2022-02-01 13:39:18 +01:00
db_pandora_audit (
AUDIT_LOG_ACL_VIOLATION ,
'Trying to access alert view'
);
2019-01-30 16:18:44 +01:00
include 'general/noaccess.php' ;
exit ;
}
$idGroup = false ;
$print_agent = false ;
$tab = get_parameter ( 'tab' , 'main' );
2019-05-28 18:03:01 +02:00
ob_start ();
2019-01-30 16:18:44 +01:00
if ( $tab == 'main' ) {
2019-05-28 18:03:01 +02:00
$agent_view_page = true ;
2019-01-30 16:18:44 +01:00
}
} else {
$agent_a = check_acl ( $config [ 'id_user' ], 0 , 'AR' );
$agent_w = check_acl ( $config [ 'id_user' ], 0 , 'AW' );
$access = ( $agent_a == true ) ? 'AR' : (( $agent_w == true ) ? 'AW' : 'AR' );
if ( ! $agent_a && ! $agent_w ) {
2022-02-01 13:39:18 +01:00
db_pandora_audit (
AUDIT_LOG_ACL_VIOLATION ,
'Trying to access alert view'
);
2019-01-30 16:18:44 +01:00
include 'general/noaccess.php' ;
return ;
}
$agents = array_keys (
agents_get_group_agents (
array_keys (
users_get_groups ( $config [ 'id_user' ], $access , false )
),
false ,
'lower' ,
true
)
);
$idGroup = $id_group ;
2022-11-02 09:41:07 +01:00
// If there is no agent defined, it means that it cannot search for the secondary groups.
2019-01-30 16:18:44 +01:00
$all_groups = [ $id_group ];
$print_agent = true ;
2023-02-28 19:01:37 +01:00
// Header.
ui_print_standard_header (
__ ( 'Alert detail' ),
'images/op_alerts.png' ,
false ,
'' ,
false ,
[],
[
2021-04-29 13:28:03 +02:00
[
2023-02-28 19:01:37 +01:00
'link' => '' ,
'label' => __ ( 'Monitoring' ),
],
[
'link' => '' ,
'label' => __ ( 'Views' ),
],
]
);
2009-01-05 19:41:14 +01:00
}
2007-04-19 20:50:07 +02:00
2019-01-30 16:18:44 +01:00
$alerts = [];
2011-05-05 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb.sql, pandoradb.postgreSQL.sql,
extras/pandoradb_migrate_v3.2_to_v4.0.sql: changed the default value for
zero/null date "0000-00-00 00:00:00" to "01-01-1970 00:00:00".
* include/functions_graph.php,include/db/postgresql.php,
include/functions_modules.php, include/functions_agents.php,
operation/agentes/alerts_status.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/exportdata.php,
operation/agentes/ver_agente.php, operation/servers/view_server.php,
operation/gis_maps/ajax.php, godmode/db/db_sanity.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/configurar_agente.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_alert.php: small fixeds for the support the
PostgreSQL engine.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4306 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-05-05 17:20:49 +02:00
2023-09-21 10:21:45 +02:00
if ( $op != null ) {
$url = $url . '&op=' . $op ;
}
2010-04-05 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_ui.php: changed some parts of source code in the
functions "format_alert_row" for show column modules in general view. In the
function "pagination" added the parameter $offset_name with default value
'offset' for to use several paginations in one page.
* include/functions_agents.php: added the parameters $limit, $idGroup,
$count in the function "get_agent_alerts_simple", and now you can limit the
rows, search by id group and return the count of rows (without limit). And
in the function "get_agent_alerts_compound" added the same parameters to
another function $idGroup, $limit, $count for similar uses.
* operation/agentes/alerts_status.php: cleaned more parts of source code,
fixed the mad array_merge of alerts, fixed SQL with the searchs IN
(large large list ids), fixed the pagination before loop all rows, now
only loop the block page rows.
* operation/agentes/alerts_status.functions.php: new file with the functions
"forceExecution", "validateAlert", and "printFormFilterAlert".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2542 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-04-06 14:46:34 +02:00
if ( $tab != null ) {
2019-01-30 16:18:44 +01:00
$url = $url . '&tab=' . $tab ;
2009-01-05 19:41:14 +01:00
}
2010-09-17 14:34:11 +02:00
2013-11-12 13:42:46 +01:00
if ( $pure ) {
2019-01-30 16:18:44 +01:00
$url .= '&pure=' . $pure ;
2013-11-12 13:42:46 +01:00
}
2023-01-16 01:28:53 +01:00
if ( empty ( $free_search ) === false ) {
2019-01-30 16:18:44 +01:00
$url .= '&free_search=' . $free_search ;
2015-08-05 12:32:02 +02:00
}
2023-01-16 01:28:53 +01:00
$columns = [];
$column_names = [];
2019-01-30 16:18:44 +01:00
2023-03-01 13:54:22 +01:00
if (( bool ) check_acl ( $config [ 'id_user' ], $id_group , 'LW' ) === true || ( bool ) check_acl ( $config [ 'id_user' ], $id_group , 'LM' ) === true ) {
array_unshift (
$column_names ,
[
'title' => __ ( 'Standby' ),
'text' => __ ( 'Standby' ),
],
2023-03-24 12:29:03 +01:00
[
'title' => __ ( 'Operations' ),
'text' => __ ( 'Operations' ),
2023-03-31 10:44:51 +02:00
'class' => 'left pdd_l_0px pdd_r_0px w100p' ,
2023-03-24 12:29:03 +01:00
],
2023-03-01 13:54:22 +01:00
);
$columns = array_merge (
[ 'standby' ],
2023-03-24 12:29:03 +01:00
[ 'force' ],
2023-03-01 13:54:22 +01:00
$columns
);
if ( $isFunctionPolicies !== ENTERPRISE_NOT_HOOK ) {
2023-01-05 13:31:40 +01:00
array_unshift (
$column_names ,
2022-07-15 12:15:37 +02:00
[
2023-03-01 13:54:22 +01:00
'title' => __ ( 'Policy' ),
'text' => __ ( 'Policy' ),
]
2023-01-05 13:31:40 +01:00
);
2022-07-15 12:15:37 +02:00
2023-01-16 01:28:53 +01:00
$columns = array_merge (
2023-03-01 13:54:22 +01:00
[ 'policy' ],
2023-01-16 01:28:53 +01:00
$columns
);
2023-01-05 13:31:40 +01:00
}
2023-01-10 10:18:37 +01:00
2023-07-12 14:11:00 +02:00
/*
if ( $print_agent === true ) {
2023-01-10 10:18:37 +01:00
array_push (
$column_names ,
2023-03-01 13:54:22 +01:00
[ 'text' => 'Agent' ]
2023-01-10 10:18:37 +01:00
);
$columns = array_merge (
$columns ,
2023-03-01 13:54:22 +01:00
[ 'agent_name' ]
2023-01-10 10:18:37 +01:00
);
2023-07-12 14:11:00 +02:00
} */
2023-01-05 13:31:40 +01:00
}
2023-01-10 10:18:37 +01:00
2023-06-01 12:27:58 +02:00
array_push (
$column_names ,
2023-07-12 14:11:00 +02:00
[ 'text' => 'Agent' ],
2023-06-01 12:27:58 +02:00
[ 'text' => 'Module' ],
[ 'text' => 'Template' ],
[
'title' => __ ( 'Action' ),
'text' => __ ( 'Action' ),
'style' => 'min-width: 15%;' ,
],
[ 'text' => 'Last fired' ],
[ 'text' => 'Status' ]
);
$columns = array_merge (
$columns ,
2023-07-12 14:11:00 +02:00
[ 'agent_name' ],
2023-06-01 12:27:58 +02:00
[ 'agent_module_name' ],
[ 'template_name' ],
[ 'action' ],
[ 'last_fired' ],
[ 'status' ]
);
2023-03-01 13:54:22 +01:00
2023-01-11 13:46:15 +01:00
if ( is_metaconsole () === false ) {
if (( bool ) check_acl ( $config [ 'id_user' ], $id_group , 'LW' ) === true || ( bool ) check_acl ( $config [ 'id_user' ], $id_group , 'LM' ) === true ) {
array_unshift (
$column_names ,
[
'title' => __ ( 'Validate' ),
'text' => html_print_checkbox ( 'all_validate' , 0 , false , true , false ),
'class' => 'dt-left' ,
'style' => 'max-width: 5%;' ,
]
);
2009-01-05 19:41:14 +01:00
2023-01-11 13:46:15 +01:00
$columns = array_merge (
[ 'validate' ],
$columns
);
}
}
2020-03-12 10:47:59 +01:00
2023-04-27 16:05:37 +02:00
if ( is_metaconsole ()) {
array_push ( $column_names , [ 'text' => 'actions' ]);
array_push ( $columns , 'actions' );
}
2023-01-05 13:31:40 +01:00
if ( is_metaconsole () === true ) {
$no_sortable_columns = [
0 ,
1 ,
2023-03-31 10:44:51 +02:00
2 ,
2023-01-05 13:31:40 +01:00
5 ,
2023-04-27 16:05:37 +02:00
- 1 ,
2023-01-05 13:31:40 +01:00
];
} else {
if ( enterprise_installed () === true ) {
$no_sortable_columns = [
0 ,
1 ,
2 ,
3 ,
2023-03-29 15:34:03 +02:00
- 3 ,
2023-03-28 12:39:02 +02:00
- 1 ,
2023-01-05 13:31:40 +01:00
];
} else {
$no_sortable_columns = [
0 ,
1 ,
2 ,
2023-03-29 15:34:03 +02:00
- 3 ,
2023-03-28 12:39:02 +02:00
- 1 ,
2023-01-05 13:31:40 +01:00
];
}
}
2020-03-12 10:47:59 +01:00
2023-01-05 13:31:40 +01:00
ob_start ();
2024-02-09 13:51:56 +01:00
if ( isset ( $agent_view_page ) === false ) {
$agent_view_page = false ;
}
2023-01-05 13:31:40 +01:00
if ( $agent_view_page === true ) {
2024-03-14 11:20:39 +01:00
$alerts_count = alerts_get_alerts ( 0 , '' , 'all' , - 1 , true , true , $agent [ 'id_agente' ]);
$disabled_alert = false ;
// Optimal limit to display alerts.
if (( int ) $alerts_count > AGENT_ALERT_LIMIT ) {
$disabled_alert = true ;
}
2023-01-05 13:31:40 +01:00
ui_print_datatable (
[
'id' => 'alerts_status_datatable' ,
'class' => 'info_table' ,
2023-05-08 14:25:57 +02:00
'style' => 'width: 100%' ,
2023-01-05 13:31:40 +01:00
'columns' => $columns ,
'column_names' => $column_names ,
'no_sortable_columns' => $no_sortable_columns ,
'ajax_url' => 'include/ajax/alert_list.ajax' ,
2023-03-10 14:49:38 +01:00
'dom_elements' => 'pfrti' ,
2023-01-05 13:31:40 +01:00
'ajax_data' => [
'get_agent_alerts_datatable' => 1 ,
'id_agent' => $idAgent ,
'url' => $url ,
'agent_view_page' => true ,
'all_groups' => $all_groups ,
],
'drawCallback' => 'alerts_table_controls()' ,
'order' => [
'field' => 'agent_module_name' ,
'direction' => 'asc' ,
],
'zeroRecords' => __ ( 'No alerts found' ),
'emptyTable' => __ ( 'No alerts found' ),
2023-05-05 13:03:38 +02:00
'search_button_class' => 'sub filter float-right secondary' ,
2023-01-05 13:31:40 +01:00
'form' => [
'inputs' => [
2023-01-10 10:18:37 +01:00
[
2023-01-05 13:31:40 +01:00
'label' => __ ( 'Free text for search (*):' ) . ui_print_help_tip (
__ ( 'Filter by module name, template name or action name' ),
2023-01-10 10:18:37 +01:00
true
),
2023-01-05 13:31:40 +01:00
'type' => 'text' ,
'name' => 'free_search_alert' ,
'value' => $free_search ,
'size' => 20 ,
'maxlength' => 100 ,
2022-07-15 12:15:37 +02:00
],
2023-01-05 13:31:40 +01:00
],
'no_toggle' => true ,
2023-03-10 14:49:38 +01:00
'class' => 'flex' ,
2023-01-05 13:31:40 +01:00
],
2024-03-14 11:20:39 +01:00
'start_disabled' => $disabled_alert ,
2023-01-05 13:31:40 +01:00
]
);
} else {
2023-11-08 12:49:45 +01:00
$tab = get_parameter ( 'tab' , 'main' );
$alert_agent_view = false ;
if ( $tab == 'alert' ) {
$alert_agent_view = true ;
}
2023-01-05 13:31:40 +01:00
ui_print_datatable (
[
'id' => 'alerts_status_datatable' ,
'class' => 'info_table' ,
2023-08-31 14:58:47 +02:00
'style' => 'width: 100%;' ,
2023-01-05 13:31:40 +01:00
'columns' => $columns ,
'column_names' => $column_names ,
'no_sortable_columns' => $no_sortable_columns ,
'ajax_url' => 'include/ajax/alert_list.ajax' ,
'ajax_data' => [
'get_agent_alerts_datatable' => 1 ,
'id_agent' => $idAgent ,
'url' => $url ,
],
'drawCallback' => 'alerts_table_controls()' ,
'order' => [
'field' => 'agent_module_name' ,
'direction' => 'asc' ,
],
'zeroRecords' => __ ( 'No alerts found' ),
'emptyTable' => __ ( 'No alerts found' ),
2023-05-05 13:03:38 +02:00
'search_button_class' => 'sub filter float-right secondary' ,
2023-02-24 10:46:46 +01:00
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar' ,
2023-01-05 13:31:40 +01:00
'form' => [
'html' => printFormFilterAlert (
$id_group ,
2023-01-31 11:51:00 +01:00
$disabled ,
2023-01-05 13:31:40 +01:00
$free_search ,
2023-11-08 12:49:45 +01:00
$alert_agent_view ,
2023-01-05 13:31:40 +01:00
$filter_standby ,
$tag_filter ,
true ,
true ,
$strict_user
),
],
2023-11-08 12:49:45 +01:00
'start_disabled' => ! $alert_agent_view ,
2023-01-05 13:31:40 +01:00
]
);
}
2019-01-30 16:18:44 +01:00
2023-03-30 16:50:30 +02:00
if ( is_metaconsole () === false ) {
if ((( bool ) check_acl ( $config [ 'id_user' ], $id_group , 'AW' ) === true || ( bool ) check_acl ( $config [ 'id_user' ], $id_group , 'LM' ) === true )) {
if ( $agent_view_page === true ) {
html_print_div (
[
2023-05-05 13:03:38 +02:00
'class' => 'action-buttons pdd_r_5px w100p' ,
2023-03-30 16:50:30 +02:00
'content' => html_print_submit_button (
__ ( 'Validate' ),
'alert_validate' ,
false ,
[
'icon' => 'wand' ,
'mode' => 'secondary mini' ,
],
true
),
]
);
} else {
html_print_action_buttons (
html_print_submit_button (
2023-01-11 13:46:15 +01:00
__ ( 'Validate' ),
'alert_validate' ,
false ,
2023-03-30 16:50:30 +02:00
[ 'icon' => 'wand' ],
2023-01-11 13:46:15 +01:00
true
),
2023-03-30 16:50:30 +02:00
[ 'type' => 'form_action' ]
);
}
2024-03-14 11:48:17 +01:00
} else {
html_print_action_buttons (
'' ,
[ 'type' => 'form_action' ]
);
2023-01-05 13:31:40 +01:00
}
2023-03-30 16:50:30 +02:00
} else {
2023-04-27 16:05:37 +02:00
echo " <form method='post' action='index.php?sec=galertas&sec2=godmode/alerts/alert_list&tab=builder&pure=0'> " ;
html_print_action_buttons (
html_print_submit_button (
__ ( 'Create alert' ),
'submit' ,
false ,
[ 'icon' => 'next' ],
true
)
);
echo '</form>' ;
2023-01-05 13:31:40 +01:00
}
2019-05-28 18:03:01 +02:00
2023-01-11 13:46:15 +01:00
$html_content = ob_get_clean ();
2019-05-28 18:03:01 +02:00
2023-01-05 13:31:40 +01:00
if ( $agent_view_page === true ) {
// Create controlled toggle content.
2023-01-11 13:46:15 +01:00
html_print_div (
[
'class' => 'agent_details_line' ,
'content' => ui_toggle (
$html_content ,
'<span class="subsection_header_title">' . __ ( 'Full list of alerts' ) . '</span>' ,
'status_monitor_agent' ,
! $alerts_defined ,
2023-05-26 12:30:36 +02:00
( $alerts_count > 0 ) ? false : true ,
2023-01-11 13:46:15 +01:00
true ,
2023-03-15 17:02:25 +01:00
'' ,
'' ,
'box-flat white_table_graph w100p'
2023-01-11 13:46:15 +01:00
),
],
2023-01-05 13:31:40 +01:00
);
} else {
// Dump entire content.
echo $html_content ;
}
2019-05-28 18:03:01 +02:00
2023-09-21 09:24:35 +02:00
// Filter control.
echo '<input type="hidden" id="filter_applied" value="0" />' ;
2023-02-23 17:57:48 +01:00
// Strict user hidden.
echo '<div id="strict_hidden" class="invisible">' ;
html_print_input_text ( 'strict_user_hidden' , $strict_user );
2016-09-08 16:06:12 +02:00
2023-02-23 17:57:48 +01:00
html_print_input_text ( 'is_meta_hidden' , ( int ) is_metaconsole ());
echo '</div>' ;
2015-01-15 18:08:58 +01:00
2023-02-23 17:57:48 +01:00
ui_require_css_file ( 'cluetip' , 'include/styles/js/' );
ui_require_jquery_file ( 'cluetip' );
2023-12-22 12:16:34 +01:00
2024-01-26 08:13:10 +01:00
if ( isset ( $id_agente )) {
$system_higher = false ;
$modules_agent = db_get_all_rows_sql ( sprintf ( 'SELECT id_agente FROM tagente_modulo WHERE id_agente = %s' , $id_agente ));
if ( is_array ( $modules_agent )) {
$all_modules = db_get_all_rows_sql ( 'SELECT id_agente FROM tagente_modulo' );
$all_agents = db_get_all_rows_sql ( 'SELECT id_agente FROM tagente' );
if ( is_array ( $all_modules ) && is_array ( $all_agents )) {
if (( count ( $all_modules ) / count ( $all_agents )) >= 200 ) {
$system_higher = true ;
}
2023-12-22 12:16:34 +01:00
}
}
2024-01-26 08:13:10 +01:00
echo '<div id="system_higher" class="invisible_important agent_details_agent_data flex_important"><img src="images/alert-yellow@svg.svg" width="10%" class="mrgn_right_20px">' . __ ( 'Your system has a much higher rate of modules per agent than recommended (200 modules per agent). This implies performance problems in the system, please consider reducing the number of modules in this agent.' ) . '</div>' ;
2024-02-09 13:51:56 +01:00
} else {
$system_higher = false ;
2024-01-26 08:13:10 +01:00
}
2023-12-22 12:16:34 +01:00
2023-01-05 13:31:40 +01:00
?>
2009-01-15 11:21:38 +01:00
< script type = " text/javascript " >
2022-07-15 12:15:37 +02:00
function alerts_table_controls () {
2019-01-30 16:18:44 +01:00
2023-04-27 16:05:37 +02:00
$ ( " button.template_details " ) . cluetip ({
arrows : true ,
attribute : 'href' ,
cluetipClass : 'default'
}) . click ( function () {
return false ;
});
2019-01-30 16:18:44 +01:00
2023-04-27 16:05:37 +02:00
$ ( " a.template_details " ) . cluetip ({
arrows : true ,
attribute : 'href' ,
cluetipClass : 'default'
});
2019-01-30 16:18:44 +01:00
2023-04-27 16:05:37 +02:00
$ ( '[id^=checkbox-all_validate]' ) . change ( function (){
if ( $ ( " #checkbox-all_validate " ) . prop ( " checked " )) {
$ ( " input[id^=checkbox-validate] " ) . prop ( 'checked' , true );
}
else {
$ ( '[id^=checkbox-validate]' ) . parent () . parent () . removeClass ( 'checkselected' );
$ ( '[name^=validate]' ) . prop ( " checked " , false );
}
2019-01-30 16:18:44 +01:00
});
2023-04-27 16:05:37 +02:00
}
2019-01-30 16:18:44 +01:00
2023-04-27 16:05:37 +02:00
$ ( document ) . ready ( function () {
alerts_table_controls ();
$ ( '#button-alert_validate' ) . on ( 'click' , function () {
validateAlerts ();
2019-01-30 16:18:44 +01:00
});
2023-04-27 16:05:37 +02:00
});
2019-01-30 16:18:44 +01:00
2023-09-19 13:50:06 +02:00
$ ( '#checkbox-search_sg' ) . click ( function (){
if ( $ ( '#checkbox-search_sg' ) . val () == 0 ) {
$ ( '#checkbox-search_sg' ) . val ( 1 );
} else {
$ ( '#checkbox-search_sg' ) . val ( 0 );
}
});
2023-04-27 16:05:37 +02:00
$ ( 'table.alert-status-filter #ag_group' ) . change ( function () {
var strict_user = $ ( " #text-strict_user_hidden " ) . val ();
var is_meta = $ ( " #text-is_meta_hidden " ) . val ();
2019-01-30 16:18:44 +01:00
2023-04-27 16:05:37 +02:00
if (( $ ( this ) . val () != 0 ) && ( strict_user != 0 )) {
$ ( " table.alert-status-filter #tag_filter " ) . hide ();
if ( is_meta ) {
$ ( " table.alert-status-filter #table1-0-4 " ) . hide ();
2019-01-30 16:18:44 +01:00
} else {
2023-04-27 16:05:37 +02:00
$ ( " table.alert-status-filter #table2-0-4 " ) . hide ();
2019-01-30 16:18:44 +01:00
}
2023-04-27 16:05:37 +02:00
} else {
$ ( " #tag_filter " ) . show ();
if ( is_meta ) {
$ ( " table.alert-status-filter #table1-0-4 " ) . show ();
} else {
$ ( " table.alert-status-filter #table2-0-4 " ) . show ();
2019-01-30 16:18:44 +01:00
}
2023-04-27 16:05:37 +02:00
}
}) . change ();
2022-07-15 12:15:37 +02:00
2023-12-22 12:16:34 +01:00
< ? php if ( $system_higher === true ) { ?>
$ ( " #system_higher " ) . dialog ({
title : " <?php echo __('Warning'); ?> " ,
resizable : true ,
draggable : true ,
modal : true ,
width : 500 ,
height : 150 ,
buttons : [{
text : " OK " ,
click : function () {
$ ( this ) . dialog ( " close " );
},
class : 'invisible_important' ,
}],
overlay : {
opacity : 0.5 ,
background : " black "
},
closeOnEscape : false ,
open : function ( event , ui ) {
$ ( " .ui-dialog-titlebar-close " ) . hide ();
2024-01-18 11:26:38 +01:00
$ ( " #system_higher " ) . removeClass ( 'invisible_important' );
2023-12-22 12:16:34 +01:00
setTimeout (() => {
$ ( " .ui-dialog-buttonset " ) . find ( 'button' ) . removeClass ( 'invisible_important' );
2023-12-22 13:12:55 +01:00
}, 4000 );
2023-12-22 12:16:34 +01:00
}
});
< ? php } ?>
2023-04-27 16:05:37 +02:00
function validateAlerts () {
var alert_ids = [];
2022-07-15 12:15:37 +02:00
2023-04-27 16:05:37 +02:00
$ ( '[id^=checkbox-validate]:checked' ) . each ( function () {
alert_ids . push ( $ ( this ) . val ());
});
2022-07-15 12:15:37 +02:00
2023-04-27 16:05:37 +02:00
if ( alert_ids . length === 0 ) {
confirmDialog ({
title : " <?php echo __('No alert selected'); ?> " ,
message : " <?php echo __('You must select at least one alert.'); ?> " ,
hideCancelButton : true
2022-07-15 12:15:37 +02:00
});
2023-04-27 16:05:37 +02:00
}
2022-07-15 12:15:37 +02:00
2023-04-27 16:05:37 +02:00
$ . ajax ({
type : " POST " ,
url : " ajax.php " ,
data : {
alert_ids : alert_ids ,
page : " include/ajax/alert_list.ajax " ,
alert_validate : 1 ,
all_groups : < ? php echo json_encode ( $all_groups ); ?> ,
},
dataType : " json " ,
success : function ( data ) {
$ ( " #menu_tab_frame_view " ) . after ( data );
var table = $ ( '#alerts_status_datatable' ) . DataTable ({
ajax : " data.json "
2022-07-15 12:15:37 +02:00
});
2023-04-27 16:05:37 +02:00
table . ajax . reload ();
},
});
2022-07-15 12:15:37 +02:00
2023-04-27 16:05:37 +02:00
}
function show_display_update_action ( id_module_action , alert_id , alert_id_agent_module , action_id , id_agent = '' ) {
$ . each ( $ ( '[id^="update_action-div"]' ), function (){
$ ( this ) . html ( '' );
});
var params = [];
params . push ( " show_update_action_menu=1 " );
params . push ( " id_agent_module= " + alert_id_agent_module );
params . push ( " id_module_action= " + id_module_action );
params . push ( " id_alert= " + alert_id );
params . push ( " id_action= " + action_id );
params . push ( " id_agent= " + id_agent );
params . push ( " page=include/ajax/alert_list.ajax " );
jQuery . ajax ({
data : params . join ( " & " ),
type : 'POST' ,
url : action = " <?php echo ui_get_full_url('ajax.php', false, false, false); ?> " ,
success : function ( data ) {
$ ( '#update_action-div-' + alert_id ) . html ( data );
$ ( '#update_action-div-' + alert_id ) . dialog ({
resizable : true ,
draggable : true ,
title : '<?php echo __(' Update action '); ?>' ,
modal : true ,
overlay : {
opacity : 0.5 ,
background : " black "
},
open : function () {
$ ( '#action_select_ajax-' + alert_id ) . select2 ();
},
onclose : function () {
$ ( '#update_action-div-' + alert_id ) . html ( " " );
},
width : 600 ,
height : 350 ,
})
. show ();
}
});
}
2023-07-04 12:47:04 +02:00
function show_add_action ( id_alert ) {
$ ( " #add_action-div- " + id_alert ) . hide ()
. dialog ({
resizable : true ,
draggable : true ,
modal : true ,
width : 700 ,
title : '<?php echo __(' Add action '); ?>' ,
modal : true ,
overlay : {
opacity : 0.5 ,
background : " black "
}
})
. show ();
}
</ script >