pylibagent


Namepylibagent JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/infrasonar/python-libagent
SummaryLibrary for building InfraSonar agents
upload_time2024-09-20 13:42:37
maintainerNone
docs_urlNone
authorCesbit
requires_pythonNone
licenseNone
keywords monitoring infrasonar agent
VCS
bugtrack_url
requirements aiohttp colorlog msgpack setproctitle
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![CI](https://github.com/infrasonar/python-libagent/workflows/CI/badge.svg)](https://github.com/infrasonar/python-libagent/actions)
[![Release Version](https://img.shields.io/github/release/infrasonar/python-libagent)](https://github.com/infrasonar/python-libagent/releases)

# Python library for building InfraSonar Agents

This library is created for building [InfraSonar](https://infrasonar.com) 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.

```python
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.

```python
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())
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/infrasonar/python-libagent",
    "name": "pylibagent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "monitoring, infrasonar, agent",
    "author": "Cesbit",
    "author_email": "info@cesbit.com",
    "download_url": "https://files.pythonhosted.org/packages/34/2f/7ae6a6cc91fda3347424c0f963e3c0c702e581346cb2b7b2fae0b45defd0/pylibagent-0.3.1.tar.gz",
    "platform": null,
    "description": "[![CI](https://github.com/infrasonar/python-libagent/workflows/CI/badge.svg)](https://github.com/infrasonar/python-libagent/actions)\n[![Release Version](https://img.shields.io/github/release/infrasonar/python-libagent)](https://github.com/infrasonar/python-libagent/releases)\n\n# Python library for building InfraSonar Agents\n\nThis library is created for building [InfraSonar](https://infrasonar.com) agents.\n\n## Installation\n\n```\npip install pylibagent\n```\n\n## Environment variables\n\nVariable                    | Default                       | Description\n----------------------------|-------------------------------|-------------------\n`TOKEN`                     | _required_                    | Token to connect to.\n`ASSET_ID`                  | _required_                    | Asset Id or file location where the Agent asset Id is stored _(e.g `123` or `/var/infrasonar/asset_id.json`)_.\n`API_URI`                   | https://api.infrasonar.com    | InfraSonar API.\n`VERIFY_SSL`                | `1`                           | Verify SSL certificate, 0 _(=disabled)_ or 1 _(=enabled)_.\n`LOG_LEVEL`                 | `warning`                     | Log level _(error, warning, info, debug)_.\n`LOG_COLORIZED`             | `0`                           | Log colorized, 0 _(=disabled)_ or 1 _(=enabled)_.\n`LOG_FMT`                   | `%y%m...`                     | Default format is `%y%m%d %H:%M:%S`.\n\n\n## Usage (Demonized agent)\n\nBuilding an InfraSonar demonized agent.\n\n```python\nfrom pylibagent.agent import Agent\nfrom pylibagent.check import CheckBase\n\n__version__ = \"0.1.0\"\n\n\nclass SampleCheck(CheckBase):\n\n    key = \"sample\"\n    interval = 300\n\n    @classmethod\n    async def run(cls):\n        return {\n            \"type\": [\n                {\n                    \"name\": \"item\",\n                    \"metric\": 123\n                }\n            ]\n        }\n\n\nif __name__ == \"__main__\":\n    collector_key = \"sample\"\n    version = \"0.1.0\"\n    checks = [SampleCheck]\n\n    Agent(collector_key, version).start(checks)\n```\n\n\n## Usage (Non-demonized agent)\n\nBuilding an InfraSonar agent.\n\n```python\nimport asyncio\nfrom pylibagent.agent import Agent\n\n__version__ = \"0.1.0\"\n\n\nasync def main():\n    version = \"0.1.0\"\n    collector_key = \"sample\"\n    check_key = \"sample\"\n\n    agent = Agent(collector_key, version)\n    await agent.announce()  # optionally, we can provide an initial asset name\n    await agent.send_data(check_key, {\n        \"type\": [\n            {\n                \"name\": \"item\",\n                \"metric\": 123\n            }\n        ]\n    })\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Library for building InfraSonar agents",
    "version": "0.3.1",
    "project_urls": {
        "Download": "https://github.com/infrasonar/python-libagent/tarball/v0.3.1",
        "Homepage": "https://github.com/infrasonar/python-libagent"
    },
    "split_keywords": [
        "monitoring",
        " infrasonar",
        " agent"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "342f7ae6a6cc91fda3347424c0f963e3c0c702e581346cb2b7b2fae0b45defd0",
                "md5": "54e632d0c356f7d4dc4256c243135bd8",
                "sha256": "9fbb6004c8d27f2fb278820a7fa00befc0ce98f338c189cad1a11eb7c6f92396"
            },
            "downloads": -1,
            "filename": "pylibagent-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "54e632d0c356f7d4dc4256c243135bd8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 22314,
            "upload_time": "2024-09-20T13:42:37",
            "upload_time_iso_8601": "2024-09-20T13:42:37.822941Z",
            "url": "https://files.pythonhosted.org/packages/34/2f/7ae6a6cc91fda3347424c0f963e3c0c702e581346cb2b7b2fae0b45defd0/pylibagent-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-20 13:42:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "infrasonar",
    "github_project": "python-libagent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "aiohttp",
            "specs": [
                [
                    ">=",
                    "3.10.5"
                ]
            ]
        },
        {
            "name": "colorlog",
            "specs": [
                [
                    ">=",
                    "6.8.2"
                ]
            ]
        },
        {
            "name": "msgpack",
            "specs": [
                [
                    ">=",
                    "1.1.0"
                ]
            ]
        },
        {
            "name": "setproctitle",
            "specs": [
                [
                    ">=",
                    "1.3.3"
                ]
            ]
        }
    ],
    "lcname": "pylibagent"
}
        
Elapsed time: 2.52868s