7468806bad
Lightweight stdlib-only Python agent runs on each monitored host, collects CPU / memory / disk / load / uptime from /proc every 30s, and POSTs signed payloads to the Roundtable ingest endpoint. One-line curl-pipe installer creates a hardened systemd unit; admin UI manages host registrations with rotate / revoke. - agent.py: 370 LoC single-file daemon, ring buffer + exponential backoff - ingest route: bearer-token auth, metric expansion into plugin_metrics - install.sh.j2: systemd unit with NoNewPrivileges / ProtectSystem / ProtectHome - settings UI: add host / rotate token / delete registration (admin-only) - dashboard widgets: fleet-glance table + per-host history chart - stale-agent scheduler: 60s log warning for agents past 180s silence Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
# plugins/host_agent/migrations/versions/host_agent_001_initial.py
|
|
"""host_agent plugin initial tables
|
|
|
|
Revision ID: host_agent_001_initial
|
|
"""
|
|
from typing import Sequence, Union
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision: str = "host_agent_001_initial"
|
|
down_revision: Union[str, None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = "host_agent"
|
|
depends_on: Union[str, Sequence[str], None] = ("0004_app_settings",)
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"host_agent_registrations",
|
|
sa.Column("id", sa.String(36), primary_key=True),
|
|
sa.Column("host_id", sa.String(36),
|
|
sa.ForeignKey("hosts.id", ondelete="CASCADE"),
|
|
nullable=False, unique=True),
|
|
sa.Column("token_hash", sa.String(64), nullable=False, unique=True, index=True),
|
|
sa.Column("token_created_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("agent_version", sa.String(32), nullable=True),
|
|
sa.Column("kernel", sa.String(128), nullable=True),
|
|
sa.Column("distro", sa.String(128), nullable=True),
|
|
sa.Column("arch", sa.String(32), nullable=True),
|
|
sa.Column("last_seen_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("host_agent_registrations")
|