# statistics
一个运用php与swoole实现的统计监控系统
> 如果有使用`laravel` 的朋友,推荐另外一个项目[fast-laravel](https://github.com/toxmc/fast-laravel)。欢迎使用,喜欢的话给个star鼓励下。谢谢各位
## 界面截图
![Swoole statistics screenshot one](https://raw.githubusercontent.com/smalleyes/statistics/master/doc/1.png)
![Swoole statistics screenshot two](https://raw.githubusercontent.com/smalleyes/statistics/master/doc/2.png)
![Swoole statistics screenshot three](https://raw.githubusercontent.com/smalleyes/statistics/master/doc/3.png)
![Swoole statistics screenshot four](https://raw.githubusercontent.com/smalleyes/statistics/master/doc/4.png)
## 说明
* statistics是一个以swoole作为服务器容器的统计监控系统。
* statisitcs使用PHP开发,无需安装Mysql等数据库,无需安装php-fpm等软件。
* statistics包含了客户端和服务端,客户端是一个类库,通过函数调用的方式以UDP协议上报数据给服务端。
* statistics服务端接收上报数据然后汇总展示。
* statistics以曲线图、饼图和表格的方式展示请求量、耗时、成功率、错误日志等。
* workerman版本实现statistics [https://github.com/walkor/workerman-statistics](https://github.com/walkor/workerman-statistics)
## 依赖
* PHP 5.3+
* Swoole 1.7.18
* Linux, OS X and basic Windows support (Thanks to cygwin)
## 安装 Swoole扩展
1. Install swoole extension from pecl
```
pecl install swoole
```
2. Install swoole extension from source
```
sudo apt-get install php5-dev
git clone https://github.com/swoole/swoole-src.git
cd swoole-src
phpize
./configure
make && make install
```
## 安装
### 1. 下载 Swoole statistics
linux shell Clone the git repo:
```
git clone https://github.com/smalleyes/statistics.git
```
linux wget the zip file:
```
wget https://github.com/smalleyes/statistics/archive/master.zip
unzip master.zip
```
### 2. 安全
管理员用户名密码默认都为admin。
如果不需要登录验证,在applications/Statistics/Config/Config.php里面设置管理员密码留空。
请自行做好安全相关的限制.
## 运行
* 配置NGINX虚拟主机
* 配置文件位于doc/statistics.conf
* 复制文件statistics.conf到nginx,虚拟主机配置文件目录下(默认为nginx/conf.d目录下)
* 重启nginx或重新加载nginx配置文件(nginx -s reload)
* 配置hoshs文件,绑定ip域名对应关系
* 使用swoole需要启动服务,php web.php与php worker.php再打开浏览器访问绑定的域名。
* 配置信息都在Config目录下。
* 开启守护进程模式,请修改配置Config/Server.php的daemonize选项为TRUE。
## 客户端使用方法
```php
<?php
/**
* examples
* @author xmc
*/
class User {
public static function getInfo()
{
$res = array();
$res = array('name'=>'xmc','password'=>'123456');
return $res;
}
public static function addInfo()
{
$res = array();
$res = array('name'=>'xmc','password'=>'123456');
return $res;
}
public static function getErrCode()
{
$errcode = 10001;
return $errcode;
}
public static function getErrMsg()
{
$errmsg = '添加用户失败';
return $errmsg;
}
}
include 'StatisticClient.php';
// 统计开始
StatisticClient::tick("User", 'addInfo');
// 统计的产生,接口调用是否成功、错误码、错误日志
$success = true; $code = 0; $msg = '';
// 假如有个User::getInfo方法要监控
$user_info = User::addInfo();
if(!$user_info){
// 标记失败
$success = false;
// 获取错误码,假如getErrCode()获得
$code = User::getErrCode();
// 获取错误日志,假如getErrMsg()获得
$msg = User::getErrMsg();
}
// 上报结果
$res = StatisticClient::report('User', 'addInfo', $success, $code, $msg);
echo "done over...\n";
var_dump($user_info,$res);
```
没有合适的资源?快使用搜索试试~ 我知道了~
毕业设计:基于PHP与swoole实现的统计监控系统.zip
共63个文件
php:35个
png:11个
js:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 75 浏览量
2023-11-06
15:28:02
上传
评论
收藏 526KB ZIP 举报
温馨提示
计算机毕设源码
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计:基于PHP与swoole实现的统计监控系统.zip (63个子文件)
Graduation Design
Core
Cookie.php 962B
Session.php 4KB
RandomKey.php 2KB
Cache
RedisCache.php 2KB
FileCache.php 2KB
Response.php 524B
Views
main.tpl.php 6KB
footer.tpl.php 133B
admin.tpl.php 3KB
setting.tpl.php 2KB
login.tpl.php 3KB
statistic.tpl.php 5KB
header.tpl.php 2KB
log.tpl.php 982B
doc
statistics.conf 1KB
3.png 71KB
1.png 25KB
4.png 132KB
2.png 79KB
data
readme.md 0B
LICENSE 1KB
Bootstrap
Worker.php 17KB
Autoload.php 391B
WebServer.php 7KB
Provider.php 10KB
Example
client.php 1KB
StatisticClient.php 3KB
Web
js
highcharts.js 143KB
bootstrap.min.js 27KB
html5shiv.js 2KB
less-1.3.3.min.js 57KB
jquery.min.js 81KB
scripts.js 0B
img
apple-touch-icon-72-precomposed.png 6KB
glyphicons-halflings-white.png 9KB
apple-touch-icon-144-precomposed.png 16KB
apple-touch-icon-114-precomposed.png 11KB
apple-touch-icon-57-precomposed.png 4KB
glyphicons-halflings.png 12KB
favicon.png 2KB
css
style.css 247B
bootstrap.min.css 100KB
bootstrap-theme.css 19KB
bootstrap.css 123KB
bootstrap-theme.min.css 17KB
index.php 1KB
Lib
functions.php 3KB
Cache.php 309B
web.php 347B
Modules
logout.php 320B
statistic.php 4KB
main.php 9KB
logger.php 2KB
admin.php 3KB
setting.php 1KB
worker.php 365B
Config
Worker.php 1KB
Config.php 594B
Cache
readme.md 21B
Server.php 1KB
Redis.php 451B
.gitignore 40B
README.md 4KB
共 63 条
- 1
资源评论
学术菜鸟小晨
- 粉丝: 1w+
- 资源: 5001
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功