Example #1
0
static void *camqp_subscribe_thread (void *user_data) /* {{{ */
{
    camqp_config_t *conf = user_data;
    int status;

    cdtime_t interval = plugin_get_interval ();

    while (subscriber_threads_running)
    {
        amqp_frame_t frame;

        status = camqp_connect (conf);
        if (status != 0)
        {
            struct timespec ts_interval;
            ERROR ("amqp plugin: camqp_connect failed. "
                    "Will sleep for %.3f seconds.",
                    CDTIME_T_TO_DOUBLE (interval));
            CDTIME_T_TO_TIMESPEC (interval, &ts_interval);
            nanosleep (&ts_interval, /* remaining = */ NULL);
            continue;
        }

        status = amqp_simple_wait_frame (conf->connection, &frame);
        if (status < 0)
        {
            struct timespec ts_interval;
            ERROR ("amqp plugin: amqp_simple_wait_frame failed. "
                    "Will sleep for %.3f seconds.",
                    CDTIME_T_TO_DOUBLE (interval));
            camqp_close_connection (conf);
            CDTIME_T_TO_TIMESPEC (interval, &ts_interval);
            nanosleep (&ts_interval, /* remaining = */ NULL);
            continue;
        }

        if (frame.frame_type != AMQP_FRAME_METHOD)
        {
            DEBUG ("amqp plugin: Unexpected frame type: %#"PRIx8,
                    frame.frame_type);
            continue;
        }

        if (frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD)
        {
            DEBUG ("amqp plugin: Unexpected method id: %#"PRIx32,
                    frame.payload.method.id);
            continue;
        }

        camqp_read_header (conf);

        amqp_maybe_release_buffers (conf->connection);
    } /* while (subscriber_threads_running) */

    camqp_config_free (conf);
    pthread_exit (NULL);
    return (NULL);
} /* }}} void *camqp_subscribe_thread */
Example #2
0
size_t cdtime_to_iso8601 (char *s, size_t max, cdtime_t t) /* {{{ */
{
  struct timespec t_spec;
  struct tm t_tm;

  size_t len;

  CDTIME_T_TO_TIMESPEC (t, &t_spec);
  NORMALIZE_TIMESPEC (t_spec);

  if (localtime_r ((time_t *)&t_spec.tv_sec, &t_tm) == NULL) {
    char errbuf[1024];
    ERROR ("cdtime_to_iso8601: localtime_r failed: %s",
        sstrerror (errno, errbuf, sizeof (errbuf)));
    return (0);
  }

  len = strftime (s, max, "%Y-%m-%dT%H:%M:%S", &t_tm);
  if (len == 0)
    return 0;

  if (max - len > 2) {
    int n = snprintf (s + len, max - len, ".%09i", (int)t_spec.tv_nsec);
    len += (n < max - len) ? n : max - len;
  }

  if (max - len > 3) {
    int n = strftime (s + len, max - len, "%z", &t_tm);
    len += (n < max - len) ? n : max - len;
  }

  s[max - 1] = '\0';
  return len;
} /* }}} size_t cdtime_to_iso8601 */
Example #3
0
static int dns_sleep_one_interval (void) /* {{{ */
{
	cdtime_t interval;
	struct timespec ts = { 0, 0 };
	int status = 0;

	interval = plugin_get_interval ();
	CDTIME_T_TO_TIMESPEC (interval, &ts);

	while (42)
	{
		struct timespec rem = { 0, 0 };

		status = nanosleep (&ts, &rem);
		if (status == 0)
			break;
		else if ((errno == EINTR) || (errno == EAGAIN))
		{
			ts = rem;
			continue;
		}
		else
			break;
	}

	return (status);
} /* }}} int dns_sleep_one_interval */
Example #4
0
static int do_loop(void) {
  cdtime_t interval = cf_get_default_interval();
  cdtime_t wait_until = cdtime() + interval;

  while (loop == 0) {
#if HAVE_LIBKSTAT
    update_kstat();
#endif

    /* Issue all plugins */
    plugin_read_all();

    cdtime_t now = cdtime();
    if (now >= wait_until) {
      WARNING("Not sleeping because the next interval is "
              "%.3f seconds in the past!",
              CDTIME_T_TO_DOUBLE(now - wait_until));
      wait_until = now + interval;
      continue;
    }

    struct timespec ts_wait = CDTIME_T_TO_TIMESPEC(wait_until - now);
    wait_until = wait_until + interval;

    while ((loop == 0) && (nanosleep(&ts_wait, &ts_wait) != 0)) {
      if (errno != EINTR) {
        ERROR("nanosleep failed: %s", STRERRNO);
        return -1;
      }
    }
  } /* while (loop == 0) */

  return 0;
} /* int do_loop */
Example #5
0
/**
 * Non blocking pause for the thread.
 */
