Skip to main content

A simple pingdom API interface for read RUM information

Project description

Simple python API Against Pingdom, that feature RUM extraction.

https://travis-ci.org/Epi10/pyngdom.svg?branch=master Join the chat at https://gitter.im/Epi10/pyngdom Downloads

Coments

Please feel free to levae a coment (if instalation fail, or something is not working) on gitter at https://gitter.im/Epi10/pyngdom or send me a email at aleivag@gmail.com

Install

As usual

python setup.py install

Or as less ussual

pip install pyngdom

Or as less less usual

pip install git+https://github.com/Epi10/pyngdom

Getting Rum

If you are here is for the RUM (and that’s not a bad pirate’s pun).

We provide with 2 interfaces to pingdom rum, the first one its using a python-only aproach, and that will give you only today’s RUM information, that’s good if you don’t want to install extra dependencies or dont like/want selenium. for the second approach you’ll need selenium and a webbrowser, for testing, Firefox is fine, but if you really wnat to take advantage of the script you should really use PhantomJS (the default).

Examples will be placed in the example folder, and you can use the at will. i really recomend check the git repository to get the latest examples.

Python-Only method

Disclaimer, the RUM search is not part of the pingdom API, and its not supported by pingdom, so it can stop working at any time, use under your own risk. Also this method is harder to maintain than the selenium approach, so will take longer to fix if pingdom change anything.

So how it is use:

from pyngdom import PyngdomRum

pingdom = Pyngdom(
    username='user@epi10.cl',
    password='super-secret-password',
    apikey='6dz4mqdms0qaxrjstntf6myt6wz5vseg',
    account='owner@epi10.cl'
)
pingdom.login()

Now you need to know the rum test ID, that’s easy all you need to do is login into pingdom and then look for the RUM link in the reports page, the format of the rum link is https://my.pingdom.com/rum/XXXXXXXXXXX

here is a example

RumID search

after you got the link all you need to do is

>>> rum = pingdom.today_rum('XXXXXXXXXXX')
>>> print rum
{
   u'allow_subdomains': False,
   u'total': {u'average': 2557,
        u'count': 40305,
        u'median': 1971.4791994493,
        u'p90': 4623.1101804124,
        u'p95': 5853.3586753731,
        u'p99': 10089.605}
   ....
   ....
   'url': 'http://epi10.cl'
}


#Get Total RUM
>> print rum['total']
{
    u'average': 2557,
    u'count': 40305,
    u'median': 1971.4791994493,
    u'p90': 4623.1101804124,
    u'p95': 5853.3586753731,
    u'p99': 10089.605
}



#Get RUM per geolocation that exist
>> print rum['geo'].get('us', {})
{
   u'average': 6657,
   u'count': 27,
   u'median': 5875.0625,
   u'p90': 9700.0416666667,
   u'p95': 10175.125,
   u'p99': 13435.125
}

# Get geographic zone (remember not all geographic zone exists)
>> print rum['geo'].get('jp', {})
{}

Also there is lots and lots of available information.

If you have selenium (and you should), use it.

If you have selenium (and even better PhantomJS [http://phantomjs.org/]) you should use it. This will open a new door to get RealTime RUM and its easy to implement and expand the PyndomDriver than the normal rum, from the user point of view, both methods should be interchangeable, but this will actually give you realtime RUM.

How do i use it?

First install selenium

pip install selenium

Now you are ready to use it

from pyngdom import PyngdomDriver

# If you want to use your native firefox (no extra install other than having your own firefox)

pingdom = PyngdomDriver(
    username='user@epi10.cl',
    password='super-secret-password',
    base_driver='Firefox'
)

#if you have phantomjs installed

pingdom = PyngdomDriver(
    username='user@epi10.cl',
    password='super-secret-password'
)

#then login
pingdom.login()

then its simple, you just get the checkid of your rum (see previous section) and then call it the same

>>> rum = pingdom.today_rum('XXXXXXXXXXX')
{
   u'allow_subdomains': False,
   u'total': {u'average': 2557,
        u'count': 40305,
        u'median': 1971.4791994493,
        u'p90': 4623.1101804124,
        u'p95': 5853.3586753731,
        u'p99': 10089.605}
   ....
   ....
   'url': 'http://epi10.cl'
}

And now the fun part, to get the realtime rum you just pick a sample interval (i.e. 30 seconds) and then you just

>>> rum = pingdom.realtime_rum('XXXXXXXXXXX', 30)
#30 seconds later

{
   u'allow_subdomains': False,
   u'total': {u'average': 2456,
        u'count': 15,
        u'median': 1971.4791994493,
        u'p90': 4623.1101804124,
        u'p95': 5853.3586753731,
        u'p99': 10089.605}
   ....
   ....
   'url': 'http://epi10.cl'
}

you can use with statements

with PyngdomDriver(username='user@epi10.cl', password='super-secret-password') as pingdom:
    realtime = pingdom.realtime_rum('XXXXXXXXXXX', 30)

And its just that simple… once again we strongly suggest using phantomjs, installit is so simple in linux and mac.

Extra API

If you need the standard pingom API, i recommend using https://pypi.python.org/pypi/PingdomLib , its mature and it is really simple to use. Never the less we include some extra functionality, using the standard pingdom API, only here because for some projects we really need them.

from pprint import pprint

from pyngdom import Pyngdom

pingdom = Pyngdom(
    username='user@epi10.cl',
    password='super-secret-password',
    apikey='6dz4mqdms0qaxrjstntf6myt6wz5vseg',
    account='owner@epi10.cl'
)

check_list = pingdom.get_check_list()

#print the check lists
pprint(check_list)

#get only the check for api.epi10.cl
api_epi10_check = filter(lambda x: x.get('hostname') == 'api.epi10.cl', check_list.get('checks', []))[0]

#print detailed information
print pingdom.get_detailed_check_information(api_epi10_check['id'])

and that how easy would you use it.

Changelog

0.1.2 2014-06-04

  • Fix (stupid) pypi error at install (we read the README.rst in setup.py, but we never include when we python setup.py sdist).

0.1.1 2014-06-04

  • Fix Documentation to include login.

  • Add example folders.

0.1.0 2014-06-03

  • initial commit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyngdom-0.1.2.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file pyngdom-0.1.2.tar.gz.

File metadata

  • Download URL: pyngdom-0.1.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyngdom-0.1.2.tar.gz
Algorithm Hash digest
SHA256 58a10d3cf73c718aed775585133d120e9fb10008d2cf87f7fc500e691580b924
MD5 b2dcf19f14e76762394794395ca39fc1
BLAKE2b-256 239cbf71e115255fd2e6f0fd58e9ed850c3eab7425405f4944dcb39ea473b382

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page