mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
move snmp options to separate form on device edit, also hide services link when services disabled
git-svn-id: http://www.observium.org/svn/observer/trunk@1928 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
BIN
html/images/icons/greyscale/snmp.png
Normal file
BIN
html/images/icons/greyscale/snmp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 500 B |
BIN
html/images/icons/snmp.png
Executable file
BIN
html/images/icons/snmp.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 566 B |
@@ -5,11 +5,17 @@ if ($_SESSION['userlevel'] < '7')
|
|||||||
print_error("Insufficient Privileges");
|
print_error("Insufficient Privileges");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$panes = array('device' => 'Device Settings',
|
$panes['device'] = 'Device Settings';
|
||||||
'ports' => 'Port Settings',
|
$panes['snmp'] = 'SNMP';
|
||||||
'apps' => 'Applications',
|
$panes['ports'] = 'Port Settings';
|
||||||
'services' => 'Services',
|
$panes['apps'] = 'Applications';
|
||||||
'ipmi' => 'IPMI');
|
|
||||||
|
if ($config['enable_services'])
|
||||||
|
{
|
||||||
|
$panes['services'] = 'Services';
|
||||||
|
}
|
||||||
|
|
||||||
|
$panes['ipmi'] = 'IPMI';
|
||||||
|
|
||||||
print_optionbar_start();
|
print_optionbar_start();
|
||||||
|
|
||||||
|
@@ -8,17 +8,10 @@ if ($_POST['editing'])
|
|||||||
$ignore = mres($_POST['ignore']);
|
$ignore = mres($_POST['ignore']);
|
||||||
$type = mres($_POST['type']);
|
$type = mres($_POST['type']);
|
||||||
$disabled = mres($_POST['disabled']);
|
$disabled = mres($_POST['disabled']);
|
||||||
$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
|
#FIXME needs more sanity checking! and better feedback
|
||||||
$sql = "UPDATE `devices` SET `purpose` = '" . $descr . "', `community` = '" . $community . "', `type` = '$type'";
|
$sql = "UPDATE `devices` SET `purpose` = '" . $descr . "', `type` = '$type'";
|
||||||
$sql .= ", `snmpver` = '" . $snmpver . "', `ignore` = '$ignore', `disabled` = '$disabled', `port` = '$port', ";
|
$sql .= ", `ignore` = '$ignore', `disabled` = '$disabled'";
|
||||||
if ($timeout) { $sql .= "`timeout` = '$timeout', "; } else { $sql .= "`timeout` = NULL, "; }
|
|
||||||
if ($retries) { $sql .= "`retries` = '$retries'"; } else { $sql .= "`retries` = NULL"; }
|
|
||||||
$sql .= " WHERE `device_id` = '".$device['device_id']."'";
|
$sql .= " WHERE `device_id` = '".$device['device_id']."'";
|
||||||
$query = mysql_query($sql);
|
$query = mysql_query($sql);
|
||||||
|
|
||||||
@@ -38,7 +31,7 @@ if ($_POST['editing'])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'"));
|
$device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'"));
|
||||||
$descr = $device['purpose'];
|
$descr = $device['purpose'];
|
||||||
|
|
||||||
if ($updated && $update_message)
|
if ($updated && $update_message)
|
||||||
@@ -64,51 +57,6 @@ echo("<table cellpadding=0 cellspacing=0><tr><td>
|
|||||||
<td><div align='right'>Description</div></td>
|
<td><div align='right'>Description</div></td>
|
||||||
<td colspan='3'><input name='descr' size='32' value='" . $device['purpose'] . "'></input></td>
|
<td colspan='3'><input name='descr' size='32' value='" . $device['purpose'] . "'></input></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td width='300'><div align='right'>SNMP Community</div></td>
|
|
||||||
<td colspan='3'><input name='community' size='20' value='" . $device['community'] . "'></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div align=right>SNMP Version</div></td>
|
|
||||||
<td><select name='snmpver'>
|
|
||||||
<option value='v1'>v1</option>
|
|
||||||
<option value='v2c'" . ($device['snmpver'] == 'v2c' ? 'selected=selected' : '') . ">v2c</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td width='300'><div align='right'>SNMP Port</div></td>
|
|
||||||
<td colspan='3'><input name='port' size='20' value='" . $device['port'] . "'></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td width='300'><div align='right'>SNMP Transport</div></td>
|
|
||||||
<td colspan='3'>
|
|
||||||
<select name='transport'>");
|
|
||||||
|
|
||||||
foreach ($config['snmp']['transports'] as $transport)
|
|
||||||
{
|
|
||||||
echo ("<option value='".$transport."'");
|
|
||||||
if ($transport == $device['transport']) { echo (" selected='selected'"); }
|
|
||||||
echo (">".$transport."</option>");
|
|
||||||
}
|
|
||||||
|
|
||||||
echo(" </select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td width='300'><div align='right'>SNMP Timeout</div></td>
|
|
||||||
<td colspan='3'><input name='timeout' size='20' value='" . ($device['timeout'] ? $device['timeout'] : '') . "'></input>
|
|
||||||
<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['timeout'] ? $device['retries'] : '') . "'></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td align='right'>
|
<td align='right'>
|
||||||
Type
|
Type
|
||||||
|
106
html/pages/device/edit/snmp.inc.php
Normal file
106
html/pages/device/edit/snmp.inc.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ($_POST['editing'])
|
||||||
|
{
|
||||||
|
if ($_SESSION['userlevel'] > "7")
|
||||||
|
{
|
||||||
|
$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 `community` = '" . $community . "', `snmpver` = '" . $snmpver . "', `port` = '$port', ";
|
||||||
|
if ($timeout) { $sql .= "`timeout` = '$timeout', "; } else { $sql .= "`timeout` = NULL, "; }
|
||||||
|
if ($retries) { $sql .= "`retries` = '$retries'"; } else { $sql .= "`retries` = NULL"; }
|
||||||
|
$sql .= " WHERE `device_id` = '".$device['device_id']."'";
|
||||||
|
$query = mysql_query($sql);
|
||||||
|
|
||||||
|
$rows_updated = mysql_affected_rows();
|
||||||
|
|
||||||
|
if ($rows_updated > 0)
|
||||||
|
{
|
||||||
|
$update_message = mysql_affected_rows() . " 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'"));
|
||||||
|
$descr = $device['purpose'];
|
||||||
|
|
||||||
|
if ($updated && $update_message)
|
||||||
|
{
|
||||||
|
print_message($update_message);
|
||||||
|
} elseif ($update_message) {
|
||||||
|
print_error($update_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo("<table cellpadding=0 cellspacing=0><tr><td>
|
||||||
|
|
||||||
|
<form id='edit' name='edit' method='post' action=''>
|
||||||
|
<input type=hidden name='editing' value='yes'>
|
||||||
|
<table width='400' border='0'>
|
||||||
|
<tr>
|
||||||
|
<td width='150'><div align='right'>SNMP Community</div></td>
|
||||||
|
<td><input name='community' size='20' value='" . $device['community'] . "'></input>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div align=right>SNMP Version</div></td>
|
||||||
|
<td><select name='snmpver'>
|
||||||
|
<option value='v1'>v1</option>
|
||||||
|
<option value='v2c'" . ($device['snmpver'] == 'v2c' ? 'selected=selected' : '') . ">v2c</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div align='right'>SNMP Port</div></td>
|
||||||
|
<td><input name='port' size='20' value='" . $device['port'] . "'></input>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div align='right'>SNMP Transport</div></td>
|
||||||
|
<td>
|
||||||
|
<select name='transport'>");
|
||||||
|
|
||||||
|
foreach ($config['snmp']['transports'] as $transport)
|
||||||
|
{
|
||||||
|
echo ("<option value='".$transport."'");
|
||||||
|
if ($transport == $device['transport']) { echo (" selected='selected'"); }
|
||||||
|
echo (">".$transport."</option>");
|
||||||
|
}
|
||||||
|
|
||||||
|
echo(" </select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div align='right'>SNMP Timeout</div></td>
|
||||||
|
<td><input name='timeout' size='20' value='" . ($device['timeout'] ? $device['timeout'] : '') . "'></input>
|
||||||
|
<em>seconds</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div align='right'>SNMP Retries</div></td>
|
||||||
|
<td colspan='3'><input name='retries' size='20' value='" . ($device['timeout'] ? $device['retries'] : '') . "'></input>
|
||||||
|
</td>
|
||||||
|
</tr>");
|
||||||
|
|
||||||
|
echo('
|
||||||
|
</table>
|
||||||
|
<input type="submit" name="Submit" value="Save" />
|
||||||
|
<label><br />
|
||||||
|
</label>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td width="50"></td><td></td></tr></table>');
|
||||||
|
|
||||||
|
?>
|
Reference in New Issue
Block a user