static int cgps_thread_pause(cdtime_t pTime)
{
  cdtime_t now;
  now = cdtime ();
  struct timespec pause_th;
  CDTIME_T_TO_TIMESPEC (MS_TO_CDTIME_T(10), &pause_th);
  while (CGPS_TRUE)
  {
    if ( (cdtime () - now) > pTime )
    {
      break;
    }

    pthread_mutex_lock (&cgps_thread_lock);
    if (cgps_thread_shutdown == CGPS_TRUE)
    {
      return CGPS_FALSE;
    }
    pthread_mutex_unlock (&cgps_thread_lock);
    nanosleep (&pause_th, NULL);
 }

 return CGPS_TRUE;
}
Example #6
0
static int format_rfc3339 (char *buffer, size_t buffer_size, cdtime_t t, _Bool print_nano) /* {{{ */
{
  struct timespec t_spec;
  struct tm t_tm;
  char base[20]; /* 2006-01-02T15:04:05 */
  char nano[11]; /* .999999999 */
  char zone[7];  /* +00:00 */
  char *fields[] = {base, nano, zone};
  size_t len;

  CDTIME_T_TO_TIMESPEC (t, &t_spec);
  NORMALIZE_TIMESPEC (t_spec);

  if (localtime_r (&t_spec.tv_sec, &t_tm) == NULL) {
    char errbuf[1024];
    int status = errno;
    ERROR ("format_rfc3339: localtime_r failed: %s",
        sstrerror (status, errbuf, sizeof (errbuf)));
    return (status);
  }

  len = strftime (base, sizeof (base), "%Y-%m-%dT%H:%M:%S", &t_tm);
  if (len == 0)
    return ENOMEM;

  if (print_nano)
    ssnprintf (nano, sizeof (nano), ".%09ld", (long) t_spec.tv_nsec);
  else
    sstrncpy (nano, "", sizeof (nano));

  format_zone (zone, sizeof (zone));

  if (strjoin (buffer, buffer_size, fields, STATIC_ARRAY_SIZE (fields), "") < 0)
    return ENOMEM;
  return 0;
} /* }}} int cdtime_to_rfc3339nano */
Example #7
0
static int c_psql_config_database (oconfig_item_t *ci)
{
	c_psql_database_t *db;

	char cb_name[DATA_MAX_NAME_LEN];
	struct timespec cb_interval = { 0, 0 };
	user_data_t ud;

	int i;

	if ((1 != ci->values_num)
			|| (OCONFIG_TYPE_STRING != ci->values[0].type)) {
		log_err ("<Database> expects a single string argument.");
		return 1;
	}

	memset (&ud, 0, sizeof (ud));

	db = c_psql_database_new (ci->values[0].value.string);
	if (db == NULL)
		return -1;

	for (i = 0; i < ci->children_num; ++i) {
		oconfig_item_t *c = ci->children + i;

		if (0 == strcasecmp (c->key, "Host"))
			cf_util_get_string (c, &db->host);
		else if (0 == strcasecmp (c->key, "Port"))
			cf_util_get_service (c, &db->port);
		else if (0 == strcasecmp (c->key, "User"))
			cf_util_get_string (c, &db->user);
		else if (0 == strcasecmp (c->key, "Password"))
			cf_util_get_string (c, &db->password);
		else if (0 == strcasecmp (c->key, "Instance"))
			cf_util_get_string (c, &db->instance);
		else if (0 == strcasecmp (c->key, "SSLMode"))
			cf_util_get_string (c, &db->sslmode);
		else if (0 == strcasecmp (c->key, "KRBSrvName"))
			cf_util_get_string (c, &db->krbsrvname);
		else if (0 == strcasecmp (c->key, "Service"))
			cf_util_get_string (c, &db->service);
		else if (0 == strcasecmp (c->key, "Query"))
			udb_query_pick_from_list (c, queries, queries_num,
					&db->queries, &db->queries_num);
		else if (0 == strcasecmp (c->key, "Interval"))
			cf_util_get_cdtime (c, &db->interval);
		else
			log_warn ("Ignoring unknown config key \"%s\".", c->key);
	}

	/* If no `Query' options were given, add the default queries.. */
	if (db->queries_num == 0) {
		for (i = 0; i < def_queries_num; i++)
			udb_query_pick_from_list_by_name (def_queries[i],
					queries, queries_num,
					&db->queries, &db->queries_num);
	}

	if (db->queries_num > 0) {
		db->q_prep_areas = (udb_query_preparation_area_t **) calloc (
				db->queries_num, sizeof (*db->q_prep_areas));

		if (db->q_prep_areas == NULL) {
			log_err ("Out of memory.");
			c_psql_database_delete (db);
			return -1;
		}
	}

	for (i = 0; (size_t)i < db->queries_num; ++i) {
		c_psql_user_data_t *data;
		data = udb_query_get_user_data (db->queries[i]);
		if ((data != NULL) && (data->params_num > db->max_params_num))
			db->max_params_num = data->params_num;

		db->q_prep_areas[i]
			= udb_query_allocate_preparation_area (db->queries[i]);

		if (db->q_prep_areas[i] == NULL) {
			log_err ("Out of memory.");
			c_psql_database_delete (db);
			return -1;
		}
	}

	ud.data = db;
	ud.free_func = c_psql_database_delete;

	ssnprintf (cb_name, sizeof (cb_name), "postgresql-%s", db->instance);

	CDTIME_T_TO_TIMESPEC (db->interval, &cb_interval);

	plugin_register_complex_read ("postgresql", cb_name, c_psql_read,
			/* interval = */ (db->interval > 0) ? &cb_interval : NULL,
			&ud);
	return 0;
} /* c_psql_config_database */
Example #8
0
static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */
{
    cj_t *db;
    int status = 0;
    int i;

    if ((ci->values_num != 1)
            || (ci->values[0].type != OCONFIG_TYPE_STRING))
    {
        WARNING ("curl_json plugin: The `URL' block "
                 "needs exactly one string argument.");
        return (-1);
    }

    db = (cj_t *) malloc (sizeof (*db));
    if (db == NULL)
    {
        ERROR ("curl_json plugin: malloc failed.");
        return (-1);
    }
    memset (db, 0, sizeof (*db));

    if (strcasecmp ("URL", ci->key) == 0)
        status = cf_util_get_string (ci, &db->url);
    else if (strcasecmp ("Sock", ci->key) == 0)
        status = cf_util_get_string (ci, &db->sock);
    else
    {
        ERROR ("curl_json plugin: cj_config: "
               "Invalid key: %s", ci->key);
        return (-1);
    }
    if (status != 0)
    {
        sfree (db);
        return (status);
    }

    /* Fill the `cj_t' structure.. */
    for (i = 0; i < ci->children_num; i++)
    {
        oconfig_item_t *child = ci->children + i;

        if (strcasecmp ("Instance", child->key) == 0)
            status = cf_util_get_string (child, &db->instance);
        else if (strcasecmp ("Host", child->key) == 0)
            status = cf_util_get_string (child, &db->host);
        else if (db->url && strcasecmp ("User", child->key) == 0)
            status = cf_util_get_string (child, &db->user);
        else if (db->url && strcasecmp ("Password", child->key) == 0)
            status = cf_util_get_string (child, &db->pass);
        else if (strcasecmp ("Digest", child->key) == 0)
            status = cf_util_get_boolean (child, &db->digest);
        else if (db->url && strcasecmp ("VerifyPeer", child->key) == 0)
            status = cf_util_get_boolean (child, &db->verify_peer);
        else if (db->url && strcasecmp ("VerifyHost", child->key) == 0)
            status = cf_util_get_boolean (child, &db->verify_host);
        else if (db->url && strcasecmp ("CACert", child->key) == 0)
            status = cf_util_get_string (child, &db->cacert);
        else if (db->url && strcasecmp ("Header", child->key) == 0)
            status = cj_config_append_string ("Header", &db->headers, child);
        else if (db->url && strcasecmp ("Post", child->key) == 0)
            status = cf_util_get_string (child, &db->post_body);
        else if (strcasecmp ("Key", child->key) == 0)
            status = cj_config_add_key (db, child);
        else if (strcasecmp ("Interval", child->key) == 0)
            status = cf_util_get_cdtime(child, &db->interval);
        else
        {
            WARNING ("curl_json plugin: Option `%s' not allowed here.", child->key);
            status = -1;
        }

        if (status != 0)
            break;
    }

    if (status == 0)
    {
        if (db->tree == NULL)
        {
            WARNING ("curl_json plugin: No (valid) `Key' block within `%s' \"`%s'\".",
                     db->url ? "URL" : "Sock", db->url ? db->url : db->sock);
            status = -1;
        }
        if (status == 0 && db->url)
            status = cj_init_curl (db);
    }

    /* If all went well, register this database for reading */
    if (status == 0)
    {
        user_data_t ud;
        char *cb_name;
        struct timespec interval = { 0, 0 };

        CDTIME_T_TO_TIMESPEC (db->interval, &interval);

        if (db->instance == NULL)
            db->instance = strdup("default");

        DEBUG ("curl_json plugin: Registering new read callback: %s",
               db->instance);

        memset (&ud, 0, sizeof (ud));
        ud.data = (void *) db;
        ud.free_func = cj_free;

        cb_name = ssnprintf_alloc ("curl_json-%s-%s",
                                   db->instance, db->url ? db->url : db->sock);

        plugin_register_complex_read (/* group = */ NULL, cb_name, cj_read,
                /* interval = */ (db->interval > 0) ? &interval : NULL,
                &ud);
        sfree (cb_name);
    }
    else
    {
        cj_free (db);
        return (-1);
    }

    return (0);
}
Example #9
0
static int mb_config_add_host (oconfig_item_t *ci) /* {{{ */
{
  mb_host_t *host;
  int status;
  int i;

  host = malloc (sizeof (*host));
  if (host == NULL)
    return (ENOMEM);
  memset (host, 0, sizeof (*host));
  host->slaves = NULL;

  status = cf_util_get_string_buffer (ci, host->host, sizeof (host->host));
  if (status != 0)
    return (status);
  if (host->host[0] == 0)
    return (EINVAL);

  for (i = 0; i < ci->children_num; i++)
  {
    oconfig_item_t *child = ci->children + i;
    status = 0;

    if (strcasecmp ("Address", child->key) == 0)
    {
      char buffer[NI_MAXHOST];
      status = cf_util_get_string_buffer (child, buffer, sizeof (buffer));
      if (status == 0)
        status = mb_config_set_host_address (host, buffer);
    }
    else if (strcasecmp ("Port", child->key) == 0)
    {
      host->port = cf_util_get_port_number (child);
      if (host->port <= 0)
        status = -1;
    }
    else if (strcasecmp ("Interval", child->key) == 0)
      status = cf_util_get_cdtime (child, &host->interval);
    else if (strcasecmp ("Slave", child->key) == 0)
      /* Don't set status: Gracefully continue if a slave fails. */
      mb_config_add_slave (host, child);
    else
    {
      ERROR ("Modbus plugin: Unknown configuration option: %s", child->key);
      status = -1;
    }

    if (status != 0)
      break;
  } /* for (i = 0; i < ci->children_num; i++) */

  assert (host->host[0] != 0);
  if (host->host[0] == 0)
  {
    ERROR ("Modbus plugin: Data block \"%s\": No type has been specified.",
        host->host);
    status = -1;
  }

  if (status == 0)
  {
    user_data_t ud;
    char name[1024];
    struct timespec interval = { 0, 0 };

    ud.data = host;
    ud.free_func = host_free;

    ssnprintf (name, sizeof (name), "modbus-%s", host->host);

    CDTIME_T_TO_TIMESPEC (host->interval, &interval);

    plugin_register_complex_read (/* group = */ NULL, name,
        /* callback = */ mb_read,
        /* interval = */ (host->interval > 0) ? &interval : NULL,
        &ud);
  }
  else
  {
    host_free (host);
  }

  return (status);
} /* }}} int mb_config_add_host */
Example #10
0
static int csnmp_config_add_host (oconfig_item_t *ci)
{
  host_definition_t *hd;
  int status = 0;
  int i;

  /* Registration stuff. */
  char cb_name[DATA_MAX_NAME_LEN];
  user_data_t cb_data;
  struct timespec cb_interval;

  hd = (host_definition_t *) malloc (sizeof (host_definition_t));
  if (hd == NULL)
    return (-1);
  memset (hd, '\0', sizeof (host_definition_t));
  hd->version = 2;
  C_COMPLAIN_INIT (&hd->complaint);

  status = cf_util_get_string(ci, &hd->name);
  if (status != 0)
    return status;

  hd->sess_handle = NULL;
  hd->interval = 0;

  for (i = 0; i < ci->children_num; i++)
  {
    oconfig_item_t *option = ci->children + i;
    status = 0;

    if (strcasecmp ("Address", option->key) == 0)
      status = cf_util_get_string(option, &hd->address);
    else if (strcasecmp ("Community", option->key) == 0)
      status = cf_util_get_string(option, &hd->community);
    else if (strcasecmp ("Version", option->key) == 0)
      status = csnmp_config_add_host_version (hd, option);
    else if (strcasecmp ("Collect", option->key) == 0)
      csnmp_config_add_host_collect (hd, option);
    else if (strcasecmp ("Interval", option->key) == 0)
      cf_util_get_cdtime (option, &hd->interval);
    else if (strcasecmp ("Username", option->key) == 0)
      status = cf_util_get_string(option, &hd->username);
    else if (strcasecmp ("AuthProtocol", option->key) == 0)
      status = csnmp_config_add_host_auth_protocol (hd, option);
    else if (strcasecmp ("PrivacyProtocol", option->key) == 0)
      status = csnmp_config_add_host_priv_protocol (hd, option);
    else if (strcasecmp ("AuthPassphrase", option->key) == 0)
      status = cf_util_get_string(option, &hd->auth_passphrase);
    else if (strcasecmp ("PrivacyPassphrase", option->key) == 0)
      status = cf_util_get_string(option, &hd->priv_passphrase);
    else if (strcasecmp ("SecurityLevel", option->key) == 0)
      status = csnmp_config_add_host_security_level (hd, option);
    else if (strcasecmp ("Context", option->key) == 0)
      status = cf_util_get_string(option, &hd->context);
    else
    {
      WARNING ("snmp plugin: csnmp_config_add_host: Option `%s' not allowed here.", option->key);
      status = -1;
    }

    if (status != 0)
      break;
  } /* for (ci->children) */

  while (status == 0)
  {
    if (hd->address == NULL)
    {
      WARNING ("snmp plugin: `Address' not given for host `%s'", hd->name);
      status = -1;
      break;
    }
    if (hd->community == NULL && hd->version < 3)
    {
      WARNING ("snmp plugin: `Community' not given for host `%s'", hd->name);
      status = -1;
      break;
    }
    if (hd->version == 3)
    {
      if (hd->username == NULL)
      {
        WARNING ("snmp plugin: `Username' not given for host `%s'", hd->name);
        status = -1;
        break;
      }
      if (hd->security_level == 0)
      {
        WARNING ("snmp plugin: `SecurityLevel' not given for host `%s'", hd->name);
        status = -1;
        break;
      }
      if (hd->security_level == SNMP_SEC_LEVEL_AUTHNOPRIV || hd->security_level == SNMP_SEC_LEVEL_AUTHPRIV)
      {
	if (hd->auth_protocol == NULL)
	{
	  WARNING ("snmp plugin: `AuthProtocol' not given for host `%s'", hd->name);
	  status = -1;
	  break;
	}
	if (hd->auth_passphrase == NULL)
	{
	  WARNING ("snmp plugin: `AuthPassphrase' not given for host `%s'", hd->name);
	  status = -1;
	  break;
	}
      }
      if (hd->security_level == SNMP_SEC_LEVEL_AUTHPRIV)
      {
	if (hd->priv_protocol == NULL)
	{
	  WARNING ("snmp plugin: `PrivacyProtocol' not given for host `%s'", hd->name);
	  status = -1;
	  break;
	}
	if (hd->priv_passphrase == NULL)
	{
	  WARNING ("snmp plugin: `PrivacyPassphrase' not given for host `%s'", hd->name);
	  status = -1;
	  break;
	}
      }
    }

    break;
  } /* while (status == 0) */

  if (status != 0)
  {
    csnmp_host_definition_destroy (hd);
    return (-1);
  }

  DEBUG ("snmp plugin: hd = { name = %s, address = %s, community = %s, version = %i }",
      hd->name, hd->address, hd->community, hd->version);

  ssnprintf (cb_name, sizeof (cb_name), "snmp-%s", hd->name);

  memset (&cb_data, 0, sizeof (cb_data));
  cb_data.data = hd;
  cb_data.free_func = csnmp_host_definition_destroy;

  CDTIME_T_TO_TIMESPEC (hd->interval, &cb_interval);

  status = plugin_register_complex_read (/* group = */ NULL, cb_name,
      csnmp_read_host, /* interval = */ &cb_interval,
      /* user_data = */ &cb_data);
  if (status != 0)
  {
    ERROR ("snmp plugin: Registering complex read function failed.");
    csnmp_host_definition_destroy (hd);
    return (-1);
  }

  return (0);
} /* int csnmp_config_add_host */
Example #11
0
static int csnmp_config_add_host (oconfig_item_t *ci)
{
  host_definition_t *hd;
  int status = 0;
  int i;

  /* Registration stuff. */
  char cb_name[DATA_MAX_NAME_LEN];
  user_data_t cb_data;
  struct timespec cb_interval;

  if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
  {
    WARNING ("snmp plugin: `Host' needs exactly one string argument.");
    return (-1);
  }

  hd = (host_definition_t *) malloc (sizeof (host_definition_t));
  if (hd == NULL)
    return (-1);
  memset (hd, '\0', sizeof (host_definition_t));
  hd->version = 2;
  C_COMPLAIN_INIT (&hd->complaint);

  hd->name = strdup (ci->values[0].value.string);
  if (hd->name == NULL)
  {
    free (hd);
    return (-1);
  }

  hd->sess_handle = NULL;
  hd->interval = 0;

  for (i = 0; i < ci->children_num; i++)
  {
    oconfig_item_t *option = ci->children + i;
    status = 0;

    if (strcasecmp ("Address", option->key) == 0)
      status = csnmp_config_add_host_address (hd, option);
    else if (strcasecmp ("Community", option->key) == 0)
      status = csnmp_config_add_host_community (hd, option);
    else if (strcasecmp ("Version", option->key) == 0)
      status = csnmp_config_add_host_version (hd, option);
    else if (strcasecmp ("Collect", option->key) == 0)
      csnmp_config_add_host_collect (hd, option);
    else if (strcasecmp ("Interval", option->key) == 0)
      cf_util_get_cdtime (option, &hd->interval);
    else
    {
      WARNING ("snmp plugin: csnmp_config_add_host: Option `%s' not allowed here.", option->key);
      status = -1;
    }

    if (status != 0)
      break;
  } /* for (ci->children) */

  while (status == 0)
  {
    if (hd->address == NULL)
    {
      WARNING ("snmp plugin: `Address' not given for host `%s'", hd->name);
      status = -1;
      break;
    }
    if (hd->community == NULL)
    {
      WARNING ("snmp plugin: `Community' not given for host `%s'", hd->name);
      status = -1;
      break;
    }

    break;
  } /* while (status == 0) */

  if (status != 0)
  {
    csnmp_host_definition_destroy (hd);
    return (-1);
  }

  DEBUG ("snmp plugin: hd = { name = %s, address = %s, community = %s, version = %i }",
      hd->name, hd->address, hd->community, hd->version);

  ssnprintf (cb_name, sizeof (cb_name), "snmp-%s", hd->name);

  memset (&cb_data, 0, sizeof (cb_data));
  cb_data.data = hd;
  cb_data.free_func = csnmp_host_definition_destroy;

  CDTIME_T_TO_TIMESPEC (hd->interval, &cb_interval);

  status = plugin_register_complex_read (/* group = */ NULL, cb_name,
      csnmp_read_host, /* interval = */ &cb_interval,
      /* user_data = */ &cb_data);
  if (status != 0)
  {
    ERROR ("snmp plugin: Registering complex read function failed.");
    csnmp_host_definition_destroy (hd);
    return (-1);
  }

  return (0);
} /* int csnmp_config_add_host */