{"id":15308229,"url":"https://github.com/yidas/mtr-database-php","last_synced_at":"2025-08-07T05:12:21.153Z","repository":{"id":57086800,"uuid":"369504582","full_name":"yidas/mtr-database-php","owner":"yidas","description":"MTR (My traceroute) centralized monitoring dashboard with agent deployment","archived":false,"fork":false,"pushed_at":"2025-07-05T15:20:06.000Z","size":2272,"stargazers_count":14,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-26T19:28:17.133Z","etag":null,"topics":["chart","dashboard","health-check","internet-connection","latency","monitoring","mtr","tracepath","traceroute"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yidas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-21T10:53:28.000Z","updated_at":"2025-07-05T15:20:23.000Z","dependencies_parsed_at":"2024-03-26T08:41:50.914Z","dependency_job_id":"0387de08-6524-459c-aa10-49aa93a065a2","html_url":"https://github.com/yidas/mtr-database-php","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"348c9c995ef52ba9b1229275dbfa5c3a8a2d48f6"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/yidas/mtr-database-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidas%2Fmtr-database-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidas%2Fmtr-database-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidas%2Fmtr-database-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidas%2Fmtr-database-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yidas","download_url":"https://codeload.github.com/yidas/mtr-database-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidas%2Fmtr-database-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269201296,"owners_count":24377460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chart","dashboard","health-check","internet-connection","latency","monitoring","mtr","tracepath","traceroute"],"created_at":"2024-10-01T08:14:55.920Z","updated_at":"2025-08-07T05:12:21.141Z","avatar_url":"https://github.com/yidas.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"MTR Database for PHP\n====================\n\n[MTR (My traceroute)](https://en.wikipedia.org/wiki/MTR_(software)) centralized monitoring dashboard with agent deployment\n\n[![Latest Stable Version](https://poser.pugx.org/yidas/mtr-database/v/stable?format=flat-square)](https://packagist.org/packages/yidas/mtr-database)\n[![License](https://poser.pugx.org/yidas/mtr-database/license?format=flat-square)](https://packagist.org/packages/yidas/mtr-database)\n\nOUTLINE\n-------\n\n- [Demonstration](#demonstration)\n- [Introduction](#introduction)\n- [Requirements](#requirements)\n- [Installation](#installation)\n    - [Download](#download) \n- [Setup](#setup)\n    - [Database Setup](#database-setup)\n    - [Agent Setup \u0026 Launch](#agent-setup--launch)\n    - [API for collector \u0026 agents](#api-for-collector--agents)\n    - [Dashboard](#dashboard)  \n- [Advanced Usage](#advanced-usage)\n    - [Agent Configuration](#agent-configuration)\n    - [Purge](#purge) \n- [References](#references)\n\n---\n\nDEMONSTRATION\n-------------\n\n\u003cimg src=\"https://raw.githubusercontent.com/yidas/mtr-database-php/main/img/demo-dashboard-overview.png\" height=\"260\" /\u003e\u003cimg src=\"https://raw.githubusercontent.com/yidas/mtr-database-php/main/img/demo-dashboard-table-details.png\" height=\"260\" /\u003e\n\n---\n\nINTRODUCTION\n------------\nEasy to deploy agents and collect MTR data into a database for monitoring via a web dashboard with charts.\n\n![Basic Flow](https://www.plantuml.com/plantuml/proxy?src=https://raw.githubusercontent.com/yidas/mtr-database-php/main/img/architecture-diagram.plantuml?v=2)\n\n---\n\nREQUIREMENTS\n------------\nThis library requires the following:\n\n- MTR library (CLI) 0.9+\n- PHP 5.4.0+\\|7.0+\n\n---\n\nINSTALLATION\n------------\n\n### Download\n\n#### Composer Installation\n\nUsing Composer to install is the easiest way with auto-installer:\n\n```shell\ncomposer create-project --prefer-dist yidas/mtr-database\n```\n\n#### Wget Installation\n\nYou could see [Release](https://github.com/yidas/mtr-database-php/releases) for picking up the package with version, for example:\n    \n```shell\n$ wget https://github.com/yidas/mtr-database-php/archive/master.tar.gz -O mtr-database-phpi.tar.gz\n```\n\nAfter download, uncompress the package:\n\n```shell\n$ tar -zxvf mtr-database-php.tar.gz\n```\n\nSETUP\n-----------\n\n### Database Setup\n\nAfter the download, you could start to set up the `config.inc.php` with your database connection:\n\n```php\n...\n    'database' =\u003e [\n        'host' =\u003e '',\n        'driver'    =\u003e 'mysql',\n        'database'  =\u003e 'mtr_database',\n        'username'  =\u003e '',\n        'password'  =\u003e '',\n        'table' =\u003e 'records',\n        'charset'   =\u003e 'utf8',\n        'collation' =\u003e 'utf8_unicode_ci',\n    ],\n...\n```\n\nThen run `install.php` which will help you to install the database \u0026 table:\n\n```shell\n$ php install.php\nInstallation completed\n```\n\n### Agent Setup \u0026 Launch\n\nThe default setting of the agent can be configurated in `config.inc.php`:\n\n```php\n...\n    'general' =\u003e [\n        'mtrCmd' =\u003e 'mtr',\n        'timezone' =\u003e 'Asia/Taipei',\n        'category' =\u003e 'agent-01',   // Category mark for distinguishing\n    ],\n    'mtr' =\u003e [\n        'host' =\u003e 'your.host',\n        'period' =\u003e 10,     // Minute\n        'count' =\u003e 60,      // Report-cycles\n        'tcp' =\u003e false,     // TCP mode\n        'port' =\u003e 443,      // Port number for TCP mode\n    ],\n    'api' =\u003e [\n        'key' =\u003e '',            // API key must be the same bewteen agent and collector\n        'agent' =\u003e [\n            'enabled' =\u003e false, // To send MTR data to collector via API Agent (deafult is database)\n            'reportUrl' =\u003e '',  // Collector's API URL\n        ],\n        'collector' =\u003e [\n            'enabled' =\u003e false, // To receive MTR data from agent via API\n        ],\n    ],\n...\n```\n\nAfter the setting, enjoy to run or set `launch.php` with your prefered arguments in crontab:\n\n```shell\n$php launch.php\nProcess success\n```\n\nSet crontab into `/etc/cron.d/mtr-database`:\n\n```shell\n# Launch and record MTR every 10 miniutes by default ('period' =\u003e 10)\n*/10 * * * * root php /var/www/html/mtr-database/launch.php \u003e/dev/null 2\u003e\u00261\n\n# Purge data before 90 days by default (Optional)\n00 00 * * * root php /var/www/html/mtr-database/purge.php \u003e/dev/null 2\u003e\u00261\n```\n\n\u003e The default batch period is configured to be 10 minutes, so we can set the batch to be executed every 10 minutes.\n\n### API for collector \u0026 agents\n\nRegarding the introduction structure diagram, it's better to collect agents' MTR data via API (Default is database).  \nThe endpoint path of collector (`reportUrl`) is `/collect.php`, you could place the project in the web path such as `/var/www/html/mtr-database/index.php`.\n\nConfiguration for collector, the database setting is required:\n\n```php\n    'api' =\u003e [\n        'key' =\u003e 'your-own-api-key',            // API key must be the same bewteen agent and collector\n        'agent' =\u003e [\n            'enabled' =\u003e false, // To send MTR data to collector via API Agent (deafult is database)\n            'reportUrl' =\u003e '',  // Collector's API URL\n        ],\n        'collector' =\u003e [\n            'enabled' =\u003e true,  // To receive MTR data from agent via API\n        ],\n    ],\n    'database' =\u003e [\n```\n\nConfiguration for agents:\n\n```php\n    'api' =\u003e [\n        'key' =\u003e 'your-own-api-key',            // API key must be the same bewteen agent and collector\n        'agent' =\u003e [\n            'enabled' =\u003e true, // To send MTR data to collector via API Agent (deafult is database)\n            'reportUrl' =\u003e 'https://your.host/mtr-database/collect.php',  // Collector's API URL\n        ],\n        'collector' =\u003e [\n            'enabled' =\u003e false, // To receive MTR data from agent via API\n        ],\n    ],\n```\n\n### Dashboard\n\nThe endpoint path of MTR Dashboard is `/index.php` and it's disable by default, you could place the project in the web path such as `/var/www/html/mtr-database/index.php`.\n\nTurn the `enabled` on and set the username and password for the authentication in `config.ini.php`, the database setting is required:\n\n```php\n...\n    'dashboard' =\u003e [\n        'enabled' =\u003e true,\n        'username' =\u003e '',\n        'password' =\u003e '',\n        'categories' =\u003e [''],   // Category list for selection\n    ],\n    'database' =\u003e [\n...\n```\n\n\u003e `categories` will enable you to query specific data by category settings or query all data with default blank values.\n\n---\n\nADVANCED USAGE\n-----\n\n### Agent Configuration\n\nThe configuration file `config.inc.php` allows you to set the default settings for MTR launching. However, you can also specify parameters immediately in the command to be run.\n\n#### Host\n\nHost parameter allows you to specify the target host to be tracked with `-h --host` parameter:\n\n```shell\nphp launch.php --host=\"yourhost.local\"\n```\n\n#### Period\n\nPeriod argument allocate the number of minutes between crontab intervals with `-p --period` parameter:\n\n```shell\n# Launch and record MTR every 5 miniutes\n*/5 * * * * root php /var/www/html/mtr-database/launch.php --period=5 \u003e/dev/null 2\u003e\u00261\n```\n\nIn addition, Count argument will distribute the sending count between the interval according to the Period setting with `-c --report-cycles`  parameter:\n\n```shell\n# Launch and record MTR every 1 miniutes, and each report will send 10 count (send every 6 seconds)\n*/1 * * * * root php /var/www/html/mtr-database/launch.php --period=1 --report-cycles=10 \u003e/dev/null 2\u003e\u00261\n```\n\n#### TCP\n\nTCP argument allows you to use MTR TCP mode with specified port, `-T --tcp` for enabling TCP mode and `-P --port` for setting port:\n\n```shell\nphp launch.php --tcp -port=443\n```\n\n#### Category\n\nCategory allows to categorize each monitor command and supports filtering from the dashboard, which also can be achieved by using the `--category` parameter:\n\n```shell\nphp launch.php --category=\"Monitor-A1\"\n```\n\n### Purge\n\nRunning `purge.php` will delete old records older than the given number of days. You can use the `-d --days` parameter to set with (default is 90 days):\n\n```shell\n00 00 * * * root php /var/www/html/mtr-database/purge.php --days=30 \u003e/dev/null 2\u003e\u00261\n```\n\n\n---\n\nREFERENCES\n----------\n\n- [MTR - Github](https://github.com/traviscross/mtr)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyidas%2Fmtr-database-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyidas%2Fmtr-database-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyidas%2Fmtr-database-php/lists"}