The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojo::Netdata::Collector - Base class for Mojo::Netdata collectors

SYNOPSIS

  package Mojo::Netdata::Collector::CoolBeans;
  use Mojo::Base 'Mojo::Netdata::Collector', -signatures;

  has type    => 'ice_cool';

  sub register ($self, $config, $netdata) { ... }
  sub update_p ($self) { ... }

  1;

DESCRIPTION

Mojo::Netdata::Collector has basic functionality which should be inherited by Mojo::Netdata collectors. See Mojo::Netdata::Collector::HTTP for an (example) implementation.

ATTRIBUTES

charts

  $hash_ref = $collector->charts;

module

  $str = $collector->module;

Defaults to a decamelized version of $collector. This is used as default value for "module" in Mojo::Netdata::Chart.

type

  $str = $collector->type;

This value must be set. This is used as default value for "type" in Mojo::Netdata::Chart.

update_every

  $num = $chart->update_every;

Used by "recurring_update_p" to figure out how often to update Netdata.

METHODS

chart

  $chart = $collector->chart($id);

Returns a Mojo::Netdata::Chart object identified by "id".

emit_charts

  $collector = $collector->emit_charts;

Emits all the "charts" specifications as an "stdout" event.

emit_data

  $collector = $collector->emit_data;

Emits all the "charts" data as an "stdout" event.

recurring_update_p

  $p = $collector->recurring_update_p;

Calls "update_p" on "update_every" interval, until the process is killed.

register

  $collector = $collector->register(\%config, $netdata);

Called by Mojo::Netdata when initialized, and should return $collector on success or undef if the collector should not be registered.

update_p

  $p = $collector->update_p;

Must be defined in the sub class. This method should update "dimensions" in Mojo::Netdata::Chart.

SEE ALSO

Mojo::Netdata.