{
  "name": "Azure VM health 23:30",
  "description": "Controlla CPU/memoria della VM ogni sera; coinvolge l'agente solo se in sofferenza.",
  "cwd": "/path/to/project",
  "schedule": { "cron": "30 23 * * *", "tz": "Europe/Rome" },
  "misfire": "skip",
  "timeout": "20m",
  "steps": [
    {
      "id": "metrics", "type": "command", "parseJson": true,
      "argv": ["az", "monitor", "metrics", "list", "--resource", "<VM_RESOURCE_ID>",
               "--metric", "Percentage CPU", "--interval", "PT5M", "--offset", "1h", "-o", "json"]
    },
    {
      "id": "gate", "type": "condition",
      "any": [{ "path": "steps.metrics.json.value[*].timeseries[*].data[*].average", "aggregate": "max", "op": ">", "value": 85 }]
    },
    {
      "id": "analyze", "type": "agent", "when": "gate", "tools": ["read", "bash"],
      "prompt": "La VM <NOME> ha superato l'85% di CPU nell'ultima ora. Metriche: {{steps.metrics.stdout}}\nConfronta con la baseline degli ultimi 7 giorni (az monitor metrics), individua cause probabili e proponi azioni."
    },
    { "id": "alert", "type": "notify", "when": "gate", "severity": "warning", "message": "VM <NOME> in sofferenza: {{steps.analyze.text}}" }
  ]
}
