/**
  * @Route("/", name="_overview")
  * @Template()
  */
 public function indexAction()
 {
     $arguments = array('container' => $this->container);
     $serviceLoader = new Loader($arguments);
     $services = $serviceLoader->getServices();
     $reports = array();
     $singleReports = array();
     $groupReports = array();
     $singleReports = array();
     foreach ($services as $service) {
         $metricConfigs = $service->getSingleMetricMergedConfigs();
         $metricNames = array_keys($metricConfigs);
         $serviceName = $service->getName();
         $fullMetricNames = array_map(function ($metricNam) use($serviceName) {
             return $serviceName . $metricNam;
         }, $metricNames);
         $singleReports = array_merge($singleReports, $fullMetricNames);
     }
     $groupReportConfig = $serviceLoader->getReportGroupConfig();
     $groupReports = array_keys($groupReportConfig);
     $reports['single'] = $singleReports;
     $reports['groups'] = $groupReports;
     //		var_dump($reports);die;
     return $this->render('MonolistWatcherBundle:Default:overview.html.php', array('name' => 'Overview', 'reports' => $reports));
 }
Пример #2
0
 /**
  * @Route("/metric/single/{metricName}", name="_metric_single")
  * @Template()
  */
 public function getMetricSingleAction($metricName)
 {
     $serviceLoader = new Loader();
     $services = $serviceLoader->getServices();
     $currentService = null;
     $singleMetricName = '';
     foreach ($services as $service) {
         if (strpos($metricName, $service->getName()) !== false) {
             $singleMetricName = str_replace($service->getName(), '', $metricName);
             $currentService = $service;
         }
     }
     $serviceConfig = $currentService->getSingleMetricMergedConfigs();
     $metricConfig = $serviceConfig[$singleMetricName];
     /** @var \Doctrine\DBAL\Connection $conn */
     $conn = $this->get('database_connection');
     $finalResult = array();
     foreach ($metricConfig['identifier'] as $identifier) {
         $sql = 'SELECT * FROM ' . $metricName . ' WHERE identifier = ? AND timestamp > UNIX_TIMESTAMP(DATE(NOW()-INTERVAL 3 DAY))';
         //UNIX_TIMESTAMP(DATE(NOW()-INTERVAL 3 DAY))
         $statement = $conn->prepare($sql);
         $statement->bindValue(1, $identifier);
         $statement->execute();
         $dbResult = $statement->fetchAll();
         $overWork = array();
         foreach ($dbResult as $result) {
             $time = $result['timestamp'];
             $overWork[] = array($time, $result['value']);
         }
         $finalResult[] = array('data' => $overWork, 'label' => $identifier);
     }
     return new JsonResponse($finalResult);
 }
 /**
  * @Route("/group/{groupName}", name="_show_chart_group")
  * @Template()
  * @param $groupName
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function groupAction($groupName)
 {
     $groupMetrics = array();
     $loader = new Loader();
     $groupConfig = $loader->getReportGroupConfig();
     $groupMetrics = $groupConfig[$groupName];
     return $this->render('MonolistWatcherBundle:Default:group.html.php', array('groupName' => $groupName, 'groupMetrics' => $groupMetrics));
 }