This library is created for building InfraSonar agents.
pip install pylibagent
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 . |
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)
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())