1 /* @(#) $Id: csyslogd.c,v 1.3 2009/06/24 17:06:29 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
18 #include "os_net/os_net.h"
22 /* OS_SyslogD: Monitor the alerts and sends them via syslog.
23 * Only return in case of error.
25 void OS_CSyslogD(SyslogConfig **syslog_config)
35 /* Getting currently time before starting */
40 /* Initating file queue - to read the alerts */
41 os_calloc(1, sizeof(file_queue), fileq);
42 Init_FileQueue(fileq, p, 0);
45 /* Connecting to syslog. */
47 while(syslog_config[s])
49 syslog_config[s]->socket = OS_ConnectUDP(syslog_config[s]->port,
50 syslog_config[s]->server);
51 if(syslog_config[s]->socket < 0)
53 merror(CONNS_ERROR, ARGV0, syslog_config[s]->server);
57 merror("%s: INFO: Forwarding alerts via syslog to: '%s:%d'.",
58 ARGV0, syslog_config[s]->server, syslog_config[s]->port);
66 /* Infinite loop reading the alerts and inserting them. */
73 /* Get message if available (timeout of 5 seconds) */
74 al_data = Read_FileMon(fileq, p, 5);
82 /* Sending via syslog */
84 while(syslog_config[s])
86 OS_Alert_SendSyslog(al_data, syslog_config[s]);
91 /* Clearing the memory */
92 FreeAlertData(al_data);