1--TEST-- 2Function snmp_getvalue 3--CREDITS-- 4Boris Lytochkin 5--EXTENSIONS-- 6snmp 7--SKIPIF-- 8<?php 9require_once(__DIR__.'/skipif.inc'); 10if (PHP_OS_FAMILY === "Windows") die("xfail fails on Windows for unknown reasons"); 11?> 12--FILE-- 13<?php 14require_once(__DIR__.'/snmp_include.inc'); 15 16//EXPECTF format is quickprint OFF 17snmp_set_quick_print(false); 18 19echo "Get with SNMP_VALUE_LIBRARY\n"; 20snmp_set_valueretrieval(SNMP_VALUE_LIBRARY); 21var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); 22 23echo "Get with SNMP_VALUE_PLAIN\n"; 24snmp_set_valueretrieval(SNMP_VALUE_PLAIN); 25var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); 26 27echo "Get with SNMP_VALUE_OBJECT\n"; 28snmp_set_valueretrieval(SNMP_VALUE_OBJECT); 29$z = snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries); 30echo gettype($z)."\n"; 31var_dump($z->type); 32var_dump($z->value); 33 34echo "Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN\n"; 35snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN); 36$z = snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries); 37echo gettype($z)."\n"; 38var_dump($z->type); 39var_dump($z->value); 40 41echo "Get with SNMP_VALUE_OBJECT for BITS OID\n"; 42snmp_set_valueretrieval(SNMP_VALUE_OBJECT); 43$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); 44echo gettype($z)."\n"; 45var_dump($z->type); 46var_dump($z->value); 47 48echo "Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN for BITS OID\n"; 49snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN); 50$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); 51echo gettype($z)."\n"; 52var_dump($z->type); 53var_dump(is_numeric($z->value)); 54var_dump(is_string($z->value)); 55var_dump(bin2hex($z->value)); 56 57echo "Check parsing of different OID types\n"; 58snmp_set_valueretrieval(SNMP_VALUE_PLAIN); 59var_dump(count(snmp2_walk($hostname, $community, '.', $timeout, $retries))); 60 61?> 62--EXPECTF-- 63Get with SNMP_VALUE_LIBRARY 64string(%d) "STRING: %s" 65Get with SNMP_VALUE_PLAIN 66string(%d) "%s" 67Get with SNMP_VALUE_OBJECT 68object 69int(4) 70string(%d) "STRING: %s" 71Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN 72object 73int(4) 74string(%d) "%s" 75Get with SNMP_VALUE_OBJECT for BITS OID 76object 77int(4) 78string(%d) "%s: %d %S" 79Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN for BITS OID 80object 81int(4) 82bool(false) 83bool(true) 84string(2) "%d" 85Check parsing of different OID types 86int(%d) 87