1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
14 #define ARGV0 "ossec-dbd"
18 /* Monitor the alerts and insert them into the database
19 * Only returns in case of error
21 void OS_DBD(DBConfig *db_config)
28 /* Get current time before starting */
32 /* Initialize file queue to read the alerts */
33 os_calloc(1, sizeof(file_queue), fileq);
34 Init_FileQueue(fileq, p, 0);
36 /* Create location hash */
37 db_config->location_hash = OSHash_Create();
38 if (!db_config->location_hash) {
39 ErrorExit(MEM_ERROR, ARGV0, errno, strerror(errno));
43 db_config->alert_id = OS_SelectMaxID(db_config);
44 db_config->alert_id++;
46 /* Infinite loop reading the alerts and inserting them */
51 /* Get message if available (timeout of 5 seconds) */
52 al_data = Read_FileMon(fileq, p, 5);
57 /* Insert into the db */
58 OS_Alert_InsertDB(al_data, db_config);
60 /* Clear the memory */
61 FreeAlertData(al_data);