Git Product home page Git Product logo

pingdomlib's People

Contributors

aaronfay avatar allardhoeve avatar ashb avatar brizrobbo avatar clouserw avatar gertjanol avatar gwillem avatar kennethwilke avatar msabramo avatar okushchenko avatar sbailey-godaddy avatar vdloo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pingdomlib's Issues

Update sendnotificationwhendown with legacy system doesn't work

There's a bug in the Pingdom API:

$ curl -s -X PUT --data "sendnotificationwhendown=2" -H "Authorization: Basic $BAUTH" -H "App-Key: $APPKEY" https://api.pingdom.com/api/2.0/checks/1459050 | python -mjson.tool
{
    "message": "Modification of check was successful!"
}

But it's lying, nothing has changed.

The apparent fix is to also supply use_legacy_notifications=true when changing this particular value. This breaks PingdomCheck.__setattr__ (when pingdom.pushChanges is True).

Awaiting reply from Pingdom (whether they will fix it in their API).

likelihood of py3 support?

Python noob here. Is this code likely to be updated to work with Python3?

I get various errors trying to use it with Python 3.6.2. Some are simple and appear to be related to the removal of list.iteritems and dict.iterkeys/values in Python3; I've fixed locally and that code now appears to do the right thing. Not sure what to do with the below, however:

def __addDetails__(self, checkinfo):
    """Fills attributes from a dictionary, uses special handling for the
        'type' key"""

    # Auto-load instance attributes from passed in dictionary
    for key in checkinfo:
        if key == 'type':
            if checkinfo[key] in checktypes:
                self.type = checkinfo[key]
            else:
                # Take key from type dict, convert to string for type
                self.type = checkinfo[key].keys().next()

                # Take value from type dict, store to member of new attrib
                object.__setattr__(self, self.type,
                                   checkinfo[key].values().next())
        else:
            # Store other key value pairs as attributes
            object.__setattr__(self, key, checkinfo[key])

The error I get is

>>> checks[0].getDetails()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/pingdomlib/check.py", line 178, in getDetails
    self.__addDetails__(response.json()['check'])
  File "/usr/local/lib/python3.6/site-packages/pingdomlib/check.py", line 155, in __addDetails__
    self.type = checkinfo[key].keys().next()
AttributeError: 'dict_keys' object has no attribute 'next'

Issue while connecting to pingdom on google app server.

I am trying to use PingdomLib to connect a django application on Google App Engine, but I am getting the following exception related to SSL. I couldn't find anything on google to solve this. Please look into this.

