1<?php
2
3echo '<h3>Inventory</h3>';
4echo '<hr>';
5echo '<table class="table table-condensed">';
6
7echo "<tr class='list'><th>Index</th><th>Description</th><th></th><th>Type</th><th>Status</th><th>Errors</th><th>Load</th></tr>";
8foreach (dbFetchRows('SELECT * FROM `hrDevice` WHERE `device_id` = ? ORDER BY `hrDeviceIndex`', [$device['device_id']]) as $hrdevice) {
9    echo "<tr class='list'><td>" . $hrdevice['hrDeviceIndex'] . '</td>';
10
11    if ($hrdevice['hrDeviceType'] == 'hrDeviceProcessor') {
12        $proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '" . $device['device_id'] . "' AND hrDeviceIndex = '" . $hrdevice['hrDeviceIndex'] . "'");
13        $proc_url = 'device/device=' . $device['device_id'] . '/tab=health/metric=processor/';
14        $proc_popup = "onmouseover=\"return overlib('<div class=list-large>" . $device['hostname'] . ' - ' . $hrdevice['hrDeviceDescr'];
15        $proc_popup .= "</div><img src=\'graph.php?id=" . $proc_id . '&amp;type=processor_usage&amp;from=' . \LibreNMS\Config::get('time.month') . '&amp;to=' . \LibreNMS\Config::get('time.now') . "&amp;width=400&amp;height=125\'>";
16        $proc_popup .= "', RIGHT" . \LibreNMS\Config::get('overlib_defaults') . ');" onmouseout="return nd();"';
17        echo "<td><a href='$proc_url' $proc_popup>" . $hrdevice['hrDeviceDescr'] . '</a></td>';
18
19        $graph_array['height'] = '20';
20        $graph_array['width'] = '100';
21        $graph_array['to'] = \LibreNMS\Config::get('time.now');
22        $graph_array['id'] = $proc_id;
23        $graph_array['type'] = 'processor_usage';
24        $graph_array['from'] = \LibreNMS\Config::get('time.day');
25        $graph_array_zoom = $graph_array;
26        $graph_array_zoom['height'] = '150';
27        $graph_array_zoom['width'] = '400';
28
29        $mini_graph = \LibreNMS\Util\Url::overlibLink($proc_url, \LibreNMS\Util\Url::lazyGraphTag($graph_array), \LibreNMS\Util\Url::graphTag($graph_array_zoom));
30
31        echo '<td>' . $mini_graph . '</td>';
32    } elseif ($hrdevice['hrDeviceType'] == 'hrDeviceNetwork') {
33        $int = str_replace('network interface ', '', $hrdevice['hrDeviceDescr']);
34        $interface = dbFetchRow('SELECT * FROM ports WHERE device_id = ? AND (ifDescr = ? or ifName = ?)', [$device['device_id'], $int, $int]);
35        $interface = cleanPort($interface);
36        if ($interface['ifIndex']) {
37            if (! empty($interface['port_descr_type'])) {
38                $interface_text = $interface['port_descr_type'] . ' (' . $int . ')';
39            } else {
40                $interface_text = $int;
41            }
42            echo '<td>' . generate_port_link($interface, $interface_text) . '</td>';
43
44            $graph_array['height'] = '20';
45            $graph_array['width'] = '100';
46            $graph_array['to'] = \LibreNMS\Config::get('time.now');
47            $graph_array['id'] = $interface['port_id'];
48            $graph_array['type'] = 'port_bits';
49            $graph_array['from'] = \LibreNMS\Config::get('time.day');
50            $graph_array_zoom = $graph_array;
51            $graph_array_zoom['height'] = '150';
52            $graph_array_zoom['width'] = '400';
53
54            $mini_graph = \LibreNMS\Util\Url::overlibLink(generate_port_url($interface), \LibreNMS\Util\Url::lazyGraphTag($graph_array), \LibreNMS\Util\Url::graphTag($graph_array_zoom));
55
56            echo "<td>$mini_graph</td>";
57        } else {
58            echo '<td>' . stripslashes($hrdevice['hrDeviceDescr']) . '</td>';
59            echo '<td></td>';
60        }
61    } else {
62        echo '<td>' . stripslashes($hrdevice['hrDeviceDescr']) . '</td>';
63        echo '<td></td>';
64    }//end if
65
66    echo '<td>' . $hrdevice['hrDeviceType'] . '</td><td>' . $hrdevice['hrDeviceStatus'] . '</td>';
67    echo '<td>' . $hrdevice['hrDeviceErrors'] . '</td><td>' . $hrdevice['hrProcessorLoad'] . '</td>';
68    echo '</tr>';
69}//end foreach
70
71echo '</table>';
72
73$pagetitle[] = 'Inventory';
74