コード例 #1
0
ファイル: afmongodb.c プロジェクト: pgit/syslog-ng-3.4
LogDriver *
afmongodb_dd_new(void)
{
  MongoDBDestDriver *self = g_new0(MongoDBDestDriver, 1);

  mongo_util_oid_init (0);

  log_dest_driver_init_instance(&self->super);
  self->super.super.super.init = afmongodb_dd_init;
  self->super.super.super.deinit = afmongodb_dd_deinit;
  self->super.super.super.queue = afmongodb_dd_queue;
  self->super.super.super.free_fn = afmongodb_dd_free;

  afmongodb_dd_set_servers((LogDriver *)self, g_list_append (NULL, g_strdup ("127.0.0.1:27017")));
  afmongodb_dd_set_database((LogDriver *)self, "syslog");
  afmongodb_dd_set_collection((LogDriver *)self, "messages");
  afmongodb_dd_set_safe_mode((LogDriver *)self, FALSE);

  init_sequence_number(&self->seq_num);

  self->writer_thread_wakeup_cond = g_cond_new();
  self->suspend_mutex = g_mutex_new();
  self->queue_mutex = g_mutex_new();

  return (LogDriver *)self;
}
コード例 #2
0
ファイル: afamqp.c プロジェクト: grunya404/syslog-ng-3.4
LogDriver *
afamqp_dd_new(void)
{
  AMQPDestDriver *self = g_new0(AMQPDestDriver, 1);

  log_dest_driver_init_instance(&self->super);
  self->super.super.super.init = afamqp_dd_init;
  self->super.super.super.deinit = afamqp_dd_deinit;
  self->super.super.super.queue = afamqp_dd_queue;
  self->super.super.super.free_fn = afamqp_dd_free;

  self->routing_key_template = log_template_new(configuration, NULL);

  afamqp_dd_set_vhost((LogDriver *) self, "/");
  afamqp_dd_set_host((LogDriver *) self, "127.0.0.1");
  afamqp_dd_set_port((LogDriver *) self, 5672);
  afamqp_dd_set_exchange((LogDriver *) self, "syslog");
  afamqp_dd_set_exchange_type((LogDriver *) self, "fanout");
  afamqp_dd_set_routing_key((LogDriver *) self, "");
  afamqp_dd_set_persistent((LogDriver *) self, TRUE);
  afamqp_dd_set_exchange_declare((LogDriver *) self, FALSE);

  init_sequence_number(&self->seq_num);

  self->writer_thread_wakeup_cond = g_cond_new();
  self->suspend_mutex = g_mutex_new();
  self->queue_mutex = g_mutex_new();

  self->max_entries = 256;
  self->entries = g_new(amqp_table_entry_t, self->max_entries);

  return (LogDriver *) self;
}
コード例 #3
0
LogDriver *
perl_dd_new(GlobalConfig *cfg)
{
  PerlDestDriver *self = g_new0(PerlDestDriver, 1);

  log_threaded_dest_driver_init_instance(&self->super);

  self->super.super.super.super.init = perl_worker_init;
  self->super.super.super.super.free_fn = perl_dd_free;

  self->super.worker.thread_init = _perl_thread_init;
  self->super.worker.thread_deinit = _perl_thread_deinit;
  self->super.worker.disconnect = NULL;
  self->super.worker.insert = perl_worker_eval;

  self->super.format.stats_instance = perl_dd_format_stats_instance;
  self->super.format.persist_name = perl_dd_format_persist_name;
  self->super.stats_source = SCS_PERL;

  init_sequence_number(&self->seq_num);

  log_template_options_defaults(&self->template_options);
  perl_dd_set_value_pairs(&self->super.super.super, value_pairs_new_default(cfg));

  return (LogDriver *)self;
}
コード例 #4
0
ファイル: redis.c プロジェクト: algernon/syslog-ng-old
LogDriver *
redis_dd_new(GlobalConfig *cfg)
{
  RedisDriver *self = g_new0(RedisDriver, 1);

  log_threaded_dest_driver_init_instance(&self->super);
  self->super.super.super.super.init = redis_dd_init;
  self->super.super.super.super.free_fn = redis_dd_free;

  self->super.worker.thread_init = redis_worker_thread_init;
  self->super.worker.thread_deinit = redis_worker_thread_deinit;
  self->super.worker.disconnect = redis_dd_disconnect;
  self->super.worker.insert = redis_worker_insert;

  self->super.format.stats_instance = redis_dd_format_stats_instance;
  self->super.format.persist_name = redis_dd_format_persist_name;
  self->super.stats_source = SCS_REDIS;

  redis_dd_set_host((LogDriver *)self, "127.0.0.1");
  redis_dd_set_port((LogDriver *)self, 6379);

  self->command = g_string_sized_new(32);

  init_sequence_number(&self->seq_num);
  log_template_options_defaults(&self->template_options);

  return (LogDriver *)self;
}
コード例 #5
0
ファイル: afmongodb.c プロジェクト: algernon/syslog-ng-old
LogDriver *
afmongodb_dd_new(GlobalConfig *cfg)
{
  MongoDBDestDriver *self = g_new0(MongoDBDestDriver, 1);

  mongo_util_oid_init (0);

  log_threaded_dest_driver_init_instance(&self->super);

  self->super.super.super.super.init = afmongodb_dd_init;
  self->super.super.super.super.free_fn = afmongodb_dd_free;
  self->super.queue_method = afmongodb_dd_queue_method;

  self->super.worker.thread_init = afmongodb_worker_thread_init;
  self->super.worker.thread_deinit = afmongodb_worker_thread_deinit;
  self->super.worker.disconnect = afmongodb_dd_disconnect;
  self->super.worker.insert = afmongodb_worker_insert;
  self->super.format.stats_instance = afmongodb_dd_format_stats_instance;
  self->super.format.persist_name = afmongodb_dd_format_persist_name;
  self->super.stats_source = SCS_MONGODB;

  afmongodb_dd_set_database((LogDriver *)self, "syslog");
  afmongodb_dd_set_collection((LogDriver *)self, "messages");
  afmongodb_dd_set_safe_mode((LogDriver *)self, FALSE);

  init_sequence_number(&self->seq_num);

  log_template_options_defaults(&self->template_options);
  afmongodb_dd_set_value_pairs(&self->super.super.super, value_pairs_new_default(cfg));

  return (LogDriver *)self;
}
コード例 #6
0
ファイル: afstomp.c プロジェクト: balabit/syslog-ng-3.5
LogDriver *
afstomp_dd_new(GlobalConfig *cfg)
{
  STOMPDestDriver *self = g_new0(STOMPDestDriver, 1);

  log_threaded_dest_driver_init_instance(&self->super);
  self->super.super.super.super.init = afstomp_dd_init;
  self->super.super.super.super.free_fn = afstomp_dd_free;

  self->super.worker.thread_init = afstomp_worker_thread_init;
  self->super.worker.disconnect = afstomp_dd_disconnect;
  self->super.worker.insert = afstomp_worker_insert;

  self->super.format.stats_instance = afstomp_dd_format_stats_instance;
  self->super.format.persist_name = afstomp_dd_format_persist_name;
  self->super.stats_source = SCS_STOMP;

  afstomp_dd_set_host((LogDriver *) self, "127.0.0.1");
  afstomp_dd_set_port((LogDriver *) self, 61613);
  afstomp_dd_set_destination((LogDriver *) self, "/topic/syslog");
  afstomp_dd_set_persistent((LogDriver *) self, TRUE);
  afstomp_dd_set_ack((LogDriver *) self, FALSE);

  init_sequence_number(&self->seq_num);

  log_template_options_defaults(&self->template_options);
  afstomp_dd_set_value_pairs(&self->super.super.super, value_pairs_new_default(cfg));

  return (LogDriver *) self;
}
コード例 #7
0
ファイル: logthrdestdrv.c プロジェクト: jbfuzier/syslog-ng
gboolean
log_threaded_dest_driver_start(LogPipe *s)
{
  LogThrDestDriver *self = (LogThrDestDriver *)s;
  GlobalConfig *cfg = log_pipe_get_config(s);

  if (cfg && self->time_reopen == -1)
    self->time_reopen = cfg->time_reopen;

  self->queue = log_dest_driver_acquire_queue(&self->super,
                                              self->format.persist_name(self));

  if (self->queue == NULL)
    {
      return FALSE;
    }

  if (self->retries.max <= 0)
    {
      msg_warning("Wrong value for retries(), setting to default",
                  evt_tag_int("value", self->retries.max),
                  evt_tag_int("default", MAX_RETRIES_OF_FAILED_INSERT_DEFAULT),
                  evt_tag_str("driver", self->super.super.id),
                  NULL);
      self->retries.max = MAX_RETRIES_OF_FAILED_INSERT_DEFAULT;
    }

  stats_lock();
  stats_register_counter(0, self->stats_source | SCS_DESTINATION, self->super.super.id,
                         self->format.stats_instance(self),
                         SC_TYPE_STORED, &self->stored_messages);
  stats_register_counter(0, self->stats_source | SCS_DESTINATION, self->super.super.id,
                         self->format.stats_instance(self),
                         SC_TYPE_DROPPED, &self->dropped_messages);
  stats_register_counter(0, self->stats_source | SCS_DESTINATION, self->super.super.id,
                         self->format.stats_instance(self),
                         SC_TYPE_PROCESSED, &self->processed_messages);
  stats_unlock();

  log_queue_set_counters(self->queue, self->stored_messages,
                         self->dropped_messages);

  self->seq_num = GPOINTER_TO_INT(cfg_persist_config_fetch(cfg, log_threaded_dest_driver_format_seqnum_for_persist(self)));
  if (!self->seq_num)
    init_sequence_number(&self->seq_num);

  log_threaded_dest_driver_start_thread(self);

  return TRUE;
}
コード例 #8
0
ファイル: afamqp.c プロジェクト: Turneliusz/syslog-ng-3.5
LogDriver *
afamqp_dd_new(GlobalConfig *cfg)
{
    AMQPDestDriver *self = g_new0(AMQPDestDriver, 1);

    log_threaded_dest_driver_init_instance(&self->super);

    self->super.super.super.super.init = afamqp_dd_init;
    self->super.super.super.super.free_fn = afamqp_dd_free;

    self->super.worker.thread_init = afamqp_worker_thread_init;
    self->super.worker.disconnect = afamqp_dd_disconnect;
    self->super.worker.insert = afamqp_worker_insert;

    self->super.format.stats_instance = afamqp_dd_format_stats_instance;
    self->super.format.persist_name = afamqp_dd_format_persist_name;
    self->super.stats_source = SCS_AMQP;

    self->routing_key_template = log_template_new(cfg, NULL);

    afamqp_dd_set_vhost((LogDriver *) self, "/");
    afamqp_dd_set_host((LogDriver *) self, "127.0.0.1");
    afamqp_dd_set_port((LogDriver *) self, 5672);
    afamqp_dd_set_exchange((LogDriver *) self, "syslog");
    afamqp_dd_set_exchange_type((LogDriver *) self, "fanout");
    afamqp_dd_set_routing_key((LogDriver *) self, "");
    afamqp_dd_set_persistent((LogDriver *) self, TRUE);
    afamqp_dd_set_exchange_declare((LogDriver *) self, FALSE);

    init_sequence_number(&self->seq_num);

    self->max_entries = 256;
    self->entries = g_new(amqp_table_entry_t, self->max_entries);

    log_template_options_defaults(&self->template_options);
    afamqp_dd_set_value_pairs(&self->super.super.super, value_pairs_new_default(cfg));

    return (LogDriver *) self;
}
コード例 #9
0
ファイル: rtp_reader.c プロジェクト: 4leavedclover/userland
/**************************************************************************//**
 * Apply a control operation to the container.
 *
 * @param p_ctx      The reader context.
 * @param operation  The control operation.
 * @param args       Optional additional arguments for the operation.
 * @return  The resulting status of the function.
 */
