pylibagent


Namepylibagent JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/infrasonar/python-libagent
SummaryLibrary for building InfraSonar agents
upload_time2023-07-26 08:04:45
maintainer
docs_urlNone
authorCesbit
requires_python
license
keywords monitoring infrasonar agent
VCS
bugtrack_url
requirements No requirements were recorded.
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": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "monitoring,infrasonar,agent",
    "author": "Cesbit",
    "author_email": "info@cesbit.com",
    "download_url": "https://files.pythonhosted.org/packages/be/46/5468e232478e2f3010335f0ca92b36e3604c50336be41cb2c5ed42e9be8c/pylibagent-0.2.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\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Library for building InfraSonar agents",
    "version": "0.2.1",
    "project_urls": {
        "Download": "https://github.com/infrasonar/python-libagent/tarball/v0.2.1",
        "Homepage": "https://github.com/infrasonar/python-libagent"
    },
    "split_keywords": [
        "monitoring",
        "infrasonar",
        "agent"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "be465468e232478e2f3010335f0ca92b36e3604c50336be41cb2c5ed42e9be8c",
                "md5": "59467b6c355993d8a38e97433f71984b",
                "sha256": "98c64d41d60d74ab324cdc8ff731ae5d78be25739ed7913e68b0daa7ee84b2a3"
            },
            "downloads": -1,
            "filename": "pylibagent-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "59467b6c355993d8a38e97433f71984b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 22032,
            "upload_time": "2023-07-26T08:04:45",
            "upload_time_iso_8601": "2023-07-26T08:04:45.257652Z",
            "url": "https://files.pythonhosted.org/packages/be/46/5468e232478e2f3010335f0ca92b36e3604c50336be41cb2c5ed42e9be8c/pylibagent-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-26 08:04:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "infrasonar",
    "github_project": "python-libagent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pylibagent"
}
        
Elapsed time: 0.20967s