Skip to main content
S

dsh-ops-kit

shenlongze/dsh-ops-kit

Server operations over SSH from a DSH chat: multi-host overview, health score, service monitors, backups and restore, TLS certificates, cron, config rollback, one-click deploy and AI diagnosis.

Install

dsh plugin --profile web add github:shenlongze/dsh-ops-kit

README

dsh-ops-kit

English | 简体中文

Server operations from a DeepSeek Harness chat: 34 tools plus a sidebar panel, no SDK, and no credentials stored by the plugin.

🔒 marks an action that needs confirm: true — the tool fails closed instead of asking in a second turn.

Connect and inventory

ToolWhat it does
ops_hostslist / add / update / remove SSH hosts (~/.dsh/ops-kit/hosts.json)
ops_ssh_testconnectivity, latency and the auth kind actually used
ops_ssh_install_keyinstall this machine's public key using the stored password
ops_inventoryread-only scan: listening ports, services, containers, nginx sites, java processes, crontab, mounts

Look at a host (read-only)

ToolWhat it does
ops_statusuptime + load, memory, root disk, failed systemd units, containers
ops_check_allevery host in parallel, one summary row each, appends to history
ops_health0–100 score plus the issues worth fixing first
ops_metricsCPU / memory / disk samples over a window (capped at 20 000 rows)
ops_pstop processes by CPU or memory
ops_diskdirectory sizes one level below a path
ops_logsjournal unit or log-file tail
ops_filesdirectory listing with sizes and mtimes
ops_sslcertificate subject, issuer, expiry for one domain
ops_diagnoseplain-language diagnosis with suggested next actions

Change something

ToolWhat it does
ops_runone shell command; a destructive denylist needs 🔒
ops_batchthe same command on several hosts in parallel
ops_servicesystemctl status/logs/start/stop/restart (start/stop/restart 🔒)
ops_dockerdocker ps/logs/inspect/restart (restart 🔒)
ops_killTERM / KILL / HUP one pid 🔒
ops_cleanupvacuum the journal, truncate rotated logs 🔒
ops_monitorshttp / port / process / service / script heartbeat checks

Config and files

ToolWhat it does
ops_configscheduler settings: interval, disk threshold, timeouts, quick commands, AI model
ops_config_fileread one configuration file
ops_save_configwrite a config file after backing it up 🔒
ops_file_history.bak.<ts> versions of a file, diff, rollback 🔒

Backups, certificates, schedule, deploy

ToolWhat it does
ops_backupMySQL dump or directory archive, list, restore, delete, retention N
ops_certcertificate days left, certbot renew --dry-run, real renewal
ops_cronlist / add / remove crontab entries
ops_deploygit pull → build → restart → health check, automatic rollback

Alerts and AI

ToolWhat it does
ops_channelsalert delivery to Feishu / DingTalk / WeCom / any webhook, plus test send
ops_alertsrecent alerts from the scheduled checks
ops_asknatural-language question; the model runs read-only commands itself
ops_ai_commandturn an intent into ONE command, without executing it
ops_ai_modelsproviders and models the ops AI can use

Design

  • No SDK, no credential storage by default. Key authentication goes through the system ssh client in BatchMode, so the plugin never reads your keys. Password authentication uses the plugin's own ssh2 client and is the only case where a secret is stored (see below).
  • Password or key. A host can be added with only IP + user + password; that path needs ssh2 present in the profile. A host without a stored password uses the system ssh client and your keys or agent.
  • Inventory outside the profile. Hosts live in $DSH_HOME/ops-kit/hosts.json (default ~/.dsh/ops-kit/hosts.json), so upgrading or removing the plugin does not lose them.
  • Read/write separation. Health checks are always read-only. Anything that changes a service or container requires confirm: true.
  • Bounded output. Tool results are clipped at 8 KB with an explicit truncation marker, so a runaway log line cannot flood the model context.

Install

dsh plugin --profile desktop add dsh-ops-kit

A task-oriented walkthrough (setup checks, the ten panel pages, setting defaults, data sensitivity, troubleshooting) is in docs/USAGE.md, also available in Chinese: docs/USAGE.zh-CN.md.

Local development install (directory):

Plugins → Add plugin → select this directory

Panel

The bundle ships a sidebar page (Ops) with ten sub-pages per host: overview, monitor, config, apps, logs, files, terminal (real PTY), backups, tasks, deploy. The overview lists hosts and runs one host or all hosts at once; runs are recorded in $DSH_HOME/ops-kit/history.json. The panel talks to the host half through /ops-kit/api/*.

Restart, stop, restore and rollback all ask for confirmation in the panel first.

First run

ops_hosts action=add name=web-1 host=10.0.0.11 user=deploy key=~/.ssh/id_ed25519 defaultHost=true

Then just ask:

看一下 web-1 的状态
nginx 最近 50 行日志
把 web-1 上的 my-api 重启一下(我确认)

Limits (deliberately not implemented)

  • No cloud APIs (Aliyun / Tencent / AWS). This kit only speaks SSH.
  • No application-level deploys beyond ops_deploy (no Docker Compose, no k8s).
  • No Windows remoting: SSH to Windows works only if the host runs an SSH server with a POSIX-like shell.
  • Metric retention is a bounded row cap, not a time-series database.

0.3.0 — backups, health score, certificates, cron, config history, deploy

  • Backups & restore. mysqldump for a database or tar.gz for a directory, stored under /home/backup by default, keep N copies, restore in one click.
  • Health score. 0–100 per host with the two or three issues that matter, shown on the server detail page.
  • Certificates. Every nginx server_name is probed for its expiry date; certbot renew --dry-run before a real renewal; alerts at 14 / 7 / 3 days.
  • Scheduled tasks. The server crontab, readable and editable from the panel.
  • Config history. Every .bak.<ts> version of a file can be diffed and rolled back.
  • One-click deploy. git pull → build → restart → health check, with an automatic rollback to the previous commit when the health check fails.

Alert delivery

Alerts produced by the scheduler (host down, disk pressure, failed units, monitor failures, certificate expiry) are pushed to the configured channels:

  • feishu → {"msg_type":"text","content":{"text":...}}
  • dingtalk / wecom → {"msgtype":"text","text":{"content":...}}
  • webhook → {"text":...,"alerts":[...]} for anything else

Each channel chooses which levels it receives (critical / warning / info). The same alert is not resent within 10 minutes. Channels live in ~/.dsh/ops-kit/channels.json with mode 0600, because the URL itself is a secret.

License

MIT

Related plugins