diff --git a/config.php.default b/config.php.default index a5080f6e8c..6293ebd587 100755 --- a/config.php.default +++ b/config.php.default @@ -25,6 +25,9 @@ $config['log_file'] = $config['install_dir'] . "/observium.log"; ### Default community $config['snmp']['community'][] = "public"; +### Enable php_snmp +$config['snmp']['internal'] = false; # Enable php_snmp functions to make gets faster + ### Authentication Model $config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth #$config['http_auth_guest'] = "guest"; # remember to configure this user if you use http-auth diff --git a/database-update.sql b/database-update.sql index a5dbd60f98..6d2e8637a3 100644 --- a/database-update.sql +++ b/database-update.sql @@ -12,4 +12,5 @@ ALTER TABLE `mempools` CHANGE `mempool_index` `mempool_index` VARCHAR( 16 ) C ALTER TABLE `vrfs` CHANGE `mplsVpnVrfRouteDistinguisher` `mplsVpnVrfRouteDistinguisher` varchar(26) default NOT NULL; ## Change port rrds ALTER TABLE `devices` ADD `timeout` INT NULL DEFAULT NULL AFTER `port`; - +ALTER TABLE `devices` ADD `retries` INT NULL DEFAULT NULL AFTER `timeout`; +ALTER TABLE `perf_times` CHANGE `duration` `duration` DOUBLE( 8, 2 ) NOT NULL diff --git a/discovery.php b/discovery.php index 199ef03bb3..e4ffbfcd0f 100755 --- a/discovery.php +++ b/discovery.php @@ -111,7 +111,7 @@ if (file_exists('.svn')) } } -$devices_discovered = 0; +$discovered_devices = 0; $device_query = mysql_query("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC"); while ($device = mysql_fetch_array($device_query)) @@ -170,18 +170,18 @@ while ($device = mysql_fetch_array($device_query)) echo("Discovered in $device_time seconds\n"); unset($cache); // Clear cache (unify all things here?) - echo("\n"); $devices_discovered++; + echo("\n"); $discovered_devices++; } $end = utime(); $run = $end - $start; $proctime = substr($run, 0, 5); -if($devices_discovered) { +if($discovered_devices) { mysql_query("INSERT INTO `perf_times` (`type`, `doing`, `start`, `duration`, `devices`) - VALUES ('discover', '$doing', '$start', '$proctime', '$devices_discovered')"); + VALUES ('discover', '$doing', '$start', '$proctime', '$discovered_devices')"); } -$string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $polled_devices devices discovered in $proctime secs"; +$string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $discovered_devices devices discovered in $proctime secs"; if ($debug) echo("$string\n"); shell_exec("echo '".$string."' >> ".$config['log_file']); diff --git a/html/includes/device-edit.inc.php b/html/includes/device-edit.inc.php index 0dc9269af1..d27d81f8d3 100644 --- a/html/includes/device-edit.inc.php +++ b/html/includes/device-edit.inc.php @@ -7,11 +7,14 @@ $community = mres($_POST['community']); $snmpver = mres($_POST['snmpver']); $port = mres($_POST['port']); + $timeout = mres($_POST['timeout']); + $retries = mres($_POST['retries']); #FIXME needs more sanity checking! and better feedback $sql = "UPDATE `devices` SET `purpose` = '" . $descr . "', `community` = '" . $community . "', `type` = '$type'"; - $sql .= ", `snmpver` = '" . $snmpver . "', `ignore` = '$ignore', `disabled` = '$disabled', `port` = '$port' WHERE `device_id` = '".$device['device_id']."'"; + $sql .= ", `snmpver` = '" . $snmpver . "', `ignore` = '$ignore', `disabled` = '$disabled', `port` = '$port', "; + $sql .= "`timeout` = '$timeout', `retries` = '$retries' WHERE `device_id` = '".$device['device_id']."'"; $query = mysql_query($sql); $rows_updated = mysql_affected_rows(); diff --git a/html/includes/graphs/common.inc.php b/html/includes/graphs/common.inc.php index 88bad8373d..4121a405bd 100644 --- a/html/includes/graphs/common.inc.php +++ b/html/includes/graphs/common.inc.php @@ -22,5 +22,7 @@ if($_GET['bg']) { $rrd_options .= " -c CANVAS#" . mres($_GET['bg']) . " "; } if($height < "99") { $rrd_options .= " --only-graph"; } if($width <= "300") { $rrd_options .= " --font LEGEND:7:" . $config['mono_font'] . " --font AXIS:6:" . $config['mono_font']; } else { $rrd_options .= " --font LEGEND:8:" . $config['mono_font'] . " --font AXIS:7:" . $config['mono_font']; } +$rrd_options .= " --font-render-mode normal"; + ?> diff --git a/html/includes/hostbox.inc b/html/includes/hostbox.inc index 97406f2cfa..74a0becef8 100644 --- a/html/includes/hostbox.inc +++ b/html/includes/hostbox.inc @@ -14,11 +14,22 @@ if ($device['os'] == "ios") { formatCiscoHardware($device, true); } $device['os_text'] = $config['os'][$device['os']]['text']; + $port_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."'"),0); + $sensor_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = '".$device['device_id']."'"),0); + echo('
SNMP Timeout |
+ + seconds + | +||
SNMP Retries |
+ + | +||
diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 1b58d55604..487a1654e4 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -35,6 +35,7 @@ if(isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["SERVER_PORT"])) { $config['title_image'] = "images/observium-logo.png"; $config['stylesheet'] = "css/styles.css"; $config['mono_font'] = "DejaVuSansMono"; +#$config['mono_font'] = "LiberationMono"; $config['favicon'] = "images/observium-icon.png"; $config['header_color'] = "#1F334E"; $config['page_refresh'] = "300"; ## Refresh the page every xx seconds @@ -60,6 +61,7 @@ $config['ports_page_default'] = "details/"; ## eg "details/" "graphs/bits/" $config['snmp']['timeout'] = 1; # timeout in seconds $config['snmp']['retries'] = 5; # how many times to retry the query $config['snmp']['community'][] = "public"; # Communities to try during discovery (dangerous) +$config['snmp']['internal'] = false; # Enable php_snmp functions to make gets faster ### Autodiscovery Settings @@ -221,5 +223,4 @@ $config['astext'][65333] = "Cymru Bogon Feed"; ### What should we warn about? $config['warn']['ifdown'] = false; - ?> diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index bae438111e..6589b73888 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -3,6 +3,11 @@ unset($ports); $ports = snmp_cache_ifIndex($device); // Cache Port List + #mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`) VALUES ('".$device['device_id']."','$ifIndex')"); + + + + // Build SNMP Cache Array $data_oids = array('ifName','ifDescr','ifAlias', 'ifAdminStatus', 'ifOperStatus', 'ifMtu', 'ifSpeed', 'ifHighSpeed', 'ifType', 'ifPhysAddress', 'ifPromiscuousMode','ifConnectorPresent','ifDuplex'); @@ -276,7 +281,8 @@ } } } elseif($port['ignore'] == "0") { - echo("Port Deleted?"); // Port missing from SNMP cache? + echo("Port Deleted"); // Port missing from SNMP cache. + mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$this_port['ifIndex']."'"); } else { echo("Port Ignored."); } diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index c92c99576f..ca84207d22 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -6,132 +6,174 @@ #$config['snmp']['timeout'] = 300; # timeout in ms #$config['snmp']['retries'] = 6; # how many times to retry the query -function snmp_get_multi ($device, $oids, $options = "-OQUs", $mib = NULL, $mibdir = NULL) -{ - global $debug; global $config; global $runtime_stats; - $cmd = $config['snmpget'] . " -" . $device['snmpver'] . " -c " . $device['community'] . " "; - if($options) { $cmd .= " " . $options; } - if($mib) { $cmd .= " -m " . $mib; } - if($mibdir) { $cmd .= " -M " . $mibdir; } else { $cmd .= " -M ".$config['mibdir']; } - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; - $cmd .= " ".$device['hostname'].":".$device['port']." ".$oids; - if (!$debug) { $cmd .= " 2>/dev/null"; } - if($debug) { echo("$cmd\n"); } - $data = trim(shell_exec($cmd)); - $runtime_stats['snmpget']++; - if($debug) { echo("$data\n"); } - foreach(explode("\n", $data) as $entry) { - list($oid,$value) = explode("=", $entry); - $oid = trim($oid); $value = trim($value); - list($oid, $index) = explode(".", $oid); - if (!strstr($value, "at this OID") && isset($oid) && isset($index)) { - $array[$index][$oid] = $value; - } - } - return $array; +function snmp_get_multi($device, $oids, $options = "-OQUs", $mib = NULL, $mibdir = NULL) { + global $debug,$config,$runtime_stats,$mibs_loaded; + if ($device['timeout'] == NULL) { $timeout = $config['snmp']['timeout']; } else { $timeout = $device['timeout']; } + if ($device['retries'] == NULL) { $retries = $config['snmp']['retries']; } else { $retries = $device['retries']; } + if ($config['snmp']['internal'] == true) { + + if ($mib && $mibdir && !$mibs_loaded[$mib]) + { + @snmp_read_mib($mibdir."/".$mib); + $mibs_loaded[$mib] = TRUE; + } + snmp_set_quick_print(1); + $oids = explode(" ",trim($oids)); + // s->ms - php snmp extension requires the timeout in microseconds. + $timeout = $timeout*1000*1000; + foreach($oids as $oid) { + if($device['snmpver'] == "v2c") { + $data = @snmp2_get($device['hostname'].":".$device['port'], $device['community'], $oid, $timeout, $retries); + } elseif( $device['snmpver'] == "v1") { + $data = @snmpget($device['hostname'].":".$device['port'], $device['community'], $oid, $timeout, $retries); + } + + list($oid, $index) = explode(".", $oid); + if ($data) { $array[$index][$oid] = $data; } + else { $array[$index][$oid] = null; } + } + } + else { + $cmd = $config['snmpget'] . " -" . $device['snmpver'] . " -c " . $device['community'] . " "; + if($options) { $cmd .= " " . $options; } + if($mib) { $cmd .= " -m " . $mib; } + if($mibdir) { $cmd .= " -M " . $mibdir; } else { $cmd .= " -M ".$config['mibdir']; } + $cmd .= " -t " . $timeout . " -r " . $retries; + $cmd .= " ".$device['hostname'].":".$device['port']." ".$oids; + if (!$debug) { $cmd .= " 2>/dev/null"; } + if($debug) { echo("$cmd\n"); } + $data = trim(shell_exec($cmd)); + $runtime_stats['snmpget']++; + if($debug) { echo("$data\n"); } + foreach(explode("\n", $data) as $entry) { + list($oid,$value) = explode("=", $entry); + $oid = trim($oid); $value = trim($value); + list($oid, $index) = explode(".", $oid); + if (!strstr($value, "at this OID") && isset($oid) && isset($index)) { + $array[$index][$oid] = $value; + } + } + } + return $array; } - - -function snmp_get ($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL) -{ - global $debug; global $config; global $runtime_stats; - $cmd = $config['snmpget'] . " -" . $device['snmpver'] . " -c " . $device['community'] . " "; - if($options) { $cmd .= " " . $options; } - if($mib) { $cmd .= " -m " . $mib; } - if($mibdir) { $cmd .= " -M " . $mibdir; } else { $cmd .= " -M ".$config['mibdir']; } - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; - $cmd .= " ".$device['hostname'].":".$device['port']." ".$oid; - if (!$debug) { $cmd .= " 2>/dev/null"; } - if($debug) { echo("$cmd\n"); } - $data = trim(shell_exec($cmd)); - $runtime_stats['snmpget']++; - if($debug) { echo("$data\n"); } - if (is_string($data) && (preg_match("/No Such Instance/i", $data) || preg_match("/No Such Object/i", $data) || preg_match("/No more variables left/i", $data))) - { $data = false; } else { return $data; } +function snmp_get($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL) { + global $debug,$config,$runtime_stats,$mibs_loaded; + if ($device['timeout'] == NULL) { $timeout = $config['snmp']['timeout']; } else { $timeout = $device['timeout']; } + if ($device['retries'] == NULL) { $retries = $config['snmp']['retries']; } else { $retries = $device['retries']; } + if ($config['snmp']['internal'] == true) + { + if ($mib && $mibdir && !$mibs_loaded[$mib]) + { + @snmp_read_mib($mibdir."/".$mib); + $mibs_loaded[$mib] = TRUE; + } + snmp_set_quick_print(1); + // s->ms - php snmp extension requires the timeout in microseconds. + $timeout = $timeout*1000*1000; + if($device['snmpver'] == "v2c") + { + $data = @snmp2_get($device['hostname'].":".$device['port'], $device['community'], $oid, $timeout, $retries); + } elseif( $device['snmpver'] == "v1") { + $data = @snmpget($device['hostname'].":".$device['port'], $device['community'], $oid, $timeout, $retries); + } + if ($debug) { print "DEBUG: $oid: $data\n"; } + } else { + $cmd = $config['snmpget'] . " -" . $device['snmpver'] . " -c " . $device['community'] . " "; + if($options) { $cmd .= " " . $options; } + if($mib) { $cmd .= " -m " . $mib; } + if($mibdir) { $cmd .= " -M " . $mibdir; } else { $cmd .= " -M ".$config['mibdir']; } + $cmd .= " -t " . $timeout . " -r " . $retries; + $cmd .= " ".$device['hostname'].":".$device['port']." ".$oid; + if (!$debug) { $cmd .= " 2>/dev/null"; } + if($debug) { echo("$cmd\n"); } + $data = trim(shell_exec($cmd)); + if($debug) { echo("$data\n"); } + } + $runtime_stats['snmpget']++; + if (is_string($data) && (preg_match("/No Such Instance/i", $data) || preg_match("/No Such Object/i", $data) || preg_match("/No more variables left/i", $data))) { return false; } + elseif ($data) { return $data; } + else { return false; } } -function snmp_walk($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL) -{ - global $debug; global $config; global $runtime_stats; - if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) - { - $snmpcommand = $config['snmpwalk']; - } - else - { - $snmpcommand = $config['snmpbulkwalk']; - } - $cmd = $snmpcommand . " -" . $device['snmpver'] . " -c " . $device['community'] . " "; - if($options) { $cmd .= " $options "; } - if($mib) { $cmd .= " -m $mib"; } - if($mibdir) { $cmd .= " -M " . $mibdir; } else { $cmd .= " -M ".$config['mibdir']; } - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; - $cmd .= " ".$device['hostname'].":".$device['port']." ".$oid; - if (!$debug) { $cmd .= " 2>/dev/null"; } - if($debug) { echo("$cmd\n"); } - $data = trim(shell_exec($cmd)); - $runtime_stats['snmpwalk']++; - if($debug) { echo("$data\n"); } - if (is_string($data) && (preg_match("/No Such (Object|Instance)/i", $data))) - { - $data = false; - } - else - { - if (preg_match("/No more variables left in this MIB View \(It is past the end of the MIB tree\)$/",$data)) - { - # Bit ugly :-( - $d_ex = explode("\n",$data); - unset($d_ex[count($d_ex)-1]); - $data = implode("\n",$d_ex); - } - return $data; - } +function snmp_walk($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL) { + global $debug,$config,$runtime_stats; + if ($device['timeout'] == NULL) { $timeout = $config['snmp']['timeout']; } else { $timeout = $device['timeout']; } + if ($device['retries'] == NULL) { $retries = $config['snmp']['retries']; } else { $retries = $device['retries']; } + // php has no bulkwalk functionality, so use binary for this. + if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) { + $snmpcommand = $config['snmpwalk']; + } + else { + $snmpcommand = $config['snmpbulkwalk']; + } + $cmd = $snmpcommand . " -" . $device['snmpver'] . " -c " . $device['community'] . " "; + if($options) { $cmd .= " $options "; } + if($mib) { $cmd .= " -m $mib"; } + if($mibdir) { $cmd .= " -M " . $mibdir; } else { $cmd .= " -M ".$config['mibdir']; } + $cmd .= " -t " . $timeout . " -r " . $retries; + $cmd .= " ".$device['hostname'].":".$device['port']." ".$oid; + if (!$debug) { $cmd .= " 2>/dev/null"; } + if($debug) { echo("$cmd\n"); } + $data = trim(shell_exec($cmd)); + if($debug) { echo("$data\n"); } + if (is_string($data) && (preg_match("/No Such (Object|Instance)/i", $data))) + { + $data = false; + } + else { + if (preg_match("/No more variables left in this MIB View \(It is past the end of the MIB tree\)$/",$data)) { + # Bit ugly :-( + $d_ex = explode("\n",$data); + unset($d_ex[count($d_ex)-1]); + $data = implode("\n",$d_ex); + } + } + $runtime_stats['snmpwalk']++; + return $data; } -function snmpwalk_cache_cip($device, $oid, $array, $mib = 0) -{ - global $config; - if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) - { - $snmpcommand = $config['snmpwalk']; - } - else - { - $snmpcommand = $config['snmpbulkwalk']; - } - $cmd = $snmpcommand . " -O snQ -" . $device['snmpver'] . " -c " . $device['community'] . " "; - if($mib) { $cmd .= " -m $mib"; } - $cmd .= " -M ".$config['install_dir']."/mibs/"; - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; - $cmd .= " ".$device['hostname'].":".$device['port']." ".$oid; - if (!$debug) { $cmd .= " 2>/dev/null"; } - $data = trim(shell_exec($cmd)); - $device_id = $device['device_id']; - #echo("Caching: $oid\n"); - foreach(explode("\n", $data) as $entry) { - list ($this_oid, $this_value) = preg_split("/=/", $entry); - $this_oid = trim($this_oid); - $this_value = trim($this_value); - $this_oid = substr($this_oid, 30); - list($ifIndex,$dir,$a,$b,$c,$d,$e,$f) = explode(".", $this_oid); - $h_a = zeropad(dechex($a)); - $h_b = zeropad(dechex($b)); - $h_c = zeropad(dechex($c)); - $h_d = zeropad(dechex($d)); - $h_e = zeropad(dechex($e)); - $h_f = zeropad(dechex($f)); - $mac = "$h_a$h_b$h_c$h_d$h_e$h_f"; - if($dir == "1") { $dir = "input"; } elseif($dir == "2") { $dir = "output"; } - if($mac && $dir) { - $array[$ifIndex][$mac][$oid][$dir] = $this_value; - } - } - return $array; +function snmpwalk_cache_cip($device, $oid, $array, $mib = 0) { + global $config; + if ($device['timeout'] == NULL) { $timeout = $config['snmp']['timeout']; } else { $timeout = $device['timeout']; } + if ($device['retries'] == NULL) { $retries = $config['snmp']['retries']; } else { $retries = $device['retries']; } + if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) { + $snmpcommand = $config['snmpwalk']; + } + else { + $snmpcommand = $config['snmpbulkwalk']; + } + $cmd = $snmpcommand . " -O snQ -" . $device['snmpver'] . " -c " . $device['community'] . " "; + if($mib) { $cmd .= " -m $mib"; } + $cmd .= " -M ".$config['install_dir']."/mibs/"; + $cmd .= " -t " . $timeout . " -r " . $retries; + $cmd .= " ".$device['hostname'].":".$device['port']." ".$oid; + if (!$debug) { $cmd .= " 2>/dev/null"; } + $data = trim(shell_exec($cmd)); + $device_id = $device['device_id']; + #echo("Caching: $oid\n"); + foreach(explode("\n", $data) as $entry) { + list ($this_oid, $this_value) = preg_split("/=/", $entry); + $this_oid = trim($this_oid); + $this_value = trim($this_value); + $this_oid = substr($this_oid, 30); + list($ifIndex,$dir,$a,$b,$c,$d,$e,$f) = explode(".", $this_oid); + $h_a = zeropad(dechex($a)); + $h_b = zeropad(dechex($b)); + $h_c = zeropad(dechex($c)); + $h_d = zeropad(dechex($d)); + $h_e = zeropad(dechex($e)); + $h_f = zeropad(dechex($f)); + $mac = "$h_a$h_b$h_c$h_d$h_e$h_f"; + if($dir == "1") { $dir = "input"; } elseif($dir == "2") { $dir = "output"; } + if($mac && $dir) { + $array[$ifIndex][$mac][$oid][$dir] = $this_value; + } + return $array; + } } -function snmp_cache_ifIndex($device) +function snmp_cache_ifIndex($device) { global $config; if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) @@ -145,7 +187,7 @@ function snmp_cache_ifIndex($device) $cmd = $snmpcommand . " -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " "; $cmd .= " -M ".$config['install_dir']."/mibs/"; $cmd .= " -m IF-MIB ifIndex"; - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries'] . " " . $device['hostname'].":".$device['port']; + $cmd .= " -t " . $timeout . " -r " . $retries . " " . $device['hostname'].":".$device['port']; if (!$debug) { $cmd .= " 2>/dev/null"; } $data = trim(shell_exec($cmd)); $device_id = $device['device_id']; @@ -244,7 +286,7 @@ function snmpwalk_cache_twopart_oid($device, $oid, $array, $mib = 0) $cmd = $snmpcommand . " -O QUs -" . $device['snmpver'] . " -c " . $device['community'] . " "; $cmd .= " -M ".$config['install_dir']."/mibs/"; if($mib) { $cmd .= " -m $mib"; } - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; + $cmd .= " -t " . $timeout . " -r " . $retries; $cmd .= " ".$device['hostname'].":".$device['port']." ".$oid; if (!$debug) { $cmd .= " 2>/dev/null"; } $data = trim(shell_exec($cmd)); @@ -273,7 +315,7 @@ function snmpwalk_cache_threepart_oid($device, $oid, $array, $mib = 0) { $cmd = $snmpcommand . " -O QUs -" . $device['snmpver'] . " -c " . $device['community'] . " "; $cmd .= " -M ".$config['install_dir']."/mibs/"; if($mib) { $cmd .= " -m $mib"; } - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; + $cmd .= " -t " . $timeout . " -r " . $retries; $cmd .= " ".$device['hostname'].":".$device['port']." ".$oid; if (!$debug) { $cmd .= " 2>/dev/null"; } $data = trim(shell_exec($cmd)); @@ -303,7 +345,7 @@ function snmp_cache_slotport_oid($oid, $device, $array, $mib = 0) { $cmd = $snmpcommand . " -O QUs -" . $device['snmpver'] . " -c " . $device['community'] . " "; if($mib) { $cmd .= " -m $mib"; } $cmd .= " -M ".$config['install_dir']."/mibs/"; - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; + $cmd .= " -t " . $timeout . " -r " . $retries; $cmd .= " ".$device['hostname'].":".$device['port']." ".$oid; if (!$debug) { $cmd .= " 2>/dev/null"; } $data = trim(shell_exec($cmd)); @@ -335,7 +377,7 @@ function snmp_cache_port_oids($oids, $port, $device, $array, $mib=0) { $cmd = $config['snmpget'] . " -O vq -" . $device['snmpver'] . " -c " . $device['community'] . " "; $cmd .= " -M ".$config['install_dir']."/mibs/"; if($mib) { $cmd .= " -m $mib"; } - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; + $cmd .= " -t " . $timeout . " -r " . $retries; $cmd .= " ".$device['hostname'].":".$device['port']." ".$string; if (!$debug) { $cmd .= " 2>/dev/null"; } $data = trim(shell_exec($cmd)); @@ -355,7 +397,7 @@ function snmp_cache_portIfIndex ($device, $array) { global $config; $cmd = $config['snmpwalk'] . " -CI -m CISCO-STACK-MIB -O q -" . $device['snmpver'] . " -c " . $device['community'] . " "; $cmd .= " -M ".$config['install_dir']."/mibs/"; - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; + $cmd .= " -t " . $timeout . " -r " . $retries; $cmd .= " ".$device['hostname'].":".$device['port']." portIfIndex"; $output = trim(shell_exec($cmd)); $device_id = $device['device_id']; @@ -374,7 +416,7 @@ function snmp_cache_portName ($device, $array) { global $config; $cmd = $config['snmpwalk'] . " -CI -m CISCO-STACK-MIB -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " "; $cmd .= " -M ".$config['install_dir']."/mibs/"; - $cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries']; + $cmd .= " -t " . $timeout . " -r " . $retries; $cmd .= " ".$device['hostname'].":".$device['port']." portName"; $output = trim(shell_exec($cmd)); $device_id = $device['device_id']; @@ -391,5 +433,4 @@ function snmp_cache_portName ($device, $array) { } return $array; } - ?> |