2008-03-09 22:49:53 +00:00
< ? php
2015-07-10 13:36:21 +02:00
2018-05-11 12:06:03 -05:00
function printEntPhysical ( $device , $ent , $level , $class )
2016-08-18 20:28:22 -05:00
{
2015-07-10 13:36:21 +02:00
$ents = dbFetchRows ( 'SELECT * FROM `entPhysical` WHERE device_id = ? AND entPhysicalContainedIn = ? ORDER BY entPhysicalContainedIn,entPhysicalIndex' , array ( $device [ 'device_id' ], $ent ));
2017-12-02 14:23:56 -06:00
2015-07-13 20:10:26 +02:00
foreach ( $ents as $ent ) {
2015-07-10 13:36:21 +02:00
echo "
< li class = '$class' > " ;
if ( $ent [ 'entPhysicalClass' ] == 'chassis' ) {
2017-12-02 14:23:56 -06:00
echo '<i class="fa fa-server fa-lg icon-theme" aria-hidden="true"></i> ' ;
} elseif ( $ent [ 'entPhysicalClass' ] == 'module' ) {
echo '<i class="fa fa-database fa-lg icon-theme" aria-hidden="true"></i> ' ;
} elseif ( $ent [ 'entPhysicalClass' ] == 'port' ) {
echo '<i class="fa fa-link fa-lg icon-theme" aria-hidden="true"></i> ' ;
} elseif ( $ent [ 'entPhysicalClass' ] == 'container' ) {
echo '<i class="fa fa-square fa-lg icon-theme" aria-hidden="true"></i> ' ;
} elseif ( $ent [ 'entPhysicalClass' ] == 'sensor' ) {
echo '<i class="fa fa-heartbeat fa-lg icon-theme" aria-hidden="true"></i> ' ;
2015-07-10 13:36:21 +02:00
$sensor = dbFetchRow ( 'SELECT * FROM `sensors` WHERE `device_id` = ? AND (`entPhysicalIndex` = ? OR `sensor_index` = ?)' , array ( $device [ 'device_id' ], $ent [ 'entPhysicalIndex' ], $ent [ 'entPhysicalIndex' ]));
if ( count ( $sensor )) {
2019-01-20 19:24:11 +01:00
$link = " <a href='graphs/id= " . $sensor [ 'sensor_id' ] . '/type=sensor_' . $sensor [ 'sensor_class' ] . " /' onmouseover= \" return overlib('<img src= \ 'graph.php?id= " . $sensor [ 'sensor_id' ] . '&type=sensor_' . $sensor [ 'sensor_class' ] . '&from=-2d&to=now&width=400&height=150&a=' . $ent [ 'entPhysical_id' ] . " \ '><img src= \ 'graph.php?id= " . $sensor [ 'sensor_id' ] . '&type=sensor_' . $sensor [ 'sensor_class' ] . '&from=-2w&to=now&width=400&height=150&a=' . $ent [ 'entPhysical_id' ] . " \ '>', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505'); \" onmouseout= \" return nd(); \" > " ;
2015-07-10 13:36:21 +02:00
}
2017-12-02 14:23:56 -06:00
} elseif ( $ent [ 'entPhysicalClass' ] == 'backplane' ) {
echo '<i class="fa fa-bars fa-lg icon-theme" aria-hidden="true"></i> ' ;
2019-01-20 19:24:11 +01:00
} elseif ( $ent [ 'entPhysicalClass' ] == 'stack' ) {
echo '<i class="fa fa-list-ol fa-lg icon-theme" aria-hidden="true"></i> ' ;
} elseif ( $ent [ 'entPhysicalClass' ] == 'powerSupply' ) {
echo '<i class="fa fa-bolt fa-lg icon-theme" aria-hidden="true"></i> ' ;
2015-07-10 13:36:21 +02:00
}
if ( $ent [ 'entPhysicalParentRelPos' ] > '-1' ) {
echo '<strong>' . $ent [ 'entPhysicalParentRelPos' ] . '.</strong> ' ;
}
2017-12-02 14:23:56 -06:00
if ( isset ( $link )) {
echo $link ;
2015-07-10 13:36:21 +02:00
}
if ( $ent [ 'ifIndex' ]) {
2017-12-02 14:23:56 -06:00
$interface = get_port_by_ifIndex ( $device [ 'device_id' ], $ent [ 'ifIndex' ]);
$interface = cleanPort ( $interface );
2015-07-10 13:36:21 +02:00
$ent [ 'entPhysicalName' ] = generate_port_link ( $interface );
}
if ( $ent [ 'entPhysicalModelName' ] && $ent [ 'entPhysicalName' ]) {
echo '<strong>' . $ent [ 'entPhysicalModelName' ] . '</strong> (' . $ent [ 'entPhysicalName' ] . ')' ;
2016-08-18 20:28:22 -05:00
} elseif ( $ent [ 'entPhysicalModelName' ]) {
2015-07-10 13:36:21 +02:00
echo '<strong>' . $ent [ 'entPhysicalModelName' ] . '</strong>' ;
2016-08-18 20:28:22 -05:00
} elseif ( is_numeric ( $ent [ 'entPhysicalName' ]) && $ent [ 'entPhysicalVendorType' ]) {
2015-07-10 13:36:21 +02:00
echo '<strong>' . $ent [ 'entPhysicalName' ] . ' ' . $ent [ 'entPhysicalVendorType' ] . '</strong>' ;
2016-08-18 20:28:22 -05:00
} elseif ( $ent [ 'entPhysicalName' ]) {
2015-07-10 13:36:21 +02:00
echo '<strong>' . $ent [ 'entPhysicalName' ] . '</strong>' ;
2016-08-18 20:28:22 -05:00
} elseif ( $ent [ 'entPhysicalDescr' ]) {
2015-07-10 13:36:21 +02:00
echo '<strong>' . $ent [ 'entPhysicalDescr' ] . '</strong>' ;
}
2017-12-02 14:23:56 -06:00
if ( $ent [ 'entPhysicalClass' ] == 'sensor' && isset ( $sensor )) {
2019-06-27 00:30:10 -05:00
echo ' ' ;
echo $sensor [ 'sensor_class' ] == 'state' ? get_state_label ( $sensor ) : get_sensor_label_color ( $sensor );
2015-07-10 13:36:21 +02:00
}
2017-12-02 14:23:56 -06:00
if ( isset ( $link )) {
2015-07-10 13:36:21 +02:00
echo '</a>' ;
2017-12-02 14:23:56 -06:00
unset ( $link );
2015-07-10 13:36:21 +02:00
}
2017-12-02 14:23:56 -06:00
// display entity state
$entState = dbFetchRow (
'SELECT * FROM `entityState` WHERE `device_id`=? && `entPhysical_id`=?' ,
array ( $device [ 'device_id' ], $ent [ 'entPhysical_id' ])
);
if ( ! empty ( $entState )) {
$display_states = array (
// 'entStateAdmin',
'entStateOper' ,
'entStateUsage' ,
'entStateStandby'
);
foreach ( $display_states as $state_name ) {
$value = $entState [ $state_name ];
$display = parse_entity_state ( $state_name , $value );
echo " <span class='label label- { $display [ 'color' ] } ' data-toggle='tooltip' title=' $state_name ( $value )'> " ;
echo $display [ 'text' ];
echo " </span> " ;
}
// ignore none and unavailable alarms
if ( $entState [ 'entStateAlarm' ] != '00' && $entState [ 'entStateAlarm' ] != '80' ) {
$alarms = parse_entity_state_alarm ( $entState [ 'entStateAlarm' ]);
echo '<br />' ;
echo " <span style='margin-left: 20px;'>Alarms: " ;
foreach ( $alarms as $alarm ) {
echo " <span class='label label- { $alarm [ 'color' ] } '> { $alarm [ 'text' ] } </span> " ;
}
echo '</span>' ;
}
}
echo " <br /><div class='interface-desc' style='margin-left: 20px;'> " . $ent [ 'entPhysicalDescr' ];
2019-01-20 19:24:11 +01:00
if ( $ent [ 'entPhysicalAlias' ] && $ent [ 'entPhysicalAssetID' ]) {
echo " <br />Alias: " . $ent [ 'entPhysicalAlias' ] . " - AssetID: " . $ent [ 'entPhysicalAssetID' ];
} elseif ( $ent [ 'entPhysicalAlias' ]) {
echo " <br />Alias: " . $ent [ 'entPhysicalAlias' ];
} elseif ( $ent [ 'entPhysicalAssetID' ]) {
echo " <br />AssetID: " . $ent [ 'entPhysicalAssetID' ];
}
2015-07-10 13:36:21 +02:00
if ( $ent [ 'entPhysicalSerialNum' ]) {
echo " <br /><span style='color: #000099;'>Serial No. " . $ent [ 'entPhysicalSerialNum' ] . '</span> ' ;
}
echo '</div>' ;
$count = dbFetchCell ( " SELECT COUNT(*) FROM `entPhysical` WHERE device_id = ' " . $device [ 'device_id' ] . " ' AND entPhysicalContainedIn = ' " . $ent [ 'entPhysicalIndex' ] . " ' " );
if ( $count ) {
echo '<ul>' ;
2019-01-20 19:24:11 +01:00
printEntPhysical ( $device , $ent [ 'entPhysicalIndex' ], ( $level + 1 ), 'liClosed' );
2015-07-10 13:36:21 +02:00
echo '</ul>' ;
}
echo '</li>' ;
} //end foreach
} //end printEntPhysical()
echo " <div style='float: right;'>
2017-01-25 19:42:26 +02:00
< a href = '#' class = 'button' onClick = \ " expandTree('enttree');return false; \" ><i class='fa fa-plus fa-lg icon-theme' aria-hidden='true'></i>Expand All Nodes</a>
< a href = '#' class = 'button' onClick = \ " collapseTree('enttree');return false; \" ><i class='fa fa-minus fa-lg icon-theme' aria-hidden='true'></i>Collapse All Nodes</a>
2015-07-10 13:36:21 +02:00
</ div > " ;
2008-03-09 22:49:53 +00:00
2015-07-10 13:36:21 +02:00
echo " <div style='clear: both;'><UL CLASS='mktree' id='enttree'> " ;
$level = '0' ;
$ent [ 'entPhysicalIndex' ] = '0' ;
2018-05-11 12:06:03 -05:00
printEntPhysical ( $device , $ent [ 'entPhysicalIndex' ], $level , 'liOpen' );
2015-07-10 13:36:21 +02:00
echo '</ul></div>' ;
2011-10-18 14:27:21 +00:00
2015-07-10 13:36:21 +02:00
$pagetitle = 'Inventory' ;