function print_graph_popup($graph_array) { echo generate_graph_popup($graph_array); }
function print_device_row($device, $vars = array('view' => 'basic'), $link_vars = array()) { global $config; if (!is_array($device)) { print_error("Invalid device passed to print_device_hostbox()!"); } if (!is_array($vars)) { $vars = array('view' => $vars); } // For compatability if ($device['os'] == "ios") { formatCiscoHardware($device, TRUE); } humanize_device($device); $tags = array('html_row_class' => $device['html_row_class'], 'device_id' => $device['device_id'], 'device_link' => generate_device_link($device, NULL, $link_vars), 'hardware' => escape_html($device['hardware']), 'features' => escape_html($device['features']), 'os_text' => $device['os_text'], 'version' => escape_html($device['version']), 'sysName' => escape_html($device['sysName']), 'device_uptime' => deviceUptime($device, 'short'), 'location' => escape_html(truncate($device['location'], 40, ''))); switch ($vars['view']) { case 'detail': case 'details': $tags['device_image'] = get_device_icon($device); $tags['ports_count'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `deleted` = 0;", array($device['device_id'])); $tags['sensors_count'] = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?;", array($device['device_id'])); $tags['sensors_count'] += dbFetchCell("SELECT COUNT(*) FROM `status` WHERE `device_id` = ?;", array($device['device_id'])); $hostbox = ' <tr class="' . $tags['html_row_class'] . '" onclick="openLink(\'device/device=' . $tags['device_id'] . '/\')" style="cursor: pointer;"> <td class="state-marker"></td> <td class="text-center vertical-align" style="width: 64px; text-align: center;">' . $tags['device_image'] . '</td> <td style="width: 300px;"><span class="entity-title">' . $tags['device_link'] . '</span><br />' . $tags['location'] . '</td> <td class="text-nowrap" style="width: 55px;">'; if ($tags['ports_count']) { $hostbox .= '<i class="oicon-network-ethernet"></i> <span class="label">' . $tags['ports_count'] . '</span>'; } $hostbox .= '<br />'; if ($tags['sensors_count']) { $hostbox .= '<i class="oicon-dashboard"></i> <span class="label">' . $tags['sensors_count'] . '</span>'; } $hostbox .= '</td> <td>' . $tags['os_text'] . ' ' . $tags['version'] . (!empty($tags['features']) ? ' (' . $tags['features'] . ')' : '') . '<br /> ' . $tags['hardware'] . '</td> <td>' . $tags['device_uptime'] . '<br />' . $tags['sysName'] . '</td> </tr>'; break; case 'perf': if ($_SESSION['userlevel'] >= "10") { $tags['device_image'] = get_device_icon($device); $graph_array = array('type' => 'device_poller_perf', 'device' => $device['device_id'], 'operation' => 'poll', 'legend' => 'no', 'width' => 600, 'height' => 90, 'from' => $config['time']['week'], 'to' => $config['time']['now']); $hostbox = ' <tr class="' . $tags['html_row_class'] . '" onclick="openLink(\'device/device=' . $tags['device_id'] . '/tab=perf/\')" style="cursor: pointer;"> <td class="state-marker"></td> <td class="vertical-align" style="width: 64px; text-align: center;">' . $tags['device_image'] . '</td> <td class="vertical-align" style="width: 300px;"><span class="entity-title">' . $tags['device_link'] . '</span><br />' . $tags['location'] . '</td> <td><div class="pull-right" style="height: 100px; padding: 2px; margin: 0;">' . generate_graph_tag($graph_array) . '</div></td> </tr>'; } break; case 'status': $tags['device_image'] = get_device_icon($device); // Graphs $graph_array = array(); $graph_array['height'] = "100"; $graph_array['width'] = "310"; $graph_array['to'] = $config['time']['now']; $graph_array['device'] = $device['device_id']; $graph_array['type'] = "device_bits"; $graph_array['from'] = $config['time']['day']; $graph_array['legend'] = "no"; $graph_array['height'] = "45"; $graph_array['width'] = "175"; $graph_array['bg'] = "FFFFFF00"; if (isset($config['os'][$device['os']]['graphs'])) { $graphs = $config['os'][$device['os']]['graphs']; } else { if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['graphs'])) { $graphs = $config['os'][$device['os_group']]['graphs']; } else { $graphs = $config['os']['default']['graphs']; } } // Preprocess device graphs array foreach ($GLOBALS['cache']['devices']['id'][$device['device_id']]['graphs'] as $graph) { $graphs_enabled[] = $graph['graph']; } foreach ($graphs as $entry) { if ($entry && in_array(str_replace("device_", "", $entry), $graphs_enabled)) { $graph_array['type'] = $entry; if (isset($config['graph_types']['device'][$entry]['name'])) { $graph_array['popup_title'] = $config['graph_types']['device'][$entry]['name']; } else { $graph_array['popup_title'] = nicecase(str_replace("_", " ", str_replace("device_", "", $entry))); } $tags['graphs'][] = '<div class="pull-right" style="margin: 5px; margin-bottom: 0px;">' . generate_graph_popup($graph_array) . '<br /><div style="text-align: center; padding: 0px; font-size: 7pt; font-weight: bold;">' . $graph_array['popup_title'] . '</div></div>'; } } $hostbox = ' <tr class="' . $tags['html_row_class'] . '" onclick="openLink(\'device/device=' . $tags['device_id'] . '/\')" style="cursor: pointer;"> <td class="state-marker"></td> <td class="vertical-align" style="width: 64px; text-align: center;">' . $tags['device_image'] . '</td> <td style="width: 300px;"><span class="entity-title">' . $tags['device_link'] . '</span><br />' . $tags['location'] . '</td> <td>'; if ($tags['graphs']) { $hostbox .= '' . implode($tags['graphs']) . ''; } $hostbox .= '</td> </tr>'; break; default: // basic $table_cols = 6; $tags['device_image'] = get_device_icon($device); $tags['ports_count'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `deleted` = 0;", array($device['device_id'])); $tags['sensors_count'] = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?;", array($device['device_id'])); $tags['sensors_count'] += dbFetchCell("SELECT COUNT(*) FROM `status` WHERE `device_id` = ?;", array($device['device_id'])); $hostbox = ' <tr class="' . $tags['html_row_class'] . '" onclick="openLink(\'device/device=' . $tags['device_id'] . '/\')" style="cursor: pointer;"> <td class="state-marker"></td> <td class="vertical-align" style="width: 64px; text-align: center;">' . $tags['device_image'] . '</td> <td style="width: 300;"><span class="entity-title">' . $tags['device_link'] . '</span><br />' . $tags['location'] . '</td> <td>' . $tags['hardware'] . ' ' . $tags['features'] . '</td> <td>' . $tags['os_text'] . ' ' . $tags['version'] . '</td> <td>' . $tags['device_uptime'] . '</td> </tr>'; } // If we're showing graphs, generate the graph if ($vars['graph']) { $hostbox .= '<tr><td colspan="' . $table_cols . '">'; $graph_array['to'] = $config['time']['now']; $graph_array['device'] = $device['device_id']; $graph_array['type'] = 'device_' . $vars['graph']; $hostbox .= generate_graph_row($graph_array); $hostbox .= '</td></tr>'; } echo $hostbox; }
function generate_printersupplies_row($supply, $vars) { $graph_type = "printersupply_usage"; $table_cols = 5; $total = $supply['supply_capacity']; $perc = $supply['supply_value']; $graph_array['type'] = $graph_type; $graph_array['id'] = $supply['supply_id']; $graph_array['from'] = $GLOBALS['config']['time']['day']; $graph_array['to'] = $GLOBALS['config']['time']['now']; $graph_array['height'] = "20"; $graph_array['width'] = "80"; if ($supply['supply_colour'] != '') { $background = toner_to_colour($supply['supply_colour'], $perc); } else { $background = toner_to_colour($supply['supply_descr'], $perc); } /// FIXME - popup for printersupply entity. $output .= '<tr class="' . $supply['html_row_class'] . '">'; $output .= '<td class="state-marker"></td>'; if ($vars['popup'] == TRUE) { $output .= '<td style="width: 40px; text-align: center;"><i class="' . $GLOBALS['config']['entities']['printersupply']['icon'] . '"></i></td>'; } else { $output .= '<td style="width: 1px;"></td>'; } if ($vars['page'] != "device" && $vars['popup'] != TRUE) { $output .= '<td class="entity">' . generate_device_link($supply) . '</td>'; $table_cols++; } $output .= '<td class="entity">' . generate_entity_link('printersupply', $supply) . '</td>'; if (!isset($vars['supply'])) { $output .= '<td>' . nicecase($supply['supply_type']) . '</td>'; } $output .= '<td style="width: 70px;">' . generate_graph_popup($graph_array) . '</td>'; $output .= '<td style="width: 200px;"><a href="' . $link . '">' . print_percentage_bar(400, 20, $perc, $perc . '%', 'ffffff', $background['right'], NULL, "ffffff", $background['left']) . '</a></td>'; $output .= '<td style="width: 50px; text-align: right;"><span class="label">' . $perc . '%</span></td>'; $output .= '</tr>'; if ($vars['view'] == "graphs") { $output .= '<tr class="' . $supply['html_row_class'] . '">'; $output .= '<td class="state-marker"></td>'; $output .= '<td colspan=' . $table_cols . '>'; unset($graph_array['height'], $graph_array['width'], $graph_array['legend']); $graph_array['to'] = $config['time']['now']; $graph_array['id'] = $supply['supply_id']; $graph_array['type'] = $graph_type; $output .= generate_graph_row($graph_array, TRUE); $output .= "</td></tr>"; } # endif graphs return $output; }
function print_device_hostbox($device, $mode = 'basic') { global $config; if (!is_array($device)) { print_error("Invalid device passed to print_device_hostbox()!"); } if ($device['os'] == "ios") { formatCiscoHardware($device, TRUE); } humanize_device($device); $hostbox_tags = array('html_row_class' => $device['html_row_class'], 'device_id' => $device['device_id'], 'device_link' => generate_device_link($device), 'hardware' => escape_html($device['hardware']), 'features' => escape_html($device['features']), 'os_text' => $device['os_text'], 'version' => escape_html($device['version']), 'sysName' => escape_html($device['sysName']), 'device_uptime' => deviceUptime($device, 'short'), 'location' => escape_html(truncate($device['location'], 32, ''))); switch ($mode) { case 'detail': case 'details': $hostbox_tags['device_image'] = get_device_icon($device); $hostbox_tags['ports_count'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?;", array($device['device_id'])); $hostbox_tags['sensors_count'] = dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?;", array($device['device_id'])); $hostbox = ' <tr class="' . $hostbox_tags['html_row_class'] . '" onclick="location.href=\'device/device=' . $hostbox_tags['device_id'] . '/\'" style="cursor: pointer;"> <td class="state-marker"></td> <td style="width: 64px; text-align: center; vertical-align: middle;">' . $hostbox_tags['device_image'] . '</td> <td style="width: 300px;"><span class="entity-title">' . $hostbox_tags['device_link'] . '</span><br />' . $hostbox_tags['location'] . '</td> <td style="width: 55px;">'; if ($hostbox_tags['ports_count']) { $hostbox .= '<i class="oicon-network-ethernet"></i> ' . $hostbox_tags['ports_count']; } $hostbox .= '<br />'; if ($hostbox_tags['sensors_count']) { $hostbox .= '<i class="oicon-dashboard"></i> ' . $hostbox_tags['sensors_count']; } $hostbox .= '</td> <td>' . $hostbox_tags['hardware'] . '<br />' . $hostbox_tags['features'] . '</td> <td>' . $hostbox_tags['os_text'] . '<br />' . $hostbox_tags['version'] . '</td> <td>' . $hostbox_tags['device_uptime'] . '<br />' . $hostbox_tags['sysName'] . '</td> </tr>'; break; case 'status': $hostbox_tags['device_image'] = get_device_icon($device); // Graphs $graph_array = array(); $graph_array['height'] = "100"; $graph_array['width'] = "310"; $graph_array['to'] = $config['time']['now']; $graph_array['device'] = $device['device_id']; $graph_array['type'] = "device_bits"; $graph_array['from'] = $config['time']['day']; $graph_array['legend'] = "no"; $graph_array['height'] = "45"; $graph_array['width'] = "175"; $graph_array['bg'] = "FFFFFF00"; if (isset($config['os'][$device['os']]['over'])) { $graphs = $config['os'][$device['os']]['over']; } else { if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) { $graphs = $config['os'][$device['os_group']]['over']; } else { $graphs = $config['os']['default']['over']; } } // Preprocess device graphs array foreach ($GLOBALS['device_graphs'][$device['device_id']] as $graph) { $graphs_enabled[] = $graph['graph']; } foreach ($graphs as $entry) { if ($entry['graph'] && in_array(str_replace('device_', '', $entry['graph']), $graphs_enabled)) { $graph_array['type'] = $entry['graph']; $graph_array['popup_title'] = $entry['text']; $hostbox_tags['graphs'][] = generate_graph_popup($graph_array); } } $hostbox = ' <tr class="' . $hostbox_tags['html_row_class'] . '" onclick="location.href=\'device/device=' . $hostbox_tags['device_id'] . '/\'" style="cursor: pointer;"> <td class="state-marker"></td> <td style="width: 64px; text-align: center; vertical-align: middle;">' . $hostbox_tags['device_image'] . '</td> <td style="width: 300px;"><span class="entity-title">' . $hostbox_tags['device_link'] . '</span><br />' . $hostbox_tags['location'] . '</td> <td>'; if ($hostbox_tags['graphs']) { $hostbox .= '<div class="pull-right" style="height: 50px; padding: 2px; margin: 0;">' . implode($hostbox_tags['graphs']) . '</div>'; } $hostbox .= '</td> </tr>'; break; default: // basic $hostbox = ' <tr class="' . $hostbox_tags['html_row_class'] . '" onclick="location.href=\'device/device=' . $hostbox_tags['device_id'] . '/\'" style="cursor: pointer;"> <td style="width: 300;"><span class="entity-title">' . $hostbox_tags['device_link'] . '</span><br />' . $hostbox_tags['location'] . '</td> <td>' . $hostbox_tags['hardware'] . ' ' . $hostbox_tags['features'] . '</td> <td>' . $hostbox_tags['os_text'] . ' ' . $hostbox_tags['version'] . '</td> <td>' . $hostbox_tags['device_uptime'] . '</td> </tr>'; } echo $hostbox; }