2010-01-07 18:27:33 +00:00
< ? php
2020-09-21 15:40:17 +02:00
2015-09-21 01:30:23 +05:30
echo '<h3>Inventory</h3>' ;
echo '<hr>' ;
2015-09-21 19:12:06 +05:30
echo '<table class="table table-condensed">' ;
2010-01-07 18:27:33 +00:00
2020-05-11 20:28:42 +02:00
echo " <tr class='list'><th>Index</th><th>Description</th><th></th><th>Type</th><th>Status</th><th>Errors</th><th>Load</th></tr> " ;
2011-05-15 15:29:47 +00:00
foreach ( dbFetchRows ( 'SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`' , [ $device [ 'device_id' ]]) as $hrdevice ) {
2012-04-10 17:21:49 +00:00
echo " <tr class='list'><td> " . $hrdevice [ 'hrDeviceIndex' ] . '</td>' ;
2011-05-15 15:29:47 +00:00
if ( $hrdevice [ 'hrDeviceType' ] == 'hrDeviceProcessor' ) {
$proc_id = dbFetchCell ( " SELECT processor_id FROM processors WHERE device_id = ' " . $device [ 'device_id' ] . " ' AND hrDeviceIndex = ' " . $hrdevice [ 'hrDeviceIndex' ] . " ' " );
$proc_url = 'device/device=' . $device [ 'device_id' ] . '/tab=health/metric=processor/' ;
2012-04-10 17:21:49 +00:00
$proc_popup = " onmouseover= \" return overlib('<div class=list-large> " . $device [ 'hostname' ] . ' - ' . $hrdevice [ 'hrDeviceDescr' ];
2019-06-23 00:29:12 -05:00
$proc_popup .= " </div><img src= \ 'graph.php?id= " . $proc_id . '&type=processor_usage&from=' . \LibreNMS\Config :: get ( 'time.month' ) . '&to=' . \LibreNMS\Config :: get ( 'time.now' ) . " &width=400&height=125 \ '> " ;
$proc_popup .= " ', RIGHT " . \LibreNMS\Config :: get ( 'overlib_defaults' ) . ');" onmouseout="return nd();"' ;
2012-04-10 17:21:49 +00:00
echo " <td><a href=' $proc_url ' $proc_popup > " . $hrdevice [ 'hrDeviceDescr' ] . '</a></td>' ;
2010-01-07 18:27:33 +00:00
2011-05-15 15:29:47 +00:00
$graph_array [ 'height' ] = '20' ;
2012-05-06 18:38:11 +00:00
$graph_array [ 'width' ] = '100' ;
2019-06-23 00:29:12 -05:00
$graph_array [ 'to' ] = \LibreNMS\Config :: get ( 'time.now' );
2012-05-06 18:38:11 +00:00
$graph_array [ 'id' ] = $proc_id ;
$graph_array [ 'type' ] = 'processor_usage' ;
2019-06-23 00:29:12 -05:00
$graph_array [ 'from' ] = \LibreNMS\Config :: get ( 'time.day' );
2011-03-16 23:10:10 +00:00
$graph_array_zoom = $graph_array ;
$graph_array_zoom [ 'height' ] = '150' ;
$graph_array_zoom [ 'width' ] = '400' ;
2021-03-28 17:25:30 -05:00
$mini_graph = \LibreNMS\Util\Url :: overlibLink ( $proc_url , \LibreNMS\Util\Url :: lazyGraphTag ( $graph_array ), \LibreNMS\Util\Url :: graphTag ( $graph_array_zoom ));
2011-03-16 23:10:10 +00:00
echo '<td>' . $mini_graph . '</td>' ;
2016-08-18 20:28:22 -05:00
} elseif ( $hrdevice [ 'hrDeviceType' ] == 'hrDeviceNetwork' ) {
2011-03-16 23:10:10 +00:00
$int = str_replace ( 'network interface ' , '' , $hrdevice [ 'hrDeviceDescr' ]);
2020-05-11 20:28:42 +02:00
$interface = dbFetchRow ( 'SELECT * FROM ports WHERE device_id = ? AND (ifDescr = ? or ifName = ?)' , [ $device [ 'device_id' ], $int , $int ]);
2017-04-04 08:08:23 +01:00
$interface = cleanPort ( $interface );
2011-04-06 13:54:50 +00:00
if ( $interface [ 'ifIndex' ]) {
2020-05-11 20:28:42 +02:00
if ( ! empty ( $interface [ 'port_descr_type' ])) {
$interface_text = $interface [ 'port_descr_type' ] . ' (' . $int . ')' ;
} else {
$interface_text = $int ;
}
echo '<td>' . generate_port_link ( $interface , $interface_text ) . '</td>' ;
2011-03-16 23:10:10 +00:00
$graph_array [ 'height' ] = '20' ;
$graph_array [ 'width' ] = '100' ;
2019-06-23 00:29:12 -05:00
$graph_array [ 'to' ] = \LibreNMS\Config :: get ( 'time.now' );
2012-05-16 13:25:50 +00:00
$graph_array [ 'id' ] = $interface [ 'port_id' ];
2011-03-16 23:10:10 +00:00
$graph_array [ 'type' ] = 'port_bits' ;
2019-06-23 00:29:12 -05:00
$graph_array [ 'from' ] = \LibreNMS\Config :: get ( 'time.day' );
2011-03-16 23:10:10 +00:00
$graph_array_zoom = $graph_array ;
$graph_array_zoom [ 'height' ] = '150' ;
$graph_array_zoom [ 'width' ] = '400' ;
2021-03-28 17:25:30 -05:00
$mini_graph = \LibreNMS\Util\Url :: overlibLink ( generate_port_url ( $interface ), \LibreNMS\Util\Url :: lazyGraphTag ( $graph_array ), \LibreNMS\Util\Url :: graphTag ( $graph_array_zoom ));
2011-03-16 23:10:10 +00:00
echo " <td> $mini_graph </td> " ;
2016-08-18 20:28:22 -05:00
} else {
2014-10-11 19:35:34 +00:00
echo '<td>' . stripslashes ( $hrdevice [ 'hrDeviceDescr' ]) . '</td>' ;
2011-03-16 23:10:10 +00:00
echo '<td></td>' ;
2015-07-13 20:10:26 +02:00
}
2016-08-18 20:28:22 -05:00
} else {
2014-10-11 19:35:34 +00:00
echo '<td>' . stripslashes ( $hrdevice [ 'hrDeviceDescr' ]) . '</td>' ;
2012-04-10 17:21:49 +00:00
echo '<td></td>' ;
2010-01-07 18:27:33 +00:00
} //end if
2011-04-15 17:22:35 +00:00
echo '<td>' . $hrdevice [ 'hrDeviceType' ] . '</td><td>' . $hrdevice [ 'hrDeviceStatus' ] . '</td>' ;
2012-04-10 17:21:49 +00:00
echo '<td>' . $hrdevice [ 'hrDeviceErrors' ] . '</td><td>' . $hrdevice [ 'hrProcessorLoad' ] . '</td>' ;
2015-07-13 20:10:26 +02:00
echo '</tr>' ;
} //end foreach
2010-01-07 18:27:33 +00:00
2011-10-18 14:27:21 +00:00
echo '</table>' ;
$pagetitle [] = 'Inventory' ;