Skill: crimsondevil333333/ops-dashboard (version 1.0.1)

--- name: ops-dashboard description: Gather operational signals (disk usage, git status, recent commits, and resources) so you can answer "How is the Clawdy infrastructure doing?" without manually running multiple checks. --- # Ops Dashboard ## Overview `ops-dashboard` exposes a single CLI (`scripts/ops_dashboard.py`) that prints a snapshot of: - Workspace disk usage (total vs. free) and storage availability. - Git status and the latest commits for the current branch. - System load averages plus the top-level directory sizes so you know where data is accumulating. Use this skill whenever you need to check health before deployments, push updates, or support teammates struggling with a slow workspace. ## CLI usage - `python3 skills/ops-dashboard/scripts/ops_dashboard.py --show summary` prints disk usage, git status, and top directories. - `--show resources` adds load averages and a break-down of recent git commits with author/summary. - `--workspace /path/to/workspace` lets you point the tool at another clone or repo. - `--output json` emits the same report as JSON so other scripts can consume it. ## Metrics explained - **Disk usage:** Reports `df` results for `/`, `/mnt/ramdisk`, and any other mounted tiers in the workspace. - **Git status:** Shows whether the current branch is clean, lists staged/unstaged files, and prints the last three commits with sha/author. - **Load averages:** Captures the 1/5/15 minute loads so you can correlate slowdowns with heavy resource usage. - **Directory sizes:** Highlights the three largest directories inside the workspace root so you can spot growth vectors. ## Sample command ```bash python3 skills/ops-dashboard/scripts/ops_dashboard.py --show summary --workspace /path/to/workspace (or omit to use the current directory) ``` This command displays the basic health story for the current repo, including git status and disk usage, before you start a risky task. ## References - `references/ops-dashboard.md` explains the meaning of each metric and how to interpret alerts like high disk usage or stale branches. ## Resources - **GitHub:** https://github.com/CrimsonDevil333333/ops-dashboard - **ClawHub:** https://www.clawhub.ai/skills/ops-dashboard

path: README.md
content: # Ops Dashboard

Ops Dashboard summarizes workspace health so you can confidently answer operational questions without hopping between terminals. The CLI in `skills/ops-dashboard/scripts/ops_dashboard.py` gathers disk usage, git status, recent commits, and load averages into a single report.

## Running the dashboard

```bash
python3 skills/ops-dashboard/scripts/ops_dashboard.py --workspace . --show summary
```

- `--show summary` prints disk usage, git status, and the top three directories by size.
- `--show resources` prints load averages, disk usage, and the last three git commits.
- The script handles non-git folders by printing a friendly message instead of crashing.

## Testing

```bash
python3 -m unittest discover skills/ops-dashboard/tests
```

## Packaging & release

```bash
python3 $(npm root -g)/openclaw/skills/skill-creator/scripts/package_skill.py skills/ops-dashboard
```

## Links

- **GitHub:** https://github.com/CrimsonDevil333333/ops-dashboard
- **ClawHub:** https://www.clawhub.ai/skills/ops-dashboard


path: references/ops-dashboard.md
content: # Ops Dashboard reference

- **Disk usage**: The script reports total free space in the workspace parent filesystem. If it drops below 10%, consider cleaning `dist/`, `outputs/`, or large skill bundles.
- **Git status**: Stale changes or diverging heads show up quickly; use `git status -sb` and `git log -n 3` to inspect recent commits.
- **Load averages**: Values above the number of cores indicate CPU saturation. Use this metric before launching heavy tests or data processing.
- **Top directories**: The dashboard prints the three largest directories under the workspace so you know where to prune.


path: scripts/ops_dashboard.py
content: #!/usr/bin/env python3
"""Report workspace health metrics for operational checks."""
from __future__ import annotations

import argparse
import os
import shutil
import subprocess
from pathlib import Path
from typing import Iterable, List, Tuple


def format_bytes(size: int) -> str:
    units = ["B", "KB", "MB", "GB", "TB"]
    for unit in units:
        if size < 1024 or unit == units[-1]:
            return f"{size:.1f} {unit}"
        size /= 1024
    return f"{size:.1f} PB"