static VC_CONTAINER_STATUS_T rtp_reader_control( VC_CONTAINER_T *p_ctx,
                                                VC_CONTAINER_CONTROL_T operation,
                                                va_list args)
{
   VC_CONTAINER_STATUS_T status;
   VC_CONTAINER_TRACK_MODULE_T *t_module = p_ctx->tracks[0]->priv->module;

   switch (operation)
   {
   case VC_CONTAINER_CONTROL_SET_TIMESTAMP_BASE:
      {
         t_module->timestamp_base = va_arg(args, uint32_t);
         if (!t_module->timestamp_base)
            t_module->timestamp_base = 1;    /* Zero is used to mean "not set" */
         status = VC_CONTAINER_SUCCESS;
      }
      break;
   case VC_CONTAINER_CONTROL_SET_NEXT_SEQUENCE_NUMBER:
      {
         init_sequence_number(t_module, (uint16_t)va_arg(args, uint32_t));
         t_module->probation = 0;
         status = VC_CONTAINER_SUCCESS;
      }
      break;
   case VC_CONTAINER_CONTROL_SET_SOURCE_ID:
      {
         t_module->expected_ssrc = va_arg(args, uint32_t);
         SET_BIT(t_module->flags, TRACK_SSRC_SET);
         status = VC_CONTAINER_SUCCESS;
      }
      break;
   default:
      status = VC_CONTAINER_ERROR_UNSUPPORTED_OPERATION;
   }

   return status;
}
コード例 #10
0
ファイル: rtp_reader.c プロジェクト: 4leavedclover/userland
/**************************************************************************//**
 * Checks whether the sequence number for a packet is acceptable or not.
 * The packet will be unacceptable if it is out of sequence by some degree, or
 * if the packet sequence is still being established.
 *
 * @param t_module   The track module.
 * @param seq        The new sequence number.
 * @return  True if the sequence number indicates the packet is acceptable
 */
