workerman-statistics分布式统计监控系统

workerman-statistics

workerman-statistics是一个以workerman作为服务器容器的分布式统计监控系统。 workermans-statisitcs使用PHP开发,无需安装MySQL数据库,无需安装nginx、apache、php-fpm等软件。 只要安装了PHP(>=5.3,非Win系统)便可以直接运行。

workerman-statistics包含了客户端和服务端,客户端是一个类库,通过函数调用的方式以UDP协议上报数据给服务端,服务端接收上报数据然后汇总展示。 workerman-statistics以曲线图和表格的方式展示请求量、耗时、成功率、错误日志等。

特性

  • 使用PHP开发
  • PHP多进程
  • 支持libevent事件轮询库,支持高并发
  • 支持服务平滑重启
  • UDP上报数据,对业务无影响
  • 支持分布式部署
  • 分布式部署节点自动感知,查询时结果自动汇总展示
  • 可以部署在本地,不占用带宽

安装启动只需两步

1、下载后解压缩到目标目录

2、运行php start.php start -d

客户端使用方法

  1. <?php  
  2. require 'yourpath/StatisticClient.php';  
  3. // 统计开始  
  4. StatisticClient::tick("User"'getInfo');  
  5. // 统计的产生,接口调用是否成功、错误码、错误日志  
  6. $success = true; $code = 0; $msg = '';  
  7. // 假如有个User::getInfo方法要监控  
  8. $user_info = User::getInfo();  
  9. if(!$user_info){  
  10.     // 标记失败  
  11.     $success = false;  
  12.     // 获取错误码,假如getErrCode()获得  
  13.     $code = User::getErrCode();  
  14.     // 获取错误日志,假如getErrMsg()获得  
  15.     $msg = User::getErrMsg();  
  16. }  
  17. // 上报结果  
  18. StatisticClient::report('User''getInfo'$success$code$msg);  
  1.   
  1. <h3 style="box-sizing: border-box; margin: 20px 0px 10px; padding: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 24px; font-weight: 500; font-family: "Microsoft YaHei", SimSun, sans-serif; line-height: 1.1; color: rgb(51, 51, 51);"><a name="t5"></a>服务端的使用</h3><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px; padding-top: 0px; padding-bottom: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-indent: 2em; color: rgb(51, 51, 51); font-family: "Microsoft YaHei", SimSun, sans-serif; font-size: 14px; line-height: 20px;">直接访问http://ip:55757便可以看到统计结果 (如果无法访问请检查服务器防火墙)</p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 10px; padding-top: 0px; padding-bottom: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-indent: 2em; color: rgb(51, 51, 51); font-family: "Microsoft YaHei", SimSun, sans-serif; font-size: 14px; line-height: 20px;">界面示例:<a target="_blank" href="http://www.workerman.net:55757/" style="box-sizing: border-box; text-decoration: none; color: rgb(66, 139, 202); background: transparent;">workerman.net:55757</a></p><h3 style="box-sizing: border-box; margin: 20px 0px 10px; padding: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 24px; font-weight: 500; font-family: "Microsoft YaHei", SimSun, sans-serif; line-height: 1.1; color: rgb(51, 51, 51);"><a name="t6"></a></h3><h3 style="box-sizing: border-box; margin: 20px 0px 10px; padding: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 24px; font-weight: 500; font-family: "Microsoft YaHei", SimSun, sans-serif; line-height: 1.1; color: rgb(51, 51, 51);"><a name="t7"></a></h3><h3 style="box-sizing: border-box; margin: 20px 0px 10px; padding: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 24px; font-weight: 500; font-family: "Microsoft YaHei", SimSun, sans-serif; line-height: 1.1; color: rgb(51, 51, 51);"><a name="t8"></a></h3><h3 style="box-sizing: border-box; margin: 20px 0px 10px; padding: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 24px; font-weight: 500; font-family: "Microsoft YaHei", SimSun, sans-serif; line-height: 1.1; color: rgb(51, 51, 51);"><a name="t9"></a>界面截图</h3>  
workerman-statistics分布式统计监控系统