uptime_report package

Submodules

uptime_report.backend_utils module

uptime_report.backend_utils.group_by_range(it, pred, keyfunc=None)

Return contiguous ranges of items satisfying a predicate.

uptime_report.backend_utils.offset_iter

Call a method with limit/offset arguments until exhausted.

Given a callable that accepts limit/offset keyword arguments and returns an iterable, call the method repeatedly until less than limit items are returned, yielding each item.

uptime_report.cli module

Uptime report CLI.

This module contains all CLI entrypoints. Command line argument parsing and execution is implemented via clize.

Examples:

$ python -m uptime_report.cli --version
uptime_report.cli.backends()

Print supported backends.

uptime_report.cli.get_log_level(level)

Convert a value to a log level.

Converts a case-insensitive log level name to the corresponding integer value from Python’s logging package.

Example

>>> assert logging.DEBUG == get_log_level('debug')
Parameters:level (str) – the value to convert
Returns:a log level from the logging package.
Return type:int
Raises:clize.errors.CliValueError – if the value cannot be converted.
uptime_report.cli.main(**kwargs)

Run the CLI application.

uptime_report.cli.outages

List outages.

Parameters:
  • filters (dict) – parameters to filter outages with.
  • backend (object) – the backend instace object
  • fmt (Format) – what format to output data as.
  • config (dict) – the settings object
uptime_report.cli.uptime

Do the uptime reporting stuff.

uptime_report.cli.version()

Get the version of this program.

uptime_report.cli.with_backend(decorated)

Provide --backend option that initializes a backend.

Parameters:backend (str, optional) – the name of the backend. Defaults to 'pingdom'.
Raises:clize.errors.CliValueError – if the backend configuration is missing
uptime_report.cli.with_common_args(decorated)

Add common CLI arguments to a method.

Provides --log-level, --config and --use-cache options.

Parameters:
  • log_level (int) – the log level code to configure logging.
  • use_cache (bool) – True if you want requests_cache to be used.
uptime_report.cli.with_filters(decorated)

Provide common filter arguments.

Parameters:
  • start (str) – the start time in a string parseable by get_time().
  • finish (str) – the finish time in a string parseable by get_time().
  • overlap (int, optional) – how many seconds must be between two outage periods so they don’t get merged.
  • minlen (int, optional) – how many seconds must an outage period be so that it’s not filtered out.
Raises:

clize.errors.CliValueError – if one of the values cannot be converted.

uptime_report.config module

uptime_report.config.write_config

Write out a sample config file. Use ‘-‘ for stdout.

Parameters:output – the path to the file to write.

uptime_report.outage module

Uptime report outages.

This module contains generic code for processing outages.

class uptime_report.outage.Outage(start, finish, before=None, after=None, meta=NOTHING)

Bases: object

An outage.

start

Arrow – the start time of the outage period.

finish

Arrow – the ending time of the outage period.

before

Arrow, optional – last time check was ok, if available.

after

Arrow, optional – next time check was ok, if available.

meta

(dict, optinal): arbitrary metadata about this outage.

classmethod fields()

Return the field names for this class.

Example

>>> Outage.fields()
['start', 'finish', 'before', 'after', 'meta']
Returns:a list of names as (str) instances.
Return type:list
for_json()

Return a representation of this object as a dict.

Example

>>> t = arrow.utcnow()
>>> Outage(t, t).for_json() == {
...    "start": t,
...    "finish": t,
...    "before": None,
...    "after": None,
...    "meta": {}
... }
True
Returns:a list of names as (str) instances.
Return type:list
uptime_report.outage.filter_outage_len(outages, minlen=0)

Filter-out outages that have a small duration.

Parameters:
  • outages (list) – list of Outage objects
  • minlen (int) – the minimum amount of seconds that the outage duration must have
Yields:

Outage – the next outage from the list that has the minimum duration.

Example

>>> outages = [Outage(start=1, finish=5), Outage(start=2, finish=3)]
>>> [o.start.timestamp for o in filter_outage_len(outages, minlen=2)]
[1]
uptime_report.outage.make_ranges(outages, overlap)

Combine outages to create new ranges.

uptime_report.outage.merge_outages(outages, overlap=0)

Merge a list of Outage objects.

uptime_report.outage.sort_range(value)

Handle None values as very far in the past or future.

Module contents

Pingdom Uptime Report - Generate uptime reports using the Pingdom API.