All Projects → laynefyc → Php Monitor

laynefyc / Php Monitor

A free, flexible, powerful tool that helps you monitor PHP Service and profiling PHP code.

Labels

Projects that are alternatives of or similar to Php Monitor

Php Ext Xlswriter
🚀 PHP Extension for creating and reader XLSX files.
Stars: ✭ 1,734 (+1033.33%)
Mutual labels:  swoole
Swoole Docker
See: https://github.com/swoole/docker-swoole
Stars: ✭ 132 (-13.73%)
Mutual labels:  swoole
Ti Rpc
基于swoole封装的一个简易的JSON协议的RPC框架,思路是借鉴的,代码是自己写的。小修小改的,目前服务于前公司(注意是前公司)生产环境,每日支撑大约8000万次调用。
Stars: ✭ 144 (-5.88%)
Mutual labels:  swoole
Smproxy
Swoole MySQL Proxy 一个基于 MySQL 协议,Swoole 开发的MySQL数据库连接池。 A MySQL database connection pool based on MySQL protocol and Swoole.
Stars: ✭ 1,665 (+988.24%)
Mutual labels:  swoole
Zhttp
基于swoole的异步轻量级web框架,内部封装协程异步非阻塞全套mysql、redis、mongo、memcached连接池,可以轻松start、reload、stop,加入数据库的查询模块,框架已经封装好近乎同步写法,底层异步调用
Stars: ✭ 131 (-14.38%)
Mutual labels:  swoole
Hyperf Chat
Hyperf Chat
Stars: ✭ 139 (-9.15%)
Mutual labels:  swoole
Swoole Tadpole
tadpole chatroom (maybe spermium) powered by swoole and slim framework
Stars: ✭ 116 (-24.18%)
Mutual labels:  swoole
Phpkafka
PHP Kafka client is used in PHP-FPM and Swoole. PHP Kafka client supports 50 APIs, which might be one that supports the most message types ever.
Stars: ✭ 149 (-2.61%)
Mutual labels:  swoole
Archer
基于协程Swoole的Task组件,支持多种模式。轻松实现协程Task的队列、并发、Defer、计时器等 | Swoole coroutine task kit - Swoole Humanization Library
Stars: ✭ 132 (-13.73%)
Mutual labels:  swoole
Guzzle Swoole
让基于 Guzzle 的项目完美无缝兼容 Swoole 协程,支持:Guzzle、Elasticsearch client——来自宇润 PHP 全家桶
Stars: ✭ 143 (-6.54%)
Mutual labels:  swoole
Charroom
PHP + Swoole 聊天室
Stars: ✭ 125 (-18.3%)
Mutual labels:  swoole
Mix
☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server / PHP 命令行模式开发框架,支持 Swoole、WorkerMan、FPM、CLI-Server
Stars: ✭ 1,753 (+1045.75%)
Mutual labels:  swoole
Swoole Task
分布式任务处理框架,基于swoole扩展,使用composer打包
Stars: ✭ 140 (-8.5%)
Mutual labels:  swoole
Group
轻量级框架 。实现了定时任务功能,分布式任务队列,命令行控制台,数据库脚本自动化,单元测试, rpc服务,多进程服务(模拟map-reduce)等等实用的功能!! 文档 https://fucongcong.gitbooks.io/group-doc/content/.
Stars: ✭ 122 (-20.26%)
Mutual labels:  swoole
Php Msf
PHP微服务框架即Micro Service Framework For PHP
Stars: ✭ 1,764 (+1052.94%)
Mutual labels:  swoole
Game Ddz
♦️ 使用Hyperf框架开发斗地主游戏
Stars: ✭ 116 (-24.18%)
Mutual labels:  swoole
Swoole Game
基于Swoole扩展开发游戏服务器框架,示例实现h5游戏开发
Stars: ✭ 131 (-14.38%)
Mutual labels:  swoole
Multiprocess
🚀Easy to make the common PHP/Python/js...script change daemon and multi-process execution
Stars: ✭ 151 (-1.31%)
Mutual labels:  swoole
Laravel Api Templates
Laravel API starter kit collection using different structures.
Stars: ✭ 149 (-2.61%)
Mutual labels:  swoole
Aint Queue
🚀 An async-queue library built on top of swoole, flexable multi-consumer, coroutine supported. 基于 Swoole 的一个异步队列库,可弹性伸缩的工作进程池,工作进程协程支持。
Stars: ✭ 143 (-6.54%)
Mutual labels:  swoole

