Seastar
High performance C++ framework for concurrent servers
Classes | Typedefs | Enumerations | Functions | Variables
seastar::scollectd Namespace Reference

Detailed Description

Implementation of rudimentary collectd data gathering.

Usage is hopefully straight forward. Though, feel free to read https://collectd.org/wiki/index.php/Naming_schema for an explanation on the naming model.

Typically, you'll add values something like:

            scollectd::type_instance_id typ("<pluginname>", "<instance_name>", "<type_name>", "<instance_name>");
    scollectd::add_polled_metric(typ, [<metric var> | scollectd::make_typed(<data_type>, <metric_var>) [, ...]);

Where <pluginname> would be the overall 'module', e.g. "cpu" <instance_name> -> optional distinguisher between plugin instances. For cpu, the built-in scollectd::per_cpu_plugin_instance constant is a good choice, i.e. 0->N cpu. If there are no instances (e.g. only one), empty constant is appropriate (none) <type_name> is the 'type' of metric collected, for ex. "usage" (cpu/0/usage) <type_instance> is a distinguisher for metric parts of the type, e.g. "idle", "user", "kernel" -> cpu/0/usage/idle | cpu/0/usage/user | cpu/0/usage/kernel

Each type instance can bind an arbitrary number of values, ech representing some aspect in turn of the instance. The structure and interpretation is up to the producer/consumer

There is a single "scollectd" instance per cpu, and values should be bound locally to this cpu. Polling is done at a frequency set in the seastar config (def once per s), and all registered values will be sent via UDP packages to the destination host(s)

Note that the tuple { plugin, plugin_instance, type, type_instance } is considered a unique ID for a value registration, so using the same tuple twice will remove the previously registered values.

Values can be unregistered at any time, though they must be so on the same thread/cpu as they we're registered. The "registration" achor type provides RAII style value unregistration semantics.

Classes

struct  typed
 
class  type_instance_id
 
struct  options
 
struct  registration
 
class  registrations
 
struct  typed_value
 
class  plugin_instance_metrics
 
class  percpu_plugin_instance_metrics
 
struct  typed_value_impl
 
struct  data_type_for
 
struct  is_callable
 
struct  is_callable< T, std::enable_if_t<!std::is_void_v< std::invoke_result_t< T > >, void > >
 
struct  is_callable< T, std::enable_if_t< std::is_fundamental_v< T >, void > >
 
struct  data_type_for< T, std::enable_if_t< std::is_integral_v< T > &&std::is_unsigned_v< T >, void > >
 
struct  data_type_for< T, std::enable_if_t< std::is_floating_point_v< T >, void > >
 
struct  data_type_for< T, std::enable_if_t< is_callable< T >::value, void > >
 
struct  data_type_for< typed< T > >
 
class  value
 
class  value< typed< T > >
 
class  value_list
 
class  values_impl
 

Typedefs

using data_type = seastar::metrics::impl::data_type
 
using plugin_id = seastar::metrics::group_name_type
 
using plugin_instance_id = seastar::metrics::instance_id_type
 
using type_id = seastar::metrics::metric_type_def
 
using type_instance = seastar::metrics::metric_name_type
 
using description = seastar::metrics::description
 
typedef typed_value_impl< known_type::total_bytes > total_bytes
 
typedef typed_value_impl< known_type::total_connections > total_connections
 
typedef typed_value_impl< known_type::total_objects > total_objects
 
typedef typed_value_impl< known_type::total_operations > total_operations
 
typedef typed_value_impl< known_type::total_requests > total_requests
 
typedef typed_value_impl< known_type::total_sessions > total_sessions
 
typedef typed_value_impl< known_type::total_threads > total_threads
 
typedef typed_value_impl< known_type::total_time_in_ms > total_time_in_ms
 
typedef typed_value_impl< known_type::total_values > total_values
 
typedef typed_value_impl< known_type::queue_length > queue_length
 
typedef typed_value_impl< known_type::counter > counter
 
typedef typed_value_impl< known_type::count > count
 
typedef typed_value_impl< known_type::gauge > gauge
 
typedef std::function< void()> notify_function
 
using collectd_value = seastar::metrics::impl::metric_value
 

Enumerations

enum class  known_type {
  absolute , backends , bitrate , blocked_clients ,
  bytes , cache_eviction , cache_operation , cache_ratio ,
  cache_result , cache_size , capacity , changes_since_last_save ,
  charge , clock_last_meas , clock_last_update , clock_mode ,
  clock_reachability , clock_skew_ppm , clock_state , clock_stratum ,
  compression , compression_ratio , connections , conntrack ,
  contextswitch , count , counter , cpu ,
  cpufreq , current , current_connections , current_sessions ,
  delay , derive , df , df_complex ,
  df_inodes , disk_io_time , disk_latency , disk_merged ,
  disk_octets , disk_ops , disk_ops_complex , disk_time ,
  dns_answer , dns_notify , dns_octets , dns_opcode ,
  dns_qtype , dns_qtype_cached , dns_query , dns_question ,
  dns_rcode , dns_reject , dns_request , dns_resolver ,
  dns_response , dns_transfer , dns_update , dns_zops ,
  drbd_resource , duration , email_check , email_count ,
  email_size , entropy , evicted_keys , expired_keys ,
  fanspeed , file_handles , file_size , files ,
  flow , fork_rate , frequency , frequency_error ,
  frequency_offset , fscache_stat , gauge , hash_collisions ,
  http_request_methods , http_requests , http_response_codes , humidity ,
  if_collisions , if_dropped , if_errors , if_multicast ,
  if_octets , if_packets , if_rx_errors , if_rx_octets ,
  if_tx_errors , if_tx_octets , invocations , io_octets ,
  io_packets , ipt_bytes , ipt_packets , irq ,
  latency , links , load , md_disks ,
  memory , memory_lua , memory_throttle_count , multimeter ,
  mutex_operations , objects , operations , packets ,
  pending_operations , percent , percent_bytes , percent_inodes ,
  ping , ping_droprate , ping_stddev , players ,
  power , pressure , protocol_counter , pubsub ,
  queue_length , records , requests , response_code ,
  response_time , root_delay , root_dispersion , route_etx ,
  route_metric , routes , segments , serial_octets ,
  signal_noise , signal_power , signal_quality , snr ,
  spl , swap , swap_io , tcp_connections ,
  temperature , threads , time_dispersion , time_offset ,
  time_offset_ntp , time_offset_rms , time_ref , timeleft ,
  total_bytes , total_connections , total_objects , total_operations ,
  total_requests , total_sessions , total_threads , total_time_in_ms ,
  total_values , uptime , users , vcl ,
  vcpu , virt_cpu_total , virt_vcpu , vmpage_action ,
  vmpage_faults , vmpage_io , vmpage_number , volatile_changes ,
  voltage , voltage_threshold , vs_memory , vs_processes ,
  vs_threads
}
 

Functions

template<typename T >
typed< T > make_typed (data_type type, T &&t)
 
type_id type_id_for (known_type)
 
void configure (const options &)
 
void remove_polled_metric (const type_instance_id &)
 
void add_polled (const type_instance_id &, const shared_ptr< value_list > &, bool enabled=true)
 
template<typename... _Args>
static auto make_type_instance (description d, _Args &&... args) -> values_impl< decltype(value< _Args >(std::forward< _Args >(args)))... >
 
template<typename ... _Args>
static type_instance_id add_polled_metric (const plugin_id &plugin, const plugin_instance_id &plugin_instance, const type_id &type, const scollectd::type_instance &type_instance, _Args &&... args)
 
template<typename ... _Args>
static type_instance_id add_polled_metric (const plugin_id &plugin, const plugin_instance_id &plugin_instance, const type_id &type, const scollectd::type_instance &type_instance, description d, _Args &&... args)
 
template<typename ... _Args>
static future send_explicit_metric (const plugin_id &plugin, const plugin_instance_id &plugin_instance, const type_id &type, const scollectd::type_instance &type_instance, _Args &&... args)
 
template<typename ... _Args>
static notify_function create_explicit_metric (const plugin_id &plugin, const plugin_instance_id &plugin_instance, const type_id &type, const scollectd::type_instance &type_instance, _Args &&... args)
 
seastar::metrics::impl::metric_id to_metrics_id (const type_instance_id &id)
 
template<typename Arg >
static type_instance_id add_polled_metric (const type_instance_id &id, description d, Arg &&arg, bool enabled=true)
 
template<typename Arg >
static type_instance_id add_polled_metric (const type_instance_id &id, Arg &&arg)
 
template<typename Args >
static type_instance_id add_disabled_polled_metric (const type_instance_id &id, description d, Args &&arg)
 
template<typename Args >
static type_instance_id add_disabled_polled_metric (const type_instance_id &id, Args &&args)
 
template<typename ... Args>
static type_instance_id add_disabled_polled_metric (const type_instance_id &id, Args &&... args)
 
template<typename ... _Args>
static future send_explicit_metric (const type_instance_id &id, _Args &&... args)
 
template<typename ... _Args>
static notify_function create_explicit_metric (const type_instance_id &id, _Args &&... args)
 
future send_notification (const type_instance_id &id, const sstring &msg)
 
std::vector< collectd_valueget_collectd_value (const scollectd::type_instance_id &id)
 
std::vector< scollectd::type_instance_idget_collectd_ids ()
 
sstring get_collectd_description_str (const scollectd::type_instance_id &)
 
bool is_enabled (const scollectd::type_instance_id &id)
 
void enable (const scollectd::type_instance_id &id, bool enable)
 
metrics::impl::value_map get_value_map ()
 

Variables

seastar::logger logger
 
static constexpr unsigned max_collectd_field_text_len = 63
 
const plugin_instance_id per_cpu_plugin_instance
 

Class Documentation

◆ seastar::scollectd::is_callable

struct seastar::scollectd::is_callable

Typedef Documentation

◆ total_bytes

typedef typed_value_impl<known_type::total_bytes> seastar::scollectd::total_bytes
Deprecated:
metrics registration should be done using the metrics layer

Some typedefs for common used types. Feel free to add.

Function Documentation

◆ add_disabled_polled_metric()

template<typename Args >
static type_instance_id seastar::scollectd::add_disabled_polled_metric ( const type_instance_id id,
description  d,
Args &&  arg 
)
static
Deprecated:
metrics registration should be done using the metrics layer

◆ add_polled_metric() [1/4]

template<typename ... _Args>
static type_instance_id seastar::scollectd::add_polled_metric ( const plugin_id &  plugin,
const plugin_instance_id &  plugin_instance,
const type_id &  type,
const scollectd::type_instance &  type_instance,
_Args &&...  args 
)
static
Deprecated:
metrics registration should be done using the metrics layer

◆ add_polled_metric() [2/4]

template<typename ... _Args>
static type_instance_id seastar::scollectd::add_polled_metric ( const plugin_id &  plugin,
const plugin_instance_id &  plugin_instance,
const type_id &  type,
const scollectd::type_instance &  type_instance,
description  d,
_Args &&...  args 
)
static
Deprecated:
metrics registration should be done using the metrics layer

◆ add_polled_metric() [3/4]

template<typename Arg >
static type_instance_id seastar::scollectd::add_polled_metric ( const type_instance_id id,
Arg &&  arg 
)
static
Deprecated:
metrics registration should be done using the metrics layer

◆ add_polled_metric() [4/4]

template<typename Arg >
static type_instance_id seastar::scollectd::add_polled_metric ( const type_instance_id id,
description  d,
Arg &&  arg,
bool  enabled = true 
)
static
Deprecated:
metrics registration should be done using the metrics layer

◆ enable()

void seastar::scollectd::enable ( const scollectd::type_instance_id id,
bool  enable 
)

Enable or disable collectd metrics on local instance

Parameters
id- the metric to enable or disable
enable- should the collectd metrics be enable or disable