ojisatriani / mikrotikapi
Mikrotik API 路由器
1.0.4
2019-08-27 07:38 UTC
Requires
- php: >=5.6.0
README
RouterOS/Mikrotik 客户端 API
安装
通过 composer
composer require ojisatriani/mikrotikapi
手动 composer.json 在 require 部分
"require": {
"ojisatriani/mikrotikapi": "dev-master", // <- this line
}
基本用法
use OjiSatriani\MikrotikApi\Mikroji;
$router = Mikroji::connect('192.168.3.1','user-api','user-api');
echo $router->ram() .'<br />'; // 1652.2
echo $router->hdd() .'<br />'; // 915.8
echo $router->cpu() .'<br />'; // 0
echo $router->rx('ether1') .'<br />'; // 1.85Kb/Mb/Gb/Tb
echo $router->tx('ether1') .'<br />'; // 47.7Kb/Mb/Gb/Tb
echo $router->rxInMb('ether1') .'<br />'; // 1.85 (view chart or graph)
echo $router->txInMb('ether1') .'<br />'; // 47.70 (view chart or graph)
echo json_encode($router->getInterface()) .'<br />'; // {"ether1":"ether1","ether2:ether2","ether3:ether3"}
echo $router->command('log/print'); // return array()
Mikrotik Wiki 页面 http://wiki.mikrotik.com/wiki/API_PHP_class
https://github.com/BenMenking/routeros-api
配置 API 凭据
RouterOS Winbox
- 启用 API。
转到 IP -> 服务 并启用 api 服务。
- 创建 API 用户。
转到 系统 -> 用户,标签 组。创建具有权限 api
、read
、write
的新组。
然后在创建组之后,转到 用户
标签并创建新的用户。将此用户关联到之前创建的组。
完成。