X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fmonitord%2Fmonitor_agents.c;h=9b87a0c9a9e129ecaee272d824aefb245b816e04;hb=HEAD;hp=fbaac5844936fa70caa4b8f5d91b331d85e93d2b;hpb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;p=ossec-hids.git diff --git a/src/monitord/monitor_agents.c b/src/monitord/monitor_agents.c old mode 100755 new mode 100644 index fbaac58..9b87a0c --- a/src/monitord/monitor_agents.c +++ b/src/monitord/monitor_agents.c @@ -1,6 +1,3 @@ -/* @(#) $Id: ./src/monitord/monitor_agents.c, 2011/09/08 dcid Exp $ - */ - /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * @@ -10,42 +7,33 @@ * 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 */