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("
| Port | ifDescr | ifAdminStatus | ifOperStatus | Ignore | |
|---|---|---|---|---|---|
| Port | ifDescr | ifAdminStatus | ifOperStatus | Disable | Ignore | ".$device['ifDescr'] . " | "); echo("". $device['ifAdminStatus']." | "); - # 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("". $device['ifOperStatus']." | "); echo(""); - echo(""); - echo(""); + echo(""); + echo(""); echo(" | "); - echo(""); + + echo(""); + echo(""); + echo(""); + echo(" | "); + + echo(" +"); } echo('