1--TEST-- 2Function snmp2_real_walk 3--CREDITS-- 4Olivier Doucet Olivier 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_real_walk($hostname, $community, '.1.3.6.1.2.1.1', '')); 19var_dump(snmp2_real_walk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, '')); 20 21echo "Checking working\n"; 22echo "Single OID\n"; 23$return = snmp2_real_walk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, $retries); 24var_dump(gettype($return)); 25var_dump(sizeof($return)); 26var_dump(key($return)); 27var_dump(array_shift($return)); 28 29echo "Single OID in array\n"; 30$return = snmp2_real_walk($hostname, $community, array('.1.3.6.1.2.1.1'), $timeout, $retries); 31var_dump(gettype($return)); 32var_dump(sizeof($return)); 33var_dump(key($return)); 34var_dump(array_shift($return)); 35 36echo "More error handling\n"; 37echo "Multiple correct OID\n"; 38$return = snmp2_real_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6'), $timeout, $retries); 39var_dump($return); 40 41echo "Multiple OID with wrong OID\n"; 42$return = snmp2_real_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6...1'), $timeout, $retries); 43var_dump($return); 44$return = snmp2_real_walk($hostname, $community, array('.1.3.6...1', '.1.3.6.1.2.1.1'), $timeout, $retries); 45var_dump($return); 46 47echo "Single nonexisting OID\n"; 48$return = snmp2_real_walk($hostname, $community, array('.1.3.6.99999.0.99999.111'), $timeout, $retries); 49var_dump($return); 50 51?> 52--EXPECTF-- 53Checking error handling 54 55Warning: snmp2_real_walk() expects parameter 4 to be int, %s given in %s on line %d 56bool(false) 57 58Warning: snmp2_real_walk() expects parameter 5 to be int, %s given in %s on line %d 59bool(false) 60Checking working 61Single OID 62string(5) "array" 63int(%d) 64string(%d) "%s" 65string(%d) "%s" 66Single OID in array 67string(5) "array" 68int(%d) 69string(%d) "%s" 70string(%d) "%s" 71More error handling 72Multiple correct OID 73 74Warning: snmp2_real_walk(): Multi OID walks are not supported! in %s on line %d 75bool(false) 76Multiple OID with wrong OID 77 78Warning: snmp2_real_walk(): Multi OID walks are not supported! in %s on line %d 79bool(false) 80 81Warning: snmp2_real_walk(): Multi OID walks are not supported! in %s on line %d 82bool(false) 83Single nonexisting OID 84 85Warning: 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 86bool(false) 87