X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fmonitord%2Fmonitord.c;h=9dbbf13aeef471dc0cb01ca5376adf2d7b18f66c;hp=8ae5c933117ac70a31737c8b2079f03d1a3ed0f0;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b diff --git a/src/monitord/monitord.c b/src/monitord/monitord.c old mode 100755 new mode 100644 index 8ae5c93..9dbbf13 --- a/src/monitord/monitord.c +++ b/src/monitord/monitord.c @@ -1,6 +1,3 @@ -/* @(#) $Id: ./src/monitord/monitord.c, 2011/09/08 dcid Exp $ - */ - /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. * @@ -10,82 +7,69 @@ * Foundation */ - - #include "shared.h" #include "monitord.h" +/* Global variables */ +monitor_config mond; + -/* Real monitord global */ void Monitord() { time_t tm; struct tm *p; - int today = 0; + int today = 0; int thismonth = 0; int thisyear = 0; - char str[OS_SIZE_1024 +1]; + char str[OS_SIZE_1024 + 1]; - /* Waiting a few seconds to settle */ + /* Wait a few seconds to settle */ sleep(10); - memset(str, '\0', OS_SIZE_1024 +1); - + memset(str, '\0', OS_SIZE_1024 + 1); - /* Getting currently time before starting */ + /* Get current time before starting */ tm = time(NULL); - p = localtime(&tm); + p = localtime(&tm); today = p->tm_mday; thismonth = p->tm_mon; - thisyear = p->tm_year+1900; + thisyear = p->tm_year + 1900; - - - /* Connecting to the message queue - * Exit if it fails. - */ - if((mond.a_queue = StartMQ(DEFAULTQUEUE,WRITE)) < 0) - { + /* Connect to the message queue or exit */ + if ((mond.a_queue = StartMQ(DEFAULTQUEUE, WRITE)) < 0) { ErrorExit(QUEUE_FATAL, ARGV0, DEFAULTQUEUE); } - - /* Sending startup message */ - snprintf(str, OS_SIZE_1024 -1, OS_AD_STARTED); - if(SendMSG(mond.a_queue, str, ARGV0, - LOCALFILE_MQ) < 0) - { + /* Send startup message */ + snprintf(str, OS_SIZE_1024 - 1, OS_AD_STARTED); + if (SendMSG(mond.a_queue, str, ARGV0, + LOCALFILE_MQ) < 0) { merror(QUEUE_SEND, ARGV0); } - /* Main monitor loop */ - while(1) - { + while (1) { tm = time(NULL); p = localtime(&tm); - - /* Checking unavailable agents */ - if(mond.monitor_agents) - { + /* Check for unavailable agents */ + if (mond.monitor_agents) { monitor_agents(); } /* Day changed, deal with log files */ - if(today != p->tm_mday) - { - /* Generate reports. */ - generate_reports(today, thismonth, thisyear, p); + if (today != p->tm_mday) { + /* Generate reports */ + generate_reports(today, thismonth, thisyear); manage_files(today, thismonth, thisyear); today = p->tm_mday; thismonth = p->tm_mon; - thisyear = p->tm_year+1900; + thisyear = p->tm_year + 1900; } /* We only check every two minutes */ @@ -93,4 +77,3 @@ void Monitord() } } -/* EOF */