PHP code example of caasdata / tars-monitor

1. Go to this page and download the library: Download caasdata/tars-monitor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

caasdata / tars-monitor example snippets


$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);

return array(
    'namespaceName' => 'HttpServer\\',
    'monitorStoreConf' => [
        'className' => Tars\monitor\cache\SwooleTableStoreCache::class,
        'config' => []
    ]
);

$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);

$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);