static bool update_sequence_number(VC_CONTAINER_TRACK_MODULE_T *t_module,
      uint16_t seq)
{
   uint16_t udelta = seq - t_module->max_seq_num;

   /* NOTE: This source is derived from the example code in RFC3550, section A.1 */

   /* Source is not valid until MIN_SEQUENTIAL packets with
    * sequential sequence numbers have been received. */
   if (t_module->probation)
   {
      /* packet is in sequence */
      if (seq == t_module->max_seq_num + 1)
      {
         t_module->probation--;
         t_module->max_seq_num = seq;
         LOG_INFO(0, "RTP: Probation, %u more packet(s) to go at 0x%4.4hx", t_module->probation, seq);

         if (!t_module->probation)
         {
            init_sequence_number(t_module, seq);
            t_module->received++;
            return 1;
         }
      } else {
         t_module->probation = MIN_SEQUENTIAL - 1;
         t_module->max_seq_num = seq;
         LOG_INFO(0, "RTP: Probation reset, wait for %u packet(s) at 0x%4.4hx", t_module->probation, seq);
      }
      return 0;
   } else if (udelta < MAX_DROPOUT)
   {
      if (!udelta)
      {
         /* Duplicate packet, drop it */
         LOG_INFO(0, "RTP: Drop duplicate packet at 0x%4.4hx", seq);
         return 0;
      }
      if (udelta > 1)
      {
         LOG_INFO(0, "RTP: Jumped by %hu packets to 0x%4.4hx", udelta, seq);
      }
      /* in order, with permissible gap */
      t_module->max_seq_num = seq;
   } else
#if (MAX_MISORDER != 0)
      /* When MAX_MISORDER is zero, always treat as out of order */
      if (udelta <= RTP_SEQ_MOD - MAX_MISORDER)
#endif
      {
         /* the sequence number made a very large jump */
         if (seq == t_module->bad_seq)
         {
            LOG_INFO(0, "RTP: Misorder restart at 0x%4.4hx", seq);
            /* Two sequential packets -- assume that the other side
             * restarted without telling us so just re-sync
             * (i.e., pretend this was the first packet). */
            init_sequence_number(t_module, seq);
         } else {
            LOG_INFO(0, "RTP: Misorder at 0x%4.4hx, expected 0x%4.4hx", seq, t_module->max_seq_num);
            t_module->bad_seq = (seq + 1) & (RTP_SEQ_MOD-1);
            return 0;
         }
      }
#if (MAX_MISORDER != 0)
   else {
      /* duplicate or reordered packet */

      /* TODO: handle out of order packets */
   }
#endif
   t_module->received++;
   return 1;
}