INFO 2016-05-12 11:31:32,447 connectionpool.py:788] Starting new HTTPS connection (1): api.pingdom.com
Internal Server Error: /
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django-1.5/django/core/handlers/base.py", line 113, in get_response
response = callback(request, _callback_args, *_callback_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/Application/views.py", line 6, in index
pingdomchecks = api.getChecks()
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/pingdomlib/pingdom.py", line 212, in getChecks
response = self.request('GET', 'checks', parameters)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/pingdomlib/pingdom.py", line 66, in request
headers=headers)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/api.py", line 71, in get
return request('get', url, params=params, *_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/api.py", line 57, in request
return session.request(method=method, url=url, *_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/sessions.py", line 475, in request
resp = self.send(prep, *_send_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/sessions.py", line 585, in send
r = adapter.send(request, *_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/adapters.py", line 477, in send
raise SSLError(e, request=request)
SSLError: Can't connect to HTTPS URL because the SSL module is not available.
ERROR2016-05-12 11:31:32,447 base.py:210] Internal Server Error: /
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django-1.5/django/core/handlers/base.py", line 113, in get_response
response = callback(request, _callback_args, *_callback_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/Application/views.py", line 6, in index
pingdomchecks = api.getChecks()
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/pingdomlib/pingdom.py", line 212, in getChecks
response = self.request('GET', 'checks', parameters)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/pingdomlib/pingdom.py", line 66, in request
headers=headers)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/api.py", line 71, in get
return request('get', url, params=params, *_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/api.py", line 57, in request
return session.request(method=method, url=url, *_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/sessions.py", line 475, in request
resp = self.send(prep, *_send_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/sessions.py", line 585, in send
r = adapter.send(request, *_kwargs)
File "/Users/ankur/Documents/Ankur/ApplicationMonitor/lib/requests/adapters.py", line 477, in send
raise SSLError(e, request=request)
SSLError: Can't connect to HTTPS URL because the SSL module is not available.
INFO 2016-05-12 11:31:32,524 module.py:788] default: "GET / HTTP/1.1" 500 83729

Incomplete list of valid arguments

In some places, a verification is done to know if the user is providing valid arguments. I think the lists have some arguments names missing:

While creating a Check, I got a warning about the "tags" argument but it works.
https://github.com/KennethWilke/PingdomLib/blob/master/pingdomlib/check.py#L66

While updating a Check, I got a warning about the "name" argument but it works.
https://github.com/KennethWilke/PingdomLib/blob/master/pingdomlib/check.py#L356

I don't know if these missing arguments are the only one, that's why I can't yet provide a PR. If you think I can make one with only these 2, I will.

Regards,

Modifying notificationdelay will delete your contactids

FYI, it's an API bug, that was reported to Pingdom at 2015-01-26

$ curl -su $PINGDOM_USER:$PINGDOM_PASS -H "App-Key: $PINGDOM_KEY" https://api.pingdom.com/api/2.0/checks/1236831 | python -mjson.tool | grep -A2 contactids
        "contactids": [
            10640040
        ],

$ curl -su $PINGDOM_USER:$PINGDOM_PASS -H "App-Key: $PINGDOM_KEY" -X PUT --data 'use_legacy_notifications=true&sendnotificationwhendown=16' https://api.pingdom.com/api/2.0/checks/1236831 | python -mjson.tool 
{
    "message": "Modification of check was successful!"
}

$ curl -su $PINGDOM_USER:$PINGDOM_PASS -H "App-Key: $PINGDOM_KEY" https://api.pingdom.com/api/2.0/checks/1236831 | python -mjson.tool | grep -A2 contactids

[...nothing...]

Warning for "sendtoandroid" in kwargs

Line 242 of pingdom.py lists the "sendtoandroid" parameter, but the warnings that start on 411 do not exclude that parameter. Using that parameter will result in a warning, but nothing worse than that.

Please tag releases to pypi

Hey there Kenneth,

Can you please create a tag when you upload to PyPi? That helps in collaborating ๐Ÿ˜„

Thanks!

Connect with different email

Hi,

I want to query the pingdom api.
My problem is i can't use email, passwd and api-key.
I must curl the api like this:
curl -X GET -u email:password -H "account-email: main login mail" -H 'Content-Type: application/json' -H 'App-Key: API-KEY' "https://api.pingdom.com/api/2.1/summary.performance/354354354354?includeuptime=true&resolution=hour&order=desc"
The Header account-email is important, without this i get 403 back.

Can someone assist me how I can use the api with this challenge?

check.__getattr__ hangs when requested item missing from Pingdom response

I think that Check.__getattr__ is in a loop of some kind when I try to access lasterrortime attribute on a check where it doesn't exist:

In [1]: details = check.getDetails()
In [2]: details
Out[2]:
{u'contactids': [10919360, 10919362, 10919361],
 u'created': 1419369381,
 u'hostname': u'domainhasbeenchanged.com',
 u'id': 1461209,
 u'lastresponsetime': 630,
 u'lasttesttime': 1421273340,
 u'name': u'domainhasbeenchanged.com',
 u'notifyagainevery': 3,
 u'notifywhenbackup': True,
 u'resolution': 1,
 u'sendnotificationwhendown': 4,
 u'sendtoandroid': False,
 u'sendtoemail': True,
 u'sendtoiphone': False,
 u'sendtosms': False,
 u'sendtotwitter': False,
 u'status': u'up',
 u'tags': [],
 u'type': {u'http': {u'encryption': False,
   u'port': 80,
   u'requestheaders': {u'User-Agent': u'Pingdom.com_bot_version_1.4_(http://www.pingdom.com)'},
   u'url': u'/'}},
 u'use_legacy_notifications': True}
In [3]: 'lasterrortime' in details
Out[3]: False
In [4]: hasattr(check, 'lasterrortime')
<hangs here>

After about 30 seconds it finally returns with a False value. A quick at the code shows that __getattr__ calls getattr again internally, so I suspect a loop or something, but I haven't tested it.

Check detailed data (from getChecks)

Hi,

It seems accessing some additional data (by additional data, I mean the keys returned by /checks/{checkid} on Pingdom API but not returned by /checks, e.g. sendnotificationwhendown attribute) on a PingdomCheck returned by Pingdom.getChecks() does not return successfully the value we want.

From what I've understood in the source code, the missing detailed keys are set to None, causing the getattr method not to be called then. See https://github.com/KennethWilke/PingdomLib/blob/master/pingdomlib/check.py#L164.

Is there any explanation for this part of the code? Am I missing something?

Thank you.

Regards,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.