2 * collectd - src/utils_logtail.h
3 * Copyright (C) 2007-2008 C-Ware, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Luke Heberling <lukeh at c-ware.com>
22 * Encapsulates useful code to plugins which must parse a log file.
26 #include "utils_llist.h"
27 #include "utils_tail.h"
29 struct logtail_instance_s;
30 typedef struct logtail_instance_s logtail_instance_t;
37 * Call to release resources associated with the plugin.
40 * `instances' The handle used to identify the plugin.
43 * Zero on success, nonzero on failure.
45 int logtail_term (llist_t **instances);
52 * Call to initialize the plugin
55 * `instances' The handle used to identify the plugin.
58 * Zero on success, nonzero on failure.
60 int logtail_init (llist_t **instances);
67 * Looks for more data in the log file, sends each line
68 * through the given function, and submits the counters to
72 * `instances' The handle used to identify the plugin.
74 * `func' The function used to parse each line from the log.
76 * `plugin' The name of the plugin.
78 * `names' An array of counter names in the same order as the
79 * counters themselves.
82 * Zero on success, nonzero on failure.
84 int logtail_read (llist_t **instances, tailfunc *func, char *plugin,
92 * Configures the logtail instance for the given plugin.
95 * `instances' The handle used to identify the plugin.
97 * `ci' The configuration item from collectd.
99 * `plugin' The name of the plugin.
101 * `names' An array of counter names in the same order as the
102 * counters themselves.
104 * `default_file' The default log file if none is found in the
107 * `default_cache_size' The default cache size if none is found in the
111 * Zero on success, nonzero on failure.
113 int logtail_config (llist_t **instances, oconfig_item_t *ci, char *plugin,
114 char **names, char *default_file,
115 int default_cache_size);
122 * Returns the counters maintained for the plugin.
125 * `instance' The handle used to identify the logtail instance.
128 unsigned long *logtail_counters (logtail_instance_t *instance);
135 * Stores the data in the cache.
138 * `instance' The handle used to identify the logtail instance.
140 * `plugin' The name of the plugin.
142 * `key' The key to identify the cached data.
144 * `data' The data to cache.
146 * `len' The length of the data to cache.
149 * Zero on success, nonzero on failure.
151 int logtail_cache (logtail_instance_t *instance, char *plugin, char *key,
152 void **data, int len);
159 * Removes the data from the cache.
162 * `instance' The handle used to identify the logtail instance.
164 * `key' The key to identify the cached data.
167 void logtail_decache (logtail_instance_t *instance, char *key);