diff --git a/database-update.sql b/database-update.sql index 9a138552a..963268a1a 100644 --- a/database-update.sql +++ b/database-update.sql @@ -13,6 +13,7 @@ ALTER TABLE `vrfs` CHANGE `mplsVpnVrfRouteDistinguisher` `mplsVpnVrfRouteDisting ## 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 `ports` ADD `disabled` tinyint(1) NOT NULL DEFAULT '0' AFTER `ignore`; ALTER TABLE `perf_times` CHANGE `duration` `duration` DOUBLE( 8, 2 ) NOT NULL ALTER TABLE `sensors` ADD `poller_type` VARCHAR(16) NOT NULL DEFAULT 'snmp' AFTER `device_id`; ## Add transport diff --git a/html/includes/port-edit.inc.php b/html/includes/port-edit.inc.php index 0cd808d87..163c73167 100644 --- a/html/includes/port-edit.inc.php +++ b/html/includes/port-edit.inc.php @@ -7,24 +7,58 @@ $rows_updated = 0; foreach ($_POST as $key => $val) { - if (strncmp($key,"oldval_",7) == 0) + if (strncmp($key,"oldign_",7) == 0) { # Interface identifier passed as part of the field name $interface_id = intval(substr($key,7)); - $oldval = intval($val) ? 1 : 0; - $newval = $_POST['ignore_'.$interface_id] ? 1 : 0; + $oldign = intval($val) ? 1 : 0; + $newign = $_POST['ignore_'.$interface_id] ? 1 : 0; # As checkboxes are not posted when unset - we effectively need to do a diff to work # out a set->unset case. - if ($oldval == $newval) + if ($oldign == $newign) { continue; } - if (!mysql_query('UPDATE `ports` SET `ignore`='.$newval.' WHERE `device_id`='.$device_id.' AND `interface_id`='.$interface_id)) + if (!mysql_query('UPDATE `ports` SET `ignore`='.$newign.' WHERE `device_id`='.$device_id.' AND `interface_id`='.$interface_id)) + { + $n = -1; + } + else + { + $n = mysql_affected_rows(); + } + + if ($n <0) + { + $rows_updated = -1; + break; + } + + $rows_updated += $n; + } + elseif (strncmp($key,"olddis_",7) == 0) + { + # Interface identifier passed as part of the field name + + $interface_id = intval(substr($key,7)); + + $olddis = intval($val) ? 1 : 0; + $newdis = $_POST['disabled_'.$interface_id] ? 1 : 0; + + # As checkboxes are not posted when unset - we effectively need to do a diff to work + # out a set->unset case. + + if ($olddis == $newdis) + { + continue; + } + + if (!mysql_query('UPDATE `ports` SET `disabled`='.$newdis.' WHERE `device_id`='.$device_id.' AND `interface_id`='.$interface_id)) { $n = -1; } @@ -55,4 +89,4 @@ if ($rows_updated > 0) $updated = 0; } -?> \ No newline at end of file +?> diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index 3c5823ee5..0e329937a 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -22,7 +22,8 @@ echo("
-"); + +"); $query = mysql_query("SELECT * FROM `ports` WHERE device_id='".$device['device_id']."' ORDER BY `ifIndex` "); while ($device = mysql_fetch_array($query)) @@ -32,18 +33,26 @@ while ($device = mysql_fetch_array($query)) echo(""); echo(""); - # Mark interfaces which are OperDown (but not AdminDown) yet not ignored, or up - yet ignored - as to draw the attention - # to a possible problem. - # - $outofsync = ($device['ignore'] == ($device['ifOperStatus'] == 'down' && $device['ifAdminStatus'] != 'down' ? 1 : 0)) ? "" : "class=red"; + # Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled + # - as to draw the attention to a possible problem. + $isportbad = ($device['ifOperStatus'] == 'down' && $device['ifAdminStatus'] != 'down') ? 1 : 0; + $dowecare = ($device['ignore'] == 0 && $device['disabled'] == 0) ? 1 : 0; + $outofsync = ($isportbad && $dowecare) ? "class=red" : ""; echo(""); echo(""); - echo(""); + + echo(""); + + echo(" +"); } echo(''); @@ -51,4 +60,4 @@ echo('
PortifDescrifAdminStatusifOperStatusIgnore
PortifDescrifAdminStatusifOperStatusDisableIgnore
".$device['ifDescr'] . "". $device['ifAdminStatus']."". $device['ifOperStatus'].""); - echo(""); - echo(""); + echo(""); + echo(""); echo("
"); + echo(""); + echo(""); + echo("
'); echo(''); echo('
'); -?> \ No newline at end of file +?> diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 07f08dfe4..90a5408e7 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -102,7 +102,7 @@ $port_query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$device[ while ($port = mysql_fetch_array($port_query)) { echo("Port " . $port['ifDescr'] . " "); - if ($port_stats[$port['ifIndex']] && $port['ignore'] == "0") + if ($port_stats[$port['ifIndex']] && $port['disabled'] == "0") { // Check to make sure Port data is cached. $this_port = &$port_stats[$port['ifIndex']]; @@ -282,7 +282,7 @@ while ($port = mysql_fetch_array($port_query)) unset($update_query); unset($update); // Send alerts for interface flaps. - if ($config['warn']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus'])) + if ($config['warn']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus']) && $port['ignore'] == 0) { if ($this_port['ifAlias']) { @@ -301,12 +301,12 @@ while ($port = mysql_fetch_array($port_query)) } } } - elseif ($port['ignore'] == "0") + elseif ($port['disabled'] == "0") { 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."); + echo("Port Disabled."); } echo("\n"); @@ -319,4 +319,4 @@ while ($port = mysql_fetch_array($port_query)) #### Clear Variables Here unset($port_stats); -?> \ No newline at end of file +?>