1--TEST-- 2Function snmpget 3--CREDITS-- 4Olivier Doucet & Boris Lytochkin 5--SKIPIF-- 6<?php 7require_once(__DIR__.'/skipif.inc'); 8?> 9--FILE-- 10<?php 11require_once(__DIR__.'/snmp_include.inc'); 12 13//EXPECTF format is quickprint OFF 14snmp_set_quick_print(false); 15snmp_set_valueretrieval(SNMP_VALUE_PLAIN); 16 17echo "Checking working\n"; 18echo "Single OID, default timeout and retries\n"; 19var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0')); 20echo "Single OID, default retries\n"; 21var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout)); 22echo "Single OID\n"; 23var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); 24echo "Single OID in array\n"; 25var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries)); 26echo "Multiple OID\n"; 27var_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)); 28 29echo "More error handling\n"; 30echo "Single OID\n"; 31var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1..1.1.0', $timeout, $retries)); 32echo "Single OID in array\n"; 33var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1...1.1.0'), $timeout, $retries)); 34echo "Multiple OID\n"; 35var_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)); 36 37echo "noSuchName checks\n"; 38echo "Single OID\n"; 39var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.110', $timeout, $retries)); 40echo "Single OID in array\n"; 41var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.110'), $timeout, $retries)); 42echo "Multiple OID\n"; 43var_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)); 44 45 46?> 47--EXPECTF-- 48Checking working 49Single OID, default timeout and retries 50string(%d) "%s" 51Single OID, default retries 52string(%d) "%s" 53Single OID 54string(%d) "%s" 55Single OID in array 56array(1) { 57 ["%s"]=> 58 string(%d) "%s" 59} 60Multiple OID 61array(2) { 62 ["%s"]=> 63 string(%d) "%s" 64 ["%s"]=> 65 string(%d) "%d" 66} 67More error handling 68Single OID 69 70Warning: snmpget(): Invalid object identifier: .1.3.6.1.2.1..1.1.0 in %s on line %d 71bool(false) 72Single OID in array 73 74Warning: snmpget(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d 75bool(false) 76Multiple OID 77 78Warning: snmpget(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d 79bool(false) 80noSuchName checks 81Single OID 82 83Warning: snmpget(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d 84bool(false) 85Single OID in array 86 87Warning: snmpget(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d 88bool(false) 89Multiple OID 90 91Warning: snmpget(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d 92array(1) { 93 ["%s"]=> 94 string(%d) "%s" 95} 96