php-monitor

A free, flexible, powerful tool that helps you monitor PHP Service and profiling PHP code.

Latest Stable Version Total Downloads Build Status

home

flame

url

English | 简体中文

✨ Features

  • 🌈 Get detailed PHP runtime data.
  • 🌍 Monitor production environment time consuming requests.
  • 🛡 Displays the memory and CPU consumption of the underlying function.
  • 🎨 Use various kinds of visual graphics to display data.

⚙️ System requirements

  • uprofiler,xhprof,tideways php extension(default tideways).
  • composer
  • PHP 5.6+

Install tideways extension

PHP 5.6(download tideways v4.1.5) PHP 7.0+(download tideways v4.1.7)

wget --no-check-certificate https://github.com/tideways/php-xhprof-extension/archive/v4.1.7.tar.gz  && tar zxvf v4.1.7.tar.gz && cd php-xhprof-extension-4.1.7 && phpize && ./configure && make && sudo make install

Add configuration data on php.ini.You should see something like:

extension=tideways.so

Once installed, you can use the following command to check:

> php --ri tideways
tideways
tideways => 4.1.7

Install php-monitor

composer create-project --prefer-dist --ignore-platform-reqs laynefyc/php-monitor php-monitor && cd php-monitor/public && php -S 127.0.0.1:8066

Visit http://127.0.0.1:8066 and input account and password(php/php).

Detailed installation tutorial

  1. Download & Update Projects

    composer create-project --prefer-dist --ignore-platform-reqs laynefyc/php-monitor php-monitor
    

    or

    git clone https://github.com/laynefyc/php-monitor.git
    cd php-monitor
    composer update --ignore-platform-reqs
    
  2. The project can set data storage mode and supports MySQL, MongoDB, SQLite. Set in configuration file src/config/config.php,The information is as follows:

    // 'save' => [
    //     'driver'    => 'mysql',
    //     'host'      => '127.0.0.1:3306',
    //     'database'  => 'php_monitor',
    //     'username'  => '',
    //     'password'  => 'abcd1234',
    //     'charset'   => 'utf8mb4'
    // ],
    // 'save' => [
    //     'driver'    => 'mongodb',
    //     'host'      => '127.0.0.1:27017',
    //     'database'  => 'php_monitor',
    //     'username'  => '',
    //     'password'  => ''
    // ],
    'save' => [
        'driver'    => 'sqlite',
        'database'  =>  dirname(__DIR__).'/db/php_monitor.sqlite3'
    ],
    

    SQLite is used by default in this project,if you use other databases, please uncomment them.

    If you want to use MySQL to run the following table creation statement (table name cannot be modified):

    CREATE TABLE `php_monitor` (
    	`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto-increment number ',
    	`url` text CHARACTER SET utf8 COMMENT 'Request URL',
    	`server_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT 'Service name',
    	`get` text COMMENT 'GET parameter',
    	`pmu` int(11) unsigned DEFAULT NULL COMMENT 'Memory spike',
    	`wt` int(11) unsigned DEFAULT NULL COMMENT 'Total time spent in microseconds',
    	`cpu` int(11) unsigned DEFAULT NULL COMMENT 'Total CPU cycle time',
    	`ct` int(3) NOT NULL COMMENT 'Total calls',
    	`mu` int(11) unsigned DEFAULT NULL COMMENT 'Current memory consumption',
    	`request_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Request time accurate to seconds',
    	`request_time_micro` int(10) unsigned DEFAULT '0' COMMENT 'Request time accurate to microseconds',
    	`profile` longblob NOT NULL COMMENT 'performance data,
    	`server` longblob COMMENT 'SERVER parameter',
    	`type` varchar(16) DEFAULT NULL COMMENT 'Request time includes GETPOST',
    	`ip` varchar(16) DEFAULT NULL COMMENT 'IP address',
    	PRIMARY KEY (`id`),
    	KEY `idx_url` (`url`),
    	KEY `idx_ip` (`ip`)
    ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
    

    Mongodb database will build its own tables, but it needs to add indexes by yourself.The adding way as follows:

    show dbs
    use php_monitor //Please select your own database
    db.php_monitor.createIndex({"url":1})
    db.php_monitor.createIndex({"ip":1})
    

    The table name for all data storage methods must be php_monitor and does not support modification.

  3. The operation of monitoring platform

    It can directly pass the following command during testing:

    cd php-monitor/public
    php -S 127.0.0.1:8066
    

    After running successfully ,It can be accessed http://127.0.0.1:8066directly .

    Non-test environment please use Nginx.The configuration is as follows:

    server {
        listen       8066;
        server_name  localhost;
        root /home/www/cai/php-monitor/public;
        index  index.php index.html;
        location / {
            root /home/www/cai/php-monitor/public;
        }
    
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            include        fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
        }
    }
    
    
  4. Login background

    Login account password can be modified directly in the configuration file,src/config/config.php

    'user' => [
        //login account and password
        ['account'=>'php','password'=>'php'],
        ['account'=>'admin','password'=>'abcd']
    ]
    

    Please change the account number and password in time after release. If you require a higher level of security, please extend the method of Login Controller.php file.

  5. Introduce monitoring into the project.

    The project is monitored in a non-invasive way, without any interference to the service in operation.

    There are two ways to add monitoring to a project. One is to modify the nginx configuration:

    For example, to monitor the running service www.site.com, you only need to add a line of configuration information in the nginx configuration file

    fastcgi_param PHP_VALUE "auto_prepend_file={php-monitor-path}/src/autoPrepend.php";
    
    

    The effect of adding configuration is as follows (other content is just for demonstration, not the same nginx configuration):

    server {
      listen 80;
      server_name www.site.com;
      root your/webroot/; 
      location ~ \.php$ {
          fastcgi_pass   127.0.0.1:9000;
          include        fastcgi_params;
          fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
          fastcgi_param PHP_VALUE "auto_prepend_file={php-monitor-path}/src/autoPrepend.php";
      }
    }
    

    This way is to use the auto_prepend_file interface provided by PHP,interfaceing https://www.php.net/manual/zh/ini.core.php#ini.auto-prepend-file.You need to restart nginx after adding configuration.

    The second way is to import the entry file that needs to monitor the project directly , usually add it in public/index.php

    require '/home/www/cai/php-monitor/src/autoPrepend.php';
    

    The effect after adding configuration is as follows (except the core code, the other code is for demonstration):

    <?php
    use pm\common\Router;
    
    //The core code is here
    require '/home/www/cai/php-monitor/src/autoPrepend.php';
    
    include 'vendor/autoload.php';
    $config = require('src/config/config.php');
    (new Router($config))->run();
    

    After adding the burying point, the request record of www.site.com project can be viewed in the http://127.0.0.1:8066 monitoring background.

  6. More details

    • MongoDB has the fastest storage speed. If you have high performance requirements, please use it first.
    • Modify the profile.enable property of the configuration file to modify the sampling frequency. Generally speaking, it is not necessary to store all requests.For example, 'rand (1, 100) > 60' is to set the sampling rate to '40%';
    • Modify the profiler.filter_path attribute of the configuration file to filter services that you do not want to collect, such as some intranet services that do not care about execution efficiency;
  7. Swoole support

    public function onReceive(\swoole_server $serv, $fd, $from_id, $dataSrc)
    {
        require '/home/www/cai/php-monitor/src/autoPrepend.php';
    
        //your code
        
        \pm\common\PMonitor::shutdown($data['params']['route'],$serv->getClientInfo($fd,$from_id)['remote_ip'],'TCP');
    }
    

TODO

  • [x] Sqlite storage mode development;
  • [x] Perfect internationalization;
  • [x] Improve documentation;
  • [x] CI process access;
  • [x] Supplementary unit test;
  • [x] Composer package encapsulation;
  • [ ] Rewrite xhprof extension;
  • [ ] Separation of buried point module and display module;
  • [ ] Docker access;

Feedback

Please submit your issues.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].