SnmpWebController.php
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace Swpb\Bundle\CocarBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Swpb\Bundle\CocarBundle\Controller\SnmpController;
class SnmpWebController extends Controller
{
/**
* @Route("/infosnmp", name="cocar_infosnmp")
* @Method("POST")
* @Template()
*/
public function snmpInfoAction(Request $request)
{
$form = $this->snmpForm();
$form->bind($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')
->getForm();
}
}