p3exporter.collector package

Entry point for collector sub module.

class p3exporter.collector.Collector(config: p3exporter.collector.CollectorConfig)[source]

Bases: object

Base class to load collectors.

All collectors have to be placed inside the directory collector. You have to follow the naming convention:

  1. Place the collector code in a <name>.py file (e.g. my.py)

  2. Within the file <name>.py` a class <Name>Collector (e.g. MyController) needs to be defined. This is the main collector class which will be imported, instantiate and registered automatically.

class p3exporter.collector.CollectorBase(config: p3exporter.collector.CollectorConfig)[source]

Bases: object

Base class for all collectors.

This class will provide methods that do generic work.

property collector_name_from_class

Convert class name to controller name.

The class name must follow naming convention:
  • camelized string

  • starts with camelized module name

  • ends with ‘Collector’

This will convert <Name>Collector class name to <name> collector name. Examples for valid names:

  • MyCollector => my

  • FooBarCollector => foo_bar

  • FooBarBazCollector => foo_bar_baz

Returns

collector name in snake case

Return type

string

class p3exporter.collector.CollectorConfig(**kwargs)[source]

Bases: object

Class that provide all the logic needed for configuration handling.

Submodules

p3exporter.collector.example module

Module that defines all needed classes and functions for example collector.

class p3exporter.collector.example.ExampleCollector(config: p3exporter.collector.CollectorConfig)[source]

Bases: p3exporter.collector.CollectorBase

A sample collector.

It does not really do much. It only runs a method and return the time it runs as a gauge metric.

collect()[source]

Collect the metrics.

p3exporter.collector.loadavg module

Module that defines all needed classes and functions for loadavg collector.

class p3exporter.collector.loadavg.LoadavgCollector(config: p3exporter.collector.CollectorConfig)[source]

Bases: p3exporter.collector.CollectorBase

Load avg collector class.

collect()[source]

Collect load avg for 1, 5 and 15 minutes interval.

Returns three gauge metrics. One for each load.

p3exporter.collector.netdev module

Module that defines all needed classes and functions for netdev collector.

class p3exporter.collector.netdev.NetdevCollector(config: p3exporter.collector.CollectorConfig)[source]

Bases: p3exporter.collector.CollectorBase

Netdev collector class.

collect()[source]

Collect netdev metrics.

Returns several info, couter and gauge metrics for interfaces.