uptime_report package¶
Subpackages¶
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
-
class
uptime_report.cli.TimeUnits¶ Bases:
enum.EnumEnumeration of time division abbreviations.
-
minutes¶ str –
m
-
hours¶ str –
h
-
days¶ str –
d
-
months¶ str –
mo
-
years¶ str –
y
-
-
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
loggingpackage.Example
>>> assert logging.DEBUG == get_log_level('debug')
Parameters: level (str) – the value to convert Returns: a log level from the loggingpackage.Return type: int Raises: clize.errors.CliValueError– if the value cannot be converted.
-
uptime_report.cli.get_time(value, now=None)¶ Convert a parameter to a timestamp.
Based on the passed value create a timestamp that represents the value. Both absolute and relative forms are supported.
Example
>>> get_time('2017-06-03') 1496448000 >>> now = arrow.utcnow().replace(microsecond=0).timestamp >>> get_time('+2d') == now + 2*60*60*24 True
Valid time units for relative values are described in
TimeUnits. If a time unit is not provided the default isTimeUnits.days.Additionally, for relative values, the current time can be specified by passing an
Arrowinstance as thenowargument.Example
>>> today = get_time('2017-06-03') >>> get_time('+1d', arrow.get(today)) 1496534400
Parameters: Returns: a timestamp
Return type: 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.
-
uptime_report.cli.uptime¶ Do the uptime reporting stuff.
-
uptime_report.cli.version()¶ Get the version of this program.
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:
objectAn outage.
-
meta¶ (dict, optinal): arbitrary metadata about this outage.
-
-
uptime_report.outage.filter_outage_len(outages, minlen=0)¶ Filter-out outages that have a small duration.
Parameters: 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.merge_outages(outages, overlap=0)¶ Merge a list of Outage objects.
-
uptime_report.outage.write_outages_csv(fhandle, outages)¶ Write a list of outages to a file as CSV.
Example
>>> from six import StringIO >>> s = StringIO() >>> t = arrow.get(0) >>> write_outages_csv(s, [Outage(t, t)]) >>> s.getvalue() 'start,finish,before,after,meta\r\n1970-01-01T00:00:00+00:00,1970-01-01T00:00:00+00:00,,,{}\r\n'
Parameters: - fhandle (io.TextIOWrapper) – the file object to write the CSV data to
- outages (list) – a list of
Outageobjects to write.
Module contents¶
Pingdom Uptime Report - Generate uptime reports using the Pingdom API.