Skip to main content

Library for building InfraSonar agents

Project description

CI Release Version

Python library for building InfraSonar Agents

This library is created for building InfraSonar agents.

Installation

pip install pylibagent

Environment variables

Variable Default Description
TOKEN required Token to connect to.
ASSET_ID required Asset Id or file location where the Agent asset Id is stored (e.g 123 or /var/infrasonar/asset_id.json).
API_URI https://api.infrasonar.com InfraSonar API.
VERIFY_SSL 1 Verify SSL certificate, 0 (=disabled) or 1 (=enabled).
LOG_LEVEL warning Log level (error, warning, info, debug).
LOG_COLORIZED 0 Log colorized, 0 (=disabled) or 1 (=enabled).
LOG_FMT %y%m... Default format is %y%m%d %H:%M:%S.

Usage (Demonized agent)

Building an InfraSonar demonized agent.

from pylibagent.agent import Agent
from pylibagent.check import CheckBase

__version__ = "0.1.0"


class SampleCheck(CheckBase):

    key = "sample"
    interval = 300

    @classmethod
    async def run(cls):
        return {
            "type": [
                {
                    "name": "item",
                    "metric": 123
                }
            ]
        }


if __name__ == "__main__":
    collector_key = "sample"
    version = "0.1.0"
    checks = [SampleCheck]

    Agent(collector_key, version).start(checks)

Usage (Non-demonized agent)

Building an InfraSonar agent.

import asyncio
from pylibagent.agent import Agent

__version__ = "0.1.0"


async def main():
    version = "0.1.0"
    collector_key = "sample"
    check_key = "sample"

    agent = Agent(collector_key, version)
    await agent.announce()  # optionally, we can provide an initial asset name
    await agent.send_data(check_key, {
        "type": [
            {
                "name": "item",
                "metric": 123
            }
        ]
    })


if __name__ == "__main__":
    asyncio.run(main())

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

pylibagent-0.3.1.tar.gz (22.3 kB view details)

Uploaded Source

File details

Details for the file pylibagent-0.3.1.tar.gz.

File metadata

  • Download URL: pylibagent-0.3.1.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pylibagent-0.3.1.tar.gz
Algorithm Hash digest
SHA256 9fbb6004c8d27f2fb278820a7fa00befc0ce98f338c189cad1a11eb7c6f92396
MD5 54e632d0c356f7d4dc4256c243135bd8
BLAKE2b-256 342f7ae6a6cc91fda3347424c0f963e3c0c702e581346cb2b7b2fae0b45defd0

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