2 * collectd - src/utils_logtail.h
3 * Copyright (C) 2007-2008 C-Ware, Inc.
4 * Copyright (C) 2008 Florian Forster
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; only version 2 of the License is applicable.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Luke Heberling <lukeh at c-ware.com>
21 * Florian Forster <octo at verplant.org>
24 * Encapsulates useful code to plugins which must parse a log file.
28 #include "utils_match.h"
31 typedef struct cu_logtail_s cu_logtail_t;
33 struct cu_logtail_simple_s
35 char plugin[DATA_MAX_NAME_LEN];
36 char plugin_instance[DATA_MAX_NAME_LEN];
37 char type[DATA_MAX_NAME_LEN];
38 char type_instance[DATA_MAX_NAME_LEN];
40 typedef struct cu_logtail_simple_s cu_logtail_simple_t;
47 * Allocates, initializes and returns a new `cu_logtail_t' object.
50 * `filename' The name to read data from.
51 * `plugin' The plugin name to use when dispatching values.
54 * Returns NULL upon failure, non-NULL otherwise.
56 cu_logtail_t *logtail_create (const char *filename);
63 * Releases resources used by the `cu_logtail_t' object.
66 * The object to destroy.
68 void logtail_destroy (cu_logtail_t *obj);
72 * logtail_add_match_simple
75 * Adds a match, in form of a regular expression, to the `cu_logtail_t'
76 * object. The values matched by that regular expression are dispatched to
77 * the daemon using the supplied `type' and `type_instance' fields.
87 * Zero upon success, non-zero otherwise.
89 int logtail_add_match (cu_logtail_t *obj, cu_match_t *match,
90 int (*submit_match) (cu_match_t *match, void *user_data),
92 void (*free_user_data) (void *user_data));
94 int logtail_add_match_simple (cu_logtail_t *obj,
95 const char *regex, int ds_type,
96 const char *plugin, const char *plugin_instance,
97 const char *type, const char *type_instance);
104 * Looks for more data in the log file, sends each line
105 * through the given function, and submits the counters to
109 * `instances' The handle used to identify the plugin.
111 * `func' The function used to parse each line from the log.
113 * `plugin' The name of the plugin.
115 * `names' An array of counter names in the same order as the
116 * counters themselves.
119 * Zero on success, nonzero on failure.
121 int logtail_read (cu_logtail_t *obj);
123 /* vim: set sw=2 sts=2 ts=8 : */