mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
allow manual ignore of ports
git-svn-id: http://www.observium.org/svn/observer/trunk@1697 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
BIN
html/images/icons/greyscale/port.png
Normal file
BIN
html/images/icons/greyscale/port.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 609 B |
BIN
html/images/icons/greyscale/ports.png
Normal file
BIN
html/images/icons/greyscale/ports.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 609 B |
BIN
html/images/icons/ports.png
Executable file
BIN
html/images/icons/ports.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 748 B |
49
html/includes/port-edit.inc.php
Normal file
49
html/includes/port-edit.inc.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
# enable/disable ports/interfaces on devices.
|
||||||
|
#
|
||||||
|
|
||||||
|
$device_id=intval($_POST['device']);
|
||||||
|
$rows_updated = 0;
|
||||||
|
|
||||||
|
foreach ($_POST as $key => $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;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@@ -6,6 +6,7 @@ if($_SESSION['userlevel'] < '7') {
|
|||||||
|
|
||||||
|
|
||||||
$panes = array('device' => 'Device Settings',
|
$panes = array('device' => 'Device Settings',
|
||||||
|
'ports' => 'Port Settings',
|
||||||
'apps' => 'Applications',
|
'apps' => 'Applications',
|
||||||
'services' => 'Services');
|
'services' => 'Services');
|
||||||
|
|
||||||
|
51
html/pages/device/edit/ports.inc.php
Normal file
51
html/pages/device/edit/ports.inc.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
echo('<div style="padding: 10px;">');
|
||||||
|
|
||||||
|
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("<div style='float: left;'>
|
||||||
|
<form id='ignoreport' name='ignoreport' method='post' action=''>
|
||||||
|
<input type=hidden name='ignoreport' value='yes'>
|
||||||
|
<input type=hidden name=device value='".$device['device_id']."'>
|
||||||
|
<table>
|
||||||
|
<tr><th>Port</th><th>ifDescr</th><th>ifAdminStatus</th><th>ifOperStatus</th><th>Ignore</th></tr>");
|
||||||
|
|
||||||
|
$query = mysql_query("SELECT * FROM `ports` WHERE device_id='".$device['device_id']."' ORDER BY `ifIndex` ");
|
||||||
|
while($device = mysql_fetch_array($query)) {
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td align=right>". $device['ifIndex']."</td>";
|
||||||
|
echo "<td align=left>".$device['ifDescr'] . "</td>";
|
||||||
|
echo "<td align=right>". $device['ifAdminStatus']."</td>";
|
||||||
|
|
||||||
|
# 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 "<td align=right><span ".$outofsync.">". $device['ifOperStatus']."</span></td>";
|
||||||
|
|
||||||
|
echo "<td>";
|
||||||
|
echo "<input type=checkbox name='ignore_".$device['interface_id']."'".($device['ignore'] ? 'checked' : '').">";
|
||||||
|
echo "<input type=hidden name='oldval_".$device['interface_id']."' value=".($device['ignore'] ? 1 : 0).">";
|
||||||
|
echo "</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo('<tr><td></td><td></td><td></td><td></td><td><input type="submit" value="Save"></td></tr>');
|
||||||
|
echo('</table>');
|
||||||
|
echo('</form>');
|
||||||
|
echo('</div>');
|
||||||
|
|
||||||
|
?>
|
Reference in New Issue
Block a user