{"id":13676342,"url":"https://github.com/toxmc/statistics","last_synced_at":"2026-01-18T20:06:41.055Z","repository":{"id":82946704,"uuid":"41524996","full_name":"toxmc/statistics","owner":"toxmc","description":"一个运用php与swoole实现的统计监控系统","archived":false,"fork":false,"pushed_at":"2020-05-19T01:06:20.000Z","size":659,"stargazers_count":443,"open_issues_count":0,"forks_count":104,"subscribers_count":34,"default_branch":"master","last_synced_at":"2024-08-12T21:26:42.042Z","etag":null,"topics":["linux","php-swoole","statistics-swoole","swoole-extension"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toxmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-08-28T03:29:37.000Z","updated_at":"2024-07-15T20:05:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"e8c9e2a1-9d2f-458e-89c5-62166fbd5c8a","html_url":"https://github.com/toxmc/statistics","commit_stats":null,"previous_names":["smalleyes/statistics"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toxmc%2Fstatistics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toxmc%2Fstatistics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toxmc%2Fstatistics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toxmc%2Fstatistics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toxmc","download_url":"https://codeload.github.com/toxmc/statistics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251450656,"owners_count":21591407,"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":["linux","php-swoole","statistics-swoole","swoole-extension"],"created_at":"2024-08-02T13:00:23.315Z","updated_at":"2026-01-18T20:06:41.005Z","avatar_url":"https://github.com/toxmc.png","language":"PHP","readme":"# statistics\n一个运用php与swoole实现的统计监控系统\n\n\u003e 如果有使用`laravel` 的朋友，推荐另外一个项目[fast-laravel](https://github.com/toxmc/fast-laravel)。欢迎使用，喜欢的话给个star鼓励下。谢谢各位\n\n## 界面截图\n![Swoole statistics screenshot one](https://raw.githubusercontent.com/smalleyes/statistics/master/doc/1.png)\n\n![Swoole statistics screenshot two](https://raw.githubusercontent.com/smalleyes/statistics/master/doc/2.png)\n\n![Swoole statistics screenshot three](https://raw.githubusercontent.com/smalleyes/statistics/master/doc/3.png)\n\n![Swoole statistics screenshot four](https://raw.githubusercontent.com/smalleyes/statistics/master/doc/4.png)\n\n## 说明\n* statistics是一个以swoole作为服务器容器的统计监控系统。\n* statisitcs使用PHP开发，无需安装Mysql等数据库，无需安装php-fpm等软件。\n* statistics包含了客户端和服务端，客户端是一个类库，通过函数调用的方式以UDP协议上报数据给服务端。\n* statistics服务端接收上报数据然后汇总展示。\n* statistics以曲线图、饼图和表格的方式展示请求量、耗时、成功率、错误日志等。\n* workerman版本实现statistics [https://github.com/walkor/workerman-statistics](https://github.com/walkor/workerman-statistics)\n\n## 依赖\n\n* PHP 5.3+\n* Swoole 1.7.18\n* Linux, OS X and basic Windows support (Thanks to cygwin)\n\n## 安装 Swoole扩展\n\n1. Install swoole extension from pecl\n    \n    ```\n    pecl install swoole\n    ```\n\n2. Install swoole extension from source\n\n    ```\n    sudo apt-get install php5-dev\n    git clone https://github.com/swoole/swoole-src.git\n    cd swoole-src\n    phpize\n    ./configure\n    make \u0026\u0026 make install\n    ```\n\n## 安装\n\n### 1. 下载 Swoole statistics\n\nlinux shell Clone the git repo: \n```\ngit clone https://github.com/smalleyes/statistics.git\n```\nlinux wget the zip file:\n```\nwget https://github.com/smalleyes/statistics/archive/master.zip\nunzip master.zip\n```\n### 2. 安全\n\n    管理员用户名密码默认都为admin。\n    如果不需要登录验证，在applications/Statistics/Config/Config.php里面设置管理员密码留空。\n    请自行做好安全相关的限制.\n\n## 运行\n\n* 配置NGINX虚拟主机\n* 配置文件位于doc/statistics.conf\n* 复制文件statistics.conf到nginx，虚拟主机配置文件目录下（默认为nginx/conf.d目录下）\n* 重启nginx或重新加载nginx配置文件（nginx -s reload）\n* 配置hoshs文件，绑定ip域名对应关系\n* 使用swoole需要启动服务，php web.php与php worker.php再打开浏览器访问绑定的域名。\n* 配置信息都在Config目录下。\n* 开启守护进程模式，请修改配置Config/Server.php的daemonize选项为TRUE。\n\n## 客户端使用方法 \n\n```php\n\n    \u003c?php\n    \n    /**\n     * examples\n     * @author xmc\n     */\n    \n    class User {\n    \tpublic static function getInfo()\n    \t{\n    \t\t$res = array();\n    \t\t$res = array('name'=\u003e'xmc','password'=\u003e'123456');\n    \t\treturn $res;\n    \t}\n    \n    \tpublic static function addInfo()\n    \t{\n    \t\t$res = array();\n    \t\t$res = array('name'=\u003e'xmc','password'=\u003e'123456');\n    \t\treturn $res;\n    \t}\n    \n    \tpublic static function getErrCode()\n    \t{\n    \t\t$errcode = 10001;\n    \t\treturn $errcode;\n    \t}\n    \n    \tpublic static function getErrMsg()\n    \t{\n    \t\t$errmsg = '添加用户失败';\n    \t\treturn $errmsg;\n    \t}\n    }\n    \n    include 'StatisticClient.php';\n    \n    // 统计开始\n    StatisticClient::tick(\"User\", 'addInfo');\n    // 统计的产生，接口调用是否成功、错误码、错误日志\n    $success = true; $code = 0; $msg = '';\n    // 假如有个User::getInfo方法要监控\n    $user_info = User::addInfo();\n    if(!$user_info){\n    \t// 标记失败\n    \t$success = false;\n    \t// 获取错误码，假如getErrCode()获得\n    \t$code = User::getErrCode();\n    \t// 获取错误日志，假如getErrMsg()获得\n    \t$msg = User::getErrMsg();\n    }\n    // 上报结果\n    $res = StatisticClient::report('User', 'addInfo', $success, $code, $msg);\n    \n    echo \"done over...\\n\";\n    var_dump($user_info,$res);\n    \n```\n","funding_links":[],"categories":["Swoole"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoxmc%2Fstatistics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoxmc%2Fstatistics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoxmc%2Fstatistics/lists"}