42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
# ---
|
|
# jupyter:
|
|
# jupytext:
|
|
# text_representation:
|
|
# extension: .py
|
|
# format_name: percent
|
|
# format_version: '1.3'
|
|
# jupytext_version: 1.19.1
|
|
# kernelspec:
|
|
# display_name: Python 3
|
|
# language: python
|
|
# name: python3
|
|
# ---
|
|
|
|
# %% [markdown]
|
|
# # Parameterized Agent Task: System Health Check
|
|
#
|
|
# This notebook demonstrates how an LLM agent can generate a task notebook,
|
|
# a scheduler can parameterize and execute it via papermill,
|
|
# and the output becomes a persistent audit artifact.
|
|
|
|
# %% tags=["parameters"]
|
|
# Default parameters — papermill will inject overrides here
|
|
threshold = 1.0
|
|
hostname = "localhost"
|
|
|
|
# %%
|
|
import json, subprocess, datetime
|
|
gather_time = datetime.datetime.now().isoformat()
|
|
load_avg = subprocess.check_output(["cat", "/proc/loadavg"]).decode().strip()
|
|
load_values = [float(x) for x in load_avg.split()[:3]]
|
|
avg_load = sum(load_values) / len(load_values)
|
|
intervention_needed = avg_load > threshold
|
|
report = {
|
|
"hostname": hostname,
|
|
"threshold": threshold,
|
|
"avg_load": round(avg_load, 3),
|
|
"intervention_needed": intervention_needed,
|
|
"gathered_at": gather_time
|
|
}
|
|
print(json.dumps(report, indent=2))
|