{"id":20914903,"url":"https://github.com/showx/statshow","last_synced_at":"2026-04-23T15:36:38.473Z","repository":{"id":75366416,"uuid":"560479570","full_name":"showx/statshow","owner":"showx","description":"API监控利器","archived":false,"fork":false,"pushed_at":"2024-11-27T03:42:19.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T16:14:59.299Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/showx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-01T15:37:54.000Z","updated_at":"2024-11-27T03:42:23.000Z","dependencies_parsed_at":"2024-11-19T05:01:42.331Z","dependency_job_id":null,"html_url":"https://github.com/showx/statshow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/showx%2Fstatshow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/showx%2Fstatshow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/showx%2Fstatshow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/showx%2Fstatshow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/showx","download_url":"https://codeload.github.com/showx/statshow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243307496,"owners_count":20270263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T16:12:06.255Z","updated_at":"2025-12-26T16:03:11.384Z","avatar_url":"https://github.com/showx.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StatShow\n\nStatShow 是一个轻量级的 HTTP 请求监控统计工具,可以帮助您实时监控和分析 API 的调用情况。\n\n## 功能特点\n\n- 实时监控 HTTP 请求\n- URI 访问统计(请求次数和响应时间)\n- IP 访问统计\n- 慢请求记录\n- 可视化数据展示\n- 支持多种时间范围查看\n- 自动数据更新\n\n## 系统要求\n\n- PHP \u003e= 7.1\n- Redis 服务器\n- PHP 扩展:\n  - redis\n  - event\n  - pcntl\n  - posix\n  - json\n  - sockets (可选，用于设置额外的socket选项)\n\n## 安装\n\n### 1. 安装PHP扩展\n\n```bash\n# Ubuntu/Debian\nsudo apt-get install php-redis php-event php-pcntl php-sockets\n\n# CentOS/RHEL\nsudo yum install php-redis php-event php-process php-sockets\n\n# 或通过PECL安装\nsudo pecl install redis event\n```\n\n### 2. 通过 Composer 安装\n\n```bash\ncomposer require showx/statshow\n```\n\n### 手动安装\n\n1. 克隆代码:\n```bash\ngit clone https://github.com/showx/statshow.git\n```\n\n2. 安装依赖:\n```bash\ncd statshow\ncomposer install\n```\n\n## 配置\n\n创建配置文件 `config.php`:\n\n```php\n\u003c?php\nuse statshow\\Config;\n\n$config = new Config([\n    'host' =\u003e '0.0.0.0',      // 监听地址\n    'port' =\u003e 8081,           // 监听端口\n    'webpath' =\u003e '/stats',    // Web界面路径\n    'monitor' =\u003e [\n        'enable_uri_stats' =\u003e true,     // 启用URI统计\n        'enable_ip_stats' =\u003e true,      // 启用IP统计\n        'slow_request_time' =\u003e 1000,    // 慢请求阈值(毫秒)\n        'stats_interval' =\u003e 60,         // 统计间隔(秒)\n    ],\n    'storage' =\u003e [\n        'type' =\u003e 'redis',\n        'redis' =\u003e [\n            'host' =\u003e '127.0.0.1',\n            'port' =\u003e 6379,\n            'db' =\u003e 0\n        ]\n    ]\n]);\n```\n\n## 使用方法\n\n### 1. 启动服务器\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\nuse statshow\\StatShow;\nuse statshow\\Config;\n\n// 加载配置\n$config = require 'config.php';\n\n// 创建服务器实例\n$server = new StatShow();\n$server-\u003esetConfig($config);\n\n// 启动服务器\n$server-\u003estart();\n```\n\n### 2. 后台运行\n\n```bash\nphp start.php -d\n```\n\n### 3. 访问监控界面\n\n打开浏览器访问: `http://your-server:8081/stats`\n\n## 监控数据说明\n\n### URI 统计\n- 显示各 URI 的访问次数\n- 平均响应时间\n- 支持按时间范围筛选\n\n### IP 统计\n- 显示访问量最大的IP\n- 每个IP的请求分布\n- 支持查看详细访问记录\n\n### 慢请求统计\n- 记录响应时间超过阈值的请求\n- 包含完整的请求信息\n- 按响应时间排序\n\n## API 接口\n\n### 获取 URI 统计\n```\nGET /stats/uri?timeRange=3600\n```\n\n### 获取 IP 统计\n```\nGET /stats/ip?timeRange=3600\n```\n\n### 获取慢请求记录\n```\nGET /stats/slow?timeRange=3600\n```\n\n参数说明:\n- timeRange: 时间范围(秒),默认3600\n\n## 注意事项\n\n1. 确保 Redis 服务器已启动\n2. 建议在生产环境使用 supervisor 等工具管理进程\n3. 统计数据默认保存24小时\n4. 建议定期清理 Redis 数据,避免占用过多内存\n\n## License\n\nMIT License\n\n## 作者\n\nshowx \u003c9448923@qq.com\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshowx%2Fstatshow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshowx%2Fstatshow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshowx%2Fstatshow/lists"}