static char *config_host = NULL;
static char *config_port = NULL;
+TCRDB *rdb = NULL;
+
static int tt_config (const char *key, const char *value)
{
if (strcasecmp ("Host", key) == 0)
static int tt_read (void) {
gauge_t rnum, size;
+ rnum = tcrdbrnum(rdb);
+ size = tcrdbsize(rdb);
+ tt_submit (rnum, "records");
+ tt_submit (size, "file_size");
+
+ return (0);
+}
+
+static int tt_init(void)
+{
char* host = NULL;
int port;
host = ((config_host != NULL) ? config_host : DEFAULT_HOST);
port = ((config_port != NULL) ? atoi(config_port) : DEFAULT_PORT);
- TCRDB *rdb = tcrdbnew();
+ rdb = tcrdbnew();
if (!tcrdbopen(rdb, host, port))
{
return (1);
}
- rnum = tcrdbrnum(rdb);
- size = tcrdbsize(rdb);
- tt_submit (rnum, "records");
- tt_submit (size, "file_size");
+ return(0);
+}
+
+static int tt_shutdown(void)
+{
+ sfree(config_host);
+ sfree(config_port);
if (!tcrdbclose(rdb))
{
}
tcrdbdel (rdb);
- return (0);
-}
-
-static int tt_shutdown(void)
-{
- sfree(config_host);
- sfree(config_port);
return(0);
}
plugin_register_config("tokyotyrant", tt_config,
config_keys, config_keys_num);
plugin_register_read("tokyotyrant", tt_read);
+ plugin_register_init("tokyotyrant", tt_init);
plugin_register_shutdown("tokyotyrant", tt_shutdown);
}