X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fmonitord%2Fmonitor_agents.c;h=9b87a0c9a9e129ecaee272d824aefb245b816e04;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=133d31f16766316cb8b5f491a2e3bf0af92cdafd;hpb=301048b51990573e58a30dc4a5bb4ec285cad554;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 133d31f..9b87a0c --- a/src/monitord/monitor_agents.c +++ b/src/monitord/monitor_agents.c @@ -1,50 +1,39 @@ -/* @(#) $Id$ */ - /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 2) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * 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; } @@ -52,27 +41,22 @@ void monitor_agents() } /* Agent disconnected */ - 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) - { + if (available == 0) { + char str[OS_SIZE_1024 + 1]; + + /* 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); } } - + 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 */