Cpu
Cpu v2.0.0 — a sysops toolkit for scanning, monitoring, reporting, alerting, benchmarking, and managing system operations. Each command logs timestamped records locally, providing a lightweight operations journal for tracking system events, fixes, backups, and performance comparisons.
Commands
| Command | Description |
|---|
| INLINECODE0 | Record a scan result (or view recent scans with no args) |
| INLINECODE1 |
Log a monitoring observation (or view recent monitors) |
|
cpu report <input> | Record a report entry (or view recent reports) |
|
cpu alert <input> | Log an alert event (or view recent alerts) |
|
cpu top <input> | Record a top-process snapshot (or view recent tops) |
|
cpu usage <input> | Log a usage measurement (or view recent usage records) |
|
cpu check <input> | Record a health check (or view recent checks) |
|
cpu fix <input> | Log a fix or remediation (or view recent fixes) |
|
cpu cleanup <input> | Record a cleanup action (or view recent cleanups) |
|
cpu backup <input> | Log a backup event (or view recent backups) |
|
cpu restore <input> | Record a restore operation (or view recent restores) |
|
cpu log <input> | Add a general log entry (or view recent log entries) |
|
cpu benchmark <input> | Record a benchmark result (or view recent benchmarks) |
|
cpu compare <input> | Log a comparison (or view recent comparisons) |
|
cpu stats | Show summary statistics across all log files |
|
cpu search <term> | Search all entries for a keyword (case-insensitive) |
|
cpu recent | Show the 20 most recent activity entries |
|
cpu status | Health check — version, entry count, disk usage, last activity |
|
cpu help | Display all available commands |
|
cpu version | Print version string |
Each operations command (scan, monitor, report, alert, top, usage, check, fix, cleanup, backup, restore, log, benchmark, compare) works identically:
- - With arguments: saves a timestamped entry to
~/.local/share/cpu/<command>.log and logs to INLINECODE21 - Without arguments: displays the 20 most recent entries from that command's log file
Data Storage
All data is stored locally in ~/.local/share/cpu/:
| File | Contents |
|---|
| INLINECODE23 | System scan results |
| INLINECODE24 |
Monitoring observations |
|
report.log | Report entries |
|
alert.log | Alert events |
|
top.log | Top-process snapshots |
|
usage.log | Usage measurements |
|
check.log | Health check records |
|
fix.log | Fix/remediation records |
|
cleanup.log | Cleanup action records |
|
backup.log | Backup event records |
|
restore.log | Restore operation records |
|
log.log | General log entries |
|
benchmark.log | Benchmark results |
|
compare.log | Comparison records |
|
history.log | Unified activity log for all commands |
The stats command reads all .log files and reports line counts per file, total entries, data directory size, and the timestamp of the first recorded activity.
The export utility function can produce JSON, CSV, or TXT output files under the data directory.
Requirements
- - Bash (4.0+)
- coreutils —
date, wc, du, head, tail, grep, basename, INLINECODE48 - No external dependencies, API keys, or network access required
- Works on Linux and macOS
When to Use
- 1. Tracking system operations — use
scan, monitor, check, and alert to maintain a timestamped journal of system health events and observations - Recording fixes and remediations — use
fix and cleanup to document what was changed and when, creating an audit trail for incident response - Benchmarking and comparing performance — use
benchmark and compare to log performance results over time and track improvements or regressions - Managing backup and restore history — use
backup and restore to log when backups were taken and restores were performed, with searchable history - Searching operational history — use
search <term> to find specific events across all log categories, or recent to view the latest 20 activities at a glance
Examples
CODEBLOCK0
How It Works
Cpu uses a simple append-only log architecture. Every command writes a pipe-delimited record (timestamp|value) to its dedicated log file. The history.log file captures a unified timeline of all operations with the format MM-DD HH:MM command: value.
This design makes Cpu:
- - Fast — pure bash, no database overhead
- Transparent — all data is human-readable plain text
- Portable — works anywhere bash runs, no install needed
- Auditable — every action is timestamped and traceable
Powered by BytesAgain | bytesagain.com | hello@bytesagain.com
Cpu
Cpu v2.0.0 — 一套用于系统操作扫描、监控、报告、告警、基准测试和管理的系统运维工具包。每条命令都会在本地记录带时间戳的日志条目,提供轻量级的运维日志,用于追踪系统事件、修复、备份和性能对比。
命令
| 命令 | 描述 |
|---|
| cpu scan <输入> | 记录扫描结果(无参数时查看最近扫描记录) |
| cpu monitor <输入> |
记录监控观察结果(无参数时查看最近监控记录) |
| cpu report <输入> | 记录报告条目(无参数时查看最近报告) |
| cpu alert <输入> | 记录告警事件(无参数时查看最近告警) |
| cpu top <输入> | 记录进程快照(无参数时查看最近快照) |
| cpu usage <输入> | 记录使用量测量结果(无参数时查看最近使用记录) |
| cpu check <输入> | 记录健康检查结果(无参数时查看最近检查记录) |
| cpu fix <输入> | 记录修复或补救措施(无参数时查看最近修复记录) |
| cpu cleanup <输入> | 记录清理操作(无参数时查看最近清理记录) |
| cpu backup <输入> | 记录备份事件(无参数时查看最近备份记录) |
| cpu restore <输入> | 记录恢复操作(无参数时查看最近恢复记录) |
| cpu log <输入> | 添加通用日志条目(无参数时查看最近日志条目) |
| cpu benchmark <输入> | 记录基准测试结果(无参数时查看最近基准测试记录) |
| cpu compare <输入> | 记录对比结果(无参数时查看最近对比记录) |
| cpu stats | 显示所有日志文件的汇总统计信息 |
| cpu search <关键词> | 在所有条目中搜索关键词(不区分大小写) |
| cpu recent | 显示最近20条活动条目 |
| cpu status | 健康检查 — 版本、条目数、磁盘使用量、最近活动时间 |
| cpu help | 显示所有可用命令 |
| cpu version | 打印版本信息 |
每个操作命令(scan、monitor、report、alert、top、usage、check、fix、cleanup、backup、restore、log、benchmark、compare)的工作方式相同:
- - 带参数时: 将带时间戳的条目保存到 ~/.local/share/cpu/<命令>.log 并记录到 history.log
- 无参数时: 显示该命令日志文件中最近20条条目
数据存储
所有数据本地存储在 ~/.local/share/cpu/ 目录下:
| 文件 | 内容 |
|---|
| scan.log | 系统扫描结果 |
| monitor.log |
监控观察结果 |
| report.log | 报告条目 |
| alert.log | 告警事件 |
| top.log | 进程快照 |
| usage.log | 使用量测量结果 |
| check.log | 健康检查记录 |
| fix.log | 修复/补救记录 |
| cleanup.log | 清理操作记录 |
| backup.log | 备份事件记录 |
| restore.log | 恢复操作记录 |
| log.log | 通用日志条目 |
| benchmark.log | 基准测试结果 |
| compare.log | 对比记录 |
| history.log | 所有命令的统一活动日志 |
stats 命令会读取所有 .log 文件,并报告每个文件的行数、总条目数、数据目录大小以及首次记录活动的时间戳。
export 工具函数可以在数据目录下生成 JSON、CSV 或 TXT 格式的输出文件。
系统要求
- - Bash(4.0+)
- coreutils — date、wc、du、head、tail、grep、basename、cat
- 无需外部依赖、API密钥或网络访问
- 适用于 Linux 和 macOS
使用场景
- 1. 追踪系统操作 — 使用 scan、monitor、check 和 alert 维护带时间戳的系统健康事件和观察日志
- 记录修复和补救措施 — 使用 fix 和 cleanup 记录变更内容和时间,为事件响应创建审计追踪
- 基准测试和性能对比 — 使用 benchmark 和 compare 记录随时间变化的性能结果,追踪改进或退化
- 管理备份和恢复历史 — 使用 backup 和 restore 记录备份和恢复操作的时间,支持可搜索的历史记录
- 搜索操作历史 — 使用 search <关键词> 在所有日志类别中查找特定事件,或使用 recent 快速查看最近20条活动
示例
bash
记录扫描发现
cpu scan web-server-01 上端口 8080 开放
记录监控观察结果
cpu monitor db-primary 内存使用率 78%
记录告警
cpu alert 磁盘 /var/log 容量使用达 92%
记录修复
cpu fix 轮转 nginx 日志,在 web-01 上释放 2.3GB 空间
记录基准测试结果
cpu benchmark sysbench cpu 运行:1847 事件/秒
对比两个环境
cpu compare 生产环境延迟 45ms vs 预发布环境 62ms
记录备份
cpu backup postgres 完整备份完成 14.2GB
在所有日志中搜索关键词
cpu search 磁盘
查看汇总统计信息
cpu stats
检查系统状态
cpu status
查看最近活动
cpu recent
工作原理
Cpu 采用简单的追加式日志架构。每条命令都会将管道分隔的记录(时间戳|值)写入其专用的日志文件。history.log 文件以 MM-DD HH:MM 命令: 值 的格式捕获所有操作的统一时间线。
这种设计使 Cpu 具备以下特点:
- - 快速 — 纯 bash 实现,无数据库开销
- 透明 — 所有数据均为人类可读的纯文本
- 可移植 — 可在任何运行 bash 的环境中使用,无需安装
- 可审计 — 每个操作都带有时间戳并可追溯
由 BytesAgain 提供支持 | bytesagain.com | hello@bytesagain.com