Commit ffdf73eb8424c59892681f7e2233d9576c44b5f2
1 parent
877b9496
Exists in
master
and in
2 other branches
Adiciona debug explícito nas impressoras e mostra saída direta
Showing
1 changed file
with
9 additions
and
6 deletions
Show diff stats
Controller/PrinterController.php
... | ... | @@ -612,8 +612,8 @@ class PrinterController extends Controller |
612 | 612 | { |
613 | 613 | $n_printers = $this->em->createQuery('SELECT count(p) FROM CocarBundle:Printer p')->getSingleScalarResult(); |
614 | 614 | |
615 | - $limit = 1000; | |
616 | - $iterations = (int)($n_printers / 1000); | |
615 | + $limit = 500; | |
616 | + $iterations = (int)($n_printers / $limit); | |
617 | 617 | $iterations = $iterations + 1; |
618 | 618 | |
619 | 619 | $i = 0; |
... | ... | @@ -636,15 +636,16 @@ class PrinterController extends Controller |
636 | 636 | gc_enable(); |
637 | 637 | |
638 | 638 | $printers = $this->em |
639 | - ->createQuery('SELECT p FROM CocarBundle:Printer p ORDER BY p.id desc') | |
639 | + ->createQuery('SELECT p FROM CocarBundle:Printer p ORDER BY p.id') | |
640 | 640 | ->setMaxResults($limit) |
641 | 641 | ->setFirstResult($offset) |
642 | 642 | ->getResult(); |
643 | 643 | |
644 | 644 | //$printers = $this->em->getRepository('CocarBundle:Printer')->findAll(); |
645 | 645 | |
646 | - $this->get('logger')->info("Executando coleta de $limit impressoras começando no número $offset"); | |
646 | + echo "Executando coleta de $limit impressoras começando no número $offset\n"; | |
647 | 647 | |
648 | + $memory_start = memory_get_usage(); | |
648 | 649 | foreach($printers as $printer) |
649 | 650 | { |
650 | 651 | try |
... | ... | @@ -652,7 +653,7 @@ class PrinterController extends Controller |
652 | 653 | $community = $printer->getCommunitySnmpPrinter(); |
653 | 654 | $host = $printer->getHost(); |
654 | 655 | |
655 | - $this->get('logger')->info("Coletando impressora $host"); | |
656 | + $this->get('logger')->info("Coletando impressora $host | ID ".$printer->getId()); | |
656 | 657 | |
657 | 658 | $com = "snmpwalk -O qv -v 1 -c $community $host 1.3.6.1.2.1.43.10.2.1.4.1.1"; |
658 | 659 | |
... | ... | @@ -668,6 +669,9 @@ class PrinterController extends Controller |
668 | 669 | $this->get('logger')->error("Erro na coleta da impressora $host \n".$e->getMessage()); |
669 | 670 | } |
670 | 671 | } |
672 | + echo "$limit impressoras lidas iniciando em $offset \t -- Memory: " . round((memory_get_usage()-$memory_start)/1024/1024, 2) ." mb\n"; | |
673 | + | |
674 | + $this->em->flush(); | |
671 | 675 | } |
672 | 676 | |
673 | 677 | /** |
... | ... | @@ -696,7 +700,6 @@ class PrinterController extends Controller |
696 | 700 | $counter->setDate($time); |
697 | 701 | |
698 | 702 | $this->em->persist($counter); |
699 | - $this->em->flush(); | |
700 | 703 | } |
701 | 704 | catch(\Exception $e) |
702 | 705 | { | ... | ... |