setName('router:run') ->setDescription('Collect and dump router interface stats'); } private function setup() { $host = 'your host'; $user = 'your user'; $pass = 'your password'; try { $this->RouterOSclient = new rosClient($host, $user, $pass); } catch (Exception $e) { die('/'); } $this->keys = array( 'rx-bits-per-second', 'tx-bits-per-second', 'rx-packets-per-second', 'tx-packets-per-second', ); $this->interfaces = [ 'ether1', 'ether2', 'ether3', 'ether4', 'ether5', 'wlan1', 'wlan2', 'bridge', ]; $this->counter = 0; } protected function execute(InputInterface $input, OutputInterface $output) { $this->setup(); $request = new Request('/interface/monitor-traffic interface=' . implode(',', $this->interfaces)); $request->setTag('stats'); $this->RouterOSclient->sendAsync($request, array($this, 'responseHandler')); $this->RouterOSclient->loop(30); } public function responseHandler(Response $response) { foreach ($response as $key => $value) { if (!in_array($key, $this->keys)) { continue; } var_dump($key, $value); } } }