new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / monitord / monitor_agents.c
old mode 100755 (executable)
new mode 100644 (file)
index fbaac58..9b87a0c
@@ -1,6 +1,3 @@
-/* @(#) $Id: ./src/monitord/monitor_agents.c, 2011/09/08 dcid Exp $
- */
-
 /* Copyright (C) 2009 Trend Micro Inc.
  * All right reserved.
  *
  * Foundation
  */
 
-
 #include "shared.h"
 #include "monitord.h"
 #include "read-agents.h"
 
 
-
 void monitor_agents()
 {
     char **cr_agents;
     char **av_agents;
 
-    av_agents = get_agents(GA_ACTIVE);
-
+    av_agents = get_agents_with_timeout(GA_ACTIVE, mond.notify_time);
 
     /* No agent saved */
-    if(!mond.agents)
-    {
+    if (!mond.agents) {
         mond.agents = av_agents;
         return;
     }
 
-    /* Checking if any of the previous available agents
-     * are disconnected.
-     */
+    /* Check if any of the previously available agents are disconnected */
     cr_agents = mond.agents;
-    while(*cr_agents)
-    {
+    while (*cr_agents) {
         int available = 0;
         char **tmp_av;
 
         tmp_av = av_agents;
-        while(tmp_av && *tmp_av)
-        {
-            if(strcmp(*cr_agents, *tmp_av) == 0)
-            {
+        while (tmp_av && *tmp_av) {
+            if (strcmp(*cr_agents, *tmp_av) == 0) {
                 available = 1;
                 break;
             }
@@ -53,15 +41,13 @@ void monitor_agents()
         }
 
         /* Agent disconnected */
-        if(available == 0)
-        {
-            char str[OS_SIZE_1024 +1];
+        if (available == 0) {
+            char str[OS_SIZE_1024 + 1];
 
-            /* Sending disconnected message */
-            snprintf(str, OS_SIZE_1024 -1, OS_AG_DISCON, *cr_agents);
-            if(SendMSG(mond.a_queue, str, ARGV0,
-                        LOCALFILE_MQ) < 0)
-            {
+            /* Send disconnected message */
+            snprintf(str, OS_SIZE_1024 - 1, OS_AG_DISCON, *cr_agents);
+            if (SendMSG(mond.a_queue, str, ARGV0,
+                        LOCALFILE_MQ) < 0) {
                 merror(QUEUE_SEND, ARGV0);
             }
         }
@@ -69,11 +55,8 @@ void monitor_agents()
         cr_agents++;
     }
 
-
-    /* Removing old agent list and adding currently one */
+    /* Remove old agent list and add current one */
     free_agents(mond.agents);
     mond.agents = av_agents;
     return;
 }
-
-/* EOF */