Code

Merged branch 'master' of git://git.tokkee.org/sysdb.git.
authorSebastian Harl <sh@tokkee.org>
Tue, 5 Mar 2013 01:11:13 +0000 (02:11 +0100)
committerSebastian Harl <sh@tokkee.org>
Tue, 5 Mar 2013 01:11:13 +0000 (02:11 +0100)
README
configure.ac
m4/sdb_plugin.m4
src/backend/collectd.c
src/backend/mk-livestatus.c
src/core/store.c
src/daemon/sysdbd.c
src/utils/llist.c

diff --git a/README b/README
index 55a8be8f983d92bb0b6deecde500f8bcadd3fce1..56dde37d9365cbc8ac73939635b6880844140992 100644 (file)
--- a/README
+++ b/README
@@ -19,9 +19,13 @@ Prerequisites
 
   * A build environment: autotools, libtool, C compiler, ...
 
+  * When building from Git, you also need the flex lexical analyzer generator
+    and bison parser generator (other lex and yacc compatible tools might work
+    as well if you are lucky).
+
   * A POSIX + Single UNIX Specification compatible C library.
 
-  * asciidoc, xsltproc:
+  * asciidoc, xsltproc, xmlto:
     The AsciiDoc text document format is used to write the manpages.
 
 Configuring / Compiling / Installing
index fac681dc116fa66328ae29bf834d25cbf6e23486..dfcb64fad94b97f47c03271adbe277b43fef08c7 100644 (file)
@@ -171,8 +171,7 @@ if test "x$enable_strict_checks" = "xyes"; then
                        -Wmissing-prototypes \
                        -Wpointer-arith \
                        -Wshadow \
-                       -Wstrict-prototypes \
-                       -Wunreachable-code; do
+                       -Wstrict-prototypes; do
                AC_MSG_CHECKING([whether $CC accepts $flag])
 
                if test_cc_flags $flag; then
@@ -207,6 +206,13 @@ AM_CONDITIONAL([BUILD_WITH_LIBDBI], test "x$with_libdbi" = "xyes")
 dnl Feature checks.
 build_documentation="yes"
 
+have_xmlto="yes"
+AC_PATH_PROG([XMLTO], [xmlto])
+if test "x$XMLTO" = "x"; then
+       have_xmlto="no"
+       build_documentation="no (missing xmlto)"
+fi
+
 have_xsltproc="yes"
 AC_PATH_PROG([XSLTPROC], [xsltproc])
 if test "x$XSLTPROC" = "x"; then
@@ -223,9 +229,9 @@ fi
 AC_SUBST([A2X])
 
 dnl Plugin checks.
