1 /* @(#) $Id: dbd.c,v 1.6 2009/06/24 17:06:30 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
11 * License details at the LICENSE file included with OSSEC or
12 * online at: http://www.ossec.net/en/licensing.html
21 #define ARGV0 "ossec-dbd"
29 /* OS_DBD: Monitor the alerts and insert them into the database.
30 * Only return in case of error.
32 void OS_DBD(DBConfig *db_config)
41 /* Getting currently time before starting */
46 /* Initating file queue - to read the alerts */
47 os_calloc(1, sizeof(file_queue), fileq);
48 Init_FileQueue(fileq, p, 0);
51 /* Creating location hash */
52 db_config->location_hash = OSHash_Create();
53 if(!db_config->location_hash)
55 ErrorExit(MEM_ERROR, ARGV0);
59 /* Getting maximum ID */
60 db_config->alert_id = OS_SelectMaxID(db_config);
61 db_config->alert_id++;
64 /* Infinite loop reading the alerts and inserting them. */
71 /* Get message if available (timeout of 5 seconds) */
72 al_data = Read_FileMon(fileq, p, 5);
79 /* Inserting into the db */
80 OS_Alert_InsertDB(al_data, db_config);
83 /* Clearing the memory */
84 FreeAlertData(al_data);