1--TEST-- 2Function snmp_getvalue 3--CREDITS-- 4Boris 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); 17 18echo "Get with SNMP_VALUE_LIBRARY\n"; 19snmp_set_valueretrieval(SNMP_VALUE_LIBRARY); 20var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); 21 22echo "Get with SNMP_VALUE_PLAIN\n"; 23snmp_set_valueretrieval(SNMP_VALUE_PLAIN); 24var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); 25 26echo "Get with SNMP_VALUE_OBJECT\n"; 27snmp_set_valueretrieval(SNMP_VALUE_OBJECT); 28$z = snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries); 29echo gettype($z)."\n"; 30var_dump($z->type); 31var_dump($z->value); 32 33echo "Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN\n"; 34snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN); 35$z = snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries); 36echo gettype($z)."\n"; 37var_dump($z->type); 38var_dump($z->value); 39 40echo "Get with SNMP_VALUE_OBJECT for BITS OID\n"; 41snmp_set_valueretrieval(SNMP_VALUE_OBJECT); 42$z = snmpget($hostname, $community, '.1.3.6.1.2.1.88.1.4.2.1.3.6.95.115.110.109.112.100.95.108.105.110.107.68.111.119.110', $timeout, $retries); 43echo gettype($z)."\n"; 44var_dump($z->type); 45var_dump($z->value); 46 47echo "Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN for BITS OID\n"; 48snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN); 49$z = snmpget($hostname, $community, '.1.3.6.1.2.1.88.1.4.2.1.3.6.95.115.110.109.112.100.95.108.105.110.107.68.111.119.110', $timeout, $retries); 50echo gettype($z)."\n"; 51var_dump($z->type); 52var_dump(is_numeric($z->value)); 53var_dump(is_string($z->value)); 54var_dump(bin2hex($z->value)); 55 56echo "Check parsing of different OID types\n"; 57snmp_set_valueretrieval(SNMP_VALUE_PLAIN); 58var_dump(count(snmp2_walk($hostname, $community, '.', $timeout, $retries))); 59 60?> 61--EXPECTF-- 62Get with SNMP_VALUE_LIBRARY 63string(%d) "STRING: %s" 64Get with SNMP_VALUE_PLAIN 65string(%d) "%s" 66Get with SNMP_VALUE_OBJECT 67object 68int(4) 69string(%d) "STRING: %s" 70Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN 71object 72int(4) 73string(%d) "%s" 74Get with SNMP_VALUE_OBJECT for BITS OID 75object 76int(4) 77string(%d) "%s: %d %S" 78Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN for BITS OID 79object 80int(4) 81bool(false) 82bool(true) 83string(2) "%d" 84Check parsing of different OID types 85int(%d) 86