---
name: systemd_local_status
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "systemd_local_status(name: string, log_lines: int = 10) -> json"
description: "Devuelve el estado de un servicio systemd local: active state, sub state, PID, enabled, y las N últimas líneas de journalctl. No requiere sudo."
tags: [systemd, service, local, infra, status, journalctl]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
params:
  - name: name
    desc: "nombre del servicio sin sufijo .service"
  - name: log_lines
    desc: "número de líneas de log a incluir en el JSON (default 10)"
output: "JSON {name, active, sub, enabled, pid, logs:[...]}. Errores a stderr, exit 1."
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/infra/systemd_local_status.sh"
---

## Ejemplo

```bash
source bash/functions/infra/systemd_local_status.sh
systemd_local_status "sqlite_api" 5
# {"name":"sqlite_api","active":"active","sub":"running","enabled":"enabled","pid":12345,"logs":["...","..."]}
```

## Valores típicos

- `active`: `active`, `inactive`, `failed`, `activating`, `deactivating`
- `sub`: `running`, `dead`, `exited`, `start-pre`, etc.
- `enabled`: `enabled`, `disabled`, `static`, `masked`

## Notas

- No requiere sudo (solo lectura).
- Si el unit no existe, `active` será `inactive` y `sub` será `dead`.
- Los logs vienen de `journalctl -u <name> -n N --no-pager -o cat` (sin prefijos, solo el mensaje).
