Skip to main content

micro client for okerr cloud monitoring system

Project description

okerrupdate - simple interface to update okerr indicator

Simplest

Reads textid and secret from default config file (/etc/okerrclient.conf), updates heartbeat indicator 'test:1' with status OK. If no such indicator - creates it (if policy allows autocreate).

#!/usr/bin/python
import okerrupdate
op = okerrupdate.OkerrProject()
i = op.indicator("test:1")
i.update('OK')

... or in one line, right from shell:

python -c 'import okerrupdate; okerrupdate.OkerrProject("MyTextID").indicator("qqqq", secret="MySecret").update("OK")'

More detailed

Sets verbose mode. Sets textid and secret from script. Creates numerical indicator and sets parameters for it, then updates it.

#!/usr/bin/python
import okerrupdate

# create okerr project
op = okerrupdate.OkerrProject('MyTextID', 'MySecret1')
op.verbose()

# create indicator
i = op.indicator("test:1", method='numerical|maxlim=37')
i.update('36.6', 'Current temperature is normal')

Classes and Methods

OkerrProject

def __init__(self, textid=None, secret=None, url=None, dry_run=False, config=None):

If textid not specified, read_config() method used.

  • textid - project textid
  • secret - secret key to update indicators
  • url - URL of server (You dont need to use it in most cases)
  • dry_run - if True, no indicators will be updated
  • config - filename of okerrclient.conf file
def read_config(self, filename=None):

Reads textid and secret from config file filename (default: /etc/okerrclient.conf).

def setloglevel(self,lvl):
    self.log.setLevel(lvl)

def verbose(self):
    self.setloglevel(logging.DEBUG)

def setlog(self, log):
    self.log = log

Can be used to configure logging

def indicator(self, name, secret=None, method=None, policy=None, tags=None, error=None, origkeypath=None, keypath=None):

Most important method. Returns OkerrIndicator project with this parameters.

OkerrIndicator

def __init__(self, name, project, secret=None, method=None, policy=None, tags=None, error=None, origkeypath=None, keypath=None):

Usually not used directly, OkerrProject.indicator() will create it.

def update(self, status, details=None):

Updates indicator. Raises OkerrExc exception if any problem. Requests exceptions are catched inside method and OkerrExc is raised.

Skips update if less then 300 seconds passed since last update. (So, it's safe to call it in quick loop, it will handle throttling itself)

OkerrExc

Dummy class for exceptions. Use it to catch any exception. Snippet from okerrupdate code:

class OkerrExc(Exception):
    pass

Examples

from okerrupdate import OkerrProject, OkerrExc

op = OkerrProject() # textid and secret not specified, will be read from /etc/okerrclient.conf
op.verbose()
i = op.indicator('testindicator', method='numerical|minlim=0|maxlim=100')

try:
    i.update(80)
except OkerrExc as e:
    print("Got OkerrExc: {}".format(e))

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

okerrupdate-1.1.37-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file okerrupdate-1.1.37-py3-none-any.whl.

File metadata

  • Download URL: okerrupdate-1.1.37-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.9

File hashes

Hashes for okerrupdate-1.1.37-py3-none-any.whl
Algorithm Hash digest
SHA256 6bf566c5d58351412077fb2503f27939cb43da28f36bb51e4e843856f9eca465
MD5 a25fa973e6ea7e18368183131f6e8053
BLAKE2b-256 8dcb4d664139e6dded70b81d6a9ce697f6a51d0bd11038df8cc2aaf69e1045aa

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