1--TEST-- 2OO API: Generic errors 3--CREDITS-- 4Boris 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 17try { 18var_dump(new SNMP(SNMP::VERSION_1, $hostname)); 19} catch (Exception $e) { 20 print $e->getMessage() . "\n"; 21} 22try { 23var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, '')); 24} catch (Exception $e) { 25 print $e->getMessage() . "\n"; 26} 27try { 28var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, '')); 29} catch (Exception $e) { 30 print $e->getMessage() . "\n"; 31} 32try { 33var_dump(new SNMP(7, $hostname, $community)); 34} catch (Exception $e) { 35 print $e->getMessage() . "\n"; 36} 37 38echo "Exception handling\n"; 39$session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries); 40try { 41 var_dump($session->get('.1.3.6.1.2.1.1.1..0')); 42} catch (SNMPException $e) { 43 var_dump($e->getCode()); 44 var_dump($e->getMessage()); 45} 46$session->exceptions_enabled = SNMP::ERRNO_ANY; 47try { 48 var_dump($session->get('.1.3.6.1.2.1.1.1..0')); 49} catch (SNMPException $e) { 50 var_dump($e->getCode()); 51 var_dump($e->getMessage()); 52} 53var_dump($session->close()); 54 55echo "Open normal session\n"; 56$session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries); 57$session->valueretrieval = 67; 58var_dump($session->valueretrieval); 59echo "Closing session\n"; 60var_dump($session->close('')); 61var_dump($session->close()); 62var_dump($session->get('.1.3.6.1.2.1.1.1.0')); 63var_dump($session->close()); 64 65$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries); 66var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, '')); 67var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, 30, '')); 68var_dump($session->get()); 69var_dump($session->getnext()); 70var_dump($session->set()); 71 72var_dump($session->max_oids); 73$session->max_oids = "ttt"; 74$session->max_oids = 0; 75var_dump($session->max_oids); 76?> 77--EXPECTF-- 78SNMP::__construct() expects at least 3 parameters, 2 given 79SNMP::__construct() expects parameter 4 to be long, string given 80SNMP::__construct() expects parameter 5 to be long, string given 81Unknown SNMP protocol version 82Exception handling 83 84Warning: SNMP::get(): Invalid object identifier: .1.3.6.1.2.1.1.1..0 in %s on line %d 85bool(false) 86int(32) 87string(46) "Invalid object identifier: .1.3.6.1.2.1.1.1..0" 88bool(true) 89Open normal session 90 91Warning: main(): Unknown SNMP value retrieval method '67' in %s on line %d 92int(%d) 93Closing session 94 95Warning: SNMP::close() expects exactly 0 parameters, 1 given in %s on line %d 96bool(false) 97bool(true) 98 99Warning: SNMP::get(): Invalid or uninitialized SNMP object in %s on line %d 100bool(false) 101bool(true) 102 103Warning: SNMP::walk() expects parameter 3 to be long, string given in %s on line %d 104bool(false) 105 106Warning: SNMP::walk() expects parameter 4 to be long, string given in %s on line %d 107bool(false) 108 109Warning: SNMP::get() expects at least 1 parameter, 0 given in %s on line %d 110bool(false) 111 112Warning: SNMP::getnext() expects exactly 1 parameter, 0 given in %s on line %d 113bool(false) 114 115Warning: SNMP::set() expects exactly 3 parameters, 0 given in %s on line %d 116bool(false) 117NULL 118 119Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d 120 121Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d 122NULL 123