From a7a0886e6ce7121299492edadd84f15d50bb5aea Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 6 Feb 2023 13:24:37 +0100 Subject: [PATCH 1/3] policy maintenance mode --- pandora_console/include/functions.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 7d4fee1d21..790df73e8a 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -6397,3 +6397,23 @@ function getBearerToken() return false; } + + +/** + * Check whether an instance of pandora_db is running. + * + * @return boolean Result. + */ +function is_pandora_db_running() +{ + $is_free_lock = mysql_db_process_sql( + 'SELECT IS_FREE_LOCK("pandora_pandora_db") AS "value"', + 'affected_rows', + '', + false + ); + + $is_free_lock = (bool) $is_free_lock[0]['value']; + + return !$is_free_lock; +} \ No newline at end of file From de3a74ae1ac61deadcfaaac4fe29ecb0dba14f26 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 6 Feb 2023 13:27:25 +0100 Subject: [PATCH 2/3] policy maintenance mode --- pandora_console/include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 790df73e8a..75e8e7ee58 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -6416,4 +6416,4 @@ function is_pandora_db_running() $is_free_lock = (bool) $is_free_lock[0]['value']; return !$is_free_lock; -} \ No newline at end of file +} From a1ccfc99eca99efe7b28a206adce400a3b3bb4af Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 6 Feb 2023 13:41:31 +0100 Subject: [PATCH 3/3] policy maintenance mode --- pandora_console/include/functions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 75e8e7ee58..a4713b6f67 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -6406,8 +6406,11 @@ function getBearerToken() */ function is_pandora_db_running() { + // Get current DB name: useful for metaconsole connection to node. + $db_name = db_get_sql('SELECT DATABASE()'); + $is_free_lock = mysql_db_process_sql( - 'SELECT IS_FREE_LOCK("pandora_pandora_db") AS "value"', + 'SELECT IS_FREE_LOCK("'.$db_name.'_pandora_db") AS "value"', 'affected_rows', '', false