index 599758bb7e9042ba31a9a555b6df11fad9d0b6fb..4905d120cdaa6189f5f0560ef9295e70f4bf2ffd 100644 (file)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
SDB_PLUGIN_MAGIC;
hostname = data[0].data.string;
timestamp = data[1].data.datetime;
- status = sdb_store_host(hostname, timestamp);
+ status = sdb_plugin_store_host(hostname, timestamp);
if (status < 0) {
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to "
- "store/update host '%s'.", hostname);
+ sdb_log(SDB_LOG_ERR, "Failed to store/update host '%s'.", hostname);
return -1;
}
else if (status > 0) /* value too old */
return 0;
- sdb_log(SDB_LOG_DEBUG, "MK Livestatus backend: Added/updated "
- "host '%s' (last update timestamp = %"PRIsdbTIME").",
+ sdb_log(SDB_LOG_DEBUG, "Added/updated host '%s' "
+ "(last update timestamp = %"PRIsdbTIME").",
hostname, timestamp);
return 0;
} /* sdb_livestatus_get_host */
svcname = data[1].data.string;
timestamp = data[2].data.datetime;
- status = sdb_store_service(hostname, svcname, timestamp);
+ status = sdb_plugin_store_service(hostname, svcname, timestamp);
if (status < 0) {
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to "
- "store/update service '%s / %s'.", hostname, svcname);
+ sdb_log(SDB_LOG_ERR, "Failed to store/update service '%s / %s'.",
+ hostname, svcname);
return -1;
}
else if (status > 0) /* value too old */
return 0;
- sdb_log(SDB_LOG_DEBUG, "MK Livestatus backend: Added/updated "
- "service '%s / %s' (last update timestamp = %"PRIsdbTIME").",
+ sdb_log(SDB_LOG_DEBUG, "Added/updated service '%s / %s' "
+ "(last update timestamp = %"PRIsdbTIME").",
hostname, svcname, timestamp);
return 0;
} /* sdb_livestatus_get_svc */
client = SDB_OBJ_WRAPPER(user_data)->data;
if (sdb_unixsock_client_connect(client)) {
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: "
- "Failed to connect to livestatus @ %s.",
+ sdb_log(SDB_LOG_ERR, "Failed to connect to livestatus @ %s.",
sdb_unixsock_client_path(client));
return -1;
}
- sdb_log(SDB_LOG_INFO, "MK Livestatus backend: Successfully "
- "connected to livestatus @ %s.",
+ sdb_log(SDB_LOG_INFO, "Successfully connected to livestatus @ %s.",
sdb_unixsock_client_path(client));
return 0;
} /* sdb_livestatus_init */
status = sdb_unixsock_client_send(client, "GET hosts\r\n"
"Columns: name last_check");
if (status <= 0) {
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to send "
- "'GET hosts' command to livestatus @ %s.",
+ sdb_log(SDB_LOG_ERR, "Failed to send 'GET hosts' command to livestatus @ %s.",
sdb_unixsock_client_path(client));
return -1;
}
if (sdb_unixsock_client_process_lines(client, sdb_livestatus_get_host,
/* user data */ NULL, /* -> EOF */ -1, /* delim */ ";",
/* column count */ 2, SDB_TYPE_STRING, SDB_TYPE_DATETIME)) {
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to read "
- "response from livestatus @ %s while reading hosts.",
- sdb_unixsock_client_path(client));
+ sdb_log(SDB_LOG_ERR, "Failed to read response from livestatus @ %s "
+ "while reading hosts.", sdb_unixsock_client_path(client));
return -1;
}
if ((! sdb_unixsock_client_eof(client))
|| sdb_unixsock_client_error(client)) {
char errbuf[1024];
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to read "
- "host from livestatus @ %s: %s",
+ sdb_log(SDB_LOG_ERR, "Failed to read host from livestatus @ %s: %s",
sdb_unixsock_client_path(client),
sdb_strerror(errno, errbuf, sizeof(errbuf)));
return -1;
status = sdb_unixsock_client_send(client, "GET services\r\n"
"Columns: host_name description last_check");
if (status <= 0) {
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to send "
- "'GET services' command to livestatus @ %s.",
+ sdb_log(SDB_LOG_ERR, "Failed to send 'GET services' command to livestatus @ %s.",
sdb_unixsock_client_path(client));
return -1;
}
/* user data */ NULL, /* -> EOF */ -1, /* delim */ ";",
/* column count */ 3, SDB_TYPE_STRING, SDB_TYPE_STRING,
SDB_TYPE_DATETIME)) {
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to read "
- "response from livestatus @ %s while reading services.",
+ sdb_log(SDB_LOG_ERR, "Failed to read response from livestatus @ %s while reading services.",
sdb_unixsock_client_path(client));
return -1;
}
if ((! sdb_unixsock_client_eof(client))
|| sdb_unixsock_client_error(client)) {
char errbuf[1024];
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to read "
- "services from livestatus @ %s: %s",
+ sdb_log(SDB_LOG_ERR, "Failed to read services from livestatus @ %s: %s",
sdb_unixsock_client_path(client),
sdb_strerror(errno, errbuf, sizeof(errbuf)));
return -1;
int i;
if (oconfig_get_string(ci, &name)) {
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Instance requires "
- "a single string argument\n\tUsage: <Instance NAME>");
+ sdb_log(SDB_LOG_ERR, "Instance requires a single string argument\n"
+ "\tUsage: <Instance NAME>");
return -1;
}
if (! strcasecmp(child->key, "Socket"))
oconfig_get_string(child, &socket_path);
else
- sdb_log(SDB_LOG_WARNING, "MK Livestatus backend: Ignoring "
- "unknown config option '%s' inside <Instance %s>.",
- child->key, name);
+ sdb_log(SDB_LOG_WARNING, "Ignoring unknown config option '%s' "
+ "inside <Instance %s>.", child->key, name);
}
if (! socket_path) {
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Instance '%s' "
- "missing the 'Socket' option.", name);
+ sdb_log(SDB_LOG_ERR, "Instance '%s' missing the 'Socket' option.", name);
return -1;
}
client = sdb_unixsock_client_create(socket_path);
if (! client) {
char errbuf[1024];
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to create "
- "unixsock client: %s",
+ sdb_log(SDB_LOG_ERR, "Failed to create unixsock client: %s",
sdb_strerror(errno, errbuf, sizeof(errbuf)));
return -1;
}
(void (*)(void *))sdb_unixsock_client_destroy);
if (! user_data) {
sdb_unixsock_client_destroy(client);
- sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Failed to "
- "allocate sdb_object_t");
+ sdb_log(SDB_LOG_ERR, "Failed to allocate sdb_object_t");
return -1;
}
if (! strcasecmp(child->key, "Instance"))
sdb_livestatus_config_instance(child);
else
- sdb_log(SDB_LOG_WARNING, "MK Livestatus backend: Ignoring "
- "unknown config option '%s'.", child->key);
+ sdb_log(SDB_LOG_WARNING, "Ignoring unknown config option '%s'.", child->key);
}
return 0;
} /* sdb_livestatus_config */
sdb_plugin_register_config(sdb_livestatus_config);
return 0;
-} /* sdb_version_extra */
+} /* sdb_module_init */
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */