Giter Site home page Giter Site logo

tars-monitor's Introduction

tars-monitor


tars-monitor is a phptars service and feature monitoring and reporting module

It consists of two sub modules:

  • Service monitoring

  • Feature monitoring

How to use

Installation of cable vehicles

Using composer for installation

composer install phptars/tars-monitor

How to call

Service Monitoring Report

  • Locator is the report address, which is generally distributed by the server

  • Socket mode is set to 1, and socket mode is used for reporting

Socketmode is set to 2. Use swoole TCP client mode for reporting (need swoole support)

Socketmode is set to 3. Use swoole TCP coroutine client to report (need support of swoole 2.0 or above)

Scheduled reporting (default)

The use of scheduled reporting requires the support of swoole table. By calling addstat, the reporting information will be temporarily saved. The task process of the tar server will collect and package the reporting information for a period of time (the reporting interval is issued by the server, generally 60s), which can reduce the reporting request

$locator = "tars.tarsregistry.QueryObj@tcp -h 172.16.0.161 -p 17890";

$socketMode = 1;

$statfWrapper = new \Tars\monitor\StatFWrapper($locator,$socketMode);

$statfWrapper->addStat("PHPTest.helloTars.obj","test","172.16.0.116",51003,200,0,0);

$statfWrapper->addStat("PHPTest.helloTars.obj","test","172.16.0.116",51003,200,0,0);

$statfWrapper->addStat("PHPTest.helloTars.obj","test","172.16.0.116",51003,200,0,0);

Report data can be stored in a variety of ways. Cache provides the implementation of 'swoole table' and 'redis'. Users can also implement' contract / storecache interface 'by themselves. Refer to the configuration of' Src / services. PHP 'in demo' tar HTTP server 'for the configuration of storage methods.

return array(

'namespaceName' => 'HttpServer\\',

'monitorStoreConf' => [

'className' => Tars\monitor\cache\SwooleTableStoreCache::class,

'config' => []

]

);

Monitorstoreconf is the configuration of storage mode, where classname is the implementation class and' config 'is the corresponding configuration. For example, when using the redis storage mode, the host, port and key prefix of redis need to be configured in config.

When monitorstoreconf is not configured, swooletablestorecache is used for storage by default.

Single report

At the same time, 'tar monitor' also provides a single escalation interface, 'monitorstat'. That is to say, each call of tar request will be reported once, which is not recommended

$locator = "tars.tarsregistry.QueryObj@tcp -h 172.16.0.161 -p 17890";

$socketMode = 1;

$statfWrapper = new \Tars\monitor\StatFWrapper($locator,$socketMode);

$statfWrapper->monitorStat("PHPTest.helloTars.obj","test","172.16.0.116",51003,200,0,0);

Feature monitoring

Parameters are similar to service monitoring

$statfWrapper = new \Tars\monitor\PropertyFWrapper("tars.tarsregistry.QueryObj@tcp -h 172.16.0.161 -p 17890",1);

$statfWrapper->monitorProperty("127.0.0.1","userdefined",'Sum',2);

$statfWrapper->monitorProperty("127.0.0.1","userdefined",'Count',2);

$statfWrapper->monitorProperty("127.0.0.1","userdefined",'Count',1);

Monitor view

After data reporting, users can view the reported data in the service monitoring / feature monitoring tab.

Others

Because other modules have integrated this module, in general, service scripts do not need to explicitly use this module.

tars-monitor's People

Contributors

copyrenzhe avatar danielzheng-tencent avatar meijing0114 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tars-monitor's Issues

addStat 函数中 $masterIp 设置了,无效.

    $masterIp="10.0.0.22";
 $slaveIp="10.0.0.11";

\Tars\App::getStatF()->addStat(
\App\Core\Tars::$project_name ,$call_name ,
$slaveIp,
\App\Core\Tars::$listen_port , floor( $diff_time*1000),0,0
, "http_client" ,$masterIp,
);


tars 统计中 看到的 $masterIp 不是 10.0.0.22 而是 10.0.0.11 .
看起来 $masterIp 不知什么原因被设置成 $slaveIp.

NOTICE

NOTICE:Accessing static property Tars\monitor\classes\
StatPropMsgHead::$__fields as non static\n/usr/local/app/tars/tarsnode/data/Vipthink.Lesson/bin/
src/vendor/phptars/tars-monitor/src/classes/StatPropMsgHead.php:70"

php7.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.