xref: /PHP-7.0/ext/snmp/tests/snmp2_get.phpt (revision e5eb9530)
1--TEST--
2Function snmp2_get
3--CREDITS--
4Olivier Doucet & Boris Lytochkin
5--SKIPIF--
6<?php
7require_once(dirname(__FILE__).'/skipif.inc');
8?>
9--FILE--
10<?php
11require_once(dirname(__FILE__).'/snmp_include.inc');
12
13//EXPECTF format is quickprint OFF
14snmp_set_quick_print(false);
15snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
16
17echo "Checking error handling\n";
18var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.0', ''));
19var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, ''));
20echo "Empty OID array\n";
21var_dump(snmp2_get($hostname, $community, array(), $timeout, $retries));
22
23echo "Checking working\n";
24echo "Single OID\n";
25var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
26echo "Single OID in array\n";
27var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries));
28echo "Multiple OID\n";
29var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
30
31echo "More error handling\n";
32echo "Single OID\n";
33var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2..1.1.1.0', $timeout, $retries));
34echo "Single OID in array\n";
35var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1...1.1.0'), $timeout, $retries));
36echo "Multiple OID\n";
37var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1...1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
38
39echo "noSuchName checks\n";
40echo "Single OID\n";
41var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.110', $timeout, $retries));
42echo "Single OID in array\n";
43var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.110'), $timeout, $retries));
44echo "Multiple OID\n";
45var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.220'), $timeout, $retries));
46
47
48?>
49--EXPECTF--
50Checking error handling
51
52Warning: snmp2_get() expects parameter 4 to be integer,%s given in %s on line %d
53bool(false)
54
55Warning: snmp2_get() expects parameter 5 to be integer,%s given in %s on line %d
56bool(false)
57Empty OID array
58
59Warning: snmp2_get(): Got empty OID array in %s on line %d
60bool(false)
61Checking working
62Single OID
63%unicode|string%(%d) "%s"
64Single OID in array
65array(1) {
66  ["%s"]=>
67  %unicode|string%(%d) "%s"
68}
69Multiple OID
70array(2) {
71  ["%s"]=>
72  %unicode|string%(%d) "%s"
73  ["%s"]=>
74  %unicode|string%(%d) "%d"
75}
76More error handling
77Single OID
78
79Warning: snmp2_get(): Invalid object identifier: .1.3.6.1.2..1.1.1.0 in %s on line %d
80bool(false)
81Single OID in array
82
83Warning: snmp2_get(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d
84bool(false)
85Multiple OID
86
87Warning: snmp2_get(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d
88bool(false)
89noSuchName checks
90Single OID
91
92Warning: snmp2_get(): Error in packet at 'SNMPv2-MIB::sysDescr.110': No Such Instance currently exists at this OID in %s on line %d
93bool(false)
94Single OID in array
95
96Warning: snmp2_get(): Error in packet at 'SNMPv2-MIB::sysDescr.110': No Such Instance currently exists at this OID in %s on line %d
97bool(false)
98Multiple OID
99
100Warning: snmp2_get(): Error in packet at 'SNMPv2-MIB::sysUpTime.220': No Such Instance currently exists at this OID in %s on line %d
101array(1) {
102  ["%s"]=>
103  %unicode|string%(%d) "%s"
104}
105