{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Parameterized Agent Task: System Health Check\n",
        "\n",
        "This notebook demonstrates how an LLM agent can generate a task notebook,\n",
        "a scheduler can parameterize and execute it via papermill,\n",
        "and the output becomes a persistent audit artifact."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {"tags": ["parameters"]},
      "outputs": [],
      "source": [
        "# Default parameters — papermill will inject overrides here\n",
        "threshold = 1.0\n",
        "hostname = \"localhost\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import json, subprocess, datetime\n",
        "gather_time = datetime.datetime.now().isoformat()\n",
        "load_avg = subprocess.check_output([\"cat\", \"/proc/loadavg\"]).decode().strip()\n",
        "load_values = [float(x) for x in load_avg.split()[:3]]\n",
        "avg_load = sum(load_values) / len(load_values)\n",
        "intervention_needed = avg_load > threshold\n",
        "report = {\n",
        "    \"hostname\": hostname,\n",
        "    \"threshold\": threshold,\n",
        "    \"avg_load\": round(avg_load, 3),\n",
        "    \"intervention_needed\": intervention_needed,\n",
        "    \"gathered_at\": gather_time\n",
        "}\n",
        "print(json.dumps(report, indent=2))"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
