X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Fplugins%2Fbackend%2Fmk-livestatus.c;h=4905d120cdaa6189f5f0560ef9295e70f4bf2ffd;hp=cd8bbd0fc79d395e1d9b8fbb407020e4893dc105;hb=dcf7802ad0958d4752b2c13f70e2fdf345d3509f;hpb=2d39d666abde2d66a55ac4536da3f250d9513f48 diff --git a/src/plugins/backend/mk-livestatus.c b/src/plugins/backend/mk-livestatus.c index cd8bbd0..4905d12 100644 --- a/src/plugins/backend/mk-livestatus.c +++ b/src/plugins/backend/mk-livestatus.c @@ -72,15 +72,14 @@ sdb_livestatus_get_host(sdb_unixsock_client_t __attribute__((unused)) *client, 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 */ @@ -108,15 +107,15 @@ sdb_livestatus_get_svc(sdb_unixsock_client_t __attribute__((unused)) *client, 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 */ @@ -135,14 +134,12 @@ sdb_livestatus_init(sdb_object_t *user_data) 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 */ @@ -173,8 +170,7 @@ sdb_livestatus_collect(sdb_object_t *user_data) 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; } @@ -184,17 +180,15 @@ sdb_livestatus_collect(sdb_object_t *user_data) 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; @@ -203,8 +197,7 @@ sdb_livestatus_collect(sdb_object_t *user_data) 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; } @@ -215,8 +208,7 @@ sdb_livestatus_collect(sdb_object_t *user_data) /* 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; } @@ -224,8 +216,7 @@ sdb_livestatus_collect(sdb_object_t *user_data) 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; @@ -245,8 +236,8 @@ sdb_livestatus_config_instance(oconfig_item_t *ci) int i; if (oconfig_get_string(ci, &name)) { - sdb_log(SDB_LOG_ERR, "MK Livestatus backend: Instance requires " - "a single string argument\n\tUsage: "); + sdb_log(SDB_LOG_ERR, "Instance requires a single string argument\n" + "\tUsage: "); return -1; } @@ -256,22 +247,19 @@ sdb_livestatus_config_instance(oconfig_item_t *ci) 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 .", - child->key, name); + sdb_log(SDB_LOG_WARNING, "Ignoring unknown config option '%s' " + "inside .", 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; } @@ -280,8 +268,7 @@ sdb_livestatus_config_instance(oconfig_item_t *ci) (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; } @@ -309,8 +296,7 @@ sdb_livestatus_config(oconfig_item_t *ci) 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 */