show ports/sensors on the device list page. add option to use php-snmp functions for snmp_get()s

git-svn-id: http://www.observium.org/svn/observer/trunk@1716 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-09-26 22:10:04 +00:00
parent 5f67749a3f
commit 038bc8c20e
11 changed files with 228 additions and 137 deletions

View File

@ -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

View File

@ -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

View File

@ -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']);

View File

@ -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();

View File

@ -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";
?>

View File

@ -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(' <tr background="'.$bg_image.'" bgcolor="' . $bg . '" onmouseover="this.style.backgroundColor=\'#fdd\';" onmouseout="this.style.backgroundColor=\'' . $bg . '\';"
onclick="location.href=\'/device/'.$device['device_id'].'/\'" style="cursor: hand;">
<td width="40" align="center" valign="middle">' . $image . '</td>
<td width="300"><span style="font-weight: bold; font-size: 14px;">' . generate_device_link($device) . '</span>
<br />' . $device['sysName'] . '</td>
<td>');
if($port_count) { echo(' <img src="images/icons/port.png" align=absmiddle> '.$port_count); }
echo('<br />');
if($sensor_count) { echo(' <img src="images/icons/sensors.png" align=absmiddle> '.$sensor_count); }
echo(' </td>
<td width="200">' . $device['os_text'] . '<br />
' . $device['version'] . '</td>
<td width="200">' . $device['hardware'] . '<br />

View File

@ -2,7 +2,10 @@
$bill_id = mres($_GET['opta']);
include("bill/actions.inc.php");
if($_SESSION['userlevel'] == "10")
{
include("pages/bill/actions.inc.php");
}
if(bill_permitted($bill_id)) {
@ -68,6 +71,11 @@ if(bill_permitted($bill_id)) {
if($_GET['optb'] == "edit") { echo("<strong>"); }
echo("<a href='bill/".$bill_id."/edit/'>Edit</a>");
if($_GET['optb'] == "edit") { echo("</strong>"); }
echo(" | ");
if($_GET['optb'] == "delete") { echo("<strong>"); }
echo("<a href='bill/".$bill_id."/delete/'>Delete</a>");
if($_GET['optb'] == "delete") { echo("</strong>"); }
}
print_optionbar_end();
@ -79,7 +87,11 @@ if(bill_permitted($bill_id)) {
include("pages/bill/edit.inc.php");
}elseif($_GET['optb'] == "details") {
} elseif($_GET['optb'] == "delete" && $_SESSION['userlevel'] == "10") {
include("pages/bill/delete.inc.php");
} elseif($_GET['optb'] == "details") {
echo("<h3>Billed Ports</h3>");

View File

@ -49,6 +49,17 @@ echo("<table cellpadding=0 cellspacing=0><tr><td>
<td colspan='3'><input name='port' size='20' value='" . $device['port'] . "'></input>
</td>
</tr>
<tr>
<td width='300'><div align='right'>SNMP Timeout</div></td>
<td colspan='3'><input name='timeout' size='20' value='" . $device['timeout'] . "'></input>&nbsp;
<em>seconds</em>
</td>
</tr>
<tr>
<td width='300'><div align='right'>SNMP Retries</div></td>
<td colspan='3'><input name='retries' size='20' value='" . $device['retries'] . "'></input>
</td>
</tr>
<tr>
<td align='right'>

View File

@ -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;
?>

View File

@ -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.");
}

View File

@ -6,129 +6,171 @@
#$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)
@ -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;
}
?>