From 632bf99239401954268bd8a3d9b1bc562e08d890 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 3 Sep 2010 13:32:11 +0000 Subject: [PATCH] allow manual ignore of ports git-svn-id: http://www.observium.org/svn/observer/trunk@1697 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/images/icons/greyscale/port.png | Bin 0 -> 609 bytes html/images/icons/greyscale/ports.png | Bin 0 -> 609 bytes html/images/icons/ports.png | Bin 0 -> 748 bytes html/includes/port-edit.inc.php | 49 +++++++++++++++++++++++++ html/pages/device/edit.inc.php | 1 + html/pages/device/edit/ports.inc.php | 51 ++++++++++++++++++++++++++ 6 files changed, 101 insertions(+) create mode 100644 html/images/icons/greyscale/port.png create mode 100644 html/images/icons/greyscale/ports.png create mode 100755 html/images/icons/ports.png create mode 100644 html/includes/port-edit.inc.php create mode 100644 html/pages/device/edit/ports.inc.php diff --git a/html/images/icons/greyscale/port.png b/html/images/icons/greyscale/port.png new file mode 100644 index 0000000000000000000000000000000000000000..1d9c3fd224ada56adfd6a614b7eb2961b9219d0c GIT binary patch literal 609 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{t+C3(BM zF#K=tKeHdm<1FxqEC$jZVC;4>+YTgHR^XTpq`_t}#2j0Dn1O*Y($mE;MB{w!#J%25 zi6Y19tM0G9w`jqFj#;@nQB2d@7A$CM``3CbW5w028~YUtvQ0C%7A^Eq;+QpC=9ko! z)u~xCu7BVAey_Onrl1dNo*yrs_t|El* znF`&q4!)T&_Y5VCZtpI3n<;eOM6ULCc%sk32{&9M#P!d7e)ar()6F&aKVG;a;d;p_ zP~B;Ywf&5p=l+YTgHR^XTpq`_t}#2j0Dn1O*Y($mE;MB{w!#J%25 zi6Y19tM0G9w`jqFj#;@nQB2d@7A$CM``3CbW5w028~YUtvQ0C%7A^Eq;+QpC=9ko! z)u~xCu7BVAey_Onrl1dNo*yrs_t|El* znF`&q4!)T&_Y5VCZtpI3n<;eOM6ULCc%sk32{&9M#P!d7e)ar()6F&aKVG;a;d;p_ zP~B;Ywf&5p=lzR>QH2KN`fNj zBHaWZEgiB#>49kYe(borqx+hj`JS_1d)R}7LjHa+tu+qg(TC+eO4&q(D;ZL8C8o8; zLEfZxiIlQ~iE1b1qBZ2=VhsA0V`*@y@M|Sc2@Wtadv3g0hOc*O(ADVFjPTWAYz(JXS z8MBaa%aCO{h8lvp*ONKIh5Bg|-DNo^;jg=q=uDZ@vodOJXfu;GK`ze`H-VrWK!nUg zje)ufRUJ&ouB2nYB2_pI=gji&GcuBL=+DM-wBZ)fbc7&a9AP1Ztk5)S4Ah03bqXOt zxx}VdK|CIVljyc=oqO1G{;Qew7T~%?tSw{^mi$E(2^Td6>M8+m4H!qrBtj~%w(Y~Q zVrXkVOEN#2&@(U(cX3H&S97B(;-}{)?<>?0)RjVZqrJ&ONChgCgE9%PC}CSBp!+d1 z`bkAqacXYz!94aLsJZ!K=3b*?T#ge1nL>bsZNf4&8mt(EkXYZ?MK0YwH2ZOI9{(VN z&%WPH*v6AY+yG?)mZ`CxE@5ZK2lW}4Pr-ctMRE2V`yf8$PurT4&^p3q*2kt>M8OM& zl@MbQ=U&8BS_$dSjo(q&2Pyd!8`}{~Xr#A_DDL|G({Ha$;Xe@?&|@q4QbvV}D#ixB ey}zEqA^Zgf(1+rQ>#k7%0000 $val) { + if (strncmp($key,"oldval_",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; + + # As checkboxes are not posted when unset - we effectively need to do a diff to work + # out a set->unset case. + # + if ($oldval == $newval) + continue; + + if (!mysql_query('UPDATE `ports` SET `ignore`='.$newval.' 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; + }; +}; + + if($rows_updated > 0) { + $update_message = $rows_updated . " Device record updated."; + $updated = 1; + } elseif ($rows_updated = '-1') { + $update_message = "Device record unchanged. No update necessary."; + $updated = -1; + } else { + $update_message = "Device record update error."; + $updated = 0; + } + +?> diff --git a/html/pages/device/edit.inc.php b/html/pages/device/edit.inc.php index 7e0f0def5c..155c582d48 100644 --- a/html/pages/device/edit.inc.php +++ b/html/pages/device/edit.inc.php @@ -6,6 +6,7 @@ if($_SESSION['userlevel'] < '7') { $panes = array('device' => 'Device Settings', + 'ports' => 'Port Settings', 'apps' => 'Applications', 'services' => 'Services'); diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php new file mode 100644 index 0000000000..c0c587f47d --- /dev/null +++ b/html/pages/device/edit/ports.inc.php @@ -0,0 +1,51 @@ +'); + +if($_POST['ignoreport']) { + if($_SESSION['userlevel'] == '10') { + include("includes/port-edit.inc.php"); + } +} + + +if($updated && $update_message) { + print_message($update_message); +} elseif ($update_message) { + print_error($update_message); +} + +echo("
+
+ + + +"); + +$query = mysql_query("SELECT * FROM `ports` WHERE device_id='".$device['device_id']."' ORDER BY `ifIndex` "); +while($device = mysql_fetch_array($query)) { + echo ""; + echo ""; + echo ""; + echo ""; + + # Mark interfaces which are down yet not ignored, or up - yet ignored - as to draw the attention + # to a possible problem. + # + $outofsync = ($device['ignore'] == ($device['ifOperStatus'] == 'down' ? 1 : 0)) ? "" : "class=red"; + + echo ""; + + echo ""; + echo ""; +} + +echo(''); +echo('
PortifDescrifAdminStatusifOperStatusIgnore
". $device['ifIndex']."".$device['ifDescr'] . "". $device['ifAdminStatus']."". $device['ifOperStatus'].""; + echo ""; + echo ""; + echo "
'); +echo('
'); +echo('
'); + +?>