mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactored device types, added power type for APC and MGE stuff + some warning fixes
git-svn-id: http://www.observium.org/svn/observer/trunk@1137 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -116,45 +116,35 @@ while ($device = mysql_fetch_array($device_query))
|
||||
include("includes/discovery/toner.inc.php");
|
||||
include("includes/discovery/ups.inc.php");
|
||||
|
||||
if($device['os'] == "screenos") {
|
||||
if ($device['type'] == "unknown") { $device['type'] = 'firewall'; }
|
||||
}
|
||||
|
||||
if($device['os'] == "junos") {
|
||||
if ($device['type'] == "unknown") { $device['type'] = 'network'; } # FIXME: could also be a Netscreen...
|
||||
}
|
||||
|
||||
if($device['os'] == "linux") {
|
||||
if (($device['type'] == "unknown") && preg_match("/-server$/", $device['version'])) { $device['type'] = 'server'; }
|
||||
}
|
||||
|
||||
if($device['os'] == "ios" || $device['os'] == "iosxe" || $device['os'] == "catos" || $device['os'] == "asa" || $device['os'] == "pix") {
|
||||
if ($device['type'] == "unknown") { $device['type'] = 'network'; };
|
||||
}
|
||||
|
||||
if ($device['os'] == "procurve" || $device['os'] == "powerconnect")
|
||||
if ($device['type'] == "unknown")
|
||||
{
|
||||
if ($device['type'] == "unknown") { $device['type'] = 'network'; };
|
||||
}
|
||||
|
||||
if ($device['os'] == "asa" || $device['os'] == "pix")
|
||||
switch ($device['os'])
|
||||
{
|
||||
if ($device['type'] == "unknown") { $device['type'] = 'firewall'; }
|
||||
}
|
||||
|
||||
if ($device['os'] == "dell-laser")
|
||||
{
|
||||
if ($device['type'] == "unknown") { $device['type'] = 'printer'; }
|
||||
}
|
||||
|
||||
if($device['os'] == "ironware")
|
||||
{
|
||||
if ($device['type'] == "unknown") { $device['type'] = 'network'; }
|
||||
}
|
||||
|
||||
if($device['os'] == "allied")
|
||||
{
|
||||
if ($device['type'] == "unknown") { $device['type'] = 'network'; }
|
||||
case "procurve":
|
||||
case "powerconnect":
|
||||
case "ironware":
|
||||
case "allied":
|
||||
case "junos": # Could also be a Netscreen?
|
||||
case "ios":
|
||||
case "iosxe":
|
||||
case "catos":
|
||||
$device['type'] = 'network';
|
||||
break;
|
||||
case "asa":
|
||||
case "pix":
|
||||
case "screenos":
|
||||
$device['type'] = 'firewall';
|
||||
break;
|
||||
case "dell-laser":
|
||||
$device['type'] = 'printer';
|
||||
break;
|
||||
case "linux":
|
||||
if (preg_match("/-server$/", $device['version']) { $device['type'] = 'server'; }
|
||||
break;
|
||||
case "apc":
|
||||
case "mgeups":
|
||||
$device['type'] = 'power';
|
||||
break;
|
||||
}
|
||||
|
||||
$update_query = "UPDATE `devices` SET ";
|
||||
|
||||
@@ -52,11 +52,11 @@ function permissions_cache($user_id) {
|
||||
$permissions = array();
|
||||
$query = mysql_query("SELECT * FROM devices_perms WHERE user_id = '".$user_id."'");
|
||||
while($device = mysql_fetch_assoc($query)) {
|
||||
$permissions['device'][$device[device_id]] = 1;
|
||||
$permissions['device'][$device['device_id']] = 1;
|
||||
}
|
||||
$query = mysql_query("SELECT * FROM ports_perms WHERE user_id = '".$user_id."'");
|
||||
while($port = mysql_fetch_assoc($query)) {
|
||||
$permissions['port'][$port[interface_id]] = 1;
|
||||
$permissions['port'][$port['interface_id']] = 1;
|
||||
}
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,7 @@ if($updated && $update_message) {
|
||||
print_error($update_message);
|
||||
}
|
||||
|
||||
if($device['type'] == 'server') { $server_select = "selected"; }
|
||||
if($device['type'] == 'network') { $network_select = "selected"; }
|
||||
if($device['type'] == 'firewall') { $firewall_select = "selected"; }
|
||||
if($device['type'] == 'workstation') { $workstation_select = "selected"; }
|
||||
if($device['type'] == 'printer') { $printer_select = "selected"; }
|
||||
if($device['type'] == 'other' || $device['type'] == 'unknown') { $other_select = "selected"; }
|
||||
$device_types = array('server','network','firewall','workstation','printer','power');
|
||||
|
||||
echo("<table cellpadding=0 cellspacing=0><tr><td>
|
||||
|
||||
@@ -58,13 +53,24 @@ echo("<table cellpadding=0 cellspacing=0><tr><td>
|
||||
Type
|
||||
</td>
|
||||
<td>
|
||||
<select name='type'>
|
||||
<option value='server' $server_select>Server</option>
|
||||
<option value='network' $network_select>Network</option>
|
||||
<option value='firewall' $firewall_select>Firewall</option>
|
||||
<option value='workstation' $workstation_select>Workstation</option>
|
||||
<option value='printer' $printer_select>Printer</option>
|
||||
<option value='other' $other_select>Other</option>
|
||||
<select name='type'>");
|
||||
|
||||
$unknown = 1;
|
||||
foreach ($device_types as $type)
|
||||
{
|
||||
echo ' <option value="'.$type.'"';
|
||||
if ($device['type'] == $type)
|
||||
{
|
||||
echo 'selected="1"';
|
||||
$unknown = 0;
|
||||
}
|
||||
echo ' >' . ucfirst($type) . '</option>';
|
||||
}
|
||||
if ($unknown)
|
||||
{
|
||||
echo ' <option value="other">Other</option>';
|
||||
}
|
||||
echo("
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -79,15 +85,15 @@ echo("/></td>
|
||||
echo("/></td>
|
||||
</tr>");
|
||||
|
||||
echo("
|
||||
echo('
|
||||
</table>
|
||||
<input type='submit' name='Submit' value='Save' />
|
||||
<input type="submit" name="Submit" value="Save" />
|
||||
<label><br />
|
||||
</label>
|
||||
</form>
|
||||
|
||||
</td>
|
||||
<td width=50></td><td></td></tr></table>");
|
||||
<td width="50"></td><td></td></tr></table>');
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user