Process Viewer
A sysops toolkit for scanning, monitoring, and managing system processes. Record observations, track alerts, run benchmarks, and generate reports — all from the command line with persistent local storage.
Quick Start
CODEBLOCK0
Commands
Core Operations
- -
scan <input> — Record a process scan entry (without args: show recent scans) - INLINECODE1 — Log a monitoring observation (without args: show recent entries)
- INLINECODE2 — Create a report entry (without args: show recent reports)
- INLINECODE3 — Log an alert or warning (without args: show recent alerts)
- INLINECODE4 — Record top-process data (without args: show recent entries)
- INLINECODE5 — Track resource usage (without args: show recent entries)
- INLINECODE6 — Run or log a health check (without args: show recent checks)
- INLINECODE7 — Document a fix applied (without args: show recent fixes)
Maintenance
- -
cleanup <input> — Record a cleanup action (without args: show recent cleanups) - INLINECODE9 — Log a backup operation (without args: show recent backups)
- INLINECODE10 — Log a restore operation (without args: show recent restores)
- INLINECODE11 — Add a general log entry (without args: show recent logs)
Analysis
- -
benchmark <input> — Record benchmark results (without args: show recent benchmarks) - INLINECODE13 — Log comparison data (without args: show recent comparisons)
Utilities
- -
stats — Show summary statistics across all entry types - INLINECODE15 — Export all data (formats:
json, csv, txt) - INLINECODE19 — Search across all log files for a keyword
- INLINECODE20 — Show the 20 most recent activity log entries
- INLINECODE21 — Display health check: version, data dir, entry count, disk usage
- INLINECODE22 — Show available commands
- INLINECODE23 — Print version (v2.0.0)
Each command accepts free-text input. When called without arguments, it displays the most recent 20 entries for that category.
Data Storage
All data is stored as plain-text log files in:
CODEBLOCK1
Each entry is stored as YYYY-MM-DD HH:MM|<input> — one line per record. The history.log file tracks all commands chronologically.
Requirements
- - Bash 4.0+ with INLINECODE26
- Standard Unix utilities:
date, wc, du, tail, grep, sed, cat, INLINECODE34 - No external dependencies, no network access required
- Write access to INLINECODE35
When to Use
- 1. Tracking system processes over time — Use
scan and monitor to build a log of process observations for later review or trend analysis - Incident response documentation — Use
alert to log warnings, fix to document remediation steps, and report to create post-incident summaries - Performance benchmarking — Use
benchmark and compare to record and contrast performance measurements across different configurations or time periods - Backup and recovery auditing — Use
backup and restore to maintain an audit trail of data protection operations - Periodic system health reviews — Use
status for a quick health check, stats for an overview, and export json to archive data for external analysis
Examples
CODEBLOCK2
Configuration
Set PROCESS_VIEWER_DIR environment variable to override the default data directory. Default: INLINECODE49
Output
All commands output to stdout. Redirect to a file with process-viewer <command> > output.txt. Export formats (json, csv, txt) write to the data directory and report the output path and file size.
Powered by BytesAgain | bytesagain.com | hello@bytesagain.com
进程查看器
一款用于扫描、监控和管理系统进程的系统运维工具包。支持记录观察结果、跟踪告警、运行基准测试和生成报告——全部通过命令行完成,并具备持久化本地存储功能。
快速开始
bash
bash scripts/script.sh <命令> [参数...]
命令
核心操作
- - scan <输入> — 记录进程扫描条目(无参数时:显示最近的扫描记录)
- monitor <输入> — 记录监控观察结果(无参数时:显示最近的条目)
- report <输入> — 创建报告条目(无参数时:显示最近的报告)
- alert <输入> — 记录告警或警告(无参数时:显示最近的告警)
- top <输入> — 记录进程排名数据(无参数时:显示最近的条目)
- usage <输入> — 跟踪资源使用情况(无参数时:显示最近的条目)
- check <输入> — 运行或记录健康检查(无参数时:显示最近的检查记录)
- fix <输入> — 记录已应用的修复(无参数时:显示最近的修复记录)
维护操作
- - cleanup <输入> — 记录清理操作(无参数时:显示最近的清理记录)
- backup <输入> — 记录备份操作(无参数时:显示最近的备份记录)
- restore <输入> — 记录恢复操作(无参数时:显示最近的恢复记录)
- log <输入> — 添加通用日志条目(无参数时:显示最近的日志记录)
分析操作
- - benchmark <输入> — 记录基准测试结果(无参数时:显示最近的基准测试记录)
- compare <输入> — 记录比较数据(无参数时:显示最近的比较记录)
实用工具
- - stats — 显示所有条目类型的汇总统计信息
- export <格式> — 导出所有数据(支持格式:json、csv、txt)
- search <关键词> — 在所有日志文件中搜索关键词
- recent — 显示最近20条活动日志条目
- status — 显示健康检查信息:版本、数据目录、条目数量、磁盘使用情况
- help — 显示可用命令
- version — 打印版本号(v2.0.0)
每个命令接受自由文本输入。当无参数调用时,显示该类别最近的20条条目。
数据存储
所有数据以纯文本日志文件形式存储在:
~/.local/share/process-viewer/
├── 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 # 统一活动历史记录
每条条目存储为 YYYY-MM-DD HH:MM|<输入> 格式——每行一条记录。history.log 文件按时间顺序记录所有命令。
系统要求
- - Bash 4.0+,启用 set -euo pipefail
- 标准 Unix 工具:date、wc、du、tail、grep、sed、cat、basename
- 无需外部依赖,无需网络访问
- 对 ~/.local/share/process-viewer/ 目录具有写入权限
使用场景
- 1. 长期跟踪系统进程 — 使用 scan 和 monitor 构建进程观察日志,供后续审查或趋势分析
- 事件响应文档记录 — 使用 alert 记录警告,fix 记录修复步骤,report 创建事后总结
- 性能基准测试 — 使用 benchmark 和 compare 记录和对比不同配置或时间段下的性能指标
- 备份与恢复审计 — 使用 backup 和 restore 维护数据保护操作的审计追踪
- 定期系统健康审查 — 使用 status 进行快速健康检查,stats 查看概览,export json 归档数据供外部分析
示例
bash
扫描并记录进程观察结果
process-viewer scan nginx 工作进程数:4,内存 128MB
记录监控告警
process-viewer alert web-server-03 的 CPU 使用率超过 90%
记录修复操作
process-viewer fix OOM 终止后重启 memcached
运行并记录基准测试
process-viewer benchmark 磁盘 I/O 测试:顺序读取 450MB/s
查看所有类别的汇总统计信息
process-viewer stats
将所有数据导出为 JSON 供外部处理
process-viewer export json
在所有日志中搜索特定关键词
process-viewer search nginx
检查系统状态
process-viewer status
配置
设置 PROCESSVIEWERDIR 环境变量可覆盖默认数据目录。默认值:~/.local/share/process-viewer/
输出
所有命令输出到标准输出。可使用 process-viewer <命令> > output.txt 重定向到文件。导出格式(json、csv、txt)会写入数据目录,并报告输出路径和文件大小。
由 BytesAgain 提供技术支持 | bytesagain.com | hello@bytesagain.com