def get_disk_usage(path: Path) -> Tuple[str, str, str]:
    usage = shutil.disk_usage(path)
    total = format_bytes(usage.total)
    used = format_bytes(usage.used)
    free = format_bytes(usage.free)
    return total, used, free


def get_git_status(workspace: Path) -> str:
    try:
        result = subprocess.run(
            ["git", "-C", str(workspace), "status", "-sb"],
            capture_output=True,
            text=True,
            check=True,
        )
        return result.stdout.strip()
    except subprocess.CalledProcessError:
        return "Not a git repository."


def get_recent_commits(workspace: Path, count: int = 3) -> List[str]:
    try:
        result = subprocess.run(
            ["git", "-C", str(workspace), "log", "-n", str(count), "--oneline"],
            capture_output=True,
            text=True,
            check=True,
        )
        return [line for line in result.stdout.strip().splitlines() if line]
    except subprocess.CalledProcessError:
        return ["No git history available."]


def get_top_directories(workspace: Path, top: int = 3) -> List[Tuple[str, str]]:
    entries: List[Tuple[str, int]] = []
    for entry in workspace.iterdir():
        if not entry.is_dir():
            continue
        size = 0
        for root, _, files in os.walk(entry):
            for name in files:
                try:
                    size += os.path.getsize(Path(root) / name)
                except OSError:
                    continue
        entries.append((entry.name, size))
    entries.sort(key=lambda item: -item[1])
    return [(name, format_bytes(size)) for name, size in entries[:top]]


def print_summary(workspace: Path) -> None:
    total, used, free = get_disk_usage(workspace)
    print("Disk usage:")
    print(f"  Total: {total}")
    print(f"  Used:  {used}")
    print(f"  Free:  {free}")
    print()

    print("Git status:")
    print(f"  {get_git_status(workspace)}")
    print()

    print("Recent commits:")
    for commit in get_recent_commits(workspace):
        print(f"  {commit}")
    print()

    top_dirs = get_top_directories(workspace)
    if top_dirs:
        print("Top directories by size:")
        for name, size in top_dirs:
            print(f"  {name}: {size}")
    else:
        print("No directories found to size.")


def print_resources(workspace: Path) -> None:
    load_avg = os.getloadavg() if hasattr(os, "getloadavg") else (0.0, 0.0, 0.0)
    print("Load averages (1m, 5m, 15m):")
    print("  " + ", ".join(f"{value:.2f}" for value in load_avg))
    print()

    total, used, free = get_disk_usage(workspace)
    print("Disk usage:")
    print(f"  Total: {total}")
    print(f"  Used:  {used}")
    print(f"  Free:  {free}")
    print()

    print("Recent commits:")
    for commit in get_recent_commits(workspace):
        print(f"  {commit}")


def main() -> int:
    parser = argparse.ArgumentParser(description="Ops Dashboard: workspace health signals.")
    parser.add_argument("--workspace", default=".", help="Workspace root to analyze.")
    parser.add_argument(
        "--show",
        choices=["summary", "resources"],
        default="summary",
        help="Which snapshot to print.",
    )

    args = parser.parse_args()
    workspace = Path(args.workspace).expanduser().resolve()
    if args.show == "summary":
        print_summary(workspace)
    else:
        print_resources(workspace)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())


path: tests/test_ops_dashboard.py
content: import subprocess
import sys
import tempfile
from pathlib import Path
import unittest

SCRIPT_PATH = Path(__file__).resolve().parents[1] / "scripts" / "ops_dashboard.py"


def run_cli(args, workspace):
    return subprocess.run(
        [sys.executable, str(SCRIPT_PATH)] + args,
        capture_output=True,
        text=True,
        cwd=workspace,
    )


class OpsDashboardTests(unittest.TestCase):
    def test_summary_detects_missing_git_repo(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            result = run_cli(["--workspace", tmpdir, "--show", "summary"], tmpdir)
            self.assertEqual(result.returncode, 0)
            self.assertIn("Not a git repository", result.stdout)

    def test_resources_prints_load_and_commits(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            result = run_cli(["--workspace", tmpdir, "--show", "resources"], tmpdir)
            self.assertEqual(result.returncode, 0)
            self.assertIn("Load averages", result.stdout)
            self.assertIn("Recent commits", result.stdout)


if __name__ == "__main__":
    unittest.main()


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)