xref: /PHP-5.4/ext/snmp/tests/snmpget.phpt (revision 4f100503)
1--TEST--
2Function snmpget
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(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', ''));
19var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, ''));
20
21echo "Checking working\n";
22echo "Single OID, default timeout and retries\n";
23var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0'));
24echo "Single OID, default retries\n";
25var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout));
26echo "Single OID\n";
27var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
28echo "Single OID in array\n";
29var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries));
30echo "Multiple OID\n";
31var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
32
33echo "More error handling\n";
34echo "Single OID\n";
35var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1..1.1.0', $timeout, $retries));
36echo "Single OID in array\n";
37var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1...1.1.0'), $timeout, $retries));
38echo "Multiple OID\n";
39var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1...1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
40
41echo "noSuchName checks\n";
42echo "Single OID\n";
43var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.110', $timeout, $retries));
44echo "Single OID in array\n";
45var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.110'), $timeout, $retries));
46echo "Multiple OID\n";
47var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.220'), $timeout, $retries));
48
49
50?>
51--EXPECTF--
52Checking error handling
53
54Warning: snmpget() expects parameter 4 to be long,%s given in %s on line %d
55bool(false)
56
57Warning: snmpget() expects parameter 5 to be long,%s given in %s on line %d
58bool(false)
59Checking working
60Single OID, default timeout and retries
61%unicode|string%(%d) "%s"
62Single OID, default retries
63%unicode|string%(%d) "%s"
64Single OID
65%unicode|string%(%d) "%s"
66Single OID in array
67array(1) {
68  ["%s"]=>
69  %unicode|string%(%d) "%s"
70}
71Multiple OID
72array(2) {
73  ["%s"]=>
74  %unicode|string%(%d) "%s"
75  ["%s"]=>
76  %unicode|string%(%d) "%d"
77}
78More error handling
79Single OID
80
81Warning: snmpget(): Invalid object identifier: .1.3.6.1.2.1..1.1.0 in %s on line %d
82bool(false)
83Single OID in array
84
85Warning: snmpget(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d
86bool(false)
87Multiple OID
88
89Warning: snmpget(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d
90bool(false)
91noSuchName checks
92Single OID
93
94Warning: snmpget(): Error in packet at 'SNMPv2-MIB::sysDescr.110': (noSuchName) There is no such variable name in this MIB. in %s on line %d
95bool(false)
96Single OID in array
97
98Warning: snmpget(): Error in packet at 'SNMPv2-MIB::sysDescr.110': (noSuchName) There is no such variable name in this MIB. in %s on line %d
99bool(false)
100Multiple OID
101
102Warning: snmpget(): Error in packet at 'SNMPv2-MIB::sysUpTime.220': (noSuchName) There is no such variable name in this MIB. in %s on line %d
103array(1) {
104  ["%s"]=>
105  %unicode|string%(%d) "%s"
106}
107