Skip to main content

Python client for the Opsview API

Project description

PyOpsview :snake:

Python REST API Client for Opsview!

Opsview Logo

Installation

Installing Dependencies

# Using `pip`
pip install -r https://raw.githubusercontent.com/jpgxs/pyopsview/master/requirements.txt

# Using `apt`
apt update && apt install python-requests python-six

# Using `apt-get`
apt-get update && apt-get install python-requests python-six

# Using `yum`
yum install python-requests python-six

# Using `dnf`
dnf install python-requests python-six

# Using `urpmi`
urpmi python-requests python-six

Installing

# From `pypi`
pip install pyopsview

# From source
git clone https://github.com/jpgxs/pyopsview
cd pyopsview
python setup.py install

Usage

Basic Usage

from __future__ import print_function

from pyopsview import OpsviewClient
from pyopsview.exceptions import OpsviewClientException

# Authenticate the client and load the appropriate API schema for the
# specific Opsview version
client = OpsviewClient(username='admin', password='initial',
                       endpoint='https://opsview.example.com')

# Create a new client using the token; this is useful for things like ansible
# where the login operation would otherwise have to be done for every operation
auth_token = client.token
client = OpsviewClient(username='admin', token=auth_token,
                       endpoint='https://opsview.example.com')

# Get a list of the configured hosts. This returns a generator.
all_hosts = client.config.hosts.list()
for host in all_hosts:
    print(host['check_interval'])

# Find all hosts monitored by the master monitoring server.
monitored_by_master = client.config.hosts.find(monitored_by='Master Monitoring Server')

# Update the address of one host
update_host = all_hosts[-1]
update_host['address'] = '127.128.129.130'
update_host = client.config.hosts.update(update_host['id'], **update_host)

# Find the Master opsview server
opsview_master = client.config.hosts.find_one(name='Opsview')
if opsview_master is None:
    raise RuntimeError('Failed to find the Opsview master server!')

# Get a list of all Service Checks on the Opsview master
master_service_checks = []
master_service_checks += opsview_master['service_checks']

for template in opsview_master['host_templates']:
    template_detail = client.hosttemplates.find_one(template['name'])
    master_service_checks += template_detail['service_checks']

TODO

  • Add schemas for other versions of Opsview
  • Add API operations for:
    • Downtime
    • Service/Host Status
    • Live Object Information (Runtime)
    • Acknowledgements
    • Scheduling Rechecks
    • Graphing Data
    • Event/History Data
    • Notes
    • SNMP queries

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

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

pyopsview-6.2.0.tar.gz (40.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyopsview-6.2.0-py2-none-any.whl (73.9 kB view details)

Uploaded Python 2

File details

Details for the file pyopsview-6.2.0.tar.gz.

File metadata

  • Download URL: pyopsview-6.2.0.tar.gz
  • Upload date:
  • Size: 40.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.15

File hashes

Hashes for pyopsview-6.2.0.tar.gz
Algorithm Hash digest
SHA256 bd66ae3ec267fa98e27a0c107636411c3dd172b891bcea4372cdc28999f7f2ac
MD5 3c940ed1755900dfb3ddc4f7074a6c07
BLAKE2b-256 d2a9871a7e5d1e885df87ea9037b5453a3afe797da18d24dff1d5a74ed63458d

See more details on using hashes here.

File details

Details for the file pyopsview-6.2.0-py2-none-any.whl.

File metadata

  • Download URL: pyopsview-6.2.0-py2-none-any.whl
  • Upload date:
  • Size: 73.9 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.15

File hashes

Hashes for pyopsview-6.2.0-py2-none-any.whl
Algorithm Hash digest
SHA256 d06415e6e3bcf4fab03b85db469d08a0c16dcaf4d94aa49f817866a919b3b117
MD5 ac7424e6d1ca2f52579d79dbcea5ba19
BLAKE2b-256 ea0a6361a33ba904171cfa545b6214ec63f3d1027c70661fcf21766b4c06df39

See more details on using hashes here.

Supported by

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