EndpointMysqlCommand.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace StatsDBundle\Command;
  3. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  4. use Symfony\Component\Console\Input\InputArgument;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Output\OutputInterface;
  7. class EndpointMysqlCommand extends ContainerAwareCommand
  8. {
  9. protected function configure()
  10. {
  11. $this
  12. ->setName('endpoint:mysql')
  13. ->setDescription('Test jsonendpoint mysql')
  14. ;
  15. }
  16. /**
  17. * @param InputInterface $input
  18. * @param OutputInterface $output
  19. */
  20. protected function execute(InputInterface $input, OutputInterface $output)
  21. {
  22. $endpoint = $this->getContainer()->get('endpoint.mysql');
  23. $json = '{"range":{"from":"2017-11-13T14:09:25.307Z","to":"2017-11-13T17:09:25.308Z"},"intervalMs":0,"targets":[{"target":"d_3_s_1_snmp_ponRxPower"}],"format":"json","maxDataPoints":10}';
  24. $subName = "d_1_s_1";
  25. $targets = array();
  26. $targets["in_bandwidth"] = array("target" => "{$subName}_inbandwidth_olt");
  27. $targets["out_bandwidth"] = array("target" => "{$subName}_outbandwidth_olt");
  28. foreach($targets as $t) {
  29. $data = array('targets' => array(0 => $t), 'maxDataPoints' => 10);
  30. $json = json_encode($data);
  31. $result = $endpoint->get($json,'last');
  32. print_r($result);
  33. }
  34. print_r(PHP_EOL);
  35. print_r(date("Y-m-d H:i:s"));
  36. print_r(PHP_EOL);
  37. }
  38. }