awslimitchecker.alerts.base module

class awslimitchecker.alerts.base.AlertProvider(region_name)[source]

Bases: object

Initialize an AlertProvider class. This MUST be overridden by subclasses. All configuration must be passed as keyword arguments to the class constructor (these come from --alert-config CLI arguments). Any dependency imports must be made in the constructor. The constructor should do as much as possible to validate configuration.

Parameters:region_name (str) – the name of the region we’re connected to
__dict__ = mappingproxy({'__module__': 'awslimitchecker.alerts.base', '__metaclass__': <class 'abc.ABCMeta'>, '__init__': <function AlertProvider.__init__>, 'on_success': <function AlertProvider.on_success>, 'on_critical': <function AlertProvider.on_critical>, 'on_warning': <function AlertProvider.on_warning>, 'providers_by_name': <staticmethod object>, 'get_provider_by_name': <staticmethod object>, '__dict__': <attribute '__dict__' of 'AlertProvider' objects>, '__weakref__': <attribute '__weakref__' of 'AlertProvider' objects>, '__doc__': None})
__init__(region_name)[source]

Initialize an AlertProvider class. This MUST be overridden by subclasses. All configuration must be passed as keyword arguments to the class constructor (these come from --alert-config CLI arguments). Any dependency imports must be made in the constructor. The constructor should do as much as possible to validate configuration.

Parameters:region_name (str) – the name of the region we’re connected to
__metaclass__

alias of abc.ABCMeta

__module__ = 'awslimitchecker.alerts.base'
__weakref__

list of weak references to the object (if defined)

static get_provider_by_name(name)[source]

Get a reference to the provider class with the specified name.

Parameters:name (str) – name of the AlertProvider subclass
Returns:AlertProvider subclass
Return type:class
Raises:RuntimeError
on_critical(problems, problem_str, exc=None, duration=None)[source]

Method called when the run encountered errors, or at least one critical threshold was met or crossed.

Parameters:
  • problems (dict or None) – dict of service name to nested dict of limit name to limit, same format as the return value of check_thresholds(). None if exc is specified.
  • problem_str (str or None) – String representation of problems, as displayed in awslimitchecker command line output. None if exc is specified.
  • exc (Exception) – Exception object that was raised during the run (optional)
  • duration (float) – duration of the run
on_success(duration=None)[source]

Method called when no thresholds were breached, and run completed successfully. Should resolve any open incidents (if the service supports that functionality) or else simply return.

Parameters:duration (float) – duration of the usage/threshold checking run
on_warning(problems, problem_str, duration=None)[source]

Method called when one or more warning thresholds were crossed, but no criticals and the run did not encounter any errors.

Parameters:
  • problems (dict or None) – dict of service name to nested dict of limit name to limit, same format as the return value of check_thresholds().
  • problem_str (str or None) – String representation of problems, as displayed in awslimitchecker command line output.
  • duration (float) – duration of the run
static providers_by_name()[source]

Return a dict of available AlertProvider subclass names to the class objects.

Returns:AlertProvider class names to classes
Return type:dict