-enable_puppet_storeconfigs=$with_libdbi
-if test "x$enable_puppet_storeconfigs" = "xno"; then
-       enable_puppet_storeconfigs="no (requires libdbi)"
+puppet_storeconfigs_default=$with_libdbi
+if test "x$puppet_storeconfigs_default" != "xyes"; then
+       puppet_storeconfigs_default="no (requires libdbi)"
 fi
 
 m4_divert_once([HELP_ENABLE], [
@@ -236,7 +242,7 @@ AC_SDB_PLUGIN([collectd], [yes],
                [backend accessing the system statistics collection daemon])
 AC_SDB_PLUGIN([mk-livestatus], [yes],
                [backend accessing Nagios/Icinga/Shinken using MK Livestatus])
-AC_SDB_PLUGIN([puppet-storeconfigs], [$enable_puppet_storeconfigs],
+AC_SDB_PLUGIN([puppet-storeconfigs], [$puppet_storeconfigs_default],
                [backend accessing the Puppet stored configuration database])
 
 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
@@ -260,7 +266,7 @@ AC_MSG_RESULT([  build date: $BUILD_DATE])
 AC_MSG_RESULT()
 AC_MSG_RESULT([  Tools:])
 AC_MSG_RESULT([    AsciiDoc (a2x): . . . . . . $have_a2x])
-AC_MSG_RESULT([    xsltproc: . . . . . . . . . $have_xsltproc])
+AC_MSG_RESULT([    xmlto / xsltproc: . . . . . $have_xmlto / $have_xsltproc])
 AC_MSG_RESULT()
 AC_MSG_RESULT([  Features:])
 AC_MSG_RESULT([    documentation:  . . . . . . $build_documentation])
index 1cf916cf4805eb692e7056e49bec78d90f9ed72e..e734e0d0b9bffb14688ae3dfb045ace05b92c09c 100644 (file)
@@ -60,7 +60,7 @@ AC_DEFUN([AC_SDB_PLUGIN],
                                if test "x$2" = "xyes"; then
                                        enable_plugin="yes"
                                else
-                                       enable_plugin="no"
+                                       enable_plugin="$2"
                                fi
                         else
                                enable_plugin="$enable_all_plugins"
index f745fc9316d66e9849c219c4ebe2e1d3769a78a9..e0e924e2c959e946f7e645a6879aba0be5ede13c 100644 (file)
@@ -294,7 +294,7 @@ static int
 sdb_collectd_config_instance(oconfig_item_t *ci)
 {
        char *name = NULL;
-       char *socket = NULL;
+       char *socket_path = NULL;
 
        char cb_name[1024];
 
@@ -313,14 +313,14 @@ sdb_collectd_config_instance(oconfig_item_t *ci)
                oconfig_item_t *child = ci->children + i;
 
                if (! strcasecmp(child->key, "Socket"))
-                       oconfig_get_string(child, &socket);
+                       oconfig_get_string(child, &socket_path);
                else
                        fprintf(stderr, "collectd backend: Ignoring unknown config "
                                        "option '%s' inside <Instance %s>.\n",
                                        child->key, name);
        }
 
-       if (! socket) {
+       if (! socket_path) {
                fprintf(stderr, "collectd backend: Instance '%s' missing "
                                "the 'Socket' option.\n", name);
                return -1;
@@ -329,7 +329,7 @@ sdb_collectd_config_instance(oconfig_item_t *ci)
        snprintf(cb_name, sizeof(cb_name), "collectd-%s", name);
        cb_name[sizeof(cb_name) - 1] = '\0';
 
-       client = sdb_unixsock_client_create(socket);
+       client = sdb_unixsock_client_create(socket_path);
        if (! client) {
                char errbuf[1024];
                fprintf(stderr, "collectd backend: Failed to create unixsock client: "
index 57fda523ddf9c81419bb6b565e0d7b305be834fe..a5126fb037e8c3e9a70412b989692b3bdb1e6c3e 100644 (file)
@@ -238,7 +238,7 @@ static int
 sdb_livestatus_config_instance(oconfig_item_t *ci)
 {
        char *name = NULL;
-       char *socket = NULL;
+       char *socket_path = NULL;
 
        char cb_name[1024];
 
@@ -257,14 +257,14 @@ sdb_livestatus_config_instance(oconfig_item_t *ci)
                oconfig_item_t *child = ci->children + i;
 
                if (! strcasecmp(child->key, "Socket"))
-                       oconfig_get_string(child, &socket);
+                       oconfig_get_string(child, &socket_path);
                else
                        fprintf(stderr, "MK Livestatus backend: Ignoring unknown config "
                                        "option '%s' inside <Instance %s>.\n",
                                        child->key, name);
        }
 
-       if (! socket) {
+       if (! socket_path) {
                fprintf(stderr, "MK Livestatus backend: Instance '%s' missing "
                                "the 'Socket' option.\n", name);
                return -1;
@@ -273,7 +273,7 @@ sdb_livestatus_config_instance(oconfig_item_t *ci)
        snprintf(cb_name, sizeof(cb_name), "mk-livestatus-%s", name);
        cb_name[sizeof(cb_name) - 1] = '\0';
 
-       client = sdb_unixsock_client_create(socket);
+       client = sdb_unixsock_client_create(socket_path);
        if (! client) {
                char errbuf[1024];
                fprintf(stderr, "MK Livestatus backend: Failed to create unixsock "
index e5cd886aae31be9bb1d35be92e9f42b7d729e4b5..cbd5f0c05595ccdca54ce2dba48b02d386fed972 100644 (file)
@@ -197,33 +197,33 @@ sdb_host_create(const char *name)
 sdb_host_t *
 sdb_host_clone(const sdb_host_t *host)
 {
-       sdb_host_t *clone;
+       sdb_host_t *new;
 
-       clone = sdb_host_create(host->host_name);
-       if (! clone)
+       new = sdb_host_create(host->host_name);
+       if (! new)
                return NULL;
 
        /* make sure these are initialized; else sdb_object_deref() might access
         * arbitrary memory in case of an error */
-       clone->services = clone->attributes = NULL;
+       new->services = new->attributes = NULL;
 
        if (host->attributes) {
-               clone->attributes = sdb_llist_clone(host->attributes);
-               if (! clone->attributes) {
-                       sdb_object_deref(SDB_OBJ(clone));
+               new->attributes = sdb_llist_clone(host->attributes);
+               if (! new->attributes) {
+                       sdb_object_deref(SDB_OBJ(new));
                        return NULL;
                }
        }
 
-       clone->host_last_update = host->host_last_update;
+       new->host_last_update = host->host_last_update;
        if (host->services) {
-               clone->services = sdb_llist_clone(host->services);
-               if (! clone->services) {
-                       sdb_object_deref(SDB_OBJ(clone));
+               new->services = sdb_llist_clone(host->services);
+               if (! new->services) {
+                       sdb_object_deref(SDB_OBJ(new));
                        return NULL;
                }
        }
-       return clone;
+       return new;
 } /* sdb_host_clone */
 
 int
@@ -350,15 +350,15 @@ sdb_attribute_create(const char *hostname,
 sdb_attribute_t *
 sdb_attribute_clone(const sdb_attribute_t *attr)
 {
-       sdb_attribute_t *clone;
+       sdb_attribute_t *new;
 
-       clone = sdb_attribute_create(attr->hostname,
+       new = sdb_attribute_create(attr->hostname,
                        attr->attr_name, attr->attr_value);
-       if (! clone)
+       if (! new)
                return NULL;
 
-       clone->attr_last_update = attr->attr_last_update;
-       return clone;
+       new->attr_last_update = attr->attr_last_update;
+       return new;
 } /* sdb_attribute_clone */
 
 int
@@ -450,14 +450,14 @@ sdb_service_create(const char *hostname, const char *name)
 sdb_service_t *
 sdb_service_clone(const sdb_service_t *svc)
 {
-       sdb_service_t *clone;
+       sdb_service_t *new;
 
-       clone = sdb_service_create(svc->hostname, svc->svc_name);
-       if (! clone)
+       new = sdb_service_create(svc->hostname, svc->svc_name);
+       if (! new)
                return NULL;
 
-       clone->svc_last_update = svc->svc_last_update;
-       return clone;
+       new->svc_last_update = svc->svc_last_update;
+       return new;
 } /* sdb_service_clone */
 
 int
index 8b7ebd49131262cf8e835a87ab3be9a06b80fba9..ef53a24693a909810108aa113c9c3a8a5843fa08 100644 (file)
@@ -157,7 +157,7 @@ int
 main(int argc, char **argv)
 {
        char *config_filename = NULL;
-       _Bool daemon = 0;
+       _Bool do_daemonize = 0;
 
        struct sigaction sa_intterm;
 
@@ -172,7 +172,7 @@ main(int argc, char **argv)
                                config_filename = optarg;
                                break;
                        case 'd':
-                               daemon = 1;
+                               do_daemonize = 1;
                                break;
 
                        case 'h':
@@ -214,7 +214,7 @@ main(int argc, char **argv)
                exit(1);
        }
 
-       if (daemon)
+       if (do_daemonize)
                if (daemonize())
                        exit(1);
 
index e853001bc45bf7fd9a02f55961930105f89366cf..7d573cfa7449ca1dba229e18702fbac009d688c5 100644 (file)
@@ -167,28 +167,28 @@ sdb_llist_create(void)
 sdb_llist_t *
 sdb_llist_clone(sdb_llist_t *list)
 {
-       sdb_llist_t *clone;
+       sdb_llist_t *new;
        sdb_llist_elem_t *elem;
 
        if (! list)
                return NULL;
 
-       clone = sdb_llist_create();
-       if (! clone)
+       new = sdb_llist_create();
+       if (! new)
                return NULL;
 
        if (! list->length) {
                assert((! list->head) && (! list->tail));
-               return clone;
+               return new;
        }
 
        for (elem = list->head; elem; elem = elem->next) {
-               if (sdb_llist_append(clone, elem->obj)) {
-                       sdb_llist_destroy(clone);
+               if (sdb_llist_append(new, elem->obj)) {
+                       sdb_llist_destroy(new);
                        return NULL;
                }
        }
-       return clone;
+       return new;
 } /* sdb_llist_clone */
 
 void