vaping.plugins

Classes


EmitBase

EmitBase(vaping.plugins.PluginBase)

Base class for emit plugins, used for sending data

expects method emit() to be defined

Methods

__init__

def __init__(self, config, ctx)

Arguments

  • config (dict)
  • ctx: vaping context

emit

def emit(self, message)

accept message to emit


FileProbe

FileProbe(vaping.plugins.ProbeBase)

Probes a file and emits everytime a new line is read

Config

  • path (str): path to file
  • backlog (int=0): number of bytes to read from backlog
  • max_lines (int=1000): maximum number of lines to read during probe

Class Attributes

  • ConfigSchema (FileProbeSchema Class): Base plugin config schema

Instanced Attributes

These attributes / properties will be available on instances of the class

  • backlog (int): number of bytes to read from backlog
  • fh (filehandler): file handler for opened file (only available if path is set)
  • max_lines (int): maximum number of liens to read during probe
  • path (str): path to file

Methods

__init__

def __init__(self, config, ctx, emit=None)

Arguments

  • config (dict)
  • ctx: vaping context

probe

def probe(self)

Probe the file for new lines


process_line

def process_line(self, line, data)

override this - parse your line in here


process_messages

def process_messages(self, messages)

override this - process your messages before they are emitted


process_probe

def process_probe(self, data)

override this - assign your data values here


validate_file_handler

def validate_file_handler(self)

Here we validate that our filehandler is pointing to an existing file.

If it doesnt, because file has been deleted, we close the filehander and try to reopen


FileProbeSchema

FileProbeSchema(vaping.plugins.PluginConfigSchema)

Configuration Schema for PluginBase

When creating new configuration schemas for extended plugins extend this.

Class Attributes

  • backlog (Int Instance):
  • max_lines (Int Instance):
  • path (Str Instance):

PluginBase

PluginBase(vaping.io.Thread)

Base plugin interface

Class Attributes

  • lazy_start (bool=False): if True plugin will not be started on vaping start, but when at a later point (usually when it starts emitting). Note that the plugin itself will need to call self.start() somewhere explicitly when this is True.

Calls self.init() prefork while loading all modules, init() should not do anything active, any files opened may be closed when it forks.

Plugins should prefer init() to __init__() to ensure the class is completely done initializing.

Calls self.on_start() and self.on_stop() before and after running in case any connections need to be created or cleaned up.

Class Attributes

  • ConfigSchema (PluginConfigSchema Class): Base plugin config schema

Instanced Attributes

These attributes / properties will be available on instances of the class

  • config (dict): plugin config
  • groups (@property): dict - group configurations keyed by name
  • log (@property): logger instance for plugin type
  • vaping: reference to the main vaping object

Methods

__init__

def __init__(self, config, ctx)

Arguments

  • config (dict)
  • ctx: vaping context

init

def init(self)

called after the plugin is initialized, plugin may define this for any other initialization code


new_message

def new_message(self)

creates and returns new message dict, setting type, source, ts, data

data is initialized to an empty array

Returns

message (dict)


on_start

def on_start(self)

called when the daemon is starting


on_stop

def on_stop(self)

called when the daemon is stopping


popen

def popen(self, args, **kwargs)

creates a subprocess with passed args

Returns

Popen instance


PluginConfigSchema

PluginConfigSchema(confu.schema.core.Schema)

Configuration Schema for PluginBase

When creating new configuration schemas for extended plugins extend this.

Class Attributes

  • name (Str Instance): Plugin name
  • type (Str Instance): Plugin type

ProbeBase

ProbeBase(vaping.plugins.PluginBase)

Base class for probe plugin, used for getting data

expects method probe() to be defined

Methods

__init__

def __init__(self, config, ctx, emit=None)

Arguments

  • config (dict)
  • ctx: vaping context

emit_all

def emit_all(self)

emit and remove all emissions in the queue


init

def init(self)

called after the plugin is initialized, plugin may define this for any other initialization code


probe

def probe(self)

probe for data, return a list of dicts


queue_emission

def queue_emission(self, msg)

queue an emission of a message for all output plugins

Arguments

  • msg (dict): dict containing type, source, ts and data keys

send_emission

def send_emission(self)

emit and remove the first emission in the queue


TimeSeriesDB

TimeSeriesDB(vaping.plugins.EmitBase)

Base interface for timeseries db storage plugins

Config

  • filename (str): database file name template
  • field (str): field name to read the value from

Class Attributes

  • ConfigSchema (TimeSeriesDBSchema Class): Base plugin config schema

Instanced Attributes

These attributes / properties will be available on instances of the class

  • field (str): fieeld name to read the value from
  • filename (str): database file name template

Methods

__init__

def __init__(self, config, ctx)

Arguments

  • config (dict)
  • ctx: vaping context

create

def create(self, filename)

Create database

Arguments

  • filename (str): database filename

emit

def emit(self, message)

emit to database

Arguments

  • message (dict): vaping message dict

filename_formatters

def filename_formatters(self, data, row)

Returns a dict containing the various filename formatter values

Values are gotten from the vaping data message as well as the currently processed row in the message

Arguments

  • data (dict): vaping message
  • row (dict): vaping message data row

Returns

formatter variables (dict)


format_filename

def format_filename(self, data, row)

Returns a formatted filename using the template stored in self.filename

Arguments

  • data (dict): vaping message
  • row (dict): vaping message data row

Returns

formatted version of self.filename (str)


get

def get(self, filename, from_time, to_time)

Retrieve data from database for the specified timespan

Arguments

  • filename (str): database filename
  • from_time (int): epoch timestamp start
  • to_time (int): epoch timestamp end

update

def update(self, filename, time, value)

Update database

Arguments

  • filename (str): database filename
  • time (int): epoch timestamp
  • value (mixed)

TimeSeriesDBSchema

TimeSeriesDBSchema(vaping.plugins.PluginConfigSchema)

Configuration Schema for PluginBase

When creating new configuration schemas for extended plugins extend this.

Class Attributes

  • field (Str Instance): field name to read the value from
  • filename (Str Instance): database file name template

TimedProbe

TimedProbe(vaping.plugins.ProbeBase)

Probe class that calls probe every config defined interval

Class Attributes

  • ConfigSchema (TimedProbeSchema Class): Base plugin config schema

Methods

__init__

def __init__(self, config, ctx, emit=None)

Arguments

  • config (dict)
  • ctx: vaping context

TimedProbeSchema

TimedProbeSchema(vaping.plugins.PluginConfigSchema)

Configuration Schema for PluginBase

When creating new configuration schemas for extended plugins extend this.

Class Attributes

  • interval (Str Instance):