From 3d635449398886bf4392cdd6ead6422744211480 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 7 Dec 2023 14:14:12 +0100 Subject: [PATCH 1/4] get data in file count from module --- .../include/class/ConsoleSupervisor.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 83208256fb..e34740711e 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -27,6 +27,7 @@ */ use PandoraFMS\Tools\Files; +use PandoraFMS\Agent; global $config; @@ -1162,11 +1163,20 @@ class ConsoleSupervisor $this->cleanNotifications('NOTIF.WRITABLE.ATTACHMENT'); } - $filecount = $this->countFiles( - $config['attachment_store'], - '', - $config['num_files_attachment'] - ); + $agentId = db_get_value('id_agente', 'tagente', 'nombre', 'pandora.internals'); + if ($agentId !== false) { + $agent = new Agent($agentId); + + $moduleId = $agent->searchModules( + ['nombre' => 'Data_in_files'], + 1 + )->toArray()['id_agente_modulo']; + + if ($moduleId > 0) { + $filecount = (int) modules_get_last_value($moduleId); + } + } + if ($filecount > $config['num_files_attachment']) { $this->notify( [ From 2eae64407d4645cd8bc4eeb73a14005c4aac62fe Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 7 Dec 2023 14:17:42 +0100 Subject: [PATCH 2/4] get data in file count from module --- pandora_console/include/class/ConsoleSupervisor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index e34740711e..a7676d4b40 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -1163,6 +1163,8 @@ class ConsoleSupervisor $this->cleanNotifications('NOTIF.WRITABLE.ATTACHMENT'); } + $filecount = 0; + $agentId = db_get_value('id_agente', 'tagente', 'nombre', 'pandora.internals'); if ($agentId !== false) { $agent = new Agent($agentId); From 44e546af395430be71a0078e48945127d3244b83 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 1 Feb 2024 17:34:42 +0100 Subject: [PATCH 3/4] minor fix --- .../include/class/ConsoleSupervisor.php | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index a7676d4b40..c01be47c4f 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -1145,7 +1145,7 @@ class ConsoleSupervisor public function checkAttachment() { global $config; - +hd("dadsada", true); if (is_writable($config['attachment_store']) !== true) { $this->notify( [ @@ -1163,22 +1163,6 @@ class ConsoleSupervisor $this->cleanNotifications('NOTIF.WRITABLE.ATTACHMENT'); } - $filecount = 0; - - $agentId = db_get_value('id_agente', 'tagente', 'nombre', 'pandora.internals'); - if ($agentId !== false) { - $agent = new Agent($agentId); - - $moduleId = $agent->searchModules( - ['nombre' => 'Data_in_files'], - 1 - )->toArray()['id_agente_modulo']; - - if ($moduleId > 0) { - $filecount = (int) modules_get_last_value($moduleId); - } - } - if ($filecount > $config['num_files_attachment']) { $this->notify( [ @@ -1292,17 +1276,28 @@ class ConsoleSupervisor $MAX_FILES_DATA_IN = 1000; $MAX_BADXML_FILES_DATA_IN = 150; - $filecount = $this->countFiles( - $remote_config_dir, - '', - $MAX_FILES_DATA_IN - ); + $filecount = 0; + + $agentId = db_get_value('id_agente', 'tagente', 'nombre', 'pandora.internals'); + if ($agentId !== false) { + $agent = new Agent($agentId); + + $moduleId = $agent->searchModules( + ['nombre' => 'Data_in_files'], + 1 + )->toArray()['id_agente_modulo']; + + if ($moduleId > 0) { + $filecount = (int) modules_get_last_value($moduleId); + } + } +hd($filecount, true); // If cannot open directory, count is '-1', skip. if ($filecount > $MAX_FILES_DATA_IN) { $this->notify( [ 'type' => 'NOTIF.FILES.DATAIN', - 'title' => __('There are too much files in spool').'.', + 'title' => __('There are too many files in spool').'.', 'message' => __( 'There are more than %d files in %s. Consider checking DataServer performance', $MAX_FILES_DATA_IN, From 05af441f19dd440bd440f12893e60f8898e4b03a Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Thu, 1 Feb 2024 17:36:21 +0100 Subject: [PATCH 4/4] minor fix --- pandora_console/include/class/ConsoleSupervisor.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index c01be47c4f..af41d60a67 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -1145,7 +1145,7 @@ class ConsoleSupervisor public function checkAttachment() { global $config; -hd("dadsada", true); + if (is_writable($config['attachment_store']) !== true) { $this->notify( [ @@ -1163,6 +1163,12 @@ hd("dadsada", true); $this->cleanNotifications('NOTIF.WRITABLE.ATTACHMENT'); } + $filecount = $this->countFiles( + $config['attachment_store'], + '', + $config['num_files_attachment'] + ); + if ($filecount > $config['num_files_attachment']) { $this->notify( [ @@ -1291,7 +1297,7 @@ hd("dadsada", true); $filecount = (int) modules_get_last_value($moduleId); } } -hd($filecount, true); + // If cannot open directory, count is '-1', skip. if ($filecount > $MAX_FILES_DATA_IN) { $this->notify(