From cf5a40a1bc3183b8f7295c0c9d73609702eddc72 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Wed, 11 Aug 2010 11:22:43 +0000 Subject: [PATCH] 2010-08-11 Sergio Martin * include/functions.php: Added a function to call snmpwalk functions setting the version, ip address, community... git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3126 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++++ pandora_console/include/functions.php | 41 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8e050c49b3..56311c48fe 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2010-08-11 Sergio Martin + + * include/functions.php: Added a function to call snmpwalk + functions setting the version, ip address, community... + 2010-08-11 Junichi Satoh * include/help/ja/help_network_map.php, diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index bc31ca230a..8fb904dd85 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1040,4 +1040,45 @@ function array_key_to_offset($array, $key) { return $offset; } + +/** + * Make a snmpwalk and return it. + * + * @param string $ip_target The target address. + * @param string $snmp_version Version of the snmp: 1,2,2c or 3. + * @param string $snmp_community. + * @param string $snmp3_auth_user. + * @param string $snmp3_security_level. + * @param string $snmp3_auth_method. + * @param string $snmp3_auth_pass. + * @param string $snmp3_privacy_method. + * @param string $snmp3_privacy_pass. + * @param integer $quick_print 0 for all details, 1 for only value. + * + * @return array SNMP result. + */ +function snmpwalk_versions($ip_target, $snmp_version, $snmp_community = '', $snmp3_auth_user = '', + $snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '', + $snmp3_privacy_method = '', $snmp3_privacy_pass = '', $quick_print = 0) { + + snmp_set_quick_print ($quick_print); + + switch ($snmp_version) { + case '3': + $snmpwalk = @snmp3_real_walk ($ip_target, $snmp3_auth_user, + $snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass, + $snmp3_privacy_method, $snmp3_privacy_pass, null); + break; + case '2': + case '2c': + $snmpwalk = @snmp2_real_walk ($ip_target, $snmp_community, NULL); + break; + case '1': + default: + $snmpwalk = @snmprealwalk($ip_target, $snmp_community, null); + break; + } + + return $snmpwalk; +} ?>