Stars: 445
Forks: 106
Pull Requests: 2
Issues: 11
Watchers: 34
Last Updated: 2020-05-19 01:06:20
一个运用php与swoole实现的统计监控系统
License: MIT License
Languages: PHP, CSS, Hack
一个运用php与swoole实现的统计监控系统
如果有使用
laravel
的朋友,推荐另外一个项目fast-laravel。欢迎使用,喜欢的话给个star鼓励下。谢谢各位
Install swoole extension from pecl
pecl install swoole
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
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
管理员用户名密码默认都为admin。
如果不需要登录验证,在applications/Statistics/Config/Config.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);