Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $watch = $input->getOption('watch');
     $buffered = new BufferedOutput($output->getVerbosity(), $output->isDecorated());
     $service = new StatsService($this->getBeanstalk());
     do {
         $tubes = $service->getAllTubeStats();
         if (empty($tubes)) {
             $output->writeln('No tubes found.');
             return;
         }
         $table = new Table($buffered);
         $table->setHeaders($service->getTubeHeaderMapping());
         foreach ($tubes as $stats) {
             if ($stats['current-jobs-buried'] > 0) {
                 $stats['name'] = "<error>{$stats['name']}</error>";
                 $stats['current-jobs-buried'] = "<error>{$stats['current-jobs-buried']}</error>";
             }
             $table->addRow($stats);
         }
         $table->render();
         $clearScreen = $watch ? "" : '';
         $output->write($clearScreen . $buffered->fetch());
         $watch && sleep(1);
     } while ($watch);
 }
Ejemplo n.º 2
0
 /**
  * @param StatsService $service
  * @param string $stat
  * @param OutputInterface $output
  * @throws InvalidArgumentException
  */
 protected function outputStat(StatsService $service, $stat, OutputInterface $output)
 {
     $stats = $service->getServerStats(StatsService::SERVER_ALL) + $service->getServerInfo();
     if (!isset($stats[$stat])) {
         throw new InvalidArgumentException("Specified statistic '{$stat}' is not valid.");
     }
     $output->writeln($stats[$stat]);
 }
Ejemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $tube = $input->getArgument('tube');
     $stat = $input->getOption('stat');
     $service = new StatsService($this->getBeanstalk());
     $stats = $service->getTubeStats($tube);
     if (empty($stats)) {
         $output->writeln("No statistics found for tube '{$tube}'.");
         return;
     }
     if ($stat == '') {
         $this->displayTable($stats, $output);
     } else {
         $this->displayStat($stats, $stat, $output);
     }
 }