diff --git a/CocarBundle.php b/CocarBundle.php
new file mode 100755
index 0000000..a99d542
--- /dev/null
+++ b/CocarBundle.php
@@ -0,0 +1,9 @@
+setName('perform:task')
+ ->setDescription('Run scheduled tasks')
+ ->addOption(
+ 'monitor',
+ null,
+ InputOption::VALUE_NONE
+ )
+ ->addOption(
+ 'status',
+ null,
+ InputOption::VALUE_NONE
+ )
+ ->addOption(
+ 'reliability',
+ null,
+ InputOption::VALUE_NONE
+ )
+ ->addOption(
+ 'rrdlog',
+ null,
+ InputOption::VALUE_NONE
+ )
+ ->addOption(
+ 'dailyperform',
+ null,
+ InputOption::VALUE_NONE
+ )
+ ->addOption(
+ 'generatealarm',
+ null,
+ InputOption::VALUE_NONE
+ )
+ ->addOption(
+ 'endalarm',
+ null,
+ InputOption::VALUE_NONE
+ )
+ ->addOption(
+ 'graphdailyperform',
+ null,
+ InputOption::VALUE_NONE
+ );
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $this->em = $this->getApplication()->getKernel()->getContainer()->get('doctrine')->getManager();
+
+ if ($input->getOption('monitor')) {
+ $return = $this->performTask('monitor');
+ }
+ elseif($input->getOption('status')) {
+ $return = $this->performTask('status');
+ }
+ elseif($input->getOption('reliability')) {
+ $return = $this->performTask('reliability');
+ }
+ elseif($input->getOption('rrdlog')) {
+ $return = $this->performTask('rrdlog');
+ }
+ elseif($input->getOption('dailyperform')) {
+ $return = $this->performTask('dailyperform');
+ }
+ elseif($input->getOption('generatealarm')) {
+ $return = $this->performTask('generatealarm');
+ }
+ elseif($input->getOption('endalarm')) {
+ $return = $this->performTask('endalarm');
+ }
+ elseif($input->getOption('graphdailyperform')) {
+ $return = $this->performTask('graphdailyperform');
+ }
+
+ $output->writeln($return);
+ }
+
+ private function performTask($task)
+ {
+ try
+ {
+ $r = file_get_contents($this->getApplication()->getKernel()->getContainer()->get('router')
+ ->generate("cocar_$task", array(), true));
+
+ echo $r;die;
+
+ if($task == 'monitor')
+ file_get_contents("http://localhost/projeto-cocar/web/app_dev.php/cocar/monitor");
+ elseif($task == 'status')
+ file_get_contents("http://localhost/projeto-cocar/web/app_dev.php/cocar/status");
+ elseif($task == 'reliability')
+ file_get_contents("http://localhost/projeto-cocar/web/app_dev.php/cocar/reliability");
+ elseif($task == 'rrdlog')
+ file_get_contents("http://localhost/projeto-cocar/web/app_dev.php/cocar/rrdlog");
+ elseif($task == 'dailyperform')
+ file_get_contents("http://localhost/projeto-cocar/web/app_dev.php/cocar/dailyperform");
+ elseif($task == 'generatealarm')
+ file_get_contents("http://localhost/projeto-cocar/web/app_dev.php/cocar/generatealarm");
+ elseif($task == 'endalarm')
+ file_get_contents("http://localhost/projeto-cocar/web/app_dev.php/cocar/endalarm");
+ elseif($task == 'graphdailyperform')
+ file_get_contents("http://localhost/projeto-cocar/web/app_dev.php/cocar/graphdailyperform");
+ }
+ catch(Exception $e)
+ {
+ return "An unexpected: $task";
+ }
+ return "Task executed: $task";
+ }
+}
\ No newline at end of file
diff --git a/Controller/AlarmController.php b/Controller/AlarmController.php
new file mode 100755
index 0000000..d7d362c
--- /dev/null
+++ b/Controller/AlarmController.php
@@ -0,0 +1,159 @@
+dir = $this->get('kernel')->getRootDir() . "/../web/rrd/";
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->createQuery(
+ "SELECT c FROM CocarBundle:Circuits c
+ WHERE c.generateAlarm = :alarm
+ AND c.manages <> :manage
+ AND c.status = 'UP'"
+ )
+ ->setParameter('alarm', true)
+ ->setParameter('manage', 'Entidades Externas')
+ ->getResult();
+
+ foreach($circuits as $cir)
+ {
+ $media_in = 0;
+ $media_out = 0;
+ $qtd = 0;
+
+ $rrd = $cir->getId() . ".rrd";
+
+ if(file_exists($this->dir . $rrd))
+ {
+ $fim = (date('U')) - 60;
+ $inicio = $fim - 720;
+ $com = "rrdtool fetch $this->dir$rrd AVERAGE --start $inicio --end $fim | sed -e \"s/ds[01]//g\" |
+ sed \"s/nan/0/g\" | tr \":\" \" \" | tr -s \" \" | sed -e \"s/ \$//\" | grep -v \"^\$\" |tail -10";
+
+ $linhas = explode("\n", shell_exec($com));
+
+ for ($i=0; $i < count($linhas) - 1; $i++)
+ {
+ $campos = explode(" ", $linhas[$i]);
+ $data = strftime("%Y-%m-%d %H:%M:%S",$campos[0]);
+ $vol_in = $this->calc($campos[1]);
+ $vol_out = $this->calc($campos[2]);
+
+ if ($data != "1970-01-01 00:00:00" && $data != "1969-12-31 21:00:00")
+ {
+ $media_in += $vol_in;
+ $media_out += $vol_out;
+ $qtd++;
+ }
+ }
+
+ $history = strtoupper($cir->getHistory());
+ $hist_novo = "N";
+
+ if ($qtd != 0)
+ {
+ # INICIO DO TRATAMENTO COMO CIRCUITO
+ $media_in = round(($media_in * 0.008)/$qtd, 1);
+ $media_out = round(($media_out * 0.008)/$qtd, 1);
+
+ if (strtolower($cir->getTypeInterface()) == "circuito" && (!preg_match("/ETH/i", $cir->getSerialBackbone())))
+ {
+ $cir_in = round(($cir->getCirIn() * 1.2), 1);
+ $cir_out = round(($cir->getCirOut() * 1.2), 1);
+
+ if ($media_in > $cir_in || $media_out > $cir_out)
+ {
+ if($history != "A1" && $history != "A2")
+ $hist_novo = "A1";
+ elseif($history == "A1" || $history == "A2")
+ $hist_novo = "A2";
+ }
+ elseif($media_out == 0.0 || $media_in == 0.0 )
+ {
+ if($history != "Z1" && $history != "Z2" )
+ $hist_novo = "Z1";
+ elseif($history == "Z1" || $history == "Z2")
+ $hist_novo = "Z2";
+ }
+ }
+ else
+ {
+ # INICIO DO TRATAMENTO COMO CONCENTRADORA
+ $porta = round(($cir->getSpeed() * 0.85), 1);
+
+ if ($media_in > $porta || $media_out > $porta)
+ {
+ if ($history != "A1" && $history != "A2")
+ $hist_novo = "A1";
+ elseif($history == "A1" || $history == "A2")
+ $hist_novo = "A2";
+ }
+ elseif ($media_out == 0.0 || $media_in == 0.0 )
+ {
+ if($history != "Z1" && $history != "Z2")
+ $hist_novo = "Z1";
+ elseif($history == "Z1" || $history == "Z2")
+ $hist_novo = "Z2";
+ }
+ }
+ }
+ else
+ {
+ $arq = strftime("%d-%m-%Y", $fim);
+ $fp = fopen($this->dir."logs/".$arq.".log", 'a');
+ $info = "Arquivo RRD: $rrd";
+ }
+
+ $cir->setHistory($hist_novo);
+
+ $em->persist($cir);
+ $em->flush();
+ }
+ }
+
+ return new Response();
+ }
+
+ /**
+ * @Route("/endalarm", name="cocar_endalarm")
+ * @Template()
+ */
+ public function endAlarmAction()
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->findAll();
+
+ foreach ($circuits as $cir) {
+ $cir->setHistory('N');
+
+ $em->persist($cir);
+ $em->flush();
+ }
+ return new Response();
+ }
+
+ public function calc($value)
+ {
+ $value = strtr($value, ",", ".");
+ settype ($value, 'double');
+ return round($value,1);
+ }
+}
\ No newline at end of file
diff --git a/Controller/CircuitsController.php b/Controller/CircuitsController.php
new file mode 100755
index 0000000..600eccf
--- /dev/null
+++ b/Controller/CircuitsController.php
@@ -0,0 +1,213 @@
+getDoctrine()->getManager();
+
+ $entity = new Circuits();
+
+ $entities = $em->getRepository('GerenciadorRedes\Bundle\CocarBundle\Entity\Circuits')->findAll();
+
+ return array(
+ 'entities' => $entities,
+ );
+ }
+ /**
+ * Creates a new Circuits entity.
+ *
+ * @Route("/", name="circuits_create")
+ * @Method("POST")
+ * @Template("CocarBundle:Circuits:new.html.twig")
+ */
+ public function createAction(Request $request)
+ {
+ $entity = new Circuits();
+ $form = $this->createForm(new CircuitsType(), $entity);
+ $form->submit($request);
+
+ if ($form->isValid()) {
+ $em = $this->getDoctrine()->getManager();
+ $em->persist($entity);
+ $em->flush();
+
+ return $this->redirect($this->generateUrl('circuits_show', array('id' => $entity->getId())));
+ }
+
+ return array(
+ 'entity' => $entity,
+ 'form' => $form->createView(),
+ );
+ }
+
+ /**
+ * Displays a form to create a new Circuits entity.
+ *
+ * @Route("/new", name="circuits_new")
+ * @Method("GET")
+ * @Template()
+ */
+ public function newAction()
+ {
+ $entity = new Circuits();
+ $form = $this->createForm(new CircuitsType(), $entity);
+
+ return array(
+ 'entity' => $entity,
+ 'form' => $form->createView(),
+ );
+ }
+
+ /**
+ * Finds and displays a Circuits entity.
+ *
+ * @Route("/{id}", name="circuits_show")
+ * @Method("GET")
+ * @Template()
+ */
+ public function showAction($id)
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $entity = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ if (!$entity) {
+ throw $this->createNotFoundException('Unable to find Circuits entity.');
+ }
+
+ $deleteForm = $this->createDeleteForm($id);
+
+ return array(
+ 'entity' => $entity,
+ 'delete_form' => $deleteForm->createView(),
+ );
+ }
+
+ /**
+ * Displays a form to edit an existing Circuits entity.
+ *
+ * @Route("/{id}/edit", name="circuits_edit")
+ * @Method("GET")
+ * @Template()
+ */
+ public function editAction($id)
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $entity = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ if (!$entity) {
+ throw $this->createNotFoundException('Unable to find Circuits entity.');
+ }
+
+ $editForm = $this->createForm(new CircuitsType(), $entity);
+ $deleteForm = $this->createDeleteForm($id);
+
+ return array(
+ 'entity' => $entity,
+ 'edit_form' => $editForm->createView(),
+ 'delete_form' => $deleteForm->createView(),
+ );
+ }
+
+ /**
+ * Edits an existing Circuits entity.
+ *
+ * @Route("/{id}", name="circuits_update")
+ * @Method("PUT")
+ * @Template("CocarBundle:Circuits:edit.html.twig")
+ */
+ public function updateAction(Request $request, $id)
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $entity = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ if (!$entity) {
+ throw $this->createNotFoundException('Unable to find Circuits entity.');
+ }
+
+ $deleteForm = $this->createDeleteForm($id);
+ $editForm = $this->createForm(new CircuitsType(), $entity);
+ $editForm->submit($request);
+
+ if ($editForm->isValid()) {
+ $em->persist($entity);
+ $em->flush();
+
+ return $this->redirect($this->generateUrl('circuits_edit', array('id' => $id)));
+ }
+
+ return array(
+ 'entity' => $entity,
+ 'edit_form' => $editForm->createView(),
+ 'delete_form' => $deleteForm->createView(),
+ );
+ }
+ /**
+ * Deletes a Circuits entity.
+ *
+ * @Route("/{id}", name="circuits_delete")
+ * @Method("DELETE")
+ */
+ public function deleteAction(Request $request, $id)
+ {
+ $form = $this->createDeleteForm($id);
+ $form->submit($request);
+
+ if ($form->isValid()) {
+ $em = $this->getDoctrine()->getManager();
+ $entity = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ if (!$entity) {
+ throw $this->createNotFoundException('Unable to find Circuits entity.');
+ }
+
+ $em->remove($entity);
+ $em->flush();
+ }
+
+ return $this->redirect($this->generateUrl('circuits'));
+ }
+
+ /**
+ * Creates a form to delete a Circuits entity by id.
+ *
+ * @param mixed $id The entity id
+ *
+ * @return \Symfony\Component\Form\Form The form
+ */
+ private function createDeleteForm($id)
+ {
+ return $this->createFormBuilder(array('id' => $id))
+ ->add('id', 'hidden')
+ ->getForm()
+ ;
+ }
+}
diff --git a/Controller/DailyPerformController.php b/Controller/DailyPerformController.php
new file mode 100755
index 0000000..cb991bc
--- /dev/null
+++ b/Controller/DailyPerformController.php
@@ -0,0 +1,404 @@
+getDoctrine()->getManager();
+
+ #puxar o id do circuito
+ $circuits = $em->createQuery(
+ "SELECT c FROM CocarBundle:Circuits c
+ WHERE c.operStatus = 'UP'"
+ )->getResult();
+
+ foreach($circuits as $cir)
+ {
+ $perform = new DailyPerformance();
+
+ $speed = $cir->getSpeed();
+ $codInterface = $cir->getId();
+ $cirIn = $cir->getCirIn();
+ $cirOut = $cir->getCirOut();
+
+ if ($cirIn == 0)
+ {
+ $cirIn = $speed * 0.85;
+ $cirOut = $speed * 0.85;
+ }
+
+ $arq = strtr($codInterface, ".", "_");
+
+ $day = strftime('%Y-%m-%d', (date('U')-86400));
+ $startDate = $day . " 07:00:00";
+ $endDate = $day . " 19:00:00";
+
+ $sum = $em->createQuery(
+ "SELECT SUM(r.volumeIn) as vin, SUM(r.volumeOut) as vout FROM CocarBundle:Rrd r
+ WHERE (r.datetime >= :start AND r.datetime <= :end)
+ AND(r.codeInterface = :code)"
+ )
+ ->setParameter('start', $day . " 00:00:00")
+ ->setParameter('end', $day . " 23:59:00")
+ ->setParameter('code', $codInterface)
+ ->getOneOrNullResult();
+
+ if(!empty($sum))
+ {
+ $volIn = $sum['vin'] * 60;
+ $volOut = $sum['vout'] * 60;
+
+ # CALCULA HMM IN: HORA, MEDIA, PICO, CRITICIDADE
+ $hmmIn =
+ $this->HMM(array(
+ 'code' => $codInterface,
+ 'field' => "volumeIn",
+ 'hStart' => 0,
+ 'hEnd' => 23,
+ 'cir' => $cirIn,
+ 'day' => $day
+ ));
+ if(isset($hmmIn[0]))
+ $hourHMMIn = $hmmIn[0] . ":" . $hmmIn[1] . ":00";
+
+ # CALCULA HMM OUT: HORA, MEDIA, PICO, CRITICIDADE
+ $hmmOut =
+ $this->HMM(array(
+ 'code' => $codInterface,
+ 'field' => "volumeOut",
+ 'hStart' => 0,
+ 'hEnd' => 23,
+ 'cir' => $cirOut,
+ 'day' => $day
+ ));
+
+ if(isset($hmmOut[0]))
+ $hourHMMOut = $hmmOut[0] . ":" . $hmmOut[1] . ":00";
+
+ # CALCULA HMM IN NO PERIODO : HORA, MEDIA, PICO, CRITICIDADE
+ $hmmInPer =
+ $this->HMM(array(
+ 'code' => $codInterface,
+ 'field' => "volumeIn",
+ 'hStart' => 7,
+ 'hEnd' => 18,
+ 'cir' => $cirIn,
+ 'day' => $day
+ ));
+ if(isset($hmmInPer[0]))
+ $hourHMMInPer = $hmmInPer[0] . ":" . $hmmInPer[1] . ":00";
+
+ # CALCULA HMM OUT NO PERIODO: HORA, MEDIA, PICO, CRITICIDADE
+ $hmmOutPer =
+ $this->HMM(array(
+ 'code' => $codInterface,
+ 'field' => "volumeOut",
+ 'hStart' => 7,
+ 'hEnd' => 18,
+ 'cir' => $cirOut,
+ 'day' => $day
+ ));
+ if(isset($hmmOutPer[0]))
+ $hourHMMOutPer = $hmmOutPer[0] . ":" . $hmmOutPer[1] . ":00";
+
+ # CALCULA PERIODO IN: HORA, MEDIA, PICO, CRITICIDADE
+ for($i=1;$i<=4;$i++)
+ {
+ $peak =
+ $this->periodMax(array(
+ 'code' => $codInterface,
+ 'field' => ($i%2 == 0) ? "volumeIn" : "volumeOut",
+ 'startDate' => $startDate,
+ 'endDate' => $endDate,
+ 'cir' => ($i%2 == 0) ? $cirIn : $cirOut
+ ));
+
+ $media =
+ $this->periodSum(array(
+ 'code' => $codInterface,
+ 'field' => ($i%2 == 0) ? "volumeIn" : "volumeOut",
+ 'startDate' => $startDate,
+ 'endDate' => $endDate,
+ 'cir' => ($i%2 == 0) ? $cirIn : $cirOut
+ ));
+
+ $criticality =
+ $this->periodField(array(
+ 'code' => $codInterface,
+ 'field' => ($i%2 == 0) ? "volumeIn" : "volumeOut",
+ 'startDate' => $startDate,
+ 'endDate' => $endDate,
+ 'cir' => ($i%2 == 0) ? $cirIn : $cirOut
+ ));
+
+ if($i%2 == 0)
+ {
+ $perform->set719PeakIn($peak);
+ $perform->set719MediaIn($media);
+ $perform->set719CriticalityIn($criticality);
+ }
+ else
+ {
+ $perform->set719PeakOut($peak);
+ $perform->set719MediaOut($media);
+ $perform->set719CriticalityOut($criticality);
+ }
+ }
+
+ $recommendedCircuitIn =
+ $this->recommendedCircuit(array(
+ 'code' => $codInterface,
+ 'field' => "volumeIn",
+ 'startDate' => $startDate,
+ 'endDate' => $endDate
+ ));
+
+ $recommendedCircuitOut =
+ $this->recommendedCircuit(array(
+ 'code' => $codInterface,
+ 'field' => "volumeOut",
+ 'startDate' => $startDate,
+ 'endDate' => $endDate
+ ));
+
+ $perform->setCodeInterface($codInterface);
+ $perform->setDay(new \DateTime($day));
+ $perform->setCirIn($cirIn);
+ $perform->setCirOut($cirOut);
+ $perform->setCirInRec($recommendedCircuitIn);
+ $perform->setCirOutRec($recommendedCircuitOut);
+ $perform->setVolumeIn($volIn);
+ $perform->setVolumeOut($volOut);
+ $perform->setLossInHour(new \DateTime('00:00:00'));
+ $perform->setLossOutHour(new \DateTime('00:00:00'));
+ $perform->setHmmHourIn(isset($hourHMMIn) ? new \DateTime($hourHMMIn) : new \DateTime('00:00:00'));
+ $perform->setHmmHourOut(isset($hourHMMOut) ? new \DateTime($hourHMMOut) : new \DateTime('00:00:00'));
+ $perform->setHmmPeakIn(isset($hmmIn[3]) ? $hmmIn[3] : 0);
+ $perform->setHmmPeakOut(isset($hmmOut[3]) ? $hmmOut[3] : 0);
+ $perform->setHmmMediaIn(isset($hmmIn[2]) ? $hmmIn[2] : 0);
+ $perform->setHmmMediaOut(isset($hmmOut[2]) ? $hmmOut[2] : 0);
+ $perform->setHmmCriticalityIn(isset($hmmIn[4]) ? $hmmIn[4] : 0);
+ $perform->setHmmCriticalityOut(isset($hmmOut[4]) ? $hmmOut[4] : 0);
+ $perform->setHmmHourInPer(isset($hourHMMInPer) ? new \DateTime($hourHMMInPer) : new \DateTime('00:00:00'));
+ $perform->setHmmHourOutPer(isset($hourHMMOutPer) ? new \DateTime($hourHMMOutPer) : new \DateTime('00:00:00'));
+ $perform->setHmmPeakInPer(isset($hmmInPer[3]) ? $hmmInPer[3] : 0);
+ $perform->setHmmPeakOutPer(isset($hmmOutPer[3]) ? $hmmOutPer[3] : 0);
+ $perform->setHmmMediaInPer(isset($hmmInPer[2]) ? $hmmInPer[2] : 0);
+ $perform->setHmmMediaOutPer(isset($hmmOutPer[2]) ? $hmmOutPer[2] : 0);
+ $perform->setHmmCriticalityInPer(isset($hmmInPer[4]) ? $hmmInPer[4] : 0);
+ $perform->setHmmCriticalityOutPer(isset($hmmOutPer[4]) ? $hmmOutPer[4] : 0);
+
+ $em->persist($perform);
+ $em->flush();
+ }
+ }
+ return new Response();
+ }
+
+ public function HMM ($params = array())
+ {
+ if(!empty($params))
+ {
+ $bytesHMM = 0;
+
+ for ($h=$params['hStart'];$h<=$params['hEnd'];$h++)
+ {
+ for ($m=0;$m<60;$m++)
+ {
+ $hour = $params['day']." ".$h.":".$m.":00";
+ $hHMM = $h + 1;
+ $hHMM = ($hHMM == 24) ? 23 : $hHMM;
+ $hour60min = $params['day']." ".$hHMM.":".$m.":00";
+
+ $sum = $this->getDoctrine()->getManager()->createQuery("SELECT SUM(r.volumeIn) as volumeIn, SUM (r.volumeOut) as volumeOut FROM CocarBundle:Rrd r
+ WHERE (r.datetime >= :start)
+ AND(r.datetime <= :end)
+ AND(r.codeInterface = :code)"
+ )
+ ->setParameter('start', $hour)
+ ->setParameter('end', $hour60min)
+ ->setParameter('code', $params['code'])
+ ->getOneOrNullResult();
+
+ if ($sum[$params['field']] > $bytesHMM)
+ {
+ $vectorHMM[0] = $h;
+ $vectorHMM[1] = $m;
+ $vectorHMM[2] = (8/60000) * $sum[$params['field']];
+ }
+ }
+ }
+
+ if(isset($vectorHMM))
+ {
+ $hour = $params['day']." ".$vectorHMM[0].":".$vectorHMM[1].":00";
+ $hHMM = $vectorHMM[0] + 1;
+ $hour60min = $params['day']." ".$hHMM.":".$vectorHMM[1].":00";
+
+ $max = $this->periodMax(
+ array(
+ 'field' => $params['field'],
+ 'startDate' => $hour,
+ 'endDate' => $hour60min,
+ 'code' => $params['code']
+ ));
+
+ if(!empty($max))
+ {
+ $vectorHMM[3] = (8/1000) * $max;
+
+ $field = $this->getDoctrine()->getManager()->createQuery("SELECT COUNT(r.volumeIn) as volumeIn, COUNT(r.volumeOut) as volumeOut FROM CocarBundle:Rrd r
+ WHERE (r.datetime >= :start)
+ AND(r.datetime < :end)
+ AND(r.codeInterface = :code)
+ AND(:field > :cir)"
+ )
+ ->setParameter('start', $max['startDate'])
+ ->setParameter('end', $max['endDate'])
+ ->setParameter('code', $params['code'])
+ ->setParameter('field', $params['field'])
+ ->setParameter('cir', $params['cir']*(1000/8))
+ ->getOneOrNullResult();
+
+ if(!empty($field))
+ $vectorHMM[4] = (100/60) * $field[$params['field']];
+ }
+ return $vectorHMM;
+ }
+ }
+ return array();
+ }
+
+ public function periodMax($params = array())
+ {
+ if(!empty($params))
+ {
+ $max = $this->getDoctrine()->getManager()->createQuery("SELECT MAX(r.volumeIn) as volumeIn, MAX(r.volumeOut) as volumeOut FROM CocarBundle:Rrd r
+ WHERE (r.datetime >= :start)
+ AND(r.datetime < :end)
+ AND(r.codeInterface = :code)"
+ )
+ ->setParameter('start', $params['startDate'])
+ ->setParameter('end', $params['endDate'])
+ ->setParameter('code', $params['code'])
+ ->getOneOrNullResult();
+
+ return (!empty($max)) ? (8/1000) * $max[$params['field']] : null;
+
+ }
+ return null;
+ }
+
+ public function periodSum($params = array())
+ {
+ if(!empty($params))
+ {
+ $sum = $this->getDoctrine()->getManager()->createQuery("SELECT SUM(r.volumeIn) as volumeIn, SUM (r.volumeOut) as volumeOut FROM CocarBundle:Rrd r
+ WHERE (r.datetime >= :start)
+ AND(r.datetime < :end)
+ AND(r.codeInterface = :code)"
+ )
+ ->setParameter('start', $params['startDate'])
+ ->setParameter('end', $params['endDate'])
+ ->setParameter('code', $params['code'])
+ ->getOneOrNullResult();
+
+ return (!empty($sum)) ? (8/720000) * $sum[$params['field']] : null;
+ }
+ return null;
+ }
+
+ public function periodField($params = array())
+ {
+ if(!empty($params))
+ {
+ $field = $this->getDoctrine()->getManager()->createQuery("SELECT COUNT(r.volumeIn) as volumeIn, COUNT(r.volumeOut) as volumeOut FROM CocarBundle:Rrd r
+ WHERE (r.datetime >= :start)
+ AND(r.datetime < :end)
+ AND(r.codeInterface = :code)
+ AND(:field > :cir)"
+ )
+ ->setParameter('start', $params['startDate'])
+ ->setParameter('end', $params['endDate'])
+ ->setParameter('code', $params['code'])
+ ->setParameter('field', $params['field'])
+ ->setParameter('cir', $params['cir']*(1000/8))
+ ->getOneOrNullResult();
+
+ return (!empty($field)) ? (100/720) * $field[$params['field']] : null;
+ }
+ return null;
+ }
+
+ public function recommendedCircuit($params = array())
+ {
+ if(!empty($params))
+ {
+ $recommendCir = array(
+ 16, 32, 48, 64, 80, 96, 112, 128, 160, 192, 224, 256, 288, 320, 352, 384,
+ 448, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920
+ );
+
+ $field = $this->getDoctrine()->getManager()->createQuery("SELECT r.volumeIn as volumeIn, r.volumeOut as volumeOut FROM CocarBundle:Rrd r
+ WHERE (r.datetime >= :start AND r.datetime < :end)
+ AND(r.codeInterface = :code)"
+ )
+ ->setParameter('start', $params['startDate'])
+ ->setParameter('end', $params['endDate'])
+ ->setParameter('code', $params['code'])
+ ->getResult();
+ $samples = 0;
+
+ $cRec = array();
+
+ foreach($field as $f)
+ {
+ $samples++;
+ $f[$params['field']] *= (8/1000);
+ $cir = round($f[$params['field']], 0);
+
+ $start = 0;
+ $end = count($recommendCir) -1;
+ $middle = ($start + $end)/2;
+
+ while (isset($recommendCir[$middle]) && $start != $end && $cir != $recommendCir[$middle])
+ {
+ if ($cir > $recommendCir[$middle])
+ $start = $middle + 1;
+ else
+ $end = $middle;
+
+ $middle = ($start + $end)/2;
+ }
+
+ $cRec[$middle] = isset($cRec[$middle]) ? $cRec[$middle] += 1 : 1;
+ }
+
+ $j = -1;
+ $x = 0;
+ while ($x < (0.95 * $samples) && isset($cRec[$j]))
+ {
+ $j++;
+ $x += $cRec[$j];
+ }
+
+ return (isset($recommendCir[$j])) ? $recommendCir[$j] : 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php
new file mode 100755
index 0000000..2f3bbe5
--- /dev/null
+++ b/Controller/DefaultController.php
@@ -0,0 +1,180 @@
+getDoctrine()->getManager();
+
+ $search = false;
+
+ if($request->isMethod('POST'))
+ {
+ $circuit = $request->request->get('circuit');
+
+ $searchResult = $em->createQuery(
+ "SELECT c.description, c.id, e.identifier FROM CocarBundle:Circuits c
+ LEFT JOIN CocarBundle:Entity e WITH c.entity = e.id
+ WHERE c.description LIKE :description"
+ )
+ ->setParameter('description', "%$circuit%")
+ ->getResult();
+
+ $search = true;
+ }
+
+ $highTraffic = $em->createQuery(
+ "SELECT c.id, c.codeInterface, c.description, e.description entity FROM CocarBundle:Circuits c
+ LEFT JOIN CocarBundle:Entity e WITH c.entity = e.id
+ WHERE c.history LIKE :history
+ AND c.manages <> :manage
+ AND c.operStatus = :status"
+ )
+ ->setParameter('history', '%A%')
+ ->setParameter('manage', 'Entidades Externas')
+ ->setParameter('status', 'UP')
+ ->getResult();
+
+ $withoutTraffic = $em->createQuery(
+ "SELECT c.id, c.codeInterface, c.description, e.description entity FROM CocarBundle:Circuits c
+ LEFT JOIN CocarBundle:Entity e WITH c.entity = e.id
+ WHERE c.history LIKE :history
+ AND c.manages <> :manage
+ AND c.operStatus = :status"
+ )
+ ->setParameter('history', '%Z%')
+ ->setParameter('manage', 'Entidades Externas')
+ ->setParameter('status', 'UP')
+ ->getResult();
+
+ $reliability = $em->createQuery(
+ "SELECT c.id, c.codeInterface, c.description, e.description entity FROM CocarBundle:Circuits c
+ LEFT JOIN CocarBundle:Entity e WITH c.entity = e.id
+ WHERE (c.manages <> :manage1
+ AND c.manages <> :manage2)
+ AND c.operStatus = :status"
+ )
+ ->setParameter('manage1', 'Entidades Externas')
+ ->setParameter('manage2', 'Firewall')
+ ->setParameter('status', 'UP')
+ ->getResult();
+
+ $total = $em->createQuery(
+ "SELECT count(c.id) total FROM CocarBundle:Circuits c
+ WHERE c.manages <> :manage
+ AND c.operStatus = :status"
+ )
+ ->setParameter('manage', 'Entidades Externas')
+ ->setParameter('status', 'UP')
+ ->getSingleResult();
+
+ return array(
+ 'reliability' => $reliability,
+ 'high_traffic' => $highTraffic,
+ 'without_traffic' => $withoutTraffic,
+ 'total' => $total['total'],
+ 'search_result' => isset($searchResult) ? $searchResult : null,
+ 'search' => $search
+ );
+ }
+
+ /**
+ * @Route("/totalizer", name="cocar_totalizer")
+ * @Template()
+ */
+ public function totalizerAction()
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $entitys = $em->getRepository('CocarBundle:Entity')->findAll();
+
+ foreach ($entitys as $entity)
+ {
+ $highTraffic = $em->createQuery(
+ "SELECT COUNT(c.id) total FROM CocarBundle:Circuits c
+ LEFT JOIN CocarBundle:Entity e WITH c.entity = e.id
+ WHERE c.history LIKE :history
+ AND c.manages <> :manage
+ AND c.operStatus = :status
+ AND e.id = :id"
+ )
+ ->setParameter('history', '%A%')
+ ->setParameter('manage', 'Entidades Externas')
+ ->setParameter('status', 'UP')
+ ->setParameter('id', $entity->getId())
+ ->getSingleResult();
+
+ $withoutTraffic = $em->createQuery(
+ "SELECT COUNT(c.id) total FROM CocarBundle:Circuits c
+ LEFT JOIN CocarBundle:Entity e WITH c.entity = e.id
+ WHERE c.history LIKE :history
+ AND c.manages <> :manage
+ AND c.operStatus = :status
+ AND e.id = :id"
+ )
+ ->setParameter('history', '%Z%')
+ ->setParameter('manage', 'Entidades Externas')
+ ->setParameter('status', 'UP')
+ ->setParameter('id', $entity->getId())
+ ->getSingleResult();
+
+ $reliability = $em->createQuery(
+ "SELECT COUNT(c.id) total FROM CocarBundle:Circuits c
+ LEFT JOIN CocarBundle:Entity e WITH c.entity = e.id
+ WHERE (c.manages <> :manage1
+ AND c.manages <> :manage2)
+ AND c.operStatus = :status
+ AND e.id = :id"
+ )
+ ->setParameter('manage1', 'Entidades Externas')
+ ->setParameter('manage2', 'Firewall')
+ ->setParameter('status', 'UP')
+ ->setParameter('id', $entity->getId())
+ ->getSingleResult();
+
+ $total = $em->createQuery(
+ "SELECT count(c.id) total FROM CocarBundle:Circuits c
+ WHERE c.manages <> :manage
+ AND c.operStatus = :status
+ AND c.entity = :entity"
+ )
+ ->setParameter('manage', 'Entidades Externas')
+ ->setParameter('status', 'UP')
+ ->setParameter('entity', $entity->getId())
+ ->getSingleResult();
+
+ $circuits[$entity->getId()] = array(
+ 'high' => $highTraffic['total'],
+ 'without' => $withoutTraffic['total'],
+ 'rly' => $reliability['total'],
+ 'description' => $entity->getDescription(),
+ 'totalCirc' => $highTraffic['total'] + $withoutTraffic['total'] + $reliability['total'],
+ 'total' => isset($total['total']) ? $total['total'] : 0
+ );
+ }
+
+ return array('circuits' => $circuits);
+ }
+}
diff --git a/Controller/EntityController.php b/Controller/EntityController.php
new file mode 100755
index 0000000..b4b0412
--- /dev/null
+++ b/Controller/EntityController.php
@@ -0,0 +1,210 @@
+getDoctrine()->getManager();
+
+ $entities = $em->getRepository('CocarBundle:Entity')->findAll();
+
+ return array(
+ 'entities' => $entities,
+ );
+ }
+ /**
+ * Creates a new Entity entity.
+ *
+ * @Route("/", name="entity_create")
+ * @Method("POST")
+ * @Template("CocarBundle:Entity:new.html.twig")
+ */
+ public function createAction(Request $request)
+ {
+ $entity = new Entity();
+ $form = $this->createForm(new EntityType(), $entity);
+ $form->submit($request);
+
+ if ($form->isValid()) {
+ $em = $this->getDoctrine()->getManager();
+ $em->persist($entity);
+ $em->flush();
+
+ return $this->redirect($this->generateUrl('entity_show', array('id' => $entity->getId())));
+ }
+
+ return array(
+ 'entity' => $entity,
+ 'form' => $form->createView(),
+ );
+ }
+
+ /**
+ * Displays a form to create a new Entity entity.
+ *
+ * @Route("/new", name="entity_new")
+ * @Method("GET")
+ * @Template()
+ */
+ public function newAction()
+ {
+ $entity = new Entity();
+ $form = $this->createForm(new EntityType(), $entity);
+
+ return array(
+ 'entity' => $entity,
+ 'form' => $form->createView(),
+ );
+ }
+
+ /**
+ * Finds and displays a Entity entity.
+ *
+ * @Route("/{id}", name="entity_show")
+ * @Method("GET")
+ * @Template()
+ */
+ public function showAction($id)
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $entity = $em->getRepository('CocarBundle:Entity')->find($id);
+
+ if (!$entity) {
+ throw $this->createNotFoundException('Unable to find Entity entity.');
+ }
+
+ $deleteForm = $this->createDeleteForm($id);
+
+ return array(
+ 'entity' => $entity,
+ 'delete_form' => $deleteForm->createView(),
+ );
+ }
+
+ /**
+ * Displays a form to edit an existing Entity entity.
+ *
+ * @Route("/{id}/edit", name="entity_edit")
+ * @Method("GET")
+ * @Template()
+ */
+ public function editAction($id)
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $entity = $em->getRepository('CocarBundle:Entity')->find($id);
+
+ if (!$entity) {
+ throw $this->createNotFoundException('Unable to find Entity entity.');
+ }
+
+ $editForm = $this->createForm(new EntityType(), $entity);
+ $deleteForm = $this->createDeleteForm($id);
+
+ return array(
+ 'entity' => $entity,
+ 'edit_form' => $editForm->createView(),
+ 'delete_form' => $deleteForm->createView(),
+ );
+ }
+
+ /**
+ * Edits an existing Entity entity.
+ *
+ * @Route("/{id}", name="entity_update")
+ * @Method("PUT")
+ * @Template("CocarBundle:Entity:edit.html.twig")
+ */
+ public function updateAction(Request $request, $id)
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $entity = $em->getRepository('CocarBundle:Entity')->find($id);
+
+ if (!$entity) {
+ throw $this->createNotFoundException('Unable to find Entity entity.');
+ }
+
+ $deleteForm = $this->createDeleteForm($id);
+ $editForm = $this->createForm(new EntityType(), $entity);
+ $editForm->submit($request);
+
+ if ($editForm->isValid()) {
+ $em->persist($entity);
+ $em->flush();
+
+ return $this->redirect($this->generateUrl('entity_edit', array('id' => $id)));
+ }
+
+ return array(
+ 'entity' => $entity,
+ 'edit_form' => $editForm->createView(),
+ 'delete_form' => $deleteForm->createView(),
+ );
+ }
+ /**
+ * Deletes a Entity entity.
+ *
+ * @Route("/{id}", name="entity_delete")
+ * @Method("DELETE")
+ */
+ public function deleteAction(Request $request, $id)
+ {
+ $form = $this->createDeleteForm($id);
+ $form->submit($request);
+
+ if ($form->isValid()) {
+ $em = $this->getDoctrine()->getManager();
+ $entity = $em->getRepository('CocarBundle:Entity')->find($id);
+
+ if (!$entity) {
+ throw $this->createNotFoundException('Unable to find Entity entity.');
+ }
+
+ $em->remove($entity);
+ $em->flush();
+ }
+
+ return $this->redirect($this->generateUrl('entity'));
+ }
+
+ /**
+ * Creates a form to delete a Entity entity by id.
+ *
+ * @param mixed $id The entity id
+ *
+ * @return \Symfony\Component\Form\Form The form
+ */
+ private function createDeleteForm($id)
+ {
+ return $this->createFormBuilder(array('id' => $id))
+ ->add('id', 'hidden')
+ ->getForm()
+ ;
+ }
+}
diff --git a/Controller/GraphController.php b/Controller/GraphController.php
new file mode 100755
index 0000000..bead9b0
--- /dev/null
+++ b/Controller/GraphController.php
@@ -0,0 +1,1001 @@
+getDoctrine()->getManager();
+
+ $circuit = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ $form = $this->graphForm();
+
+ return array('circuit' => $circuit, 'form' => $form->createView());
+ }
+
+ /**
+ * @Route("/graphshow/{id}", name="cocar_graphshow")
+ * @Method("GET")
+ */
+ public function graphShowAction(Request $request, $id)
+ {
+ $form = $this->graphForm();
+ $form->submit($request);
+
+ if ($form->isValid())
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $data = $form->getData();
+
+ switch($data['choice'])
+ {
+ case 0:
+ $img[] = $this->graphTraffic($id, $data['period']);
+ $img[] = $this->graphConcentrator($id, $data['period']);
+ $img[] = $this->graphReliability($id, $data['period']);
+ break;
+ case 1:
+ $img[] = $this->graphTraffic($id, $data['period']);
+ break;
+ case 2:
+ $img[] = $this->graphConcentrator($id, $data['period']);
+ break;
+ case 3:
+ $img[] = $this->graphReliability($id, $data['period']);
+ break;
+ case 4:
+ $img = $this->graphMachine($id, $data['period']);
+ break;
+ default:
+ $img[] = $this->graphTraffic($id, $data['period']);
+ }
+
+ $paginator = $this->get('knp_paginator');
+ $img = $paginator->paginate($img, $this->get('request')->query->get('page', 1), 5);
+
+ $circuit = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ return $this->render('CocarBundle:Graph:graph.html.twig',
+ array('id' => $id, 'form' => $form->createView(), 'circuit' => $circuit, 'img' => $img));
+ }
+
+ return $this->redirect($this->generateUrl('entity'), array('id' => $id));
+ }
+
+ /**
+ * @param mixed $id the circuit id
+ *
+ * @return \Symfony\Component\Form\Form the form
+ */
+ private function graphForm()
+ {
+ return $this->createFormBuilder()
+ ->add('choice', 'choice', array(
+ 'choices' => array(
+ 0 => 'Todos',
+ 1 => 'Tráfego',
+ 2 => 'Concentradora',
+ 3 => 'Confiabilidade',
+ 4 => 'Maquinas',
+ ),
+ 'multiple' => false,
+ 'expanded' => true,
+ 'required' => true,
+ ))
+ ->add('period', 'choice', array(
+ 'choices' => array(
+ '6hours' => '6 horas',
+ '8hours' => '8 horas',
+ '1day' => '1 dia',
+ '40hours' => '40 horas',
+ '160hours' => '1 semana',
+ '720hours' => '1 mês',
+ '4months' => '4 meses',
+ '1year' => '1 ano'
+ ),
+ 'required' => true,
+ ))
+ ->add('send', 'submit', array('label' => 'Enviar' ))
+ ->getForm();
+ }
+
+ /**
+ * Retorna gráfico do tráfego
+ */
+ private function graphTraffic($id, $period = '6hours')
+ {
+ $this->dir = $this->get('kernel')->getRootDir() . "/../web/rrd/";
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ $codInterface = $circuits->getCodeInterface();
+ $typeInterface = $circuits->getTypeInterface();
+ $cirIn = $circuits->getCirIn();
+ $cirOut = $circuits->getCirOut();
+ $serial = $circuits->getSerialBackbone();
+ $name = $circuits->getCodeInterface();
+ $arq = $circuits->getId() . ".rrd";
+
+ if(!$this->rrdExists($arq)){
+ return new Response("
Erro: A Unidade: " . $name . " não esta sendo monitorada. ");
+ }
+
+ $cir = ($cirIn >= $cirOut) ? $cirIn : $cirOut;
+
+ $cirBits = ($cir * 1000);
+
+ $img = $codInterface . "_concentradora_" . $period . "_" . time() . ".png";
+ $scales = $this->scales(1, $period);
+
+ $args = array(
+ 'img' => $img,
+ 'period' => $period,
+ 'scales' => $scales,
+ 'name' => $name,
+ 'arq' => $arq,
+ 'dir' => $this->dir,
+ 'typeInterface' => $typeInterface,
+ 'serial' => $serial,
+ 'cir' => $cir,
+ 'cirBits' => $cirBits,
+ );
+
+ shell_exec($this->getRrdToolGraphCommand($args, true));
+
+ return $img;
+ }
+
+ /**
+ * Retorna gráfico da concentradora
+ */
+ private function graphConcentrator($id, $period = '6hours')
+ {
+ $this->dir = $this->get('kernel')->getRootDir() . "/../web/rrd/";
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ $codInterface = $circuits->getCodeInterface();
+ $typeInterface = $circuits->getTypeInterface();
+ $cirIn = $circuits->getCirIn();
+ $cirOut = $circuits->getCirOut();
+ $serial = $circuits->getSerialBackbone();
+ $name = "Concentradora: " . $serial;
+ $arq = $circuits->getId() . ".rrd";
+
+ if(!$this->rrdExists($arq))
+ {
+ return new Response("Erro: A Unidade: " . $name . " não esta sendo monitorada. ");
+ }
+
+ $cir = ($cirIn >= $cirOut) ? $cirIn : $cirOut;
+
+ $cirBits = ($cir * 1000);
+
+ $img = $codInterface . "_" . $period . "_" . time() . ".png";
+ $scales = $this->scales(1, $period);
+
+ $args = array(
+ 'img' => $img,
+ 'period' => $period,
+ 'scales' => $scales,
+ 'name' => $name,
+ 'arq' => $arq,
+ 'dir' => $this->dir,
+ 'typeInterface' => $typeInterface,
+ 'serial' => $serial,
+ 'cir' => $cir,
+ 'cirBits' => $cirBits,
+ );
+
+ shell_exec($this->getRrdToolGraphCommand($args));
+
+ return $img;
+ }
+
+ /**
+ * Retorna gráfico de confiabilidade
+ */
+ private function graphReliability($id, $period = '6hours')
+ {
+ $this->dir = $this->get('kernel')->getRootDir() . "/../web/rrd/rly/";
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ $scales = $this->scales(2, $period);
+
+ $codInterface = $circuits->getCodeInterface();
+ $typeInterface = $circuits->getTypeInterface();
+ $cirIn = $circuits->getCirIn();
+ $cirOut = $circuits->getCirOut();
+ $serial = $circuits->getSerialBackbone();
+
+ $arq = $codInterface . "_rly.rrd";
+
+ if(!$this->rrdExists($arq))
+ {
+ return new Response("Erro: A Unidade: " . $name . " não esta sendo monitorada. ");
+ }
+
+ if(!preg_match("/Eth/i", $serial))
+ {
+ $img = $codInterface . "_" . $period . "_rly_" . time() . ".png";
+
+ if($typeInterface == "circuito"){
+ $name = "Ponta - " . $serial . " - " . $scales['scale'] . " (" . $scales['media'] . ")";
+ }else{
+ $name = "Concentradora - " . $codInterface . " - " . $circuits->getSerialRouterTip() . " - " .
+ $scales['scale'] . " (" . $scales['media'] . ")";
+ }
+
+ $args = array(
+ 'img' => $img,
+ 'period' => $period,
+ 'scales' => $scales,
+ 'name' => $name,
+ 'arq' => $arq,
+ 'dir' => $this->dir,
+ 'typeInterface' => $typeInterface,
+ 'serial' => $serial,
+ );
+
+ shell_exec($this->getRlyToolGraphCommand($args));
+
+ return $img;
+ }
+ }
+
+ public function rrdExists($arq)
+ {
+ return (!file_exists($this->dir . $arq)) ? false : true;
+ }
+
+ public function scales($type = 1, $period = '6hours')
+ {
+ if($type == 1)
+ {
+ switch (strtolower($period))
+ {
+ case '6hours': $scale = "6 Horas"; $step=60; $media="1 min"; break;
+ case '8hours': $scale = "8 Horas"; $step=60; $media="1 min"; break;
+ case '1day': $scale = "1 Dia"; $step=300; $media="5 min"; break;
+ case '40hours': $scale = "40 Horas"; $step=300; $media="5 min"; break;
+ case '160hours': $scale = "1 Semana"; $step=1200; $media="20 min"; break;
+ case '720hours': $scale = "1 Mes"; $step=5400; $media="90 min"; break;
+ case '4months': $scale = "4 Meses"; $step=21600; $media="360 min"; break;
+ case '1year': $scale = "1 Ano"; $step=86400; $media="1440 min"; break;
+ default: $scale = $period; $media="desconhecido";
+ }
+ }
+ elseif($type == 2)
+ {
+ switch (strtolower($period))
+ {
+ case '6hours': $scale = "6 Horas"; $step=600; $media="10 min"; break;
+ case '8hours': $scale = "8 Horas"; $step=600; $media="10 min"; break;
+ case '1day': $scale = "1 Dia"; $step=600; $media="10 min"; break;
+ case '40hours': $scale = "40 Horas"; $step=600; $media="10 min"; break;
+ case '160hours': $scale = "1 Semana"; $step=1200; $media="20 min"; break;
+ case '720hours': $scale = "1 Mes"; $step=5400; $media="90 min"; break;
+ case '4months': $scale = "4 Meses"; $step=21600; $media="360 min"; break;
+ case '1year': $scale = "1 Ano"; $step=86400; $media="1440 min"; break;
+ default: $scale = $period; $media="desconhecido";
+ }
+ }
+ return array('scale' => $scale, 'step' => $step, 'media' => $media);
+ }
+
+ /**
+ * @Route("/graphdailyperform", name="cocar_graphdailyperform")
+ */
+ public function graphDailyPerfomAction()
+ {
+ $this->dir = $this->get('kernel')->getRootDir() . "/../web/rrd/";
+
+ $em = $this->getDoctrine()->getManager();
+
+ $hoje = date('Y-m-d');
+ $dia_fim = strtotime($hoje) - 86400;
+ $dia_ini = $dia_fim - 2592000;
+ $dia_ini = date('Y-m-d',$dia_ini);
+ $dia_fim = date('Y-m-d',$dia_fim);
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->findAll();
+
+ foreach ($circuits as $cir)
+ {
+ $entityId = $cir->getEntity();
+ $tech = $cir->getTechnology();
+
+ $fields = $em->createQuery(
+ "SELECT d.cirIn, d.cirOut, d.day FROM CocarBundle:DailyPerformance d
+ WHERE (d.day >= :start
+ AND d.day <= :end)
+ AND d.codeInterface = :code"
+ )
+ ->setParameter('start', $dia_ini)
+ ->setParameter('end', $dia_fim)
+ ->setParameter('code', $cir->getId())
+ ->getResult();
+
+ $i = 0;
+
+ if($fields)
+ {
+ foreach ($fields as $field)
+ {
+ if($field['day']->format('d') >= 1)
+ {
+ if (($tech != "ETH") && ($field['cirOut'] < 2000))
+ {
+ $ydata3[$i] = $field['cirIn']; //linhas com o cir
+ $ydata4[$i] = $field['cirOut'];
+ }
+ else
+ {
+ $ydata3[$i] = 0; //linhas com o cir
+ $ydata4[$i] = 0;
+ }
+ $i++;
+ }
+ }
+
+ $this->createGraph(array("volume_in","volume_out","MBytes",1000,"volume","Volume - Ultimos 30 dias"),
+ array($ydata3, $ydata4, $dia_fim, $dia_ini, $cir->getId(), $fields));
+ $this->createGraph(array("cir_in_rec","cir_out_rec","kbps",1,"cir_rec","Taxa = 95% amostras - 30 dias"),
+ array($ydata3, $ydata4, $dia_fim, $dia_ini, $cir->getId(), $fields));
+
+ $this->createGraph2(array("cir_out_rec","7_19_media_out","7_19_pico_out","kbps",1,"out_m95M","SAIDA APS (Ultimos 30 dias) - Media/Taxa95%/Max"),
+ array($ydata3, $ydata4, $dia_fim, $dia_ini, $cir->getId(), $fields));
+
+ $this->createGraph2(array("cir_in_rec","7_19_media_in","7_19_pico_in","kbps",1,"in_m95M", "ENTRADA APS (Ultimos 30 dias) - Media/Taxa95%/Max"),
+ array($ydata3, $ydata4, $dia_fim, $dia_ini, $cir->getId(), $fields));
+
+ $this->createGraphHMM(array("hmm_hour_in", "hmm_hour_out", "HMM"),
+ array($ydata3, $ydata4, $dia_fim, $dia_ini, $cir->getId(), $fields));
+ $this->createGraphHMM(array("hmm_hour_in_per", "hmm_hour_out_per", "HMMper"),
+ array($ydata3, $ydata4, $dia_fim, $dia_ini, $cir->getId(), $fields));
+ }
+ }
+
+ return new Response();
+ }
+
+ /**
+ * @Route("/graphmonthlyperform", name="cocar_graph_monthlyperform")
+ */
+ public function graphMonthlyPerfomAction()
+ {
+ $this->dir = $this->get('kernel')->getRootDir() . "/../web/rrd/";
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->findAll();
+
+ $mes_atual = date('Y-m-01');
+ $mes_ini = mktime (0, 0, 0, date("m")-7, date("d"), date("Y"));
+ $mes_ini = date('Y-m-01', $mes_ini);
+
+ foreach ($circuits as $cir)
+ {
+ $this->createGraphMonthly(array("volume_in","volume_out","GBytes",1,"volume","Volume Mensal"),
+ array($cir->getId(), $mes_atual, $mes_ini));
+ $this->createGraphMonthly(array("cir_in_rec","cir_out_rec","kbps",1,"cir_rec","Taxa = 95% amostras Mensal"),
+ array($cir->getId(), $mes_atual, $mes_ini));
+ }
+
+ return new Response();
+ }
+
+ public function createGraph($params = array(), $params2 = array())
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ list($param1, $param2, $y_eixo, $k, $nome, $tipo) = $params;
+ list($ydata3, $ydata4, $dia_fim, $dia_ini, $code, $circuit) = $params2;
+
+ $fields = $em->createQuery(
+ "SELECT d.volumeIn, d.volumeOut, d.cirInRec, d.cirOutRec, d.day FROM CocarBundle:DailyPerformance d
+ WHERE (d.day >= :start
+ AND d.day <= :end)
+ AND d.codeInterface = :code"
+ )
+ ->setParameter('start', $dia_ini)
+ ->setParameter('end', $dia_fim)
+ ->setParameter('code', $code)
+ ->getResult();
+
+ foreach ($fields as $f)
+ {
+ $p1 = ($param1 == 'volume_in') ? $f['volumeIn'] : $f['cirInRec'];
+ $p2 = ($param2 == 'volume_out') ? $f['volumeOut'] : $f['cirOutRec'];
+
+ $data1y[] = $p1/$k;
+ $data2y[] = $p2/$k;
+
+ $a[] = $f['day']->format('d/m');
+ }
+
+ if(isset($data1y))
+ {
+ // Create the graph. These two calls are always required
+ $graph = new \Graph(580, 280, "auto");
+ $graph->SetScale("textlin");
+ $graph->img->SetMargin(60, 10, 5, 60);
+
+ // Create the bar plots
+ $b1plot = new \BarPlot($data1y);
+ $b1plot->SetFillColor("green:0.8");
+ $b1plot->SetWeight(0);
+
+ $b2plot = new \BarPlot($data2y);
+ $b2plot->SetFillColor("blue");
+ $b2plot->SetWeight(0);
+
+ $graph->title->Set("$tipo");
+ $graph->yaxis->title->Set($y_eixo);
+
+ $graph->title->SetFont(FF_FONT1, FS_BOLD);
+ $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
+ $graph->xaxis->SetTickLabels($a);
+ $graph->xaxis->SetLabelAngle(90);
+
+ if ($tipo == "Taxa = 95% amostras - 30 dias"){
+ //acrescenta linhas de cir
+ $lineplot3 = new \LinePlot($ydata3);
+ $lineplot4 = new \LinePlot($ydata4);
+
+ $graph->Add($lineplot4);
+ $graph->Add($lineplot3);
+
+ $lineplot3->SetColor("green:0.8");
+ $lineplot3->SetWeight(1);
+
+ $lineplot4->SetColor("blue");
+ $lineplot4->SetWeight(1);
+ }
+
+ // Set the legends for the plots
+ $b1plot->SetLegend("APS>");
+ $b2plot->SetLegend(">APS");
+
+ // Adjust the legend position
+ $graph->legend->SetLayout(LEGEND_HOR);
+ $graph->legend->Pos(0.02, 0.07, "right", "center");
+ $graph->legend->SetFrameWeight(0);
+ $graph->legend->SetShadow(0);
+
+ // Create the grouped bar plot
+ $gbplot = new \GroupBarPlot(array($b1plot,$b2plot));
+
+ // ...and add it to the graPH
+ $graph->Add($gbplot);
+
+ //Display the graph
+ $graph->SetFrame(false);
+
+ $nome_graf = $this->dir."graficos/daily/".$code."_".$nome.".png";
+ $graph->Stroke($nome_graf);
+ }
+ }
+
+ public function createGraph2($params = array(), $params2 = array())
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ list($param1, $param2, $param3, $y_eixo, $k, $nome, $tipo) = $params;
+ list($ydata3, $ydata4, $dia_fim, $dia_ini, $code, $circuit) = $params2;
+
+ $fields = $em->createQuery(
+ "SELECT d._719MediaOut, d._719MediaIn, d._719PeakOut, d._719PeakIn,
+ d.cirInRec, d.cirOutRec, d.day FROM CocarBundle:DailyPerformance d
+ WHERE (d.day >= :start
+ AND d.day <= :end)
+ AND d.codeInterface = :code"
+ )
+ ->setParameter('start', $dia_ini)
+ ->setParameter('end', $dia_fim)
+ ->setParameter('code', $code)
+ ->getResult();
+
+ $i = 0;
+ foreach ($fields as $f)
+ {
+ $p1 = ($param1 == 'cir_out_rec') ? $f['cirOutRec'] : $f['cirInRec'];
+ $p2 = ($param2 == '7_19_media_out') ? $f['_719MediaOut'] : $f['_719MediaIn'];
+ $p3 = ($param3 == '7_19_pico_out') ? $f['_719PeakOut'] : $f['_719PeakIn'];
+
+ $ydata = ($param1 == 'cir_out_rec') ? $ydata4[$i] : $ydata3[$i];
+ $datay[] = $ydata/20 + $p1/$k;
+ $datay[] = $p1/$k;
+ $datay[] = $p2/$k;
+ $datay[] = $p3/$k;
+
+ $a[] = $f['day']->format('d/m');
+ $i++;
+ }
+
+ // Create the graph. These two calls are always required
+ $graph = new \Graph(580, 280, "auto");
+ $graph->SetScale("textlin");
+ $graph->img->SetMargin(60, 10, 5, 60);
+
+ // Create the bar plots
+ $b1plot = new \StockPlot($datay);
+
+ $b1plot->SetWidth(9);
+
+ $graph->title->Set("$tipo");
+ $graph->yaxis->title->Set($y_eixo);
+
+ $graph->title->SetFont(FF_FONT1, FS_BOLD);
+ $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
+ $graph->xaxis->SetTickLabels($a);
+ $graph->xaxis->SetLabelAngle(90);
+
+ //acrescenta linhas de cir
+ $lineplot3 = new \LinePlot($ydata3);
+ $lineplot4 = new \LinePlot($ydata4);
+
+ $lineplot3->SetColor("red");
+ $lineplot3->SetWeight(1);
+
+ $lineplot4->SetColor("red");
+ $lineplot4->SetWeight(1);
+
+ if ($tipo == "ENTRADA APS (últimos 30 dias) - Média/Taxa95%/Máx") {
+ $graph->Add($lineplot4);
+ }else{
+ $graph->Add($lineplot3);
+ }
+
+ $b1plot->SetWeight(2);
+ $b1plot->SetColor('blue','blue','orange','red');
+
+ // ...and add it to the graPH
+ $graph->Add($b1plot);
+
+ //Display the graph
+ $graph->SetFrame(false);
+
+ $nome_graf = $this->dir."graficos/daily/".$code."_".$nome.".png";
+ $graph->Stroke($nome_graf);
+ }
+
+ public function createGraphHMM($params = array(), $params2 = array())
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ list($param1, $param2, $nome) = $params;
+ list($ydata3, $ydata4, $dia_fim, $dia_ini, $code, $circuit) = $params2;
+
+ $fields = $em->createQuery(
+ "SELECT d.hmmHourIn, d.hmmHourOut, d.hmmHourInPer, d.hmmHourOutPer, d.day FROM CocarBundle:DailyPerformance d
+ WHERE (d.day >= :start
+ AND d.day <= :end)
+ AND d.codeInterface = :code"
+ )
+ ->setParameter('start', $dia_ini)
+ ->setParameter('end', $dia_fim)
+ ->setParameter('code', $code)
+ ->getResult();
+
+ foreach ($fields as $f)
+ {
+ $p1 = ($param1 == 'hmm_hour_in') ? $f['hmmHourIn'] : $f['hmmHourOut'];
+ $p2 = ($param2 == 'hmm_hour_in_per') ? $f['hmmHourInPer'] : $f['hmmHourOutPer'];
+
+ $ydata[] = $p1->format('H');
+ $ydata2[] = $p2->format('H');
+ $a[] = $f['day']->format('d/m');
+ }
+
+ // Create the graph. These two calls are always required
+ $graph = new \Graph(580, 280, "auto");
+ $graph->SetScale("textlin");
+ $graph->img->SetMargin(60, 10, 5, 60);
+
+ $lineplot = new \LinePlot($ydata);
+ $lineplot2 = new \LinePlot($ydata2);
+
+ // Adiciona a linha ao grafico
+ $graph->Add($lineplot);
+ $graph->Add($lineplot2);
+
+ $graph->title->SetFont(FF_FONT1, FS_BOLD);
+ $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
+ $graph->yaxis->title->Set("hora");
+ $graph->xaxis->SetTickLabels($a);
+ $graph->xaxis->SetLabelAngle(90);
+
+ $lineplot->SetColor("green:0.8");
+ $lineplot->SetWeight(1);
+ $lineplot->mark->SetType(MARK_SQUARE);
+
+ $lineplot2->SetColor("blue");
+ $lineplot2->SetWeight(1);
+ $lineplot2->mark->SetType(MARK_SQUARE);
+ $lineplot->mark->SetFillColor("green");
+
+ $graph->title->Set("Horario inicial da HMM");
+
+ // Set the legends for the plots
+ $lineplot->SetLegend("->APS");
+ $lineplot2->SetLegend("APS->");
+
+ // Adjust the legend position
+ $graph->legend->SetLayout(LEGEND_HOR);
+ $graph->legend->Pos(0.02,0.06,"right","center");
+ $graph->legend->SetFrameWeight(0);
+ $graph->legend->SetShadow(0);
+
+ //grava figura
+ $graph->SetFrame(false);
+ $nome_graf = $this->dir."graficos/daily/".$code."_".$nome.".png";
+ $graph->Stroke($nome_graf);
+ }
+
+ public function createGraphMonthly($params = array(), $params2 = array())
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ list($param1, $param2, $y_eixo, $k, $nome, $tipo) = $params;
+ list($code, $mes_atual, $mes_ini) = $params2;
+
+ $fields = $em->createQuery(
+ "SELECT d.volumeIn, d.volumeOut, d.cirIn, d.cirOut, d.cirInRec, d.cirOutRec, d.date FROM CocarBundle:MonthlyPerformance d
+ WHERE (d.codeInterface = :code
+ AND d.date < :currentMonth AND d.date > :startDate) ORDER BY d.date ASC"
+ )
+ ->setParameter('code', $code)
+ ->setParameter('currentMonth', $mes_atual)
+ ->setParameter('startDate', $mes_ini)
+ ->getResult();
+
+ foreach ($fields as $f)
+ {
+ $p1 = ($param1 == 'volume_in') ? $f['volumeIn'] : $f['cirInRec'];
+ $p2 = ($param2 == 'volume_out') ? $f['volumeOut'] : $f['cirOutRec'];
+
+ $data1y[] = $p1/$k;
+ $data2y[] = $p2/$k;
+
+ $ydata3[] = $f['cirIn'];
+ $ydata4[] = $f['cirOut'];
+
+ $a[] = $f['date']->format('m/Y');
+ }
+
+ if(isset($data1y))
+ {
+ // Create the graph. These two calls are always required
+ $graph = new \Graph(580, 280, "auto");
+ $graph->SetScale("textlin");
+ $graph->img->SetMargin(60, 10, 5, 60);
+
+ // Create the bar plots
+ $b1plot = new \BarPlot($data1y);
+ $b1plot->SetFillColor("green:0.8");
+ $b1plot->SetWeight(0);
+
+ $b2plot = new \BarPlot($data2y);
+ $b2plot->SetFillColor("blue");
+ $b2plot->SetWeight(0);
+
+ $graph->title->Set("$tipo");
+ $graph->yaxis->title->Set($y_eixo);
+
+ $graph->title->SetFont(FF_FONT1, FS_BOLD);
+ $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
+ $graph->xaxis->SetTickLabels($a);
+ $graph->xaxis->SetLabelAngle(90);
+
+ // Set the legends for the plots
+ $b1plot->SetLegend("APS>");
+ $b2plot->SetLegend(">APS");
+
+ // Adjust the legend position
+ $graph->legend->SetLayout(LEGEND_HOR);
+ $graph->legend->Pos(0.01,0.1,"right","center");
+ $graph->legend->SetFrameWeight(0);
+ $graph->legend->SetShadow(0);
+
+ // Create the grouped bar plot
+ $gbplot = new \GroupBarPlot(array($b1plot,$b2plot));
+
+ // ...and add it to the graPH
+ $graph->Add($gbplot);
+
+ if ($tipo == "CIR Mensal recomendado"){
+ //apanha o cir in e cir out
+ $lineplot3 = new \LinePlot($ydata3);
+ $lineplot4 = new \LinePlot($ydata4);
+ $graph->Add($lineplot4);
+ $graph->Add($lineplot3);
+ $lineplot3->SetColor("green:0.8");
+ $lineplot3->SetWeight(1);
+ $lineplot4->SetColor("blue");
+ $lineplot4->SetWeight(1);
+ }
+
+ //Display the graph
+ $graph->SetFrame(false);
+
+ $nome_graf = $this->dir."graficos/monthly/".$code."_".$nome.".png";
+ $graph->Stroke($nome_graf);
+ }
+ }
+
+ public function getRrdToolGraphCommand($args = array(), $hrule = false)
+ {
+ extract($args, EXTR_PREFIX_SAME, "wddx");
+
+ $com = "rrdtool graph $this->dir" . "graficos/" . $img .
+ " --start -". $period . " --end now --step ". $scales['step'] .
+ " --title='" . $name . " - " . $scales['scale'] . " (" . $scales['media'] . ")' ".
+ "--vertical-label 'Trafego em Bits/s' " .
+ "--width 480 --height 162 " .
+ "DEF:in=" . $this->dir . $arq . ":ds0:AVERAGE " .
+ "DEF:out=" . $this->dir . $arq . ":ds1:AVERAGE " .
+ "CDEF:bitIn=in,8,* " .
+ "CDEF:bitOut=out,8,* " .
+ "COMMENT:' ' ";
+
+ if($hrule)
+ {
+ if($typeInterface == "circuito" && !preg_match("/ETH/i", $serial))
+ {
+ $com .= "HRULE:$cirBits#FF0000:'CIR = $cir ' " .
+ "COMMENT:'\\n' " .
+ "COMMENT:' ' ";
+ }
+ }
+
+ $com .= "COMMENT:' ' ".
+ "AREA:bitIn#00CC00:'Entrada ' " .
+ "LINE1:bitOut#0000FF:'Saida ' " .
+ "COMMENT:'\\n' ".
+ "COMMENT:' ' ".
+ "GPRINT:bitIn:MAX:'Maximo\\:%14.1lf %sbit/s' ".
+ "GPRINT:bitOut:MAX:'%11.1lf %sbit/s' ".
+ "COMMENT:'\\n' ".
+ "COMMENT:' ' ".
+ "GPRINT:bitIn:AVERAGE:'Media\\:%15.1lf %sbit/s' ".
+ "GPRINT:bitOut:AVERAGE:'%11.1lf %sbit/s' ".
+ "COMMENT:'\\n' ".
+ "COMMENT:' ' ".
+ "GPRINT:bitIn:LAST:'Ultima\\:%14.1lf %sbit/s' " .
+ "GPRINT:bitOut:LAST:'%11.1lf %sbit/s' ";
+
+ return $com;
+ }
+
+ private function getRlyToolGraphCommand($args = array())
+ {
+ extract($args, EXTR_PREFIX_SAME, "wddx");
+
+ $com = "rrdtool graph $this->dir" . "../graficos/". $img .
+ " --start -". $period . " --end now --step ". $scales['step'] .
+ " --title='" . $name . "' ".
+ "--vertical-label 'Confiabilidade' -w 480 -h 162 " .
+ "DEF:myrly=" . $this->dir . $arq . ":rly:AVERAGE " .
+ "CDEF:valor=myrly " .
+ "CDEF:ideal=valor,255,EQ,valor,0,IF " .
+ "CDEF:baixo=valor,255,EQ,0,valor,IF " .
+ "HRULE:255#0000FF:'Valor Ideal = 255 ' " .
+ "AREA:ideal#80FF80:'Normal ' " .
+ "AREA:baixo#FE3C36:'Critico\\c' " .
+ "COMMENT:'\\n' ".
+ "COMMENT:' ' ".
+ "GPRINT:valor:MIN:'Valor Minimo = %10.0lf' " .
+ "COMMENT:'\\n' ".
+ "COMMENT:' ' ".
+ "GPRINT:valor:LAST:'Ultimo Valor = %10.0lf' ";
+
+ return $com;
+ }
+
+ /**
+ * @Route("/report/{id}", name="cocar_report")
+ * @Template()
+ */
+ public function reportAction($id)
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $circuit = $em->getRepository('CocarBundle:Circuits')->findByEntity($id);
+
+ $form = $this->reportForm($id);
+
+ return array('circuit' => $circuit, 'form' => $form->createView());
+ }
+
+ /**
+ * @Route("/reportshow", name="cocar_reportshow")
+ * @Method("POST")
+ */
+ public function reportShowAction(Request $request)
+ {
+ $form = $this->reportForm($request->request->get('entity'));
+ $form->submit($request);
+
+ if ($form->isValid())
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $data = $form->getData();
+
+ $circuit = $em->getRepository('CocarBundle:Circuits')->findByEntity($data['entity']);
+
+ switch ($data['type']) {
+ case 'taxa':
+ $name = $request->request->get('circuit') . "_cir_rec.png";
+ $img[] = "monthly/" . $name;
+ $img[] = "daily/" . $name;
+ $type = "Taxa = 95% amostras";
+ break;
+ case 'volume':
+ $name = $request->request->get('circuit') . "_volume.png";
+ $img[] = "monthly/" . $name;
+ $img[] = "daily/" . $name;
+ $type = "Volume";
+ break;
+ case 'hmm_day':
+ $name = $request->request->get('circuit') . "_HMM.png";
+ $img[] = "daily/" . $name;
+ $type = "HMM do dia";
+ break;
+ case 'hmm_per':
+ $name = $request->request->get('circuit') . "_HMMper.png";
+ $img[] = "daily/" . $name;
+ $type = "HMM do período";
+ break;
+ case 'med_in':
+ $name = $request->request->get('circuit') . "_in_m95M.png";
+ $img[] = "daily/" . $name;
+ $type = "Med 95% Max - Entrada";
+ break;
+ case 'med_out':
+ $name = $request->request->get('circuit') . "_out_m95M.png";
+ $img[] = "daily/" . $name;
+ $type = "Med 95% Max - Saida";
+ break;
+
+ default:
+ $img[] = array();
+ break;
+ }
+ }
+
+ return $this->render('CocarBundle:Graph:report.html.twig',
+ array('form' => $form->createView(), 'circuit' => $circuit,
+ 'img' => $img, 'type' => $type, 'id' => $request->request->get('circuit')));
+ }
+
+ /**
+ * @param mixed $id the circuit id
+ *
+ * @return \Symfony\Component\Form\Form the form
+ */
+ private function reportForm($id)
+ {
+ return $this->createFormBuilder()
+ ->add('type', 'choice', array(
+ 'choices' => array(
+ 'taxa' => 'Taxa = 95% amostras',
+ 'volume' => 'Volume',
+ 'hmm_day' => 'HMM do dia',
+ 'hmm_per' => 'HMM do período',
+ 'med_in' => 'Med 95% Max - Entrada',
+ 'med_out' => 'Med 95% Max - Saida',
+ ),
+ 'required' => true,
+ ))
+ ->add('entity', 'hidden', array(
+ 'data' => $id
+ ))
+ ->add('send', 'submit', array('label' => 'Enviar' ))
+ ->getForm();
+ }
+
+ /**
+ * Retorna gráfico do tráfego das máquinas
+ */
+ private function graphMachine($id, $period = '6hours')
+ {
+ $this->dir = $this->get('kernel')->getRootDir() . "/../web/rrd/machine/" . $id . "/";
+
+ if(is_dir($this->dir))
+ {
+ if(!is_dir($this->dir . "graficos/"))
+ mkdir($this->dir . "graficos/");
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->find($id);
+
+ $machines = $em->createQuery(
+ "SELECT DISTINCT m.macAddress, m.ip FROM CocarBundle:Machine m
+ WHERE m.gateway = :gateway
+ GROUP BY m.macAddress, m.ip, m.id"
+ )
+ ->setParameter('gateway', $id)
+ ->getResult();
+
+ $img = array();
+
+ foreach ($machines as $machine)
+ {
+ $typeInterface = $circuits->getTypeInterface();
+ $cirIn = $circuits->getCirIn();
+ $cirOut = $circuits->getCirOut();
+ $serial = $circuits->getSerialBackbone();
+
+ $ip = $machine['ip'];
+ $mcAddr = $machine['macAddress'];
+
+ $name = $circuits->getCodeInterface() . " ($ip) - $mcAddr";
+ $arq = str_replace(":", "", $mcAddr . ".rrd");
+
+ if(!$this->rrdExists($arq)){
+ return new Response("Erro: A Unidade: " . $name . " não esta sendo monitorada. ");
+ }
+
+ $cir = ($cirIn >= $cirOut) ? $cirIn : $cirOut;
+
+ $cirBits = ($cir * 1000);
+
+ $image = str_replace(":", "", $mcAddr) . "_concentradora_" . $period . "_" . time() . ".png";
+ $scales = $this->scales(1, $period);
+
+ $args = array(
+ 'img' => $image,
+ 'period' => $period,
+ 'scales' => $scales,
+ 'name' => $name,
+ 'arq' => $arq,
+ 'dir' => $this->dir,
+ 'typeInterface' => $typeInterface,
+ 'serial' => $serial,
+ 'cir' => $cir,
+ 'cirBits' => $cirBits,
+ );
+
+ shell_exec($this->getRrdToolGraphCommand($args, true));
+
+ $img[] = "../machine/$id/graficos/$image";
+ }
+
+ return $img;
+ }
+ else
+ {
+ return new Response("Não existem máquinas cadastradas para esse circuito! ");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Controller/MonitorController.php b/Controller/MonitorController.php
new file mode 100755
index 0000000..d0778fd
--- /dev/null
+++ b/Controller/MonitorController.php
@@ -0,0 +1,96 @@
+dir = $this->get('kernel')->getRootDir() . "/../web/rrd/";
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->findAll();
+
+ foreach($circuits as $cir)
+ {
+ try
+ {
+ $id = $cir->getId();
+ $community = $cir->getCommunitySnmpBackbone();
+ $host = $cir->getIpBackbone();
+ $codInterface = $cir->getCodeInterface();
+ $numInterface = $cir->getNumSnmpInterface();
+
+ $com = "snmpget -Ov -t 1 -r 1 -c $community -v 1 $host .1.3.6.1.2.1.2.2.1.10.$numInterface .1.3.6.1.2.1.2.2.1.16.$numInterface";
+
+ if($outPut = shell_exec($com))
+ {
+ list($in, $out) = explode("\n", shell_exec($com));
+
+ $inOctets = $this->snmp($in);
+ $outOctets = $this->snmp($out);
+
+ if($inOctets || $outOctets)
+ {
+ $arqRrd = $this->dir . $id . '.rrd';
+
+ if (!file_exists($arqRrd))
+ $this->createRrd($arqRrd);
+ $this->updateRrd($arqRrd, $inOctets , $outOctets);
+ }
+ }
+ }
+ catch(Exception $e)
+ {
+ return new Response($e->getMessage());
+ }
+ }
+ return new Response();
+ }
+
+ public function createRrd($arqRrd)
+ {
+ $create = "rrdtool create $arqRrd --step 60 " .
+ "DS:ds0:COUNTER:120:0:125000000 " .
+ "DS:ds1:COUNTER:120:0:125000000 " .
+ "RRA:AVERAGE:0.5:1:4320 " .
+ "RRA:AVERAGE:0.5:5:2016 " .
+ "RRA:AVERAGE:0.5:20:2232 " .
+ "RRA:AVERAGE:0.5:90:2976 " .
+ "RRA:AVERAGE:0.5:360:1460 " .
+ "RRA:AVERAGE:0.5:1440:730 " .
+ "RRA:MAX:0.5:1:4320 " .
+ "RRA:MAX:0.5:5:2016 " .
+ "RRA:MAX:0.5:20:2232 " .
+ "RRA:MAX:0.5:90:2976 " .
+ "RRA:MAX:0.5:360:1460 " .
+ "RRA:MAX:0.5:1440:730";
+ shell_exec($create);
+ }
+
+ public function snmp($resp)
+ {
+ $resp = strstr($resp, ':');
+ $resp = str_replace(":", "", $resp);
+ return (trim($resp));
+ }
+
+ public function updateRrd($arqRrd, $in, $out, $date = null)
+ {
+ $date = empty($date) ? date('U') : $date;
+ shell_exec("rrdtool update $arqRrd $date:$in:$out");
+ }
+}
\ No newline at end of file
diff --git a/Controller/MonthlyPerformController.php b/Controller/MonthlyPerformController.php
new file mode 100755
index 0000000..7b9d621
--- /dev/null
+++ b/Controller/MonthlyPerformController.php
@@ -0,0 +1,166 @@
+getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->findAll();
+
+ foreach($circuits as $cir)
+ {
+ for ($mes=1;$mes<=12;$mes++)
+ {
+ //Período a ser gerado na tabela
+ $uso_20_50_in = 0;
+ $uso_50_85_in = 0;
+ $uso_m_85_in = 0;
+ $uso_20_50_out = 0;
+ $uso_50_85_out = 0;
+ $uso_m_85_out = 0;
+ $ocorrencias = 0;
+ $volume_mensal_out = 0;
+ $volume_mensal_in = 0;
+
+ unset($c_out_rec);
+ unset($c_in_rec);
+
+ $ano = date('Y');
+ $mes = ($mes < 10) ? "0".$mes : $mes;
+ $mes_ano = $ano."-".$mes."-01";
+ $ldia = date("t", mktime(0,0,0,$mes,'01',$ano));
+
+ $daily = $em->createQuery(
+ "SELECT d FROM CocarBundle:DailyPerformance d
+ WHERE d.codeInterface = :code
+ AND (d.day >= :startDate AND d.day <= :endDate)"
+ )
+ ->setParameter('code', $cir->getId())
+ ->setParameter('startDate', $mes_ano." 00:00:00")
+ ->setParameter('endDate', $ano."-".$mes."-".$ldia." 23:59:59")
+ ->getResult();
+
+ foreach($daily as $d)
+ {
+ //volume mensal
+ $volume_mensal_out += $d->getVolumeOut();
+ $volume_mensal_in += $d->getVolumeIn();
+
+ //cir mensal recomendado - separa valores
+ if(isset($c_out_rec[$d->getCirOutRec()]))
+ {
+ $c_out_rec[$d->getCirOutRec()]++;
+ $c_in_rec[$d->getCirInRec()]++;
+ }
+ else
+ {
+ $c_out_rec[$d->getCirOutRec()] = 1;
+ $c_in_rec[$d->getCirInRec()] = 1;
+ }
+
+ $c_out = $d->getCirOut();
+ $c_in = $d->getCirIn();
+
+ //criticidade mensal - separa valores
+ $ocorrencias++;
+
+ $criticidade_out = $d->get719CriticalityOut();
+ $criticidade_in = $d->get719CriticalityIn();
+
+ if (($criticidade_out >= 20) && ($criticidade_out < 50))
+ {
+ $uso_20_50_out++;
+ }elseif(($criticidade_out >= 50) && ($criticidade_out < 85))
+ {
+ $uso_50_85_out++;
+ }elseif ($criticidade_out >= 85)
+ {
+ $uso_m_85_out++;
+ }
+ if(($criticidade_in >= 20) && ($criticidade_in < 50))
+ {
+ $uso_20_50_in++;
+ }elseif (($criticidade_in >= 50) && ($criticidade_in < 85))
+ {
+ $uso_50_85_in++;
+ }elseif ($criticidade_in >= 85)
+ {
+ $uso_m_85_in++;
+ }
+
+ //criticidade mensal - em %
+ $uso_20_50_in = 100 * $uso_20_50_in/$ocorrencias;
+ $uso_50_85_in = 100 * $uso_50_85_in/$ocorrencias;
+ $uso_m_85_in = 100 * $uso_m_85_in/$ocorrencias;
+ $uso_20_50_out = 100 * $uso_20_50_out/$ocorrencias;
+ $uso_50_85_out = 100 * $uso_50_85_out/$ocorrencias;
+ $uso_m_85_out = 100 * $uso_m_85_out/$ocorrencias;
+ }
+
+ if(isset($c_in_rec))
+ {
+ //cir mensal recomendado - apanha valor
+ krsort($c_in_rec);
+ $cir_in_rec_m = key($c_in_rec);
+ if ($c_in_rec[$cir_in_rec_m] < 2)
+ {
+ next($c_in_rec);
+ $cir_in_rec_m = key($c_in_rec);
+ }
+ }
+
+ if(isset($c_out_rec))
+ {
+ krsort($c_out_rec);
+ $cir_out_rec_m = key($c_out_rec);
+ if ($c_out_rec[$cir_out_rec_m] < 2)
+ {
+ next ($c_out_rec);
+ $cir_out_rec_m = key ($c_out_rec);
+ }
+ }
+
+ //volume mensal em Gigabytes
+ $volume_mensal_out /= 1000000;
+ $volume_mensal_in /= 1000000;
+
+ $mPerform = new MonthlyPerformance();
+
+ $mPerform->setDate(new \DateTime($mes_ano));
+ $mPerform->setCodeInterface($cir->getId());
+ $mPerform->setUse2050In(isset($uso_20_50_in) ? $uso_20_50_in : 0);
+ $mPerform->setUse2050Out(isset($uso_20_50_out) ? $uso_20_50_out : 0);
+ $mPerform->setUse5085In(isset($uso_50_85_in) ? $uso_50_85_in : 0);
+ $mPerform->setUse5085Out(isset($uso_50_85_out) ? $uso_50_85_out : 0);
+ $mPerform->setUseM85In(isset($uso_m_85_in) ? $uso_m_85_in : 0);
+ $mPerform->setUseM85Out(isset($uso_m_85_out) ? $uso_m_85_out : 0);
+ $mPerform->setVolumeIn(isset($volume_mensal_in) ? $volume_mensal_in : 0);
+ $mPerform->setVolumeOut(isset($volume_mensal_out) ? $volume_mensal_out : 0);
+ $mPerform->setCirIn(isset($c_in) ? $c_in : 0);
+ $mPerform->setCirOut(isset($c_out) ? $c_out : 0);
+ $mPerform->setCirInRec(isset($cir_in_rec_m) ? $cir_in_rec_m : 0);
+ $mPerform->setCirOutRec(isset($cir_out_rec_m) ? $cir_out_rec_m : 0);
+
+ $em->persist($mPerform);
+ $em->flush();
+ }
+ }
+
+ return new Response();
+ }
+}
\ No newline at end of file
diff --git a/Controller/ReliabilityController.php b/Controller/ReliabilityController.php
new file mode 100755
index 0000000..a8cd3ab
--- /dev/null
+++ b/Controller/ReliabilityController.php
@@ -0,0 +1,85 @@
+dir = $this->get('kernel')->getRootDir() . "/../web/rrd/rly/";
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->findAll();
+
+ foreach($circuits as $cir)
+ {
+ $codInterface = $cir->getCodeInterface();
+ $hostTip = $cir->getIpSerialRouterTip();
+ $communityTip = $cir->getCommunitySnmpRouterTip();
+ $snmpPortTip = $cir->getSnmpPortTip();
+
+ $com = "snmpget -Ov -t 1 -r 1 -c $communityTip -v 1 $hostTip .1.3.6.1.4.1.9.2.2.1.1.22.$snmpPortTip 2> /dev/null";
+
+ $rly = $this->get('cocar_monitor')->snmp(shell_exec($com));
+
+ $rly = (!$rly) ? 0 : $rly;
+
+ $date = ((int)(date('U')/600))*600;
+
+ $reliability->setCodeInterface($codInterface);
+ $reliability->setDate($date);
+ $reliability->setRly($rly);
+
+ $em->persist($reliability);
+ $em->flush();
+
+ $arqRrd = $this->dir . $codInterface . "_rly.rrd";
+
+ if (!file_exists($arqRrd))
+ $this->createRrdRly($arqRrd);
+
+ $this->updateRrdRly($arqRrd, $date, $rly);
+ }
+ return new Response();
+ }
+
+ public function createRrdRly($arqRrd)
+ {
+ $com = "rrdtool create " . $arqRrd . " --step 600 " .
+ "DS:rly:GAUGE:1200:0:256 " .
+ "RRA:AVERAGE:0.5:1:480 " .
+ "RRA:AVERAGE:0.5:2:510 " .
+ "RRA:AVERAGE:0.5:9:500 " .
+ "RRA:AVERAGE:0.5:36:500 " .
+ "RRA:AVERAGE:0.5:144:370 " .
+ "RRA:MIN:0.5:1:480 " .
+ "RRA:MIN:0.5:2:510 " .
+ "RRA:MIN:0.5:9:500 " .
+ "RRA:MIN:0.5:36:500 " .
+ "RRA:MIN:0.5:144:370";
+
+ shell_exec($com);
+ }
+
+ public function updateRrdRly($arqRrd, $date, $rly)
+ {
+ shell_exec("rrdtool update $arqRrd $date:$rly");
+ }
+}
\ No newline at end of file
diff --git a/Controller/RestController.php b/Controller/RestController.php
new file mode 100755
index 0000000..d3b546d
--- /dev/null
+++ b/Controller/RestController.php
@@ -0,0 +1,124 @@
+getDoctrine()->getManager();
+ $dir = $this->get('kernel')->getRootDir() . "/../web/rrd/machine/";
+
+ foreach ($_FILES as $file)
+ {
+ try
+ {
+ $machine = new \Cocar\CocarBundle\Entity\Machine;
+
+ $file = new \Symfony\Component\HttpFoundation\File\UploadedFile(
+ $file['tmp_name'],
+ $file['name'],
+ $file['type'],
+ $file['size'],
+ $file['error']);
+
+ $machine->setFile($file);
+ $machine->preUpload();
+ $machine->upload();
+
+ $content = simplexml_load_file($machine->getAbsolutePath());
+
+ if(isset($content->machine["gateway"]) && isset($content->machine->macaddress))
+ {
+ $circuit = $em->getRepository('CocarBundle:Circuits')->findByIpBackbone($content->machine["gateway"]);
+
+ foreach ($circuit as $c)
+ {
+ $id = $c->getId();
+ $circuit = $em->getRepository('CocarBundle:Circuits')->find($id);
+ }
+
+ $machine->setGateway($circuit);
+ $machine->setIp($content->machine->ip);
+ $machine->setMacAddress($content->machine->macaddress);
+
+ $em->persist($machine);
+ $em->flush();
+
+ $dir .= $id . "/";
+
+ if(!is_dir($dir))
+ mkdir($dir);
+
+ $file = $dir . str_replace(":", "", $content->machine->macaddress) . '.rrd';
+
+ if (!file_exists($file))
+ $this->get('cocar_monitor')->createRrd($file);
+
+ foreach ($content->snmp->period as $value)
+ {
+ $this->get('cocar_monitor')->updateRrd($file, $value->in,
+ $value->out, $value['date']);
+ }
+
+ } else {
+ return new Response("Error in XML format");
+ }
+
+ } catch(\Exception $e) {
+ return new Response ($e->getMessage());
+ return new Response($this->get('jms_serializer')->serialize(array('result' => 'error'), 'json'));
+ }
+ }
+
+ return new Response($this->get('jms_serializer')->serialize(array('result' => 'success'), 'json'));
+ }
+
+ /**
+ * GET Route annotation.
+ * @Rest\Get("/snmp/{slug}")
+ */
+ public function getSnmpAction($slug)
+ {
+ $entity = array('campo' => 'conteudo', 'campo2' => array('campo3' => 'conteudo2'));
+
+ $context = new SerializationContext();
+
+ $serializer = $this->get('jms_serializer');
+
+ $response = new Response($serializer->serialize($entity, 'json', $context));
+ $response->headers->set('Content-Type', 'application/json');
+
+ return $response;
+ }
+
+ /**
+ * GET Route annotation.
+ * @Rest\Put("/snmp/{slug}")
+ */
+ public function putSnmpAction($slug)
+ {
+
+ }
+
+ /**
+ * GET Route annotation.
+ * @Rest\Delete("/snmp/{slug}")
+ */
+ public function deleteSnmpAction($slug)
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/Controller/RrdLogController.php b/Controller/RrdLogController.php
new file mode 100755
index 0000000..3cd2987
--- /dev/null
+++ b/Controller/RrdLogController.php
@@ -0,0 +1,81 @@
+dir = $this->get('kernel')->getRootDir() . "/../web/rrd/";
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->findAll();
+
+ foreach($circuits as $cir)
+ {
+ $rrd = $cir->getId() . ".rrd";
+ $arq = $this->dir . $rrd;
+
+ if(file_exists($arq))
+ {
+ $end = (date('U')) - 120;
+ $start = $end - 86400;
+
+ $com = "rrdtool fetch $arq AVERAGE --start $start --end $end | sed -e \"s/ds[01]//g\" |
+ sed \"s/nan/0/g\" | tr \":\" \" \" | tr -s \" \" | sed -e \"s/ \$//\" | grep -v \"^\$\"";
+
+ $lines = explode("\n", shell_exec($com));
+
+ $codInt = strtr($cir->getId(), ".", "_");
+
+ for ($i=0; $i < count($lines); $i++)
+ {
+ $fields = explode(" ", $lines[$i]);
+ $date = new \DateTime();
+ $date->setTimestamp(intval($fields[0]));
+ $volIn = $this->calc(isset($fields[1]) ? $fields[1] : 0);
+ $volOut = $this->calc(isset($fields[2]) ? $fields[2] : 0);
+
+ if ($date->format('Y-m-d H:i:s') != "1970-01-01 00:00:00" && $date->format('Y-m-d H:i:s') != "1969-12-31 21:00:00")
+ {
+ $rrdLog = new Rrd();
+
+ $rrdLog->setDatetime($date);
+ $rrdLog->setCodeInterface($codInt);
+ $rrdLog->setVolumeIn($volIn);
+ $rrdLog->setVolumeOut($volOut);
+
+ $em->persist($rrdLog);
+ }
+ $em->flush();
+ }
+ }
+ }
+ return new Response();
+ }
+
+ public function calc($value)
+ {
+ $value = strtr($value, ",", ".");
+ settype ($value, "double");
+ return round($value, 1);
+ }
+
+}
diff --git a/Controller/SnmpController.php b/Controller/SnmpController.php
new file mode 100755
index 0000000..f34f0df
--- /dev/null
+++ b/Controller/SnmpController.php
@@ -0,0 +1,855 @@
+host = $host;
+ $this->community = $community;
+ $this->codeInterface = $codeInterface;
+ }
+
+ public function fcSnmpWalk($oId, $t = 1, $r = 1)
+ {
+ /*
+ Nao permite SNMP BULK.
+ Retorna Resposta, apenas, para a primeira OID solicitada
+ */
+
+ $com = "snmpwalk -Ov -t " . $t . " -r " . $r . " -c " . $this->community . " -v 1 " . $this->host . " " . $oId;
+ $arrayInfo = explode("\n", shell_exec($com));
+
+ $arrayInfo = $this->formatSnmp($arrayInfo);
+
+ return $arrayInfo;
+ }
+
+ public function fcSnmpGet($oIds, $t=1, $r=1)
+ {
+ $com = "snmpget -Ov -t " . $t . " -r " . $r . " -c " . $this->community . " -v 1 " . $this->host . " " . $oIds;
+ $arrayInfo = explode("\n", shell_exec($com));
+
+ return (!empty($arrayInfo[0])) ? $this->formatSnmp($arrayInfo) : null;
+ }
+
+
+ public function formatSnmp($array)
+ {
+ for($i=0;$i1) ? $newArray : $newArray[0] : null;
+ }
+
+ public function sysUpTime()
+ {
+ $this->sysUpTime = $this->fcSnmpGet(".1.3.6.1.2.1.1.3.0");
+
+ return ($this->sysUpTime == NULL) ? 0 : 1;
+ }
+
+
+ public function server()
+ {
+ $aux = shell_exec('ifconfig | head -2| tail -1');
+ $aux = substr(strstr($aux, ':'),2);
+ $server = explode(" " , $aux);
+ return $server[0];
+ }
+
+ public function hostName()
+ {
+ $name = $this->fcSnmpGet(".1.3.6.1.2.1.1.5.0");
+
+ if($name == NULL)
+ $this->problems();
+
+ $this->sysName = $name;
+ }
+
+ public function problems()
+ {
+ echo "
+
PROBLEMAS!!! " .
+ $this->host .
+ "
+
+
+
+
+ >>> Verifique se o equipamento possui 'Hostname' .
+
+ >>> Verifique se equipamento está ligado. Usando comando ping .
+
+ >>> Verifique se o IP e/ou Community esta(ão) correto(s).
+
+
+ ";
+ exit;
+ }
+
+ public function printHost()
+ {
+ $chassis = $this->chassis();
+ echo "" . $this->host . " (Modelo: $chassis) ";
+ }
+
+ public function chassis()
+ {
+ $ChassisTypes[0] = "Desconhecido";
+ $ChassisTypes[2] = "multibus";
+ $ChassisTypes[3] = "agsplus";
+ $ChassisTypes[4] = "igs";
+ $ChassisTypes[5] = "c2000";
+ $ChassisTypes[6] = "c3000";
+ $ChassisTypes[7] = "c4000";
+ $ChassisTypes[8] = "c7000";
+ $ChassisTypes[9] = "cs500";
+ $ChassisTypes[10] = "c7010";
+ $ChassisTypes[11] = "c2500";
+ $ChassisTypes[12] = "c4500";
+ $ChassisTypes[13] = "c2102";
+ $ChassisTypes[14] = "c2202";
+ $ChassisTypes[15] = "c2501";
+ $ChassisTypes[16] = "c2502";
+ $ChassisTypes[17] = "c2503";
+ $ChassisTypes[18] = "c2504";
+ $ChassisTypes[19] = "c2505";
+ $ChassisTypes[20] = "c2506";
+ $ChassisTypes[21] = "c2507";
+ $ChassisTypes[22] = "c2508";
+ $ChassisTypes[23] = "c2509";
+ $ChassisTypes[24] = "c2510";
+ $ChassisTypes[25] = "c2511";
+ $ChassisTypes[26] = "c2512";
+ $ChassisTypes[27] = "c2513";
+ $ChassisTypes[28] = "c2514";
+ $ChassisTypes[29] = "c2515";
+ $ChassisTypes[30] = "c3101";
+ $ChassisTypes[31] = "c3102";
+ $ChassisTypes[32] = "c3103";
+ $ChassisTypes[33] = "c3104";
+ $ChassisTypes[34] = "c3202";
+ $ChassisTypes[35] = "c3204";
+ $ChassisTypes[36] = "accessProRC";
+ $ChassisTypes[37] = "accessProEC";
+ $ChassisTypes[38] = "c1000";
+ $ChassisTypes[39] = "c1003";
+ $ChassisTypes[40] = "c1004";
+ $ChassisTypes[41] = "c2516";
+ $ChassisTypes[42] = "c7507";
+ $ChassisTypes[43] = "c7513";
+ $ChassisTypes[44] = "c7506";
+ $ChassisTypes[45] = "c7505";
+ $ChassisTypes[46] = "c1005";
+ $ChassisTypes[47] = "c4700";
+ $ChassisTypes[48] = "c2517";
+ $ChassisTypes[49] = "c2518";
+ $ChassisTypes[50] = "c2519";
+ $ChassisTypes[51] = "c2520";
+ $ChassisTypes[52] = "c2521";
+ $ChassisTypes[53] = "c2522";
+ $ChassisTypes[54] = "c2523";
+ $ChassisTypes[55] = "c2524";
+ $ChassisTypes[56] = "c2525";
+ $ChassisTypes[57] = "c4700S";
+ $ChassisTypes[58] = "c7206";
+ $ChassisTypes[59] = "c3640";
+ $ChassisTypes[60] = "as5200";
+ $ChassisTypes[61] = "c1601";
+ $ChassisTypes[62] = "c1602";
+ $ChassisTypes[63] = "c1603";
+ $ChassisTypes[64] = "c1604";
+ $ChassisTypes[65] = "c7204";
+ $ChassisTypes[66] = "c3620";
+ $ChassisTypes[68] = "wsx3011";
+ $ChassisTypes[72] = "c1503";
+ $ChassisTypes[73] = "as5300";
+ $ChassisTypes[74] = "as2509RJ";
+ $ChassisTypes[75] = "as2511RJ";
+ $ChassisTypes[77] = "c2501FRADFX";
+ $ChassisTypes[78] = "c2501LANFRADFX";
+ $ChassisTypes[79] = "c2502LANFRADFX";
+ $ChassisTypes[80] = "wsx5302";
+ $ChassisTypes[82] = "c12012";
+ $ChassisTypes[84] = "c12004";
+ $ChassisTypes[87] = "c2600";
+ $ChassisTypes[165] = "c7606";
+ $ChassisTypes[278] = "c7606";
+
+ $chassis = $this->fcSnmpWalk(".1.3.6.1.4.1.9.3.6.1.0");
+
+ if(isset($ChassisTypes[$chassis]))
+ {
+ return ($ChassisTypes[$chassis] == NULL) ? $ChassisTypes[0] : $ChassisTypes[$chassis];
+ }
+
+ return $ChassisTypes[0];
+ }
+
+ public function general()
+ {
+ $oids = array
+ (
+ "sysUptime" => ".1.3.6.1.2.1.1.3.0",
+ "whyReload" => ".1.3.6.1.4.1.9.2.1.2.0",
+ "version" => ".1.3.6.1.2.1.1.1.0",
+ "location" => ".1.3.6.1.2.1.1.6.0",
+ "contact" => ".1.3.6.1.2.1.1.4.0",
+ "avgBusy1" => ".1.3.6.1.4.1.9.2.1.57.0",
+ "avgBusy5" => ".1.3.6.1.4.1.9.2.1.58.0",
+ "sysConfigName" => ".1.3.6.1.4.1.9.2.1.73.0",
+ "tsLines" => ".1.3.6.1.4.1.9.2.9.1.0",
+ "cmSystemInstalledModem" => ".1.3.6.1.4.1.9.9.47.1.1.1.0",
+ "cmSystemModemsInUse" => ".1.3.6.1.4.1.9.9.47.1.1.6.0",
+ "cmSystemModemsDead" => ".1.3.6.1.4.1.9.9.47.1.1.10.0",
+ "Memory" => ".1.3.6.1.4.1.9.3.6.6.0",
+ "Services" => ".1.3.6.1.2.1.1.7.0"
+ );
+
+ $MIBs = $oids['sysUptime'] . " " .
+ $oids['whyReload'] . " " .
+ $oids['location'] . " " .
+ $oids['contact'] . " " .
+ $oids['Memory'] . " " .
+ $oids['avgBusy1'] . " " .
+ $oids['avgBusy5'] . " " .
+ $oids['tsLines'] . " " .
+ $oids['Services'] . " " .
+ $oids['sysConfigName'] . " " .
+ $oids['cmSystemInstalledModem'];
+
+ $result = $this->fcSnmpGet($MIBs);
+
+ $sysName = $this->sysName;
+ $services = $this->sysSrv((isset($result[8])) ? $result[8] : "");
+ $memory = isset($result[4]) ? $result[4] : 0;
+ $memory /= (1024*1024); # TRANSFORMA PARA Mb
+
+ $this->version = $this->sysVersion($oids["version"]);
+ $this->sysUpTime = $this->upTime($result[0]);
+
+ echo $services;
+
+ $this->y = 0;
+
+ echo "
+
+
+ Informações Gerais
+ ";
+
+ echo $this->printGeneralInfo("UpTime", $this->sysUpTime . "(motivo: $result[1])");
+ echo $this->printGeneralInfo("Nome do Equipamento", "$sysName");
+ echo $this->printGeneralInfo("Services", "$services");
+
+ if ($result[2] != NULL)
+ echo $this->printGeneralInfo("Localização", $result[2]);
+
+ if ($result[2] != NULL)
+ echo $this->printGeneralInfo("Contato", $result[2]);
+
+ echo $this->printGeneralInfo("Memória Mb", "$memory");
+ echo $this->printGeneralInfo("Versão", $this->version);
+ echo $this->printGeneralInfo("1/5 min CPU util", ""); //$avgBusy1/$avgBusy5 %
+ echo $this->printGeneralInfo("Imagem Carregada", ""); //$sysCfgName
+ echo $this->printGeneralInfo("Terminal lines", ""); //$tsLines
+/*
+ if ($sysModem > 0)
+ {
+
+ $MIBs = $oids['cmSystemModemsInUse'] . " " .
+ $oids['cmSystemModemsDead'];
+
+ list($modemsInUse, $modemsDead) = $this->fcSnmpGet($MIBs);
+
+ $this->printGeneralInfo("Digital modems", "$sysModem");
+ $this->printGeneralInfo("In use modems", "$modemsInUse");
+ $this->printGeneralInfo("Modems Dead", "$modemsDead");
+ }
+*/
+ echo "
";
+ }
+
+ public function sysSrv($sv)
+ {
+ if ($sv & 1) {$srv = "Repeater"; }
+ if ($sv & 2) {$srv = "$srv Bridge"; }
+ if ($sv & 4) {$srv = "$srv Router"; }
+ if ($sv & 8) {$srv = "$srv Gateway"; }
+ if ($sv & 16) {$srv = "$srv Session"; }
+ if ($sv & 32) {$srv = "$srv Terminal"; }
+ if ($sv & 64) {$srv = "$srv Application"; }
+ if (!$sv) {$srv = "serviço SNMP não suportado"; }
+ return $srv;
+ }
+
+ public function sysVersion($version)
+ {
+ $arrayVersion = $this->fcSnmpGet($version);
+
+ for($i=0; $iUpTimeTickts = $sysUpTime;
+
+ $day = bcdiv($sysUpTime, 86400);
+ $sysUpTime = bcmod($sysUpTime, 86400);
+ $hour = bcdiv($sysUpTime, 3600);
+ $sysUpTime = bcmod($sysUpTime, 3600);
+ $minute = bcdiv($sysUpTime, 60);
+ $sec = bcmod($sysUpTime, 60);
+
+ $daystr = ($day == 1) ? "Dia" : "Dias";
+ $hourstr = ($hour == 1) ? "hora" : "horas";
+ $minutestr = ($minute == 1) ? "minuto" : "minutos";
+ $secstr = ($sec == 1) ? "segundo" : "segundos";
+
+ return "$day $daystr $hour $hourstr $minute $minutestr e $sec $secstr";
+ }
+
+ public function printGeneralInfo($th, $info)
+ {
+ $classe = $this->oddCouple();
+ return "$th $info ";
+ }
+
+ public function oddCouple()
+ {
+ $classe = ((bcmod($this->y, 2)) == 0 ) ? "par" : "impar";
+ $this->y++;
+
+ return $classe;
+ }
+
+ public function hardware()
+ {
+ $oids = array(
+ "cards" => ".1.3.6.1.4.1.9.3.6.11.1.3",
+ "ctype" => ".1.3.6.1.4.1.9.3.6.11.1.2",
+ "slotnum" => ".1.3.6.1.4.1.9.3.6.11.1.7",
+ "cardSlots" => ".1.3.6.1.4.1.9.3.6.12.0"
+ );
+
+ $CardTypes[1] = "desconhecido";
+ $CardTypes[2] = "csc1";
+ $CardTypes[3] = "csc2";
+ $CardTypes[4] = "csc3";
+ $CardTypes[5] = "csc4";
+ $CardTypes[6] = "rp";
+ $CardTypes[7] = "cpu-igs";
+ $CardTypes[8] = "cpu-2500";
+ $CardTypes[9] = "cpu-3000";
+ $CardTypes[10] = "cpu-3100";
+ $CardTypes[11] = "cpu-accessPro";
+ $CardTypes[12] = "cpu-4000";
+ $CardTypes[13] = "cpu-4000m";
+ $CardTypes[14] = "cpu-4500";
+ $CardTypes[15] = "rsp1";
+ $CardTypes[16] = "rsp2";
+ $CardTypes[17] = "cpu-4500m";
+ $CardTypes[18] = "cpu-1003";
+ $CardTypes[19] = "cpu-4700";
+ $CardTypes[20] = "csc-m";
+ $CardTypes[21] = "csc-mt";
+ $CardTypes[22] = "csc-mc";
+ $CardTypes[23] = "csc-mcplus";
+ $CardTypes[24] = "csc-envm";
+ $CardTypes[25] = "chassisInterface";
+ $CardTypes[26] = "cpu-4700S";
+ $CardTypes[27] = "cpu-7200-npe100";
+ $CardTypes[28] = "rsp7000";
+ $CardTypes[29] = "chassisInterface7000";
+ $CardTypes[30] = "rsp4";
+ $CardTypes[31] = "cpu-3600";
+ $CardTypes[32] = "cpu-as5200";
+ $CardTypes[33] = "c7200-io1fe";
+ $CardTypes[34] = "cpu-4700m";
+ $CardTypes[35] = "cpu-1600";
+ $CardTypes[36] = "c7200-io";
+ $CardTypes[37] = "cpu-1503";
+ $CardTypes[38] = "cpu-1502";
+ $CardTypes[39] = "cpu-as5300";
+ $CardTypes[40] = "csc-16";
+ $CardTypes[41] = "csc-p";
+ $CardTypes[50] = "csc-a";
+ $CardTypes[51] = "csc-e1";
+ $CardTypes[52] = "csc-e2";
+ $CardTypes[53] = "csc-y";
+ $CardTypes[54] = "csc-s";
+ $CardTypes[55] = "csc-t";
+ $CardTypes[80] = "csc-r";
+ $CardTypes[81] = "csc-r16";
+ $CardTypes[82] = "csc-r16m";
+ $CardTypes[83] = "csc-1r";
+ $CardTypes[84] = "csc-2r";
+ $CardTypes[56] = "sci4s";
+ $CardTypes[57] = "sci2s2t";
+ $CardTypes[58] = "sci4t";
+ $CardTypes[59] = "mci1t";
+ $CardTypes[60] = "mci2t";
+ $CardTypes[61] = "mci1s";
+ $CardTypes[62] = "mci1s1t";
+ $CardTypes[63] = "mci2s";
+ $CardTypes[64] = "mci1e";
+ $CardTypes[65] = "mci1e1t";
+ $CardTypes[66] = "mci1e2t";
+ $CardTypes[67] = "mci1e1s";
+ $CardTypes[68] = "mci1e1s1t";
+ $CardTypes[69] = "mci1e2s";
+ $CardTypes[70] = "mci2e";
+ $CardTypes[71] = "mci2e1t";
+ $CardTypes[72] = "mci2e2t";
+ $CardTypes[73] = "mci2e1s";
+ $CardTypes[74] = "mci2e1s1t";
+ $CardTypes[75] = "mci2e2s";
+ $CardTypes[100] = "csc-cctl1";
+ $CardTypes[101] = "csc-cctl2";
+ $CardTypes[110] = "csc-mec2";
+ $CardTypes[111] = "csc-mec4";
+ $CardTypes[112] = "csc-mec6";
+ $CardTypes[113] = "csc-fci";
+ $CardTypes[114] = "csc-fcit";
+ $CardTypes[115] = "csc-hsci";
+ $CardTypes[116] = "csc-ctr";
+ $CardTypes[121] = "cpu-7200-npe150";
+ $CardTypes[122] = "cpu-7200-npe200";
+ $CardTypes[123] = "cpu-wsx5302";
+ $CardTypes[124] = "gsr-rp";
+ $CardTypes[126] = "cpu-3810";
+ $CardTypes[150] = "sp";
+ $CardTypes[151] = "eip";
+ $CardTypes[152] = "fip";
+ $CardTypes[153] = "hip";
+ $CardTypes[154] = "sip";
+ $CardTypes[155] = "trip";
+ $CardTypes[156] = "fsip";
+ $CardTypes[157] = "aip";
+ $CardTypes[158] = "mip";
+ $CardTypes[159] = "ssp";
+ $CardTypes[160] = "cip";
+ $CardTypes[161] = "srs-fip";
+ $CardTypes[162] = "srs-trip";
+ $CardTypes[163] = "feip";
+ $CardTypes[164] = "vip";
+ $CardTypes[165] = "vip2";
+ $CardTypes[166] = "ssip";
+ $CardTypes[167] = "smip";
+ $CardTypes[168] = "posip";
+ $CardTypes[169] = "feip-tx";
+ $CardTypes[170] = "feip-fx";
+ $CardTypes[178] = "cbrt1";
+ $CardTypes[179] = "cbr120e1";
+ $CardTypes[180] = "cbr75e";
+ $CardTypes[181] = "vip2-50";
+ $CardTypes[182] = "feip2";
+ $CardTypes[183] = "acip";
+ $CardTypes[200] = "npm-4000-fddi-sas";
+ $CardTypes[201] = "npm-4000-fddi-das";
+ $CardTypes[202] = "npm-4000-1e";
+ $CardTypes[203] = "npm-4000-1r";
+ $CardTypes[204] = "npm-4000-2s";
+ $CardTypes[205] = "npm-4000-2e1";
+ $CardTypes[206] = "npm-4000-2e";
+ $CardTypes[207] = "npm-4000-2r1";
+ $CardTypes[208] = "npm-4000-2r";
+ $CardTypes[209] = "npm-4000-4t";
+ $CardTypes[210] = "npm-4000-4b";
+ $CardTypes[211] = "npm-4000-8b";
+ $CardTypes[212] = "npm-4000-ct1";
+ $CardTypes[213] = "npm-4000-ce1";
+ $CardTypes[214] = "npm-4000-1a";
+ $CardTypes[215] = "npm-4000-6e";
+ $CardTypes[217] = "npm-4000-1fe";
+ $CardTypes[218] = "npm-4000-1hssi";
+ $CardTypes[230] = "pa-1fe";
+ $CardTypes[231] = "pa-8e";
+ $CardTypes[232] = "pa-4e";
+ $CardTypes[233] = "pa-5e";
+ $CardTypes[234] = "pa-4t";
+ $CardTypes[235] = "pa-4r";
+ $CardTypes[236] = "pa-fddi";
+ $CardTypes[237] = "sa-encryption";
+ $CardTypes[238] = "pa-ah1t";
+ $CardTypes[239] = "pa-ah2t";
+ $CardTypes[241] = "pa-a8t-v35";
+ $CardTypes[242] = "pa-1fe-tx-isl";
+ $CardTypes[243] = "pa-1fe-fx-isl";
+ $CardTypes[244] = "pa-1fe-tx-nisl";
+ $CardTypes[245] = "sa-compression";
+ $CardTypes[246] = "pa-atm-lite-1";
+ $CardTypes[247] = "pa-ct3";
+ $CardTypes[248] = "pa-oc3sm-mux-cbrt1";
+ $CardTypes[249] = "pa-oc3sm-mux-cbr120e1";
+ $CardTypes[254] = "pa-ds3-mux-cbrt1";
+ $CardTypes[255] = "pa-e3-mux-cbr120e1";
+ $CardTypes[257] = "pa-8b-st";
+ $CardTypes[258] = "pa-4b-u";
+ $CardTypes[259] = "pa-fddi-fd";
+ $CardTypes[260] = "pm-cpm-1e2w";
+ $CardTypes[261] = "pm-cpm-2e2w";
+ $CardTypes[262] = "pm-cpm-1e1r2w";
+ $CardTypes[263] = "pm-ct1-csu";
+ $CardTypes[264] = "pm-2ct1-csu";
+ $CardTypes[265] = "pm-ct1-dsx1";
+ $CardTypes[266] = "pm-2ct1-dsx1";
+ $CardTypes[267] = "pm-ce1-balanced";
+ $CardTypes[268] = "pm-2ce1-balanced";
+ $CardTypes[269] = "pm-ce1-unbalanced";
+ $CardTypes[270] = "pm-2ce1-unbalanced";
+ $CardTypes[271] = "pm-4b-u";
+ $CardTypes[272] = "pm-4b-st";
+ $CardTypes[273] = "pm-8b-u";
+ $CardTypes[274] = "pm-8b-st";
+ $CardTypes[275] = "pm-4as";
+ $CardTypes[276] = "pm-8as";
+ $CardTypes[277] = "pm-4e";
+ $CardTypes[278] = "pm-1e";
+ $CardTypes[280] = "pm-m4t";
+ $CardTypes[281] = "pm-16a";
+ $CardTypes[282] = "pm-32a";
+ $CardTypes[283] = "pm-c3600-1fe-tx";
+ $CardTypes[284] = "pm-c3600-compression";
+ $CardTypes[285] = "pm-dmodem";
+ $CardTypes[288] = "pm-c3600-1fe-fx";
+ $CardTypes[288] = "pm-c3600-1fe-fx";
+ $CardTypes[290] = "as5200-carrier";
+ $CardTypes[291] = "as5200-2ct1";
+ $CardTypes[292] = "as5200-2ce1";
+ $CardTypes[310] = "pm-as5xxx-12m";
+ $CardTypes[330] = "wm-c2500-5in1";
+ $CardTypes[331] = "wm-c2500-t1-csudsu";
+ $CardTypes[332] = "wm-c2500-sw56-2wire-csudsu";
+ $CardTypes[333] = "wm-c2500-sw56-4wire-csudsu";
+ $CardTypes[334] = "wm-c2500-bri";
+ $CardTypes[335] = "wm-c2500-bri-nt1";
+ $CardTypes[360] = "wic-serial-1t";
+ $CardTypes[364] = "wic-s-t-3420";
+ $CardTypes[365] = "wic-s-t-2186";
+ $CardTypes[366] = "wic-u-3420";
+ $CardTypes[367] = "wic-u-2091";
+ $CardTypes[368] = "wic-u-2091-2081";
+ $CardTypes[400] = "pa-jt2";
+ $CardTypes[401] = "pa-posdw";
+ $CardTypes[402] = "pa-4me1-bal";
+ $CardTypes[414] = "pa-a8t-x21";
+ $CardTypes[415] = "pa-a8t-rs232";
+ $CardTypes[416] = "pa-4me1-unbal";
+ $CardTypes[417] = "pa-4r-fdx";
+ $CardTypes[424] = ",pa-1fe-fx-nisl";
+ $CardTypes[435] = ",mc3810-dcm";
+ $CardTypes[436] = ",mc3810-mfm-e1balanced-bri";
+ $CardTypes[437] = ",mc3810-mfm-e1unbalanced-bri";
+ $CardTypes[438] = ",mc3810-mfm-e1-unbalanced";
+ $CardTypes[439] = ",mc3810-mfm-dsx1-bri";
+ $CardTypes[440] = ",mc3810-mfm-dsx1-csu";
+ $CardTypes[441] = ",mc3810-vcm";
+ $CardTypes[442] = ",mc3810-avm";
+ $CardTypes[443] = ",mc3810-avm-fxs";
+ $CardTypes[444] = ",mc3810-avm-fxo";
+ $CardTypes[445] = ",mc3810-avm-em";
+ $CardTypes[445] = ",mc3810-avm-em";
+ $CardTypes[480] = ",as5300-4ct1";
+ $CardTypes[481] = ",as5300-4ce1";
+ $CardTypes[482] = ",as5300-carrier";
+ $CardTypes[500] = ",vic-em";
+ $CardTypes[501] = "vic-fxo";
+ $CardTypes[502] = "vic-fxs";
+ $CardTypes[503] = "vpm-2v";
+ $CardTypes[504] = "vpm-4v";
+ $CardTypes[530] = ",pos-qoc3-mm";
+ $CardTypes[531] = ",pos-qoc3-sm";
+ $CardTypes[532] = ",pos-oc12-mm";
+ $CardTypes[533] = ",pos-oc12-sm";
+ $CardTypes[534] = ",atm-oc12-mm";
+ $CardTypes[535] = ",atm-oc12-sm";
+ $CardTypes[536] = ",pos-oc48-mm-l";
+ $CardTypes[537] = ",pos-oc48-sm-l";
+ $CardTypes[538] = ",gsr-sfc";
+ $CardTypes[539] = ",gsr-csc";
+ $CardTypes[540] = ",gsr-csc4";
+ $CardTypes[541] = ",gsr-csc8";
+ $CardTypes[542] = ",gsr-sfc8";
+ $CardTypes[545] = ",gsr-oc12chds3-mm";
+ $CardTypes[546] = ",gsr-oc12chds3-sm";
+ $CardTypes[546] = ",gsr-oc12chds3-sm";
+ $CardTypes[546] = ",gsr-oc12chds3-sm";
+ $CardTypes[605] = ",pm-atm25";
+
+ $cards = $this->fcSnmpWalk($oids['cards']);
+ $ctype = $this->fcSnmpWalk($oids['ctype']);
+ $slotnum = $this->fcSnmpWalk($oids['slotnum']);
+ $cardSlots = $this->fcSnmpGet($oids['cardSlots']) -1 ;
+
+ $this->y = 0;
+
+ if(count($cards) > 1)
+ {
+ echo "
+
+ Informações de Hardware
+ Descrição Tipo Slot
+ ";
+
+ for ($x = 0; $xprintInfoHardware($cards[$x], $CdTypes, $slotnum[$x]);
+ }
+ echo "
+
+ Número mais elevado de Slot
+
+ $cardSlots
+
+
+
";
+ }
+ }
+
+ public function printInfoHardware($cards, $CdTypes, $slotnum)
+ {
+ $classe = $this->oddCouple();
+ echo "
+
+ $cards
+ $CdTypes
+ $slotnum
+
+ ";
+ }
+
+ public function memoryFlash()
+ {
+ if (!preg_match("/[1-11]\./i", $this->version))
+ {
+ $oids = array
+ (
+ "flashSupported" => ".1.3.6.1.4.1.9.9.10.1.1.1.0",
+ "flashSize" => ".1.3.6.1.4.1.9.9.10.1.1.2.1.2",
+ "flashFileName" => ".1.3.6.1.4.1.9.9.10.1.1.4.2.1.1.5",
+ "flashDeviceDescr" => ".1.3.6.1.4.1.9.9.10.1.1.2.1.8",
+ "flashFreeSpace" => ".1.3.6.1.4.1.9.9.10.1.1.4.1.1.5"
+ );
+ }
+
+ echo
+ "
+
+
+ Índices de Memória Flash
+
+
+ Filename
+ Dispositivo
+ Size (MB)
+ Free (MB)
+ ";
+
+ $flashSupported = $this->fcSnmpGet($oids{'flashSupported'});
+ $flashSize = $this->fcSnmpWalk($oids{'flashSize'});
+
+ for ($x = 0; $x< count($flashSize); $x++)
+ {
+ $flashSize[$x] = round( ($flashSize[$x]/(1024*1024)), 1);
+
+ if($flashSize[$x])
+ {
+ $MIBs = $oids{'flashFileName'} . '.' . ($x + 1) . ".1.1 " .
+ $oids{'flashDeviceDescr'} . '.' . ($x + 1) . " " .
+ $oids{'flashFreeSpace'} . '.' . ($x + 1) . ".1 ";
+
+ list($flashFileName, $flashDeviceDescr, $flashFreeSpace) = $this->fcSnmpGet($MIBs);
+
+ $flashFreeSpace = round(($flashFreeSpace/(1024*1024)), 1);
+
+ $this->printInfoFlash($flashFileName, $flashDeviceDescr, $flashSize[$x], $flashFreeSpace);
+ }
+ }
+
+ echo "
";
+ }
+
+ public function printInfoFlash($flashFileName, $flashDeviceDescr, $flashSize, $flashFreeSpace)
+ {
+ $classe = $this->oddCouple();
+
+ echo "
+ $flashFileName
+ $flashDeviceDescr
+ $flashSize
+ $flashFreeSpace
+ ";
+ }
+
+ public function interfaces()
+ {
+ $oids = array
+ (
+ "sysUptime" => ".1.3.6.1.2.1.1.3.0",
+ "IfIndex" => ".1.3.6.1.2.1.2.2.1.1",
+ "IfDescr" => ".1.3.6.1.2.1.2.2.1.2",
+ "Description" => ".1.3.6.1.2.1.31.1.1.1.18",
+ "Ip" => ".1.3.6.1.2.1.4.20.1.1",
+ "IpPorder" => ".1.3.6.1.2.1.4.20.1.2",
+ "IfAdminStatus" => ".1.3.6.1.2.1.2.2.1.7",
+ "IfOperStatus" => ".1.3.6.1.2.1.2.2.1.8",
+ "LastChange" => ".1.3.6.1.2.1.2.2.1.9",
+ "ifMac" => ".1.3.6.1.2.1.2.2.1.6"
+ );
+
+ echo
+ "
+
+ Informações das Interfaces
+ Nº Interface Tipo de Interface Descrição da Interface Status Endereço Ip Endereço MAC Last Change
+ Adm Opr
+ ";
+
+ $this->y=0;
+
+ echo $this->sysUpTime;
+
+ $ArrayIndex = $this->fcSnmpWalk($oids{'IfIndex'});
+ $IP = $this->fcSnmpWalk($oids{'Ip'});
+ $IpPorder = $this->fcSnmpWalk($oids{'IpPorder'});
+
+
+ if(count($IP) == count($IpPorder))
+ {
+ for ($i=0; $i < count($ArrayIndex); $i++)
+ {
+ for ($x=0; $xfcSnmpGet($MIBs);
+
+ $IfAdminStatus = $this->status($IfAdminStatus);
+ $IfOperStatus = $this->status($IfOperStatus);
+ $ifMac = $this->ifMacAddress($ifMac);
+ $LastChange = $this->lastChange($LastChange);
+
+ $classe = $this->oddCouple();
+
+ $ip = isset($IPs[$index]) ? $IPs[$index] : null;
+
+ echo "
+ $index
+ $IfDescr
+ $Description
+ $IfAdminStatus
+ $IfOperStatus
+ $ip
+ $ifMac
+ $LastChange
+ ";
+ }
+ echo "
";
+ }
+
+ public function status($status)
+ {
+ return (preg_match("/UP/i", $status)) ? "UP" : "DOWN";
+ }
+
+ public function ifMacAddress($Mac)
+ {
+ $ifMac = ' ';
+
+ $partes = explode(":", strtoupper($Mac));
+
+ for($i=0; $iUpTimeTickts - $LsCh;
+
+ $day = bcdiv($x, 86400);
+ $x = bcmod($x, 86400);
+ $hour = bcdiv($x, 3600);
+ $x = bcmod($x, 3600);
+ $minute = bcdiv($x, 60);
+ $sec = bcmod($x, 60);
+
+ return "$day d $hour h $minute m e $sec s";
+ }
+}
\ No newline at end of file
diff --git a/Controller/SnmpWebController.php b/Controller/SnmpWebController.php
new file mode 100755
index 0000000..3ae798d
--- /dev/null
+++ b/Controller/SnmpWebController.php
@@ -0,0 +1,73 @@
+snmpForm();
+ $form->submit($request);
+
+ if ($form->isValid())
+ {
+ $data = $form->getData();
+
+ $snmp = new SnmpController(
+ $data['host'],
+ $data['community'],
+ null
+ );
+
+ $snmp->hostName();
+
+ $snmp->printHost();
+ $snmp->general();
+ $snmp->hardware();
+ $snmp->memoryFlash();
+ $snmp->interfaces();
+ }
+
+ return new Response();
+ }
+
+ /**
+ * @Route("/snmpweb", name="cocar_snmpweb")
+ * @Template()
+ */
+ public function snmpAction()
+ {
+ $form = $this->snmpForm();
+
+ return array('form' => $form->createView());
+ }
+
+ /**
+ * @param mixed $id the circuit id
+ *
+ * @return \Symfony\Component\Form\Form the form
+ */
+ private function snmpForm()
+ {
+ return $this->createFormBuilder()
+ ->add('host', 'text')
+ ->add('community', 'text')
+ ->add('send', 'submit', array('label' => 'Enviar' ))
+ ->getForm();
+ }
+}
\ No newline at end of file
diff --git a/Controller/StatusController.php b/Controller/StatusController.php
new file mode 100755
index 0000000..09746ad
--- /dev/null
+++ b/Controller/StatusController.php
@@ -0,0 +1,82 @@
+ ".1.3.6.1.2.1.2.2.1.1",
+ "descr" => ".1.3.6.1.2.1.2.2.1.2",
+ "adminStatus" => ".1.3.6.1.2.1.2.2.1.7",
+ "operStatus" => ".1.3.6.1.2.1.2.2.1.8"
+ );
+
+ #verificar o campo geraAlarme='S' na tabela tb_circuits
+
+ $em = $this->getDoctrine()->getManager();
+
+ $circuits = $em->getRepository('CocarBundle:Circuits')->findAll();
+
+ foreach($circuits as $cir)
+ {
+ $obj = new SnmpController(
+ $cir->getIpBackbone(),
+ $cir->getCommunitySnmpBackbone(),
+ $cir->getCodeInterface()
+ );
+
+ if($obj->sysUpTime())
+ {
+ $numInterface = $cir->getNumSnmpinterface();
+
+ $MensageIBs = $oids{'descr'} . ".$numInterface " .
+ $oids{'adminStatus'} . ".$numInterface " .
+ $oids{'operStatus'} . ".$numInterface ";
+
+ list($ifDescr, $ifAdminStatus, $ifOperStatus) = $obj->fcSnmpGet($MensageIBs);
+
+ $ifDescr = str_replace("-aal5 layer", "", $ifDescr);
+ $ifDescr = str_replace("atm subif", "", $ifDescr);
+
+ if($cir->getSerialBackbone() == $ifDescr)
+ {
+ $cir->setAdminStatus($this->status($ifAdminStatus));
+ $cir->setOperStatus($this->status($ifOperStatus));
+
+ $em->persist($cir);
+ $em->flush();
+ }
+ }
+ else
+ {
+ $cir->setAdminStatus($this->status('INAT'));
+ $cir->setOperStatus($this->status('INAT'));
+
+ $em->persist($cir);
+ $em->flush();
+ }
+ }
+
+ return new Response();
+ }
+
+ public function status($status)
+ {
+ return preg_match("/1/i", $status) ? "UP" :
+ (preg_match("/2/i", $status) ? "DOWN" : "INAT");
+ }
+}
\ No newline at end of file
diff --git a/DependencyInjection/CocarExtension.php b/DependencyInjection/CocarExtension.php
new file mode 100755
index 0000000..7dcac6f
--- /dev/null
+++ b/DependencyInjection/CocarExtension.php
@@ -0,0 +1,28 @@
+processConfiguration($configuration, $configs);
+
+ $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader->load('services.yml');
+ }
+}
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
new file mode 100755
index 0000000..37fe1e6
--- /dev/null
+++ b/DependencyInjection/Configuration.php
@@ -0,0 +1,29 @@
+root('cocar');
+
+ // Here you should define the parameters that are allowed to
+ // configure your bundle. See the documentation linked above for
+ // more information on that topic.
+
+ return $treeBuilder;
+ }
+}
diff --git a/Entity/Circuits.php b/Entity/Circuits.php
new file mode 100755
index 0000000..db88ef9
--- /dev/null
+++ b/Entity/Circuits.php
@@ -0,0 +1,830 @@
+machine = new ArrayCollection();
+ }
+
+ /**
+ * Get id
+ *
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Set codeInterface
+ *
+ * @param string $codeInterface
+ * @return Circuits
+ */
+ public function setCodeInterface($codeInterface)
+ {
+ $this->codeInterface = $codeInterface;
+
+ return $this;
+ }
+
+ /**
+ * Get codeInterface
+ *
+ * @return string
+ */
+ public function getCodeInterface()
+ {
+ return $this->codeInterface;
+ }
+
+ /**
+ * Set description
+ *
+ * @param string $description
+ * @return Circuits
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+
+ return $this;
+ }
+
+ /**
+ * Get description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Set manages
+ *
+ * @param string $manages
+ * @return Circuits
+ */
+ public function setManages($manages)
+ {
+ $this->manages = $manages;
+
+ return $this;
+ }
+
+ /**
+ * Get manages
+ *
+ * @return string
+ */
+ public function getManages()
+ {
+ return $this->manages;
+ }
+
+ /**
+ * Set ipBackbone
+ *
+ * @param string $ipBackbone
+ * @return Circuits
+ */
+ public function setIpBackbone($ipBackbone)
+ {
+ $this->ipBackbone = $ipBackbone;
+
+ return $this;
+ }
+
+ /**
+ * Get ipBackbone
+ *
+ * @return string
+ */
+ public function getIpBackbone()
+ {
+ return $this->ipBackbone;
+ }
+
+ /**
+ * Set communitySnmpBackbone
+ *
+ * @param string $communitySnmpBackbone
+ * @return Circuits
+ */
+ public function setCommunitySnmpBackbone($communitySnmpBackbone)
+ {
+ $this->communitySnmpBackbone = $communitySnmpBackbone;
+
+ return $this;
+ }
+
+ /**
+ * Get communitySnmpBackbone
+ *
+ * @return string
+ */
+ public function getCommunitySnmpBackbone()
+ {
+ return $this->communitySnmpBackbone;
+ }
+
+ /**
+ * Set serialBackbone
+ *
+ * @param string $serialBackbone
+ * @return Circuits
+ */
+ public function setSerialBackbone($serialBackbone)
+ {
+ $this->serialBackbone = $serialBackbone;
+
+ return $this;
+ }
+
+ /**
+ * Get serialBackbone
+ *
+ * @return string
+ */
+ public function getSerialBackbone()
+ {
+ return $this->serialBackbone;
+ }
+
+ /**
+ * Set technology
+ *
+ * @param string $technology
+ * @return Circuits
+ */
+ public function setTechnology($technology)
+ {
+ $this->technology = $technology;
+
+ return $this;
+ }
+
+ /**
+ * Get technology
+ *
+ * @return string
+ */
+ public function getTechnology()
+ {
+ return $this->technology;
+ }
+
+ /**
+ * Set typeInterface
+ *
+ * @param string $typeInterface
+ * @return Circuits
+ */
+ public function setTypeInterface($typeInterface)
+ {
+ $this->typeInterface = $typeInterface;
+
+ return $this;
+ }
+
+ /**
+ * Get typeInterface
+ *
+ * @return string
+ */
+ public function getTypeInterface()
+ {
+ return $this->typeInterface;
+ }
+
+ /**
+ * Set numSnmpInterface
+ *
+ * @param string $numSnmpInterface
+ * @return Circuits
+ */
+ public function setNumSnmpInterface($numSnmpInterface)
+ {
+ $this->numSnmpInterface = $numSnmpInterface;
+
+ return $this;
+ }
+
+ /**
+ * Get numSnmpInterface
+ *
+ * @return string
+ */
+ public function getNumSnmpInterface()
+ {
+ return $this->numSnmpInterface;
+ }
+
+ /**
+ * Set ipSerialInterface
+ *
+ * @param string $ipSerialInterface
+ * @return Circuits
+ */
+ public function setIpSerialInterface($ipSerialInterface)
+ {
+ $this->ipSerialInterface = $ipSerialInterface;
+
+ return $this;
+ }
+
+ /**
+ * Get ipSerialInterface
+ *
+ * @return string
+ */
+ public function getIpSerialInterface()
+ {
+ return $this->ipSerialInterface;
+ }
+
+ /**
+ * Set registerCircuit
+ *
+ * @param string $registerCircuit
+ * @return Circuits
+ */
+ public function setRegisterCircuit($registerCircuit)
+ {
+ $this->registerCircuit = $registerCircuit;
+
+ return $this;
+ }
+
+ /**
+ * Get registerCircuit
+ *
+ * @return string
+ */
+ public function getRegisterCircuit()
+ {
+ return $this->registerCircuit;
+ }
+
+ /**
+ * Set speed
+ *
+ * @param string $speed
+ * @return Circuits
+ */
+ public function setSpeed($speed)
+ {
+ $this->speed = $speed;
+
+ return $this;
+ }
+
+ /**
+ * Get speed
+ *
+ * @return string
+ */
+ public function getSpeed()
+ {
+ return $this->speed;
+ }
+
+ /**
+ * Set cirIn
+ *
+ * @param string $cirIn
+ * @return Circuits
+ */
+ public function setCirIn($cirIn)
+ {
+ $this->cirIn = $cirIn;
+
+ return $this;
+ }
+
+ /**
+ * Get cirIn
+ *
+ * @return string
+ */
+ public function getCirIn()
+ {
+ return $this->cirIn;
+ }
+
+ /**
+ * Set cirOut
+ *
+ * @param string $cirOut
+ * @return Circuits
+ */
+ public function setCirOut($cirOut)
+ {
+ $this->cirOut = $cirOut;
+
+ return $this;
+ }
+
+ /**
+ * Get cirOut
+ *
+ * @return string
+ */
+ public function getCirOut()
+ {
+ return $this->cirOut;
+ }
+
+ /**
+ * Set serialRouterTip
+ *
+ * @param string $serialRouterTip
+ * @return Circuits
+ */
+ public function setSerialRouterTip($serialRouterTip)
+ {
+ $this->serialRouterTip = $serialRouterTip;
+
+ return $this;
+ }
+
+ /**
+ * Get serialRouterTip
+ *
+ * @return string
+ */
+ public function getSerialRouterTip()
+ {
+ return $this->serialRouterTip;
+ }
+
+ /**
+ * Set snmpPortTip
+ *
+ * @param string $snmpPortTip
+ * @return Circuits
+ */
+ public function setSnmpPortTip($snmpPortTip)
+ {
+ $this->snmpPortTip = $snmpPortTip;
+
+ return $this;
+ }
+
+ /**
+ * Get snmpPortTip
+ *
+ * @return string
+ */
+ public function getSnmpPortTip()
+ {
+ return $this->snmpPortTip;
+ }
+
+ /**
+ * Set communitySnmpRouterTip
+ *
+ * @param string $communitySnmpRouterTip
+ * @return Circuits
+ */
+ public function setCommunitySnmpRouterTip($communitySnmpRouterTip)
+ {
+ $this->communitySnmpRouterTip = $communitySnmpRouterTip;
+
+ return $this;
+ }
+
+ /**
+ * Get communitySnmpRouterTip
+ *
+ * @return string
+ */
+ public function getCommunitySnmpRouterTip()
+ {
+ return $this->communitySnmpRouterTip;
+ }
+
+ /**
+ * Set ipSerialRouterTip
+ *
+ * @param string $ipSerialRouterTip
+ * @return Circuits
+ */
+ public function setIpSerialRouterTip($ipSerialRouterTip)
+ {
+ $this->ipSerialRouterTip = $ipSerialRouterTip;
+
+ return $this;
+ }
+
+ /**
+ * Get ipSerialRouterTip
+ *
+ * @return string
+ */
+ public function getIpSerialRouterTip()
+ {
+ return $this->ipSerialRouterTip;
+ }
+
+ /**
+ * Set entity
+ *
+ * @param \Cocar\CocarBundle\Entity\Entity $entity
+ * @return Circuits
+ */
+ public function setEntity(\GerenciadorRedes\Bundle\CocarBundle\Entity\Entity $entity = null)
+ {
+ $this->entity = $entity;
+
+ return $this;
+ }
+
+ /**
+ * Get entity
+ *
+ * @return \Cocar\CocarBundle\Entity\Entity
+ */
+ public function getEntity()
+ {
+ return $this->entity;
+ }
+
+ /**
+ * Set adminStatus
+ *
+ * @param string $adminStatus
+ * @return Circuits
+ */
+ public function setAdminStatus($adminStatus)
+ {
+ $this->adminStatus = $adminStatus;
+
+ return $this;
+ }
+
+ /**
+ * Get adminStatus
+ *
+ * @return string
+ */
+ public function getAdminStatus()
+ {
+ return $this->adminStatus;
+ }
+
+ /**
+ * Set operStatus
+ *
+ * @param string $operStatus
+ * @return Circuits
+ */
+ public function setOperStatus($operStatus)
+ {
+ $this->operStatus = $operStatus;
+
+ return $this;
+ }
+
+ /**
+ * Get operStatus
+ *
+ * @return string
+ */
+ public function getOperStatus()
+ {
+ return $this->operStatus;
+ }
+
+ /**
+ * Set status
+ *
+ * @param string $status
+ * @return Circuits
+ */
+ public function setStatus($status)
+ {
+ $this->status = $status;
+
+ return $this;
+ }
+
+ /**
+ * Get status
+ *
+ * @return string
+ */
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ /**
+ * Set generateAlarm
+ *
+ * @param boolean $generateAlarm
+ * @return Circuits
+ */
+ public function setGenerateAlarm($generateAlarm)
+ {
+ $this->generateAlarm = $generateAlarm;
+
+ return $this;
+ }
+
+ /**
+ * Get generateAlarm
+ *
+ * @return boolean
+ */
+ public function getGenerateAlarm()
+ {
+ return $this->generateAlarm;
+ }
+
+ /**
+ * Set reliability
+ *
+ * @param string $reliability
+ * @return Circuits
+ */
+ public function setReliability($reliability)
+ {
+ $this->reliability = $reliability;
+
+ return $this;
+ }
+
+ /**
+ * Get reliability
+ *
+ * @return string
+ */
+ public function getReliability()
+ {
+ return $this->reliability;
+ }
+
+ /**
+ * Set history
+ *
+ * @param string $history
+ * @return Circuits
+ */
+ public function setHistory($history)
+ {
+ $this->history = $history;
+
+ return $this;
+ }
+
+ /**
+ * Get history
+ *
+ * @return string
+ */
+ public function getHistory()
+ {
+ return $this->history;
+ }
+
+
+ /**
+ * Add circuits
+ *
+ * @param \Cocar\CocarBundle\Entity\Machine $machine
+ * @return Entity
+ */
+ public function addMachine(\GerenciadorRedes\Bundle\CocarBundle\Entity\Machine $machine)
+ {
+ $this->machine[] = $machine;
+
+ return $this;
+ }
+
+ /**
+ * Remove machine
+ *
+ * @param \Cocar\CocarBundle\Entity\Circuits $machine
+ */
+ public function removeMachine(\GerenciadorRedes\Bundle\CocarBundle\Entity\Machine $machine)
+ {
+ $this->machine->removeElement($machine);
+ }
+
+ /**
+ * Get machine
+ *
+ * @return \Doctrine\Common\Collections\Collection
+ */
+ public function getMachine()
+ {
+ return $this->machine;
+ }
+}
\ No newline at end of file
diff --git a/Entity/CustomCircuitsRepository.php b/Entity/CustomCircuitsRepository.php
new file mode 100755
index 0000000..7cb1690
--- /dev/null
+++ b/Entity/CustomCircuitsRepository.php
@@ -0,0 +1,31 @@
+getEntityManager()
+ ->createQuery(
+ "SELECT c FROM CocarBundle:Circuits c
+ WHERE c.codeInterface = :cod
+ AND c.ipBackbone = :ip
+ AND c.status = :status
+ AND c.generateAlarm = :alarm"
+ )
+ ->setParameter('cod', $codeInterface)
+ ->setParameter('ip', $ipBackbone)
+ ->setParameter('status', 'UP')
+ ->setParameter('alarm', true)
+ ->getResult();
+ }
+}
\ No newline at end of file
diff --git a/Entity/CustomEntityRepository.php b/Entity/CustomEntityRepository.php
new file mode 100755
index 0000000..0843899
--- /dev/null
+++ b/Entity/CustomEntityRepository.php
@@ -0,0 +1,15 @@
+id;
+ }
+
+ /**
+ * Set codeInterface
+ *
+ * @param integer $codeInterface
+ * @return Performance
+ */
+ public function setCodeInterface($codeInterface)
+ {
+ $this->codeInterface = $codeInterface;
+
+ return $this;
+ }
+
+ /**
+ * Get codeInterface
+ *
+ * @return integer
+ */
+ public function getCodeInterface()
+ {
+ return $this->codeInterface;
+ }
+
+ /**
+ * Set day
+ *
+ * @param \DateTime $day
+ * @return Performance
+ */
+ public function setDay($day)
+ {
+ $this->day = $day;
+
+ return $this;
+ }
+
+ /**
+ * Get day
+ *
+ * @return \DateTime
+ */
+ public function getDay()
+ {
+ return $this->day;
+ }
+
+ /**
+ * Set cirIn
+ *
+ * @param integer $cirIn
+ * @return Performance
+ */
+ public function setCirIn($cirIn)
+ {
+ $this->cirIn = $cirIn;
+
+ return $this;
+ }
+
+ /**
+ * Get cirIn
+ *
+ * @return integer
+ */
+ public function getCirIn()
+ {
+ return $this->cirIn;
+ }
+
+ /**
+ * Set cirOut
+ *
+ * @param integer $cirOut
+ * @return Performance
+ */
+ public function setCirOut($cirOut)
+ {
+ $this->cirOut = $cirOut;
+
+ return $this;
+ }
+
+ /**
+ * Get cirOut
+ *
+ * @return integer
+ */
+ public function getCirOut()
+ {
+ return $this->cirOut;
+ }
+
+ /**
+ * Set cirInRec
+ *
+ * @param integer $cirInRec
+ * @return Performance
+ */
+ public function setCirInRec($cirInRec)
+ {
+ $this->cirInRec = $cirInRec;
+
+ return $this;
+ }
+
+ /**
+ * Get cirInRec
+ *
+ * @return integer
+ */
+ public function getCirInRec()
+ {
+ return $this->cirInRec;
+ }
+
+ /**
+ * Set cirOutRec
+ *
+ * @param integer $cirOutRec
+ * @return Performance
+ */
+ public function setCirOutRec($cirOutRec)
+ {
+ $this->cirOutRec = $cirOutRec;
+
+ return $this;
+ }
+
+ /**
+ * Get cirOutRec
+ *
+ * @return integer
+ */
+ public function getCirOutRec()
+ {
+ return $this->cirOutRec;
+ }
+
+ /**
+ * Set volumeIn
+ *
+ * @param integer $volumeIn
+ * @return Performance
+ */
+ public function setVolumeIn($volumeIn)
+ {
+ $this->volumeIn = $volumeIn;
+
+ return $this;
+ }
+
+ /**
+ * Get volumeIn
+ *
+ * @return integer
+ */
+ public function getVolumeIn()
+ {
+ return $this->volumeIn;
+ }
+
+ /**
+ * Set volumeOut
+ *
+ * @param integer $volumeOut
+ * @return Performance
+ */
+ public function setVolumeOut($volumeOut)
+ {
+ $this->volumeOut = $volumeOut;
+
+ return $this;
+ }
+
+ /**
+ * Get volumeOut
+ *
+ * @return integer
+ */
+ public function getVolumeOut()
+ {
+ return $this->volumeOut;
+ }
+
+ /**
+ * Set delay120160
+ *
+ * @param float $delay120160
+ * @return Performance
+ */
+ public function setDelay120160($delay120160)
+ {
+ $this->delay120160 = $delay120160;
+
+ return $this;
+ }
+
+ /**
+ * Get delay120160
+ *
+ * @return float
+ */
+ public function getDelay120160()
+ {
+ return $this->delay120160;
+ }
+
+ /**
+ * Set delayM160
+ *
+ * @param float $delayM160
+ * @return Performance
+ */
+ public function setDelayM160($delayM160)
+ {
+ $this->delayM160 = $delayM160;
+
+ return $this;
+ }
+
+ /**
+ * Get delayM160
+ *
+ * @return float
+ */
+ public function getDelayM160()
+ {
+ return $this->delayM160;
+ }
+
+ /**
+ * Set lossInHour
+ *
+ * @param \DateTime $lossInHour
+ * @return Performance
+ */
+ public function setLossInHour($lossInHour)
+ {
+ $this->lossInHour = $lossInHour;
+
+ return $this;
+ }
+
+ /**
+ * Get lossInHour
+ *
+ * @return \DateTime
+ */
+ public function getLossInHour()
+ {
+ return $this->lossInHour;
+ }
+
+ /**
+ * Set lossInPeak
+ *
+ * @param float $lossInPeak
+ * @return Performance
+ */
+ public function setLossInPeak($lossInPeak)
+ {
+ $this->lossInPeak = $lossInPeak;
+
+ return $this;
+ }
+
+ /**
+ * Get lossInPeak
+ *
+ * @return float
+ */
+ public function getLossInPeak()
+ {
+ return $this->lossInPeak;
+ }
+
+ /**
+ * Set lossOutHour
+ *
+ * @param \DateTime $lossOutHour
+ * @return Performance
+ */
+ public function setLossOutHour($lossOutHour)
+ {
+ $this->lossOutHour = $lossOutHour;
+
+ return $this;
+ }
+
+ /**
+ * Get lossOutHour
+ *
+ * @return \DateTime
+ */
+ public function getLossOutHour()
+ {
+ return $this->lossOutHour;
+ }
+
+ /**
+ * Set lossOutPeak
+ *
+ * @param float $lossOutPeak
+ * @return Performance
+ */
+ public function setLossOutPeak($lossOutPeak)
+ {
+ $this->lossOutPeak = $lossOutPeak;
+
+ return $this;
+ }
+
+ /**
+ * Get lossOutPeak
+ *
+ * @return float
+ */
+ public function getLossOutPeak()
+ {
+ return $this->lossOutPeak;
+ }
+
+ /**
+ * Set lossOut36
+ *
+ * @param float $lossOut36
+ * @return Performance
+ */
+ public function setLossOut36($lossOut36)
+ {
+ $this->lossOut36 = $lossOut36;
+
+ return $this;
+ }
+
+ /**
+ * Get lossOut36
+ *
+ * @return float
+ */
+ public function getLossOut36()
+ {
+ return $this->lossOut36;
+ }
+
+ /**
+ * Set lossInt36
+ *
+ * @param float $lossInt36
+ * @return Performance
+ */
+ public function setLossInt36($lossInt36)
+ {
+ $this->lossInt36 = $lossInt36;
+
+ return $this;
+ }
+
+ /**
+ * Get lossInt36
+ *
+ * @return float
+ */
+ public function getLossInt36()
+ {
+ return $this->lossInt36;
+ }
+
+ /**
+ * Set lossOutM6
+ *
+ * @param float $lossOutM6
+ * @return Performance
+ */
+ public function setLossOutM6($lossOutM6)
+ {
+ $this->lossOutM6 = $lossOutM6;
+
+ return $this;
+ }
+
+ /**
+ * Get lossOutM6
+ *
+ * @return float
+ */
+ public function getLossOutM6()
+ {
+ return $this->lossOutM6;
+ }
+
+ /**
+ * Set lossInM6
+ *
+ * @param float $lossInM6
+ * @return Performance
+ */
+ public function setLossInM6($lossInM6)
+ {
+ $this->lossInM6 = $lossInM6;
+
+ return $this;
+ }
+
+ /**
+ * Get lossInM6
+ *
+ * @return float
+ */
+ public function getLossInM6()
+ {
+ return $this->lossInM6;
+ }
+
+ /**
+ * Set congestIn1030
+ *
+ * @param float $congestIn1030
+ * @return Performance
+ */
+ public function setCongestIn1030($congestIn1030)
+ {
+ $this->congestIn1030 = $congestIn1030;
+
+ return $this;
+ }
+
+ /**
+ * Get congestIn1030
+ *
+ * @return float
+ */
+ public function getCongestIn1030()
+ {
+ return $this->congestIn1030;
+ }
+
+ /**
+ * Set congestInM30
+ *
+ * @param float $congestInM30
+ * @return Performance
+ */
+ public function setCongestInM30($congestInM30)
+ {
+ $this->congestInM30 = $congestInM30;
+
+ return $this;
+ }
+
+ /**
+ * Get congestInM30
+ *
+ * @return float
+ */
+ public function getCongestInM30()
+ {
+ return $this->congestInM30;
+ }
+
+ /**
+ * Set congestOut1030
+ *
+ * @param float $congestOut1030
+ * @return Performance
+ */
+ public function setCongestOut1030($congestOut1030)
+ {
+ $this->congestOut1030 = $congestOut1030;
+
+ return $this;
+ }
+
+ /**
+ * Get congestOut1030
+ *
+ * @return float
+ */
+ public function getCongestOut1030()
+ {
+ return $this->congestOut1030;
+ }
+
+ /**
+ * Set congestOutM30
+ *
+ * @param float $congestOutM30
+ * @return Performance
+ */
+ public function setCongestOutM30($congestOutM30)
+ {
+ $this->congestOutM30 = $congestOutM30;
+
+ return $this;
+ }
+
+ /**
+ * Get congestOutM30
+ *
+ * @return float
+ */
+ public function getCongestOutM30()
+ {
+ return $this->congestOutM30;
+ }
+
+ /**
+ * Set hmmHourIn
+ *
+ * @param \DateTime $hmmHourIn
+ * @return Performance
+ */
+ public function setHmmHourIn($hmmHourIn)
+ {
+ $this->hmmHourIn = $hmmHourIn;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmHourIn
+ *
+ * @return \DateTime
+ */
+ public function getHmmHourIn()
+ {
+ return $this->hmmHourIn;
+ }
+
+ /**
+ * Set hmmHourOut
+ *
+ * @param \DateTime $hmmHourOut
+ * @return Performance
+ */
+ public function setHmmHourOut($hmmHourOut)
+ {
+ $this->hmmHourOut = $hmmHourOut;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmHourOut
+ *
+ * @return \DateTime
+ */
+ public function getHmmHourOut()
+ {
+ return $this->hmmHourOut;
+ }
+
+ /**
+ * Set hmmPeakIn
+ *
+ * @param integer $hmmPeakIn
+ * @return Performance
+ */
+ public function setHmmPeakIn($hmmPeakIn)
+ {
+ $this->hmmPeakIn = $hmmPeakIn;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmPeakIn
+ *
+ * @return integer
+ */
+ public function getHmmPeakIn()
+ {
+ return $this->hmmPeakIn;
+ }
+
+ /**
+ * Set hmmPeakOut
+ *
+ * @param integer $hmmPeakOut
+ * @return Performance
+ */
+ public function setHmmPeakOut($hmmPeakOut)
+ {
+ $this->hmmPeakOut = $hmmPeakOut;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmPeakOut
+ *
+ * @return integer
+ */
+ public function getHmmPeakOut()
+ {
+ return $this->hmmPeakOut;
+ }
+
+ /**
+ * Set hmmMediaIn
+ *
+ * @param integer $hmmMediaIn
+ * @return Performance
+ */
+ public function setHmmMediaIn($hmmMediaIn)
+ {
+ $this->hmmMediaIn = $hmmMediaIn;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmMediaIn
+ *
+ * @return integer
+ */
+ public function getHmmMediaIn()
+ {
+ return $this->hmmMediaIn;
+ }
+
+ /**
+ * Set hmmMediaOut
+ *
+ * @param integer $hmmMediaOut
+ * @return Performance
+ */
+ public function setHmmMediaOut($hmmMediaOut)
+ {
+ $this->hmmMediaOut = $hmmMediaOut;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmMediaOut
+ *
+ * @return integer
+ */
+ public function getHmmMediaOut()
+ {
+ return $this->hmmMediaOut;
+ }
+
+ /**
+ * Set hmmCriticalityIn
+ *
+ * @param float $hmmCriticalityIn
+ * @return Performance
+ */
+ public function setHmmCriticalityIn($hmmCriticalityIn)
+ {
+ $this->hmmCriticalityIn = $hmmCriticalityIn;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmCriticalityIn
+ *
+ * @return float
+ */
+ public function getHmmCriticalityIn()
+ {
+ return $this->hmmCriticalityIn;
+ }
+
+ /**
+ * Set hmmCriticalityOut
+ *
+ * @param float $hmmCriticalityOut
+ * @return Performance
+ */
+ public function setHmmCriticalityOut($hmmCriticalityOut)
+ {
+ $this->hmmCriticalityOut = $hmmCriticalityOut;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmCriticalityOut
+ *
+ * @return float
+ */
+ public function getHmmCriticalityOut()
+ {
+ return $this->hmmCriticalityOut;
+ }
+
+ /**
+ * Set hmmHourInPer
+ *
+ * @param integer $hmmHourInPer
+ * @return Performance
+ */
+ public function setHmmHourInPer($hmmHourInPer)
+ {
+ $this->hmmHourInPer = $hmmHourInPer;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmHourInPer
+ *
+ * @return integer
+ */
+ public function getHmmHourInPer()
+ {
+ return $this->hmmHourInPer;
+ }
+
+ /**
+ * Set hmmHourOutPer
+ *
+ * @param \DateTime $hmmHourOutPer
+ * @return Performance
+ */
+ public function setHmmHourOutPer($hmmHourOutPer)
+ {
+ $this->hmmHourOutPer = $hmmHourOutPer;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmHourOutPer
+ *
+ * @return \DateTime
+ */
+ public function getHmmHourOutPer()
+ {
+ return $this->hmmHourOutPer;
+ }
+
+ /**
+ * Set hmmPeakInPer
+ *
+ * @param integer $hmmPeakInPer
+ * @return Performance
+ */
+ public function setHmmPeakInPer($hmmPeakInPer)
+ {
+ $this->hmmPeakInPer = $hmmPeakInPer;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmPeakInPer
+ *
+ * @return integer
+ */
+ public function getHmmPeakInPer()
+ {
+ return $this->hmmPeakInPer;
+ }
+
+ /**
+ * Set hmmPeakOutPer
+ *
+ * @param integer $hmmPeakOutPer
+ * @return Performance
+ */
+ public function setHmmPeakOutPer($hmmPeakOutPer)
+ {
+ $this->hmmPeakOutPer = $hmmPeakOutPer;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmPeakOutPer
+ *
+ * @return integer
+ */
+ public function getHmmPeakOutPer()
+ {
+ return $this->hmmPeakOutPer;
+ }
+
+ /**
+ * Set hmmMediaInPer
+ *
+ * @param integer $hmmMediaInPer
+ * @return Performance
+ */
+ public function setHmmMediaInPer($hmmMediaInPer)
+ {
+ $this->hmmMediaInPer = $hmmMediaInPer;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmMediaInPer
+ *
+ * @return integer
+ */
+ public function getHmmMediaInPer()
+ {
+ return $this->hmmMediaInPer;
+ }
+
+ /**
+ * Set hmmMediaOutPer
+ *
+ * @param integer $hmmMediaOutPer
+ * @return Performance
+ */
+ public function setHmmMediaOutPer($hmmMediaOutPer)
+ {
+ $this->hmmMediaOutPer = $hmmMediaOutPer;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmMediaOutPer
+ *
+ * @return integer
+ */
+ public function getHmmMediaOutPer()
+ {
+ return $this->hmmMediaOutPer;
+ }
+
+ /**
+ * Set hmmCriticalityInPer
+ *
+ * @param float $hmmCriticalityInPer
+ * @return Performance
+ */
+ public function setHmmCriticalityInPer($hmmCriticalityInPer)
+ {
+ $this->hmmCriticalityInPer = $hmmCriticalityInPer;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmCriticalityInPer
+ *
+ * @return float
+ */
+ public function getHmmCriticalityInPer()
+ {
+ return $this->hmmCriticalityInPer;
+ }
+
+ /**
+ * Set hmmCriticalityOutPer
+ *
+ * @param float $hmmCriticalityOutPer
+ * @return Performance
+ */
+ public function setHmmCriticalityOutPer($hmmCriticalityOutPer)
+ {
+ $this->hmmCriticalityOutPer = $hmmCriticalityOutPer;
+
+ return $this;
+ }
+
+ /**
+ * Get hmmCriticalityOutPer
+ *
+ * @return float
+ */
+ public function getHmmCriticalityOutPer()
+ {
+ return $this->hmmCriticalityOutPer;
+ }
+
+ /**
+ * Set 719PeakInt
+ *
+ * @param integer $719PeakInt
+ * @return Performance
+ */
+ public function set719PeakIn($_719PeakIn)
+ {
+ $this->_719PeakIn = $_719PeakIn;
+
+ return $this;
+ }
+
+ /**
+ * Get 719PeakInt
+ *
+ * @return integer
+ */
+ public function get719PeakIn()
+ {
+ return $this->_719PeakIn;
+ }
+
+ /**
+ * Set 719PeakOut
+ *
+ * @param integer $719PeakOut
+ * @return Performance
+ */
+ public function set719PeakOut($_719PeakOut)
+ {
+ $this->_719PeakOut = $_719PeakOut;
+
+ return $this;
+ }
+
+ /**
+ * Get 719PeakOut
+ *
+ * @return integer
+ */
+ public function get719PeakOut()
+ {
+ return $this->_719PeakOut;
+ }
+
+ /**
+ * Set 719MediaIn
+ *
+ * @param integer $719MediaIn
+ * @return Performance
+ */
+ public function set719MediaIn($_719MediaIn)
+ {
+ $this->_719MediaIn = $_719MediaIn;
+
+ return $this;
+ }
+
+ /**
+ * Get 719MediaIn
+ *
+ * @return integer
+ */
+ public function get719MediaIn()
+ {
+ return $this->_719MediaIn;
+ }
+
+ /**
+ * Set 719MediaOut
+ *
+ * @param integer $719MediaOut
+ * @return Performance
+ */
+ public function set719MediaOut($_719MediaOut)
+ {
+ $this->_719MediaOut = $_719MediaOut;
+
+ return $this;
+ }
+
+ /**
+ * Get 719MediaOut
+ *
+ * @return integer
+ */
+ public function get719MediaOut()
+ {
+ return $this->_719MediaOut;
+ }
+
+ /**
+ * Set 719CriticalityIn
+ *
+ * @param float $719CriticalityIn
+ * @return Performance
+ */
+ public function set719CriticalityIn($_719CriticalityIn)
+ {
+ $this->_719CriticalityIn = $_719CriticalityIn;
+
+ return $this;
+ }
+
+ /**
+ * Get 719CriticalityIn
+ *
+ * @return float
+ */
+ public function get719CriticalityIn()
+ {
+ return $this->_719CriticalityIn;
+ }
+
+ /**
+ * Set 719CriticalityOut
+ *
+ * @param float $719CriticalityOut
+ * @return Performance
+ */
+ public function set719CriticalityOut($_719CriticalityOut)
+ {
+ $this->_719CriticalityOut = $_719CriticalityOut;
+
+ return $this;
+ }
+
+ /**
+ * Get 719CriticalityOut
+ *
+ * @return float
+ */
+ public function get719CriticalityOut()
+ {
+ return $this->_719CriticalityOut;
+ }
+}
diff --git a/Entity/DailyPerformanceRepository.php b/Entity/DailyPerformanceRepository.php
new file mode 100755
index 0000000..412346c
--- /dev/null
+++ b/Entity/DailyPerformanceRepository.php
@@ -0,0 +1,15 @@
+circuits = new ArrayCollection();
+ }
+
+ /**
+ * Get id
+ *
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Set identifier
+ *
+ * @param string $identifier
+ * @return Entity
+ */
+ public function setIdentifier($identifier)
+ {
+ $this->identifier = $identifier;
+
+ return $this;
+ }
+
+ /**
+ * Get identifier
+ *
+ * @return string
+ */
+ public function getIdentifier()
+ {
+ return $this->identifier;
+ }
+
+ /**
+ * Set description
+ *
+ * @param string $description
+ * @return Entity
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+
+ return $this;
+ }
+
+ /**
+ * Get description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Add circuits
+ *
+ * @param \Cocar\CocarBundle\Entity\Circuits $circuits
+ * @return Entity
+ */
+ public function addCircuit(\GerenciadorRedes\Bundle\CocarBundle\Entity\Circuits $circuits)
+ {
+ $this->circuits[] = $circuits;
+
+ return $this;
+ }
+
+ /**
+ * Remove circuits
+ *
+ * @param \Cocar\CocarBundle\Entity\Circuits $circuits
+ */
+ public function removeCircuit(\GerenciadorRedes\Bundle\CocarBundle\Entity\Circuits $circuits)
+ {
+ $this->circuits->removeElement($circuits);
+ }
+
+ /**
+ * Get circuits
+ *
+ * @return \Doctrine\Common\Collections\Collection
+ */
+ public function getCircuits()
+ {
+ return $this->circuits;
+ }
+}
\ No newline at end of file
diff --git a/Entity/Machine.php b/Entity/Machine.php
new file mode 100755
index 0000000..b31e397
--- /dev/null
+++ b/Entity/Machine.php
@@ -0,0 +1,244 @@
+path = $path;
+
+ return $this;
+ }
+
+ /**
+ * Get path
+ *
+ * @return string
+ */
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ /**
+ * Sets file.
+ *
+ * @param UploadedFile $file
+ */
+ public function setFile(UploadedFile $file = null)
+ {
+ $this->file = $file;
+ }
+
+ /**
+ * Get file.
+ *
+ * @return UploadedFile
+ */
+ public function getFile()
+ {
+ return $this->file;
+ }
+
+ public function getAbsolutePath()
+ {
+ return null === $this->path
+ ? null
+ : $this->getUploadRootDir().'/'.$this->path;
+ }
+
+ public function getWebPath()
+ {
+ return null === $this->path
+ ? null
+ : $this->getUploadDir().'/'.$this->path;
+ }
+
+ protected function getUploadRootDir()
+ {
+ // the absolute directory path where uploaded
+ // documents should be saved
+ return __DIR__.'/../../../../web/'.$this->getUploadDir();
+ }
+
+ protected function getUploadDir()
+ {
+ // get rid of the __DIR__ so it doesn't screw up
+ // when displaying uploaded doc/image in the view.
+ return 'uploads/documents';
+ }
+
+ /**
+ * @ORM\PrePersist()
+ * @ORM\PreUpdate()
+ */
+ public function preUpload()
+ {
+ if (null !== $this->file) {
+ $filename = sha1(uniqid(mt_rand(), true));
+ $this->path = $filename.'.'.$this->getFile()->guessExtension();
+ }
+ }
+
+ /**
+ * @ORM\PostPersist()
+ * @ORM\PostUpdate()
+ */
+ public function upload()
+ {
+ if (null === $this->file) {
+ return;
+ }
+
+ $this->file->move($this->getUploadRootDir(), $this->path);
+
+ unset($this->file);
+ }
+
+ /**
+ * @ORM\PostRemove()
+ */
+ public function removeUpload()
+ {
+ if ($file = $this->getAbsolutePath()) {
+ unlink($file);
+ }
+ }
+
+ /**
+ * Get id
+ *
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Set ip
+ *
+ * @param string $ip
+ * @return Machine
+ */
+ public function setIp($ip)
+ {
+ $this->ip = $ip;
+
+ return $this;
+ }
+
+ /**
+ * Get ip
+ *
+ * @return string
+ */
+ public function getIp()
+ {
+ return $this->ip;
+ }
+
+ /**
+ * Set macAddress
+ *
+ * @param string $macAddress
+ * @return Machine
+ */
+ public function setMacAddress($macAddress)
+ {
+ $this->macAddress = $macAddress;
+
+ return $this;
+ }
+
+ /**
+ * Get macAddress
+ *
+ * @return string
+ */
+ public function getMacAddress()
+ {
+ return $this->macAddress;
+ }
+
+ /**
+ * Set gateway
+ *
+ * @param \Cocar\CocarBundle\Entity\Circuits $gateway
+ * @return Circuits
+ */
+ public function setGateway(\GerenciadorRedes\Bundle\CocarBundle\Entity\Circuits $gateway = null)
+ {
+ $this->gateway = $gateway;
+
+ return $this;
+ }
+
+ /**
+ * Get gateway
+ *
+ * @return \GerenciadorRedes\Bundle\CocarBundle\Entity\Circuits
+ */
+ public function getGateway()
+ {
+ return $this->gateway;
+ }
+}
diff --git a/Entity/MachineRepository.php b/Entity/MachineRepository.php
new file mode 100755
index 0000000..4c9a68b
--- /dev/null
+++ b/Entity/MachineRepository.php
@@ -0,0 +1,15 @@
+id;
+ }
+
+ /**
+ * Set date
+ *
+ * @param \DateTime $date
+ * @return MonthlyPerformance
+ */
+ public function setDate($date)
+ {
+ $this->date = $date;
+
+ return $this;
+ }
+
+ /**
+ * Get date
+ *
+ * @return \DateTime
+ */
+ public function getDate()
+ {
+ return $this->date;
+ }
+
+ /**
+ * Set codeInterface
+ *
+ * @param integer $codeInterface
+ * @return MonthlyPerformance
+ */
+ public function setCodeInterface($codeInterface)
+ {
+ $this->codeInterface = $codeInterface;
+
+ return $this;
+ }
+
+ /**
+ * Get codeInterface
+ *
+ * @return integer
+ */
+ public function getCodeInterface()
+ {
+ return $this->codeInterface;
+ }
+
+ /**
+ * Set use2050In
+ *
+ * @param float $use2050In
+ * @return MonthlyPerformance
+ */
+ public function setUse2050In($use2050In)
+ {
+ $this->use2050In = $use2050In;
+
+ return $this;
+ }
+
+ /**
+ * Get use2050In
+ *
+ * @return float
+ */
+ public function getUse2050In()
+ {
+ return $this->use2050In;
+ }
+
+ /**
+ * Set use5085In
+ *
+ * @param float $use5085In
+ * @return MonthlyPerformance
+ */
+ public function setUse5085In($use5085In)
+ {
+ $this->use5085In = $use5085In;
+
+ return $this;
+ }
+
+ /**
+ * Get use5085In
+ *
+ * @return float
+ */
+ public function getUse5085In()
+ {
+ return $this->use5085In;
+ }
+
+ /**
+ * Set useM85In
+ *
+ * @param float $useM85In
+ * @return MonthlyPerformance
+ */
+ public function setUseM85In($useM85In)
+ {
+ $this->useM85In = $useM85In;
+
+ return $this;
+ }
+
+ /**
+ * Get useM85In
+ *
+ * @return float
+ */
+ public function getUseM85In()
+ {
+ return $this->useM85In;
+ }
+
+ /**
+ * Set use2050Out
+ *
+ * @param float $use2050Out
+ * @return MonthlyPerformance
+ */
+ public function setUse2050Out($use2050Out)
+ {
+ $this->use2050Out = $use2050Out;
+
+ return $this;
+ }
+
+ /**
+ * Get use2050Out
+ *
+ * @return float
+ */
+ public function getUse2050Out()
+ {
+ return $this->use2050Out;
+ }
+
+ /**
+ * Set use5085Out
+ *
+ * @param float $use5085Out
+ * @return MonthlyPerformance
+ */
+ public function setUse5085Out($use5085Out)
+ {
+ $this->use5085Out = $use5085Out;
+
+ return $this;
+ }
+
+ /**
+ * Get use5085Out
+ *
+ * @return float
+ */
+ public function getUse5085Out()
+ {
+ return $this->use5085Out;
+ }
+
+ /**
+ * Set useM85Out
+ *
+ * @param float $useM85Out
+ * @return MonthlyPerformance
+ */
+ public function setUseM85Out($useM85Out)
+ {
+ $this->useM85Out = $useM85Out;
+
+ return $this;
+ }
+
+ /**
+ * Get useM85Out
+ *
+ * @return float
+ */
+ public function getUseM85Out()
+ {
+ return $this->useM85Out;
+ }
+
+ /**
+ * Set volumeIn
+ *
+ * @param float $volumeIn
+ * @return MonthlyPerformance
+ */
+ public function setVolumeIn($volumeIn)
+ {
+ $this->volumeIn = $volumeIn;
+
+ return $this;
+ }
+
+ /**
+ * Get volumeIn
+ *
+ * @return float
+ */
+ public function getVolumeIn()
+ {
+ return $this->volumeIn;
+ }
+
+ /**
+ * Set volumeOut
+ *
+ * @param float $volumeOut
+ * @return MonthlyPerformance
+ */
+ public function setVolumeOut($volumeOut)
+ {
+ $this->volumeOut = $volumeOut;
+
+ return $this;
+ }
+
+ /**
+ * Get volumeOut
+ *
+ * @return float
+ */
+ public function getVolumeOut()
+ {
+ return $this->volumeOut;
+ }
+
+ /**
+ * Set cirIn
+ *
+ * @param integer $cirIn
+ * @return MonthlyPerformance
+ */
+ public function setCirIn($cirIn)
+ {
+ $this->cirIn = $cirIn;
+
+ return $this;
+ }
+
+ /**
+ * Get cirIn
+ *
+ * @return integer
+ */
+ public function getCirIn()
+ {
+ return $this->cirIn;
+ }
+
+ /**
+ * Set cirOut
+ *
+ * @param integer $cirOut
+ * @return MonthlyPerformance
+ */
+ public function setCirOut($cirOut)
+ {
+ $this->cirOut = $cirOut;
+
+ return $this;
+ }
+
+ /**
+ * Get cirOut
+ *
+ * @return integer
+ */
+ public function getCirOut()
+ {
+ return $this->cirOut;
+ }
+
+ /**
+ * Set cirInRec
+ *
+ * @param integer $cirInRec
+ * @return MonthlyPerformance
+ */
+ public function setCirInRec($cirInRec)
+ {
+ $this->cirInRec = $cirInRec;
+
+ return $this;
+ }
+
+ /**
+ * Get cirInRec
+ *
+ * @return integer
+ */
+ public function getCirInRec()
+ {
+ return $this->cirInRec;
+ }
+
+ /**
+ * Set cirOutRec
+ *
+ * @param integer $cirOutRec
+ * @return MonthlyPerformance
+ */
+ public function setCirOutRec($cirOutRec)
+ {
+ $this->cirOutRec = $cirOutRec;
+
+ return $this;
+ }
+
+ /**
+ * Get cirOutRec
+ *
+ * @return integer
+ */
+ public function getCirOutRec()
+ {
+ return $this->cirOutRec;
+ }
+}
diff --git a/Entity/MonthlyPerformanceRepository.php b/Entity/MonthlyPerformanceRepository.php
new file mode 100755
index 0000000..2047dcc
--- /dev/null
+++ b/Entity/MonthlyPerformanceRepository.php
@@ -0,0 +1,15 @@
+id;
+ }
+
+ /**
+ * Set codeInterface
+ *
+ * @param string $codeInterface
+ * @return Reliability
+ */
+ public function setCodeInterface($codeInterface)
+ {
+ $this->codeInterface = $codeInterface;
+
+ return $this;
+ }
+
+ /**
+ * Get codeInterface
+ *
+ * @return string
+ */
+ public function getCodeInterface()
+ {
+ return $this->codeInterface;
+ }
+
+ /**
+ * Set date
+ *
+ * @param integer $date
+ * @return Reliability
+ */
+ public function setDate($date)
+ {
+ $this->date = $date;
+
+ return $this;
+ }
+
+ /**
+ * Get date
+ *
+ * @return integer
+ */
+ public function getDate()
+ {
+ return $this->date;
+ }
+
+ /**
+ * Set rly
+ *
+ * @param integer $rly
+ * @return Reliability
+ */
+ public function setRly($rly)
+ {
+ $this->rly = $rly;
+
+ return $this;
+ }
+
+ /**
+ * Get rly
+ *
+ * @return integer
+ */
+ public function getRly()
+ {
+ return $this->rly;
+ }
+}
\ No newline at end of file
diff --git a/Entity/ReliabilityRepository.php b/Entity/ReliabilityRepository.php
new file mode 100755
index 0000000..eeb8530
--- /dev/null
+++ b/Entity/ReliabilityRepository.php
@@ -0,0 +1,15 @@
+id;
+ }
+
+ /**
+ * Set datetime
+ *
+ * @param \DateTime $datetime
+ * @return Rrd
+ */
+ public function setDatetime($datetime)
+ {
+ $this->datetime = $datetime;
+
+ return $this;
+ }
+
+ /**
+ * Get datetime
+ *
+ * @return \DateTime
+ */
+ public function getDatetime()
+ {
+ return $this->datetime;
+ }
+
+ /**
+ * Set codeInterface
+ *
+ * @param integer $codeInterface
+ * @return Rrd
+ */
+ public function setCodeInterface($codeInterface)
+ {
+ $this->codeInterface = $codeInterface;
+
+ return $this;
+ }
+
+ /**
+ * Get codeInterface
+ *
+ * @return integer
+ */
+ public function getCodeInterface()
+ {
+ return $this->codeInterface;
+ }
+
+ /**
+ * Set volumeIn
+ *
+ * @param integer $volumeIn
+ * @return Rrd
+ */
+ public function setVolumeIn($volumeIn)
+ {
+ $this->volumeIn = $volumeIn;
+
+ return $this;
+ }
+
+ /**
+ * Get volumeIn
+ *
+ * @return integer
+ */
+ public function getVolumeIn()
+ {
+ return $this->volumeIn;
+ }
+
+ /**
+ * Set volumeOut
+ *
+ * @param integer $volumeOut
+ * @return Rrd
+ */
+ public function setVolumeOut($volumeOut)
+ {
+ $this->volumeOut = $volumeOut;
+
+ return $this;
+ }
+
+ /**
+ * Get volumeOut
+ *
+ * @return integer
+ */
+ public function getVolumeOut()
+ {
+ return $this->volumeOut;
+ }
+
+ /**
+ * Set dellay
+ *
+ * @param integer $dellay
+ * @return Rrd
+ */
+ public function setDellay($dellay)
+ {
+ $this->dellay = $dellay;
+
+ return $this;
+ }
+
+ /**
+ * Get dellay
+ *
+ * @return integer
+ */
+ public function getDellay()
+ {
+ return $this->dellay;
+ }
+
+ /**
+ * Set stDelay
+ *
+ * @param integer $stDelay
+ * @return Rrd
+ */
+ public function setStDelay($stDelay)
+ {
+ $this->stDelay = $stDelay;
+
+ return $this;
+ }
+
+ /**
+ * Get stDelay
+ *
+ * @return integer
+ */
+ public function getStDelay()
+ {
+ return $this->stDelay;
+ }
+}
diff --git a/Form/CircuitsType.php b/Form/CircuitsType.php
new file mode 100755
index 0000000..ab36ec7
--- /dev/null
+++ b/Form/CircuitsType.php
@@ -0,0 +1,67 @@
+add('codeInterface')
+ ->add('entity', 'entity',
+ array(
+ 'class' => 'CocarBundle:Entity',
+ 'property' => 'identifier'
+ )
+ )
+ ->add('description')
+ ->add('manages')
+ ->add('ipBackbone')
+ ->add('communitySnmpBackbone')
+ ->add('serialBackbone')
+ ->add('technology')
+ ->add('typeInterface', 'choice',
+ array(
+ 'choices' => array('circuito' => 'Circuito', 'porta' => 'Porta'),
+ 'expanded' => TRUE,
+ 'preferred_choices' => array('circuito'),
+ )
+ )
+ ->add('numSnmpInterface')
+ ->add('ipSerialInterface')
+ ->add('registerCircuit')
+ ->add('speed')
+ ->add('cirIn')
+ ->add('cirOut')
+ ->add('serialRouterTip')
+ ->add('snmpPortTip')
+ ->add('communitySnmpRouterTip')
+ ->add('ipSerialRouterTip');
+ }
+
+ /**
+ * @param OptionsResolverInterface $resolver
+ */
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'GerenciadorRedes\Bundle\CocarBundle\Entity\Circuits'
+ ));
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return 'cocar_cocarbundle_circuitstype';
+ }
+}
diff --git a/Form/EntityType.php b/Form/EntityType.php
new file mode 100755
index 0000000..70e993a
--- /dev/null
+++ b/Form/EntityType.php
@@ -0,0 +1,39 @@
+add('identifier')
+ ->add('description');
+ }
+
+ /**
+ * @param OptionsResolverInterface $resolver
+ */
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'GerenciadorRedes\Bundle\CocarBundle\Entity\Entity'
+ ));
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return 'cocar_cocarbundle_entitytype';
+ }
+}
diff --git a/LICENSE b/LICENSE
new file mode 100755
index 0000000..88a57f8
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2004-2013 Fabien Potencier
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100755
index 0000000..8b76998
--- /dev/null
+++ b/README.md
@@ -0,0 +1,89 @@
+Cocar
+===============
+
+Descrição: CocarBundle
+
+Pré-requisitos:
+===============
+ * Protocolo de gerência SNMP
+ * Sistema de Banco de dados RRDTool
+ * Agendador de tarefas cron
+
+ - Instalação: apt-get install snmp rrdtool php5-snmp php5-json php-gd libicu-dev
+
+Instalação:
+------------
+
+1 – Adicione a seguinte linha ao seu composer.json
+```js
+//composer.json
+{
+ //...
+
+ "require": {
+ //...
+ "jpgraph/jpgraph": "dev-master",
+ "symfony/class-loader": "2.2.*",
+ "incenteev/composer-parameter-handler": "~2.0",
+ "friendsofsymfony/rest-bundle": "dev-master",
+ "jms/serializer": "0.14.*@dev",
+ "jms/serializer-bundle": "0.13.*@dev",
+ "knplabs/knp-paginator-bundle": "dev-master",
+ "gerenciador-redes/cocar-bundle": "dev-master"
+ }
+
+ //...
+}
+```
+
+2 – Atualize o composer.
+
+ php composer.phar update
+
+3 - Adicione o CocarBundle ao seu AppKernel.php
+```php
+
+
+
+
+
+ Symfony2 is great
+ J'aime Symfony2
+
+
+
+
diff --git a/Resources/views/Circuits/edit.html.twig b/Resources/views/Circuits/edit.html.twig
new file mode 100755
index 0000000..9025d92
--- /dev/null
+++ b/Resources/views/Circuits/edit.html.twig
@@ -0,0 +1,110 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main -%}
+ {{ entity.description }}
+
+
+
+
+{% endblock %}
diff --git a/Resources/views/Circuits/index.html.twig b/Resources/views/Circuits/index.html.twig
new file mode 100755
index 0000000..dff35be
--- /dev/null
+++ b/Resources/views/Circuits/index.html.twig
@@ -0,0 +1,47 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main -%}
+ Circuitos cadastrados
+
+
+
+
+ Id
+ Codeinterface
+ Description
+ Manages
+ Ipbackbone
+ Ações
+
+
+
+ {% for entity in entities %}
+
+ {{ entity.id }}
+ {{ entity.codeInterface }}
+ {{ entity.description }}
+ {{ entity.manages }}
+ {{ entity.ipBackbone }}
+
+
+
+
+ {% endfor %}
+
+
+
+
+ {% endblock %}
diff --git a/Resources/views/Circuits/new.html.twig b/Resources/views/Circuits/new.html.twig
new file mode 100755
index 0000000..2d6ea38
--- /dev/null
+++ b/Resources/views/Circuits/new.html.twig
@@ -0,0 +1,118 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main -%}
+
+ Cadastro de Circuitos
+
+
+ Problemas ao cadastrar o circuito? Verifique a tabela de configurações ou faça o teste de snmp.
+
+
+ {% image '@CocarBundle/Resources/public/images/help_circuit.jpg' %}
+
+ {% endimage %}
+
+{% endblock %}
diff --git a/Resources/views/Circuits/show.html.twig b/Resources/views/Circuits/show.html.twig
new file mode 100755
index 0000000..3989c45
--- /dev/null
+++ b/Resources/views/Circuits/show.html.twig
@@ -0,0 +1,106 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main -%}
+ Circuitos
+
+
+
+
+ Id
+ {{ entity.id }}
+
+
+ Código da Interface
+ {{ entity.codeInterface }}
+
+
+ Descrição do circuito
+ {{ entity.description }}
+
+
+ Gerencia
+ {{ entity.manages }}
+
+
+ IP roteador backbone
+ {{ entity.ipBackbone }}
+
+
+ Community snmp do roteador backbone
+ {{ entity.communitySnmpBackbone }}
+
+
+ Serial no roteador backbone
+ {{ entity.serialBackbone }}
+
+
+ Tecnologia
+ {{ entity.technology }}
+
+
+ Tipo da interface
+ {{ entity.typeInterface }}
+
+
+ Número SNMP da interface
+ {{ entity.numSnmpInterface }}
+
+
+ IP da serial da Interface
+ {{ entity.ipSerialInterface }}
+
+
+ Cadastro do circuito
+ {{ entity.registerCircuit }}
+
+
+ Velocidade
+ {{ entity.speed }}
+
+
+ CIR In
+ {{ entity.cirIn }}
+
+
+ CIR Out
+ {{ entity.cirOut }}
+
+
+ Serial no roteador da ponta
+ {{ entity.serialRouterTip }}
+
+
+ Identificação SNMP da porta na ponta
+ {{ entity.snmpPortTip }}
+
+
+ Community SNMP do roteador da ponta
+ {{ entity.communitySnmpRouterTip }}
+
+
+ IP da serial do roteador da ponta
+ {{ entity.ipSerialRouterTip }}
+
+
+
+
+
+{% endblock %}
diff --git a/Resources/views/Default/index.html.twig b/Resources/views/Default/index.html.twig
new file mode 100755
index 0000000..10ddd6d
--- /dev/null
+++ b/Resources/views/Default/index.html.twig
@@ -0,0 +1 @@
+Hello!
diff --git a/Resources/views/Default/map.html.twig b/Resources/views/Default/map.html.twig
new file mode 100755
index 0000000..3addef3
--- /dev/null
+++ b/Resources/views/Default/map.html.twig
@@ -0,0 +1,112 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block search %}
+ {% if search_result is defined %}
+ {% for result in search_result %}
+
+
+
+ {% image '@CocarBundle/Resources/public/images/boxverde_e.gif' %}
+
+ {% endimage %}
+
+ {% image '@CocarBundle/Resources/public/images/boxverde_m.gif' %}
+
+ /{{ result.identifier }}
+
+ {% endimage %}
+ {% image '@CocarBundle/Resources/public/images/boxverde_d.gif' %}
+
+
+
+ {% endimage %}
+
+
+
+
+ {% endfor %}
+ {% if search_result == null and search == true %}
+
+ Nenhum resultado encontrado
+
+ {% endif %}
+ {% endif %}
+{% endblock %}
+
+{% block main %}
+
+
+
+
+
+ Total de Unidades com Alerta de Tráfego Irregular {{ (high_traffic|length + without_traffic|length) + reliability|length}} de {{ total }}
+
+
+
+
+ Tráfego Alto
+ Tráfego Baixo
+ Confiabilidade
+
+
+ {{ high_traffic|length }}
+ {{ without_traffic|length }}
+ {{ reliability|length }}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/Resources/views/Default/totalizer.html.twig b/Resources/views/Default/totalizer.html.twig
new file mode 100755
index 0000000..3779b89
--- /dev/null
+++ b/Resources/views/Default/totalizer.html.twig
@@ -0,0 +1,40 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main %}
+
+ Totalização de Desempenho
+
+
+
+ Organização
+ Tráfego Alto
+ Tráfego Baixo
+ Confiabilidade
+ Total
+
+ {% if circuits is defined %}
+ {% set total, t, high, without, rly = 0, 0, 0, 0, 0 %}
+ {% for key, cir in circuits %}
+
+
+ {{ cir.description }}
+
+ {{ cir.high }}
+ {{ cir.without }}
+ {{ cir.rly }}
+ {{ cir.totalCirc }}/{{ cir.total }}
+
+ {% set total, t = total + cir.total, t + cir.totalCirc %}
+ {% set high, without, rly = high + cir.high, without + cir.without, rly + cir.rly %}
+ {% endfor %}
+ {% endif %}
+
+ TOTAL
+ {{ high }}
+ {{ without }}
+ {{ rly }}
+ {{ t }}/{{ total }}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/Resources/views/Entity/edit.html.twig b/Resources/views/Entity/edit.html.twig
new file mode 100755
index 0000000..bdb2a9b
--- /dev/null
+++ b/Resources/views/Entity/edit.html.twig
@@ -0,0 +1,41 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main -%}
+ {{ entity.description }}
+
+
+
+
+{% endblock %}
diff --git a/Resources/views/Entity/index.html.twig b/Resources/views/Entity/index.html.twig
new file mode 100755
index 0000000..43ec958
--- /dev/null
+++ b/Resources/views/Entity/index.html.twig
@@ -0,0 +1,43 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main -%}
+ Entidades cadastradas
+
+
+
+
+ Id
+ Identificador
+ Descrição
+ Ações
+
+
+
+ {% for entity in entities %}
+
+ {{ entity.id }}
+ {{ entity.identifier }}
+ {{ entity.description }}
+
+
+
+
+ {% endfor %}
+
+
+
+
+ {% endblock %}
diff --git a/Resources/views/Entity/new.html.twig b/Resources/views/Entity/new.html.twig
new file mode 100755
index 0000000..90e8819
--- /dev/null
+++ b/Resources/views/Entity/new.html.twig
@@ -0,0 +1,40 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main -%}
+
+ Cadastro de Entidades
+
+
+
+{% endblock %}
diff --git a/Resources/views/Entity/show.html.twig b/Resources/views/Entity/show.html.twig
new file mode 100755
index 0000000..905d1aa
--- /dev/null
+++ b/Resources/views/Entity/show.html.twig
@@ -0,0 +1,42 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main -%}
+ Entidade
+
+
+
+
+ Id
+ {{ entity.id }}
+
+
+ Identificador
+ {{ entity.identifier }}
+
+
+ Descrição
+ {{ entity.description }}
+
+
+
+
+
+{% endblock %}
diff --git a/Resources/views/Graph/graph.html.twig b/Resources/views/Graph/graph.html.twig
new file mode 100755
index 0000000..3e04af1
--- /dev/null
+++ b/Resources/views/Graph/graph.html.twig
@@ -0,0 +1,58 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main %}
+
+
+
+
+ wlan0
+ Porta: 1024 KB
+ Cir In: 512 KB
+ Cir Out: 512 KB
+
+
+
+
+
+ {% if img is defined %}
+
+ {% for image in img %}
+
+ {% endfor %}
+
+
+ {{ knp_pagination_render(img, "CocarBundle::pagination.html.twig") }}
+
+ {% endif %}
+{% endblock %}
\ No newline at end of file
diff --git a/Resources/views/Graph/graphDailyPerfom.html.twig b/Resources/views/Graph/graphDailyPerfom.html.twig
new file mode 100755
index 0000000..fe32852
--- /dev/null
+++ b/Resources/views/Graph/graphDailyPerfom.html.twig
@@ -0,0 +1,11 @@
+{% extends '::base.html.twig' %}
+
+{% block body -%}
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/Resources/views/Graph/graphTraffic.html.twig b/Resources/views/Graph/graphTraffic.html.twig
new file mode 100755
index 0000000..fe32852
--- /dev/null
+++ b/Resources/views/Graph/graphTraffic.html.twig
@@ -0,0 +1,11 @@
+{% extends '::base.html.twig' %}
+
+{% block body -%}
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/Resources/views/Graph/report.html.twig b/Resources/views/Graph/report.html.twig
new file mode 100755
index 0000000..8edf0e5
--- /dev/null
+++ b/Resources/views/Graph/report.html.twig
@@ -0,0 +1,80 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main %}
+
+
+
+ Rede de Acesso - Performance dos Circuitos
+
+
+
+
+ {% if img is defined %}
+
+
+
+ {% if type is defined %}
+ {{ type }}
+ {% endif %}
+
+
+ {% image '@CocarBundle/Resources/public/images/help1.gif' %}
+
+ {% endimage %}
+
+
+ {% image '@CocarBundle/Resources/public/images/tabela.jpg' %}
+
+ {% endimage %}
+
+
+
+
+
+
+
+ {% for image in img %}
+
+
+
+ {% endfor %}
+
+
+ {% endif %}
+{% endblock %}
\ No newline at end of file
diff --git a/Resources/views/SnmpWeb/snmp.html.twig b/Resources/views/SnmpWeb/snmp.html.twig
new file mode 100755
index 0000000..54fbb19
--- /dev/null
+++ b/Resources/views/SnmpWeb/snmp.html.twig
@@ -0,0 +1,29 @@
+{% extends 'CocarBundle::layout.html.twig' %}
+
+{% block main %}
+
+
+
+
+ Teste SNMP
+
+
+
+
+
+
+
+
+
+ Ex.: [HOST = 127.0.0.1 / COMMUNITY = public]
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/Resources/views/base.html.twig b/Resources/views/base.html.twig
new file mode 100755
index 0000000..4bad672
--- /dev/null
+++ b/Resources/views/base.html.twig
@@ -0,0 +1,11 @@
+{% extends '::base.html.twig' %}
+
+{% block title 'Cocar' %}
+
+{% block stylesheets %}
+ {% stylesheets filter='cssrewrite'
+ 'bundles/cocar/css/*'
+ %}
+
+ {% endstylesheets %}
+{% endblock %}
\ No newline at end of file
diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig
new file mode 100755
index 0000000..5fe1d2e
--- /dev/null
+++ b/Resources/views/layout.html.twig
@@ -0,0 +1,127 @@
+{% extends 'CocarBundle::base.html.twig' %}
+
+{% block body -%}
+
+
+ COCAR: Controlador Centralizado do Ambiente de Rede
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% image '@CocarBundle/Resources/public/images/boxverde_e.gif' %}
+
+ {% endimage %}
+ {% image '@CocarBundle/Resources/public/images/boxverde_m.gif' %}
+ Buscar
+ {% endimage %}
+ {% image '@CocarBundle/Resources/public/images/boxverde_d.gif' %}
+
+ {% endimage %}
+
+
+
+
+ {% block search %}{% endblock %}
+
+
+
+
+
+
+ Digite o Nome da Unidade desejada.
+
+
+
+
+
+
+
+ {% block main %}{% endblock %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/Resources/views/pagination.html.twig b/Resources/views/pagination.html.twig
new file mode 100755
index 0000000..fc85ce8
--- /dev/null
+++ b/Resources/views/pagination.html.twig
@@ -0,0 +1,68 @@
+ {% if pageCount > 1 %}
+
+{% endif %}
\ No newline at end of file
diff --git a/Tests/Controller/CircuitsControllerTest.php b/Tests/Controller/CircuitsControllerTest.php
new file mode 100755
index 0000000..b059392
--- /dev/null
+++ b/Tests/Controller/CircuitsControllerTest.php
@@ -0,0 +1,55 @@
+request('GET', '/circuits/');
+ $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /circuits/");
+ $crawler = $client->click($crawler->selectLink('Create a new entry')->link());
+
+ // Fill in the form and submit it
+ $form = $crawler->selectButton('Create')->form(array(
+ 'cocar_cocarbundle_circuitstype[field_name]' => 'Test',
+ // ... other fields to fill
+ ));
+
+ $client->submit($form);
+ $crawler = $client->followRedirect();
+
+ // Check data in the show view
+ $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")');
+
+ // Edit the entity
+ $crawler = $client->click($crawler->selectLink('Edit')->link());
+
+ $form = $crawler->selectButton('Edit')->form(array(
+ 'cocar_cocarbundle_circuitstype[field_name]' => 'Foo',
+ // ... other fields to fill
+ ));
+
+ $client->submit($form);
+ $crawler = $client->followRedirect();
+
+ // Check the element contains an attribute with value equals "Foo"
+ $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]');
+
+ // Delete the entity
+ $client->submit($crawler->selectButton('Delete')->form());
+ $crawler = $client->followRedirect();
+
+ // Check the entity has been delete on the list
+ $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent());
+ }
+
+ */
+}
diff --git a/Tests/Controller/DefaultControllerTest.php b/Tests/Controller/DefaultControllerTest.php
new file mode 100755
index 0000000..3a05888
--- /dev/null
+++ b/Tests/Controller/DefaultControllerTest.php
@@ -0,0 +1,17 @@
+request('GET', '/hello/Fabien');
+
+ $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
+ }
+}
diff --git a/Tests/Controller/EntityControllerTest.php b/Tests/Controller/EntityControllerTest.php
new file mode 100755
index 0000000..3c52394
--- /dev/null
+++ b/Tests/Controller/EntityControllerTest.php
@@ -0,0 +1,55 @@
+request('GET', '/entity/');
+ $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /entity/");
+ $crawler = $client->click($crawler->selectLink('Create a new entry')->link());
+
+ // Fill in the form and submit it
+ $form = $crawler->selectButton('Create')->form(array(
+ 'cocar_cocarbundle_entitytype[field_name]' => 'Test',
+ // ... other fields to fill
+ ));
+
+ $client->submit($form);
+ $crawler = $client->followRedirect();
+
+ // Check data in the show view
+ $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")');
+
+ // Edit the entity
+ $crawler = $client->click($crawler->selectLink('Edit')->link());
+
+ $form = $crawler->selectButton('Edit')->form(array(
+ 'cocar_cocarbundle_entitytype[field_name]' => 'Foo',
+ // ... other fields to fill
+ ));
+
+ $client->submit($form);
+ $crawler = $client->followRedirect();
+
+ // Check the element contains an attribute with value equals "Foo"
+ $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]');
+
+ // Delete the entity
+ $client->submit($crawler->selectButton('Delete')->form());
+ $crawler = $client->followRedirect();
+
+ // Check the entity has been delete on the list
+ $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent());
+ }
+
+ */
+}
diff --git a/UPGRADE-2.2.md b/UPGRADE-2.2.md
new file mode 100755
index 0000000..cad9eeb
--- /dev/null
+++ b/UPGRADE-2.2.md
@@ -0,0 +1,30 @@
+UPGRADE FROM 2.1 to 2.2
+=======================
+
+ * The [`web/.htaccess`](https://github.com/symfony/symfony-standard/blob/2.2/web/.htaccess)
+ file has been enhanced substantially to prevent duplicate content with and
+ without `/app.php` in the URI. It also improves functionality when using
+ Apache aliases or when mod_rewrite is not available. So you might want to
+ update your `.htaccess` file as well.
+
+ * The ``_internal`` route is not used any more. It should then be removed
+ from both your routing and security configurations. A ``fragments`` key has
+ been added to the framework configuration and must be specified when ESI or
+ Hinclude are in use. No security configuration is required for this path as
+ by default ESI access is only permitted for trusted hosts and Hinclude
+ access uses an URL signing mechanism.
+
+ ```
+ framework:
+ # ...
+ fragments: { path: /_proxy }
+ ```
+
+Functional Tests
+----------------
+
+ * The profiler has been disabled by default in the test environment. You can
+ enable it again by modifying the ``config_test.yml`` configuration file or
+ even better, you can just enable it for the very next request by calling
+ ``$client->enableProfiler()`` when you need the profiler in a test (that
+ speeds up functional tests quite a bit).
diff --git a/UPGRADE-2.3.md b/UPGRADE-2.3.md
new file mode 100755
index 0000000..eb4b3ec
--- /dev/null
+++ b/UPGRADE-2.3.md
@@ -0,0 +1,52 @@
+UPGRADE FROM 2.2 to 2.3
+=======================
+
+When upgrading Symfony from 2.2 to 2.3, you need to do the following changes
+to the code that came from the Standard Edition:
+
+ * The debugging tools are not enabled by default anymore and should be added
+ to the
+ [`web/app_dev.php`](https://github.com/symfony/symfony-standard/blob/2.3/web/app_dev.php)
+ front controller manually, just after including the bootstrap cache:
+
+ use Symfony\Component\Debug\Debug;
+
+ Debug::enable();
+
+ You also need to enable debugging in the
+ [`app/console`](https://github.com/symfony/symfony-standard/blob/2.3/app/console)
+ script, after the `$debug` variable is defined:
+
+ use Symfony\Component\Debug\Debug;
+
+ if ($debug) {
+ Debug::enable();
+ }
+
+ * The `parameters.yml` file can now be managed by the
+ `incenteev/composer-parameter-handler` bundle that comes with the 2.3
+ Standard Edition:
+
+ * add `"incenteev/composer-parameter-handler": "~2.0"` to your
+ `composer.json` file;
+
+ * add `/app/config/parameters.yml` to your `.gitignore` file;
+
+ * create a
+ [`app/config/parameters.yml.dist`](https://github.com/symfony/symfony-standard/blob/2.3/app/config/parameters.yml.dist)
+ file with sensible values for all your parameters.
+
+ * It is highly recommended that you switch the minimum stability to `stable`
+ in your `composer.json` file.
+
+ * If you are using Apache, have a look at the new
+ [`.htaccess`](https://github.com/symfony/symfony-standard/blob/2.3/web/.htaccess)
+ configuration and change yours accordingly.
+
+ * In the
+ [`app/autoload.php`](https://github.com/symfony/symfony-standard/blob/2.3/app/autoload.php)
+ file, the section about `intl` should be removed as it is not needed anymore.
+
+You can also have a look at the
+[diff](https://github.com/symfony/symfony-standard/compare/v2.2.0%E2%80%A62.3)
+between the 2.2 version of the Standard Edition and the 2.3 version.
diff --git a/UPGRADE.md b/UPGRADE.md
new file mode 100755
index 0000000..504367f
--- /dev/null
+++ b/UPGRADE.md
@@ -0,0 +1,268 @@
+Symfony Standard Edition Upgrade
+================================
+
+From Symfony 2.0 to Symfony 2.1
+-------------------------------
+
+### Project Dependencies
+
+As of Symfony 2.1, project dependencies are managed by
+[Composer](http://getcomposer.org/):
+
+* The `bin/vendors` script can be removed as `composer.phar` does all the work
+ now (it is recommended to install it globally on your machine).
+
+* The `deps` file need to be replaced with the `composer.json` one.
+
+* The `composer.lock` is the equivalent of the generated `deps.lock` file and
+ it is automatically generated by Composer.
+
+Download the default
+[`composer.json`](https://raw.github.com/symfony/symfony-standard/2.1/composer.json)
+and
+[`composer.lock`](https://raw.github.com/symfony/symfony-standard/2.1/composer.lock)
+files for Symfony 2.1 and put them into the main directory of your project. If
+you have customized your `deps` file, move the added dependencies to the
+`composer.json` file (many bundles and PHP libraries are already available as
+Composer packages -- search for them on [Packagist](http://packagist.org/)).
+
+Remove your current `vendor` directory.
+
+Finally, run Composer:
+
+ $ composer.phar install
+
+Note: You must complete the upgrade steps below so composer can successfully generate the autoload files.
+
+### `app/autoload.php`
+
+The default `autoload.php` reads as follows (it has been simplified a lot as
+autoloading for libraries and bundles declared in your `composer.json` file is
+automatically managed by the Composer autoloader):
+
+ add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
+ }
+
+ AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
+
+ return $loader;
+
+### `app/config/config.yml`
+
+The `framework.charset` setting must be removed. If you are not using `UTF-8`
+for your application, override the `getCharset()` method in your `AppKernel`
+class instead:
+
+ class AppKernel extends Kernel
+ {
+ public function getCharset()
+ {
+ return 'ISO-8859-1';
+ }
+
+ // ...
+ }
+
+You might want to add the new `strict_requirements` parameter to
+`framework.router` (it avoids fatal errors in the production environment when
+a link cannot be generated):
+
+ framework:
+ router:
+ strict_requirements: %kernel.debug%
+
+You can even disable the requirements check on production with `null` as you should
+know that the parameters for URL generation always pass the requirements, e.g. by
+validating them beforehand. This additionally enhances performance. See
+[config_prod.yml](https://github.com/symfony/symfony-standard/blob/master/app/config/config_prod.yml).
+
+The `default_locale` parameter is now a setting of the main `framework`
+configuration (it was under the `framework.session` in 2.0):
+
+ framework:
+ default_locale: %locale%
+
+The `auto_start` setting under `framework.session` must be removed as it is
+not used anymore (the session is now always started on-demand). If
+`auto_start` was the only setting under the `framework.session` entry, don't
+remove it entirely, but set its value to `~` (`~` means `null` in YAML)
+instead:
+
+ framework:
+ session: ~
+
+The `trust_proxy_headers` setting was added in the default configuration file
+(as it should be set to `true` when you install your application behind a
+reverse proxy):
+
+ framework:
+ trust_proxy_headers: false
+
+An empty `bundles` entry was added to the `assetic` configuration:
+
+ assetic:
+ bundles: []
+
+The default `swiftmailer` configuration now has the `spool` setting configured
+to the `memory` type to defer email sending after the response is sent to the
+user (recommended for better end-user performance):
+
+ swiftmailer:
+ spool: { type: memory }
+
+The `jms_security_extra` configuration was moved to the `security.yml`
+configuration file.
+
+### `app/config/config_dev.yml`
+
+An example of how to send all emails to a unique address was added:
+
+ #swiftmailer:
+ # delivery_address: me@example.com
+
+### `app/config/config_test.yml`
+
+The `storage_id` setting must be changed to `session.storage.mock_file`:
+
+ framework:
+ session:
+ storage_id: session.storage.mock_file
+
+### `app/config/parameters.ini`
+
+The file has been converted to a YAML file which reads as follows:
+
+ parameters:
+ database_driver: pdo_mysql
+ database_host: localhost
+ database_port: ~
+ database_name: symfony
+ database_user: root
+ database_password: ~
+
+ mailer_transport: smtp
+ mailer_host: localhost
+ mailer_user: ~
+ mailer_password: ~
+
+ locale: en
+ secret: ThisTokenIsNotSoSecretChangeIt
+
+Note that if you convert your parameters file to YAML, you must also change
+its reference in `app/config/config.yml`.
+
+### `app/config/routing_dev.yml`
+
+The `_assetic` entry was removed:
+
+ #_assetic:
+ # resource: .
+ # type: assetic
+
+### `app/config/security.yml`
+
+Under `security.access_control`, the default rule for internal routes was changed:
+
+ security:
+ access_control:
+ #- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
+
+Under `security.providers`, the `in_memory` example was updated to the following:
+
+ security:
+ providers:
+ in_memory:
+ memory:
+ users:
+ user: { password: userpass, roles: [ 'ROLE_USER' ] }
+ admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
+
+### `app/AppKernel.php`
+
+The following bundles have been added to the list of default registered bundles:
+
+ new JMS\AopBundle\JMSAopBundle(),
+ new JMS\DiExtraBundle\JMSDiExtraBundle($this),
+
+You must also rename the DoctrineBundle from:
+
+ new Symfony\Bundle\DoctrineBundle\DoctrineBundle(),
+
+to:
+
+ new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
+
+### `web/app.php`
+
+The default `web/app.php` file now reads as follows:
+
+ register(true);
+ */
+
+ require_once __DIR__.'/../app/AppKernel.php';
+ //require_once __DIR__.'/../app/AppCache.php';
+
+ $kernel = new AppKernel('prod', false);
+ $kernel->loadClassCache();
+ //$kernel = new AppCache($kernel);
+ $request = Request::createFromGlobals();
+ $response = $kernel->handle($request);
+ $response->send();
+ $kernel->terminate($request, $response);
+
+### `web/app_dev.php`
+
+The default `web/app_dev.php` file now reads as follows:
+
+ loadClassCache();
+ $request = Request::createFromGlobals();
+ $response = $kernel->handle($request);
+ $response->send();
+ $kernel->terminate($request, $response);
diff --git a/autoload.php b/autoload.php
new file mode 100755
index 0000000..ab2a3ca
--- /dev/null
+++ b/autoload.php
@@ -0,0 +1,15 @@
+useIncludePath(true);
+
+// ... register namespaces and prefixes here - see below
+
+$loader->registerNamespace('Jpgraph', __DIR__.'/vendor/jpgraph/jpgraph/lib/JpGraph/src');
+
+$loader->register();
diff --git a/composer.json b/composer.json
new file mode 100755
index 0000000..a44fc07
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,63 @@
+{
+ "name": "gerenciador-redes/cocar-bundle",
+ "version": "1.0",
+ "license": "MIT",
+ "type": "project",
+ "description": "The \"Symfony Standard Edition\" distribution",
+ "autoload": {
+ "psr-0": { "GerenciadorRedes\\Bundle\\CocarBundle": "" }
+ },
+ "target-dir": "GerenciadorRedes/Bundle/CocarBundle",
+ "require": {
+ "php": ">=5.3.3",
+ "symfony/symfony": "2.2.*",
+ "doctrine/orm": "~2.2,>=2.2.3",
+ "doctrine/doctrine-bundle": "1.2.*",
+ "twig/extensions": "1.0.*",
+ "symfony/assetic-bundle": "2.1.*",
+ "symfony/swiftmailer-bundle": "2.2.*",
+ "symfony/monolog-bundle": "2.2.*",
+ "sensio/distribution-bundle": "2.2.*",
+ "sensio/framework-extra-bundle": "2.2.*",
+ "sensio/generator-bundle": "2.2.*",
+ "jms/security-extra-bundle": "1.4.*",
+ "jms/di-extra-bundle": "1.3.*",
+ "jpgraph/jpgraph": "dev-master",
+ "symfony/class-loader": "2.2.*",
+ "incenteev/composer-parameter-handler": "~2.0",
+ "friendsofsymfony/rest-bundle": "dev-master",
+ "jms/serializer": "0.14.*@dev",
+ "jms/serializer-bundle": "0.13.*@dev",
+ "knplabs/knp-paginator-bundle": "dev-master"
+ },
+ "scripts": {
+ "post-install-cmd": [
+ "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
+ ],
+ "post-update-cmd": [
+ "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
+ "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
+ ]
+ },
+ "config": {
+ "bin-dir": "bin"
+ },
+ "minimum-stability": "stable",
+ "extra": {
+ "symfony-app-dir": "app",
+ "symfony-web-dir": "web",
+ "incenteev-parameters": {
+ "file": "app/config/parameters.yml"
+ },
+ "branch-alias": {
+ "dev-master": "2.3-dev"
+ }
+ }
+}
diff --git a/schedules.txt b/schedules.txt
new file mode 100755
index 0000000..b2f6ce8
--- /dev/null
+++ b/schedules.txt
@@ -0,0 +1,8 @@
+30 06 * * * php /var/www/cocar/app/console perform:task --graphdailyperform
+0 06 * * * php /var/www/cocar/app/console perform:task --rrdlog
+0 5 * * * php /var/www/cocar/app/console perform:task --dailyperform
+*/5 * * * * php /var/www/cocar/app/console perform:task --reliability
+0,5,10,15,20,25,30,35,40,45,50,55 7-19 * * * php /var/www/projeto-cocar/app/console perform:task --generatealarm
+0 20 * * * php /var/www/cocar/app/console perform:task --endalarm
+1,6,11,16,21,26,31,36,41,46,51,56 7-19 * * * php /var/www/projeto-cocar/app/console perform:task --status
+* * * * * php /var/www/cocar/app/console perform:task --monitor
--
libgit2 0.21.2