Pingdom Uptime Report documentation¶
Installation¶
To install this package:
pip install pingdom-uptime-report
Configuring, using Pingdom as an example:
mkdir -p ~/.config
cat > ~/.config/uptime_report.cfg <<EOF
[pingdom]
apikey = ...
password = ...
username = user@domain.com
EOF
Code reference¶
uptime_report package¶
Subpackages¶
uptime_report.backends package¶
Submodules¶
uptime_report.backends.pingdom module¶
Pingdom backend for uptime data.
-
class
uptime_report.backends.pingdom.
PingdomBackend
(username, password, apikey, include_ok=False)¶ Bases:
object
-
apikey
= Attribute(name='apikey', default=NOTHING, validator=None, repr=True, cmp=True, hash=None, init=True, convert=None, metadata=mappingproxy({}))¶
-
classmethod
defaults
()¶
-
classmethod
from_config
(config=None)¶
-
get_checks
()¶
-
get_outages
(*args, **kwargs)¶
-
get_results
(start=None, finish=None, status=None, checks=None, *args, **kwargs)¶ Iterate over results in the given timeframe.
Parameters: - start – int, timestamp
- finish – int, timestamp
- status – list, a list of uptime_report.outage.ResultType values
- checks – list, a list of check IDs
-
include_ok
= Attribute(name='include_ok', default=False, validator=None, repr=True, cmp=True, hash=None, init=True, convert=None, metadata=mappingproxy({}))¶
-
new_connection
()¶
-
password
= Attribute(name='password', default=NOTHING, validator=None, repr=True, cmp=True, hash=None, init=True, convert=None, metadata=mappingproxy({}))¶
-
username
= Attribute(name='username', default=NOTHING, validator=None, repr=True, cmp=True, hash=None, init=True, convert=None, metadata=mappingproxy({}))¶
-
-
class
uptime_report.backends.pingdom.
PingdomStatus
¶ Bases:
enum.Enum
-
DOWN
= 'down'¶
-
UNCONFIRMED
= 'unconfirmed_down'¶
-
UNKNOWN
= 'unknown'¶
-
UP
= 'up'¶
-
to_result
()¶
-
-
class
uptime_report.backends.pingdom.
Result
(time, check, type, meta=NOTHING)¶ Bases:
object
Base result class.
-
check
= Attribute(name='check', default=NOTHING, validator=None, repr=True, cmp=True, hash=None, init=True, convert=None, metadata=mappingproxy({}))¶
-
meta
= Attribute(name='meta', default=Factory(factory=<type 'dict'>, takes_self=False), validator=None, repr=True, cmp=True, hash=None, init=True, convert=None, metadata=mappingproxy({}))¶
-
time
= Attribute(name='time', default=NOTHING, validator=None, repr=True, cmp=True, hash=None, init=True, convert=<function get>, metadata=mappingproxy({}))¶
-
type
= Attribute(name='type', default=NOTHING, validator=<in_ validator with options <enum 'ResultType'>>, repr=True, cmp=True, hash=None, init=True, convert=None, metadata=mappingproxy({}))¶
-
-
class
uptime_report.backends.pingdom.
ResultType
¶ Bases:
enum.Enum
-
DOWN
= 'down'¶
-
UNCONFIRMED
= 'unconfirmed'¶
-
UNKNOWN
= 'unknown'¶
-
UP
= 'up'¶
-
-
uptime_report.backends.pingdom.
backend
¶ alias of
PingdomBackend
-
uptime_report.backends.pingdom.
check_results
(check, start=None, finish=None, *args, **kwargs)¶
-
uptime_report.backends.pingdom.
make_result
(check, item)¶
-
uptime_report.backends.pingdom.
outages_from_results
(results, group_by=None)¶
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.Enum
Enumeration 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
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.
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
Arrow
instance as thenow
argument.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:
object
An 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
Outage
objects to write.
Module contents¶
Pingdom Uptime Report - Generate uptime reports using the Pingdom API.