Skip to main content

Swarmauri Psutil Tool.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_psutil


Swarmauri Tool · psutil

A Swarmauri-compatible system inspection tool powered by psutil. Use it to surface CPU, memory, disk, network, and sensor telemetry inside agents, observability workflows, or health checks.

  • Wraps rich psutil APIs behind a single callable interface.
  • Returns structured dictionaries that mirror psutil's native data models (converted to plain Python objects for JSON serialization).
  • Handles common permission gaps gracefully (e.g., network connections, sensors) so calls do not crash automation.

Requirements

  • Python 3.10 – 3.13.
  • psutil installed (pulled automatically with the package).
  • Optional platform support: some sensor endpoints require root/admin privileges or may not exist on virtualized hosts.

Installation

Select the installer that matches your environment; each command resolves transitive dependencies.

pip

pip install swarmauri_tool_psutil

Poetry

poetry add swarmauri_tool_psutil

uv

# Add to the current project and update uv.lock
uv add swarmauri_tool_psutil

# or install directly into the active environment without editing pyproject.toml
uv pip install swarmauri_tool_psutil

Tip: psutil needs native build tooling on some platforms (musl-based containers, Alpine). Install the OS-level prerequisites before running the package install command.

Quick Start

from pprint import pprint
from swarmauri_tool_psutil import PsutilTool

psutil_tool = PsutilTool()

cpu = psutil_tool("cpu")
mem = psutil_tool("memory")

print("CPU summary:")
pprint(cpu)

print("Memory summary:")
pprint(mem)

Each call returns a dictionary keyed by metrics families (e.g., cpu_times, virtual_memory). Use only the sections you need in downstream automations.

Usage Scenarios

Build a Lightweight Health Endpoint

from fastapi import FastAPI
from swarmauri_tool_psutil import PsutilTool

app = FastAPI()
ps_tool = PsutilTool()

@app.get("/health/system")
def system_health():
    return {
        "cpu": ps_tool("cpu"),
        "memory": ps_tool("memory"),
        "disk": ps_tool("disk"),
    }

Expose system metrics to dashboards or probes without wiring psutil manually.

Enrich Swarmauri Agent Responses With Telemetry

from swarmauri_core.agent.Agent import Agent
from swarmauri_core.messages.HumanMessage import HumanMessage
from swarmauri_standard.tools.registry import ToolRegistry
from swarmauri_tool_psutil import PsutilTool

registry = ToolRegistry()
registry.register(PsutilTool())
agent = Agent(tool_registry=registry)

message = HumanMessage(content="report system cpu load and memory usage")
response = agent.run(message)
print(response)

Register the tool alongside other Swarmauri capabilities so agents can answer operational questions on demand.

Archive High-Usage Events for Later Analysis

import json
import time
from pathlib import Path
from swarmauri_tool_psutil import PsutilTool

ps_tool = PsutilTool()
log_dir = Path("telemetry_logs")
log_dir.mkdir(exist_ok=True)

while True:
    snapshot = {
        "ts": time.time(),
        "cpu": ps_tool("cpu"),
        "memory": ps_tool("memory"),
        "network": ps_tool("network"),
    }
    (log_dir / f"snapshot-{int(snapshot['ts'])}.json").write_text(
        json.dumps(snapshot, indent=2)
    )
    time.sleep(60)

Capture periodic snapshots that can be loaded into notebooks, dashboards, or anomaly detection jobs.

Troubleshooting

  • ValueError: Invalid info_type – Only "cpu", "memory", "disk", "network", and "sensors" are supported. Validate user input before calling the tool.
  • Permission denied retrieving connections/sensors – Run with elevated privileges or filter out those sections. The tool returns a descriptive string when it cannot access the data.
  • psutil.AccessDenied on containerized hosts – Grant the container additional capabilities (e.g., SYS_PTRACE) or restrict to metrics that do not require elevated rights.

License

swarmauri_tool_psutil is released under the Apache 2.0 License. See LICENSE for details.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_tool_psutil-0.9.0.dev22.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

swarmauri_tool_psutil-0.9.0.dev22-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_tool_psutil-0.9.0.dev22.tar.gz.

File metadata

  • Download URL: swarmauri_tool_psutil-0.9.0.dev22.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_psutil-0.9.0.dev22.tar.gz
Algorithm Hash digest
SHA256 1cc437c8482a562178f07903b7b5e457f46b8f0c0e93f00897499568f1b3fa7b
MD5 73096e50fcc5ed645d5180414feb5981
BLAKE2b-256 fefb05f98744e7385fa3d1391ff4a6325230aa382e665ab7f665a30866b6d8dd

See more details on using hashes here.

File details

Details for the file swarmauri_tool_psutil-0.9.0.dev22-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_psutil-0.9.0.dev22-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_psutil-0.9.0.dev22-py3-none-any.whl
Algorithm Hash digest
SHA256 2edd0b210be38f78410bbf23344469b706b5a253ec7fd8db5f456788eb1c342b
MD5 d3c677c0cc17a2923c20c72a9ef76ac3
BLAKE2b-256 98612ca198e57cb55fefc10cd731dc3c37d8c9a8d7608b6a6a9a788655bcbf97

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