1 /* @(#) $Id: ./src/os_dbd/dbd.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
12 * License details at the LICENSE file included with OSSEC or
13 * online at: http://www.ossec.net/en/licensing.html
22 #define ARGV0 "ossec-dbd"
30 /* OS_DBD: Monitor the alerts and insert them into the database.
31 * Only return in case of error.
33 void OS_DBD(DBConfig *db_config)
42 /* Getting currently time before starting */
47 /* Initating file queue - to read the alerts */
48 os_calloc(1, sizeof(file_queue), fileq);
49 Init_FileQueue(fileq, p, 0);
52 /* Creating location hash */
53 db_config->location_hash = OSHash_Create();
54 if(!db_config->location_hash)
56 ErrorExit(MEM_ERROR, ARGV0);
60 /* Getting maximum ID */
61 db_config->alert_id = OS_SelectMaxID(db_config);
62 db_config->alert_id++;
65 /* Infinite loop reading the alerts and inserting them. */
72 /* Get message if available (timeout of 5 seconds) */
73 al_data = Read_FileMon(fileq, p, 5);
80 /* Inserting into the db */
81 OS_Alert_InsertDB(al_data, db_config);
84 /* Clearing the memory */
85 FreeAlertData(al_data);