Skip to main content

AMI parser data

Project description

AMI Data Parser

This repository aims to provide a tool to interpret and process data received from the Asterisk Manager Interface (AMI). It identifies and exposes status changes in queues and extensions in real-time, enabling more efficient integration with external systems or monitoring dashboards.

Key Features

  • Parsing data from the AMI.
  • Detecting status changes in queues and extensions.
  • Exposing processed data in an integration-friendly format.

Repository

Github: https://github.com/tatianno/ami-data-parser

Requirements

  • Python 3.10 +

Installation

Clone the repository and install the dependencies:

pip install -r requirements.txt

Dependencies

The project requires the following packages:

  • pyst2
  • ami-data-parser

Example Code

import sys
from time import sleep
from ami_data_parser import Controller
from asterisk.manager import (
   Manager,
   ManagerAuthException,
   ManagerException,
   ManagerSocketException
)

AMI_HOST = '192.168.0.103'
AMI_USERNAME = 'DEV'
AMI_PASSWORD = 'gnew'

if __name__ == '__main__':

   manager = Manager()
   controller = Controller()

   try:
      # connect to the manager
      try:
         manager.connect(AMI_HOST)
         manager.login(AMI_USERNAME, AMI_PASSWORD)

         while True:
            queue_data = manager.command('queue show').response
            peer_data = manager.command('core show hints').response
            channel_data = manager.command('core show channels concise').response
            print('-----------queue data-----------------')
            print(controller.queue_update(queue_data))
            print('-----------peer data------------------')
            print(controller.peer_update(peer_data))
            print('-----------channel data---------------')
            print(controller.channel_update(channel_data))
            sleep(2)

      except ManagerSocketException:
         print("Error connecting to the manager")
         sys.exit(1)

      except ManagerAuthException:
         print("Error logging in to the manager")
         sys.exit(1)

      except ManagerException:
         print("Error")
         sys.exit(1)
      
      except KeyboardInterrupt:
         sys.exit(0)

   finally:
      manager.logoff()

Project details


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

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

ami_data_parser-0.2.5-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file ami_data_parser-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for ami_data_parser-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5a8b02d84aa7be833d63e0707d31ed69ee3ca63f9e2b51ff13c95182b11c039a
MD5 ace142e4a8604d901934b1e6a839dbf5
BLAKE2b-256 d5d04e01e17819778be80b2da3a1e8061b49a94b6fc232fd63a51a5f52b17977

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