Skip to main content

Module to interact with the AKiPS Network Monitoring Software API interface

Project description

PyPI - Python Version PyPI Downloads GitHub contributors

akips

This akips module provides a simple way for python scripts to interact with the AKiPS Network Monitoring Software API interface.

Installation

To install akips, simply use pip:

pip install akips

AKiPS Setup

AKiPS includes a way to extend the server through custom perl scripts. They publish a list from their Support - Site scripts page, along with install instructions.

This module can use additional routines included in the akips_setup directory of this repository, site_scripting.pl.

Usage Examples

Connect to AKiPS

import pprint
from akips import AKIPS

api = AKIPS('akips.example.com',username='api-ro',password='something')

List all devices (with an optional group filter)

devices = api.get_devices(groups=['a10'])
pprint.pp(devices, sort_dicts=True, width=120, indent=4)

The above code will output the text below.

{   'TH840-A': {   'SNMPv2-MIB.sysDescr': 'Thunder Series Unified Application Service Gateway TH840 ACOS',
                   'SNMPv2-MIB.sysLocation': 'Datacenter A',
                   'SNMPv2-MIB.sysName': 'TH840-A',
                   'ip4addr': '192.168.20.15'},
    'TH840-B': {   'SNMPv2-MIB.sysDescr': 'Thunder Series Unified Application Service Gateway TH840 ACOS',
                   'SNMPv2-MIB.sysLocation': 'Datacenter B',
                   'SNMPv2-MIB.sysName': 'TH840-B',
                   'ip4addr': '192.168.30.25'}}

List all data for a specific device

device = api.get_device('TH840-A')
pprint.pp(device, sort_dicts=True, width=120, indent=4)

Lookup the AKiPS device key for a specific IP address

device_key = api.get_device_by_ip(ipaddr='192.168.20.15')
pprint.pp(device_key, sort_dicts=True, width=120, indent=4)

The above code will return the key used by AKiPS for the device with this IP.

'TH840-A'

Get attributes for a specific device and child

attributes = api.get_attributes(device="TH840-A", child="sys")
pprint.pp(attributes, sort_dicts=True, width=120, indent=4)

The above code will return the key used by AKiPS for the device with this IP.

{   'TH840-A': {   'sys': {   'SNMP.community': 'private',
                              'SNMP.discover_oids': '2440',
                              'SNMP.discover_runtime': '0',
                              'SNMP.discover_tt': '1759478985',
                              'SNMP.discover_walks': '57',
                              'SNMP.discover_walks_fail': '0',
                              'SNMP.discover_walks_ok': '57',
                              'SNMP.discover_walks_unknown': '0',
                              'SNMP.ipaddr': '192.168.20.15',
                              'SNMP.lost': '1',
                              'SNMP.maxrep': '20',
                              'SNMP.rtt': '1',
                              'SNMP.rx': '1',
                              'SNMP.snmpState': '2,up,1581605551,1706545348,',
                              'SNMP.tx': '1',
                              'SNMP.version': '2',
                              'SNMPv2-MIB.sysContact': 'Networking',
                              'SNMPv2-MIB.sysDescr': 'Thunder Series Unified Application Service Gateway TH840 ACOS',
                              'SNMPv2-MIB.sysLocation': 'Datacenter A',
                              'SNMPv2-MIB.sysName': 'TH840-A',
                              'SNMPv2-MIB.sysObjectID': 'A10-COMMON-MIB.a10AX.38',
                              'SNMPv2-MIB.sysUpTime': '1749494858,1759502716',
                              'ifXTable': '1',
                              'ip4addr': '192.168.20.15',
                              'mac_md5': 'a34558cd34432f618f5b29fb4376b5a2'}}}

Get a specific attribute over all devices (with optional group filter)

attributes = api.get_attributes(attribute='SNMPv2-MIB.sysUpTime',groups=['a10'])
pprint.pp(attributes, sort_dicts=True, width=120, indent=4)

The above code will return the following data.

{   'TH840-A': {'sys': {'SNMPv2-MIB.sysUpTime': '1749494858,1759502176'}},
    'TH840-B': {'sys': {'SNMPv2-MIB.sysUpTime': '1738681335,1759502177'}}}

Get list of devices in a specific group

group_list = api.get_group_membership(groups=["a10"])
pprint.pp(group_list, sort_dicts=True, width=120, indent=4)

The above code will return the following data.

{   'TH840-A': ['A10', 'admin', 'Core-Routers', 'Not-Core', 'OpsCenter', 'Ungrouped', 'user '],
    'TH840-B': ['A10', 'admin', 'Core-Routers', 'Not-Core', 'OpsCenter', 'Ungrouped', 'user ']}

Get list of groups for a specific device

group_list = api.get_group_membership(device="TH840-A")
pprint.pp(group_list, sort_dicts=True, width=120, indent=4)

The above code will return the following data.

{'TH840-A': ['A10', 'admin', 'Core-Routers', 'Not-Core', 'OpsCenter', 'Ungrouped', 'user ']}

API Errors

An AkipsError exception will be thrown if the AKiPS API responds with an error message. The output below was generated by providing an invalid password and making a call.

api = AKIPS('server' ,username='api-ro', password='badpassword')
device = api.get_device('TH840-A')
% ./akips_test.py
Web API request failed: ERROR: api-db invalid username/password

Traceback (most recent call last):
  File "/Users/test/project/akips_test/./akips_test.py", line 25, in <module>
    device = api.get_device('TH840-A')
  File "/Users/test/project/akips_test/venv/lib/python3.10/site-packages/akips/__init__.py", line 93, in get_device
    text = self._get(params=params)
  File "/Users/test/project/akips_test/venv/lib/python3.10/site-packages/akips/__init__.py", line 502, in _get
    raise AkipsError(message=r.text)
akips.exceptions.AkipsError: ERROR: api-db invalid username/password

API Documentation

API Documentation

Contributing

CONTRIBUTING.md

Bugs/Requests

Please use the GitHub issue tracker to submit bugs or request features.

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

akips-0.5.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

akips-0.5.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file akips-0.5.1.tar.gz.

File metadata

  • Download URL: akips-0.5.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.2 Darwin/24.6.0

File hashes

Hashes for akips-0.5.1.tar.gz
Algorithm Hash digest
SHA256 b2ddf76322eec5f14a7cc783b9bf21ee6c421292bb1bd7ad118f8cd95c8d9ba4
MD5 62ddae1fbf3bb3e671ca0136771616af
BLAKE2b-256 d4a7b81c419872d48b9d7703de00eca3d12dca582ee0b327b0e985bbc90b2cd7

See more details on using hashes here.

File details

Details for the file akips-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: akips-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.2 Darwin/24.6.0

File hashes

Hashes for akips-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3743c039ec18314395a9d7bd7cced0f6e9867a848870aa45cc25567a60651f29
MD5 4e518239289394768d47a20d55d9b2fb
BLAKE2b-256 5c7807072f19f0cf70ce89e38e573fea89403c29894e51fb594a48df37255ab3

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