X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=t%2Fintegration%2Fmock_plugin.c;h=0724ce1dd49b9dc9b18f0e7dbb2693c381d5c403;hp=7e2b4a67dae3fc5e843a1eaf33cd307becc5762c;hb=1f99d1a0d8a7e923dede7c938340c26061b8398b;hpb=5ef6f70a8eae3e4ee1a839e10b2d2037382463e0 diff --git a/t/integration/mock_plugin.c b/t/integration/mock_plugin.c index 7e2b4a6..0724ce1 100644 --- a/t/integration/mock_plugin.c +++ b/t/integration/mock_plugin.c @@ -51,6 +51,29 @@ static const char *hostnames[] = { "localhost", }; +static struct { + const char *hostname; + const char *metric; + sdb_metric_store_t store; +} metrics[] = { + { "some.host.name", "foo/bar/qux", + { "mock", "/var/lib/collectd/rrd/foo/bar/qux.rrd", NULL, 0 } }, + { "some.host.name", "foo/bar/baz", + { "mock", "/var/lib/collectd/rrd/foo/bar/baz.rrd", NULL, 0 } }, + { "some.host.name", "foo2/bar/qux", + { "mock", "/var/lib/collectd/rrd/foo2/bar/qux.rrd", NULL, 0 } }, + { "some.host.name", "foo2/bar/baz", + { "mock", "/var/lib/collectd/rrd/foo2/bar/baz.rrd", NULL, 0 } }, + { "other.host.name", "foo/bar/qux", + { "mock", "/var/lib/collectd/rrd/foo/bar/qux.rrd", NULL, 0 } }, + { "other.host.name", "foo/bar/baz", + { "mock", "/var/lib/collectd/rrd/foo/bar/baz.rrd", NULL, 0 } }, + { "other.host.name", "foo2/bar/qux", + { "mock", "/var/lib/collectd/rrd/foo2/bar/qux.rrd", NULL, 0 } }, + { "other.host.name", "foo2/bar/baz", + { "mock", "/var/lib/collectd/rrd/foo2/bar/baz.rrd", NULL, 0 } }, +}; + static struct { const char *hostname; const char *service; @@ -130,14 +153,23 @@ mock_collect(sdb_object_t *user_data) } for (i = 0; i < SDB_STATIC_ARRAY_LEN(hostnames); ++i) { - if ((check = sdb_store_host(hostnames[i], sdb_gettime()))) { + if ((check = sdb_plugin_store_host(hostnames[i], sdb_gettime()))) { sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store host: " "status %d", check); exit(1); } } + for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) { + if ((check = sdb_plugin_store_metric(metrics[i].hostname, + metrics[i].metric, &metrics[i].store, + sdb_gettime()))) { + sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store metric: " + "status %d", check); + exit(1); + } + } for (i = 0; i < SDB_STATIC_ARRAY_LEN(services); ++i) { - if ((check = sdb_store_service(services[i].hostname, + if ((check = sdb_plugin_store_service(services[i].hostname, services[i].service, sdb_gettime()))) { sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store service: " "status %d", check); @@ -148,7 +180,7 @@ mock_collect(sdb_object_t *user_data) sdb_data_t datum = { SDB_TYPE_STRING, { .string = NULL } }; datum.data.string = strdup(attributes[i].value); - if ((check = sdb_store_attribute(attributes[i].hostname, + if ((check = sdb_plugin_store_attribute(attributes[i].hostname, attributes[i].name, &datum, sdb_gettime()))) { sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store attribute: " "status %d", check); @@ -183,9 +215,9 @@ mock_config(oconfig_item_t *ci) exit(1); } - sdb_plugin_register_init("mock::init", mock_init, user_data); - sdb_plugin_register_shutdown("mock::shutdown", mock_shutdown, user_data); - sdb_plugin_register_collector("mock::collect", mock_collect, + sdb_plugin_register_init("main", mock_init, user_data); + sdb_plugin_register_shutdown("main", mock_shutdown, user_data); + sdb_plugin_register_collector("main", mock_collect, /* interval = */ NULL, user_data); sdb_object_deref(user_data); @@ -195,7 +227,6 @@ mock_config(oconfig_item_t *ci) int sdb_module_init(sdb_plugin_info_t *info) { - sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "test::integration::mock"); sdb_plugin_set_info(info, SDB_PLUGIN_INFO_DESC, "a mock plugin"); sdb_plugin_set_info(info, SDB_PLUGIN_INFO_COPYRIGHT, "Copyright (C) 2012 Sebastian 'tokkee' Harl ");