1--TEST-- 2Function snmp2_real_walk 3--CREDITS-- 4Olivier Doucet Olivier Doucet Boris Lytochkin 5--EXTENSIONS-- 6snmp 7--SKIPIF-- 8<?php 9require_once(__DIR__.'/skipif.inc'); 10?> 11--FILE-- 12<?php 13require_once(__DIR__.'/snmp_include.inc'); 14 15//EXPECTF format is quickprint OFF 16snmp_set_quick_print(false); 17snmp_set_valueretrieval(SNMP_VALUE_PLAIN); 18 19echo "Checking working\n"; 20echo "Single OID\n"; 21$return = snmp2_real_walk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, $retries); 22var_dump(gettype($return)); 23var_dump(sizeof($return)); 24var_dump(key($return)); 25var_dump(array_shift($return)); 26 27echo "Single OID in array\n"; 28$return = snmp2_real_walk($hostname, $community, array('.1.3.6.1.2.1.1'), $timeout, $retries); 29var_dump(gettype($return)); 30var_dump(sizeof($return)); 31var_dump(key($return)); 32var_dump(array_shift($return)); 33 34echo "More error handling\n"; 35echo "Multiple correct OID\n"; 36$return = snmp2_real_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6'), $timeout, $retries); 37var_dump($return); 38 39echo "Multiple OID with wrong OID\n"; 40$return = snmp2_real_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6...1'), $timeout, $retries); 41var_dump($return); 42$return = snmp2_real_walk($hostname, $community, array('.1.3.6...1', '.1.3.6.1.2.1.1'), $timeout, $retries); 43var_dump($return); 44 45echo "Single nonexisting OID\n"; 46$return = snmp2_real_walk($hostname, $community, array('.1.3.6.99999.0.99999.111'), $timeout, $retries); 47var_dump($return); 48 49?> 50--EXPECTF-- 51Checking working 52Single OID 53string(5) "array" 54int(%d) 55string(%d) "%s" 56string(%d) "%s" 57Single OID in array 58string(5) "array" 59int(%d) 60string(%d) "%s" 61string(%d) "%s" 62More error handling 63Multiple correct OID 64 65Warning: snmp2_real_walk(): Multi OID walks are not supported! in %s on line %d 66bool(false) 67Multiple OID with wrong OID 68 69Warning: snmp2_real_walk(): Multi OID walks are not supported! in %s on line %d 70bool(false) 71 72Warning: snmp2_real_walk(): Multi OID walks are not supported! in %s on line %d 73bool(false) 74Single nonexisting OID 75 76Warning: snmp2_real_walk(): Error in packet at '%s': No more variables left in this MIB View (It is past the end of the MIB tree) in %s on line %d 77bool(false) 78