function renderCheckReport() { global $tool, $form, $status_array, $status_collors, $report_types; // Generating rerports can take a while // Increase time out $report_id = $_GET[report_id]; $profile_id = $_GET[profileid]; if (isset($report_id)) { // This means a saved report $mode = "saved_report"; $report = new Report($report_id); $profile_name = $report->get_name(); $report_type = $report->get_report_type(); $from = $report->get_start_time(); $to = $report->get_end_time(); $profile = new CheckReportProfile($report->get_profile_id()); $profile_name = $profile->get_name(); $report_checks = array(); foreach ($profile->get_checks() as $report_id => $report_name) { array_push($report_checks, $report_id); } } else { // else a live report $profile_name = ''; if (is_numeric($profile_id)) { $mode = "report"; $profile = new CheckReportProfile($_GET[profileid]); $report_type = $profile->get_report_type(); $profile_name = $profile->get_name(); $report_checks = array(); foreach ($profile->get_checks() as $report_id => $report_name) { array_push($report_checks, $report_id); } } else { $report_checks = $_GET[checks]; if (!is_array($report_checks)) { $form->warning("NO checks specified "); return; } elseif (count($report_checks) < 1) { $form->warning("NO checks specified "); return; } $mode = "checks"; $report_type = $_GET['report_type']; } $from = $_GET[from]; $to = $_GET[to]; } // Different report types // * one_down_all_down ie worst case // * one_up_all_up ie best case // * summary if ($report_type != 'one_down_all_down' && $report_type != 'one_up_all_up') { $report_type = 'summary'; } // Check From date if (is_numeric($from) && date($from)) { $start_stamp = date($from); } // Check From date if (is_numeric($from) && date($from)) { $start_stamp = date($from); } elseif ($from != '' && strtotime($from)) { $start_stamp = strtotime($from); } else { $form->warning("Invalid start date {$from}"); return false; } // Check To date if (is_numeric($to) && date($to)) { $end_stamp = date($to); } elseif ($to != '' && strtotime($to)) { $end_stamp = strtotime($to); } else { $form->warning("Invalid End date {$to}"); return false; } if ($mode == 'saved_report') { $timers = array(); $timers[ok] = $report->get_ok_secs(); $timers[warning] = $report->get_warning_secs(); $timers[critical] = $report->get_critical_secs(); $timers[unknown] = $report->get_unknown_secs(); //$timers[other] = $report->get_other_secs(); $timers[no_data] = $report->get_no_data_secs(); } else { $timers = get_report_data($start_stamp, $end_stamp, $report_type, $report_checks); } print "<h2>Availability Report</h2>"; if ($mode == 'saved_report') { print "<div style='background-color: orange; color: black;\n\t\t width: 500px; padding: 1px; padding-right:\n\t\t1px; border: 2px black solid; position: relative; float: right; padding-top: 0.1em;\n\t\tpadding-right: 0.1em;\n\t\tpadding-bottom: 0.1em;\n\t\tpadding-left: 0.1em;\n\t\t'>\n\n\t\t<b>Note:</b> This is a saved report; the time data is extracted from the report data however all other data\n\t\tsuch as the events are re-generated from the database. <br>This is based on which checks are currently in the\n\t\tReport profile and not at the time of report generation<br>\n\t\t</div><br><br>"; } echo "<div style='position: relative; float:left; clear:both; width:;'>"; echo "<br><b>Report for: {$profile_name}:</b><ul>"; foreach ($report_checks as $check_id) { $check = new Check($check_id); print "<li>" . $check->get_name() . " (" . $check->get_desc() . ")</li>"; } print "</ul></div>"; echo "<div style='position: relative; float:left; margin-left:105px; width:;'>\n\t\t<br><b>Reporting Detaills:</b><ul>\n\t\t\t<li>" . date("F j, Y, H:i ", $start_stamp) . " -- " . date("F j, Y, H:i ", $end_stamp) . "</li>\n\t\t\t<li>Reporting Type: {$report_types[$report_type]}</li>\n\t\t</ul>\n\t\t</div>"; $totalsec = $timers[ok] + $timers[warning] + $timers[critical] + $timers[unknown] + $timers[no_data]; $data = array("Ok", strTime($timers[ok]), $timers[ok] / $totalsec * 100 . "%", "Warning", strTime($timers[warning]), $timers[warning] / $totalsec * 100 . "%", "Critical", strTime($timers[critical]), $timers[critical] / $totalsec * 100 . "%", "Unknown", strTime($timers[unknown]), $timers[unknown] / $totalsec * 100 . "%", "No Measurement data", strTime($timers[no_data]), $timers[no_data] / $totalsec * 100 . "%"); $headings = array("Status", "Time", "Percentage"); $form->setCols(3); $form->setTableWidth("500px"); $form->setHeadings($headings); $form->setSortable(true); $form->setData($data); echo "<div style='position: relative; float:left; clear:both; width:;'>"; echo $form->showForm(); echo "</div"; echo "<div style='position: relative; float:left; margin-left:25px; width:;'>"; print report_chart($timers); echo "</div>"; $keyData = array(); $keyData = array(); $recent_events = Event::get_events_for_checks($report_checks, $start_stamp, $end_stamp); foreach ($recent_events as $event_id => $status) { unset($event); $event = new Event($event_id); $status = 3; $status = $event->get_status(); $status_name = $status_array[$status]; array_push($keyData, "<font color={$status_collors[$status]}> {$status_name} </font>"); array_push($keyData, $event->get_check_name()); array_push($keyData, $event->get_hostname()); //array_push($keyData, $event->get_check_name() .".tip.". $event->get_key1() ." ". $event->get_key2()); array_push($keyData, $event->get_insert_date()); array_push($keyData, $event->get_last_updated()); $insert_time = strtotime($event->get_insert_date()); $last_time = strtotime($event->get_last_updated()); $diff = strTime($last_time - $insert_time); array_push($keyData, $diff); array_push($keyData, $event->get_info_msg()); } $headings = array("Status", "Check Name", "Host", "Insert Time", "Last Check", "Duration", "Service Information"); $form = new Form("auto"); $form->setCols(7); $form->setTableWidth("auto"); $form->setData($keyData); $form->setTitles($keyTitle); $form->setEventHandler($keyHandlers); $form->setHeadings($headings); $form->setSortable(true); print "<div style='clear:both'></div><h3>Events</h3>"; print $form->showForm(); }
function display_report($ip_manager, $arr = array(), $search_str = "") { $ip_fam = 4; if (isset($_GET['report'])) { $ip_fam = $_GET['report']; } $all_ip = $arr; $free = 0; $reserved = 0; $assigned = 0; $allstats = 0; $totalspace = "0"; $limit = 0; foreach ($all_ip as $n_ip => $n_name) { if (!IP_Database::is_parent($n_ip)) { $t_ip = new IP_Database($n_ip); $allstats++; $ip_manager->set_IP($t_ip->get_address_ip(), $ip_fam); switch ($t_ip->get_status()) { case "FREE": $free = bcadd($ip_manager->get_ipPerNet(), $free); break; case "RESERVED": $reserved = bcadd($ip_manager->get_ipPerNet(), $reserved); break; case "ASSIGNED": $assigned = bcadd($ip_manager->get_ipPerNet(), $assigned); break; } $totalspace = bcadd($ip_manager->get_ipPerNet(), $totalspace); } } $limit = strlen($totalspace) - 10; if ($limit < 10) { $limit = 0; } //set the default column $form = new Form("auto", 2); $temp_space = explode(".", $totalspace); $totalspace = $temp_space[0]; if ($totalspace == 0) { $divisor = 1; } else { $divisor = $totalspace; } //their calories and locations correspondingly $num_slash = ""; if ($_GET['report'] == 6) { $num_slash = "Number of /48s"; $data_slash = bcdiv($totalspace, bcpow(2, 80), 2); $num_slash2 = "Number of /64s"; $data_slash2 = bcdiv($totalspace, bcpow(2, 64), 2); //create the headings for these if ($search_str != "") { $search_str = " for " . $search_str; } $heading = array("IPV6 Report" . $search_str); $free = bcdiv($free, bcpow(10, $limit), 2); $assigned = bcdiv($assigned, bcpow(10, $limit), 2); $reserved = bcdiv($reserved, bcpow(10, $limit), 2); $divisor = bcdiv($divisor, bcpow(10, $limit), 2); if ($divisor == 0) { $divisor = 1; } $titles = array("Number of IPs", $num_slash, $num_slash2, "Percent of free IPs", "Percent of assigned IPs", "Percent of reserved IPs"); $data = array(number_format($totalspace) . " IPs in " . number_format($allstats) . " Networks", number_format($data_slash), number_format($data_slash2), bcmul(bcdiv($free, $divisor, 5), 100, 2) . "%", bcmul(bcdiv($assigned, $divisor, 5), 100, 2) . "%", bcmul(bcdiv($reserved, $divisor, 5), 100, 2) . "%"); } else { if ($_GET['report'] == 4 || !isset($_GET['report'])) { $num_slash = "Number of /24s"; $data_slash = bcdiv($totalspace, 256, 2); //create the headings for these if ($search_str != "") { $search_str = " for " . $search_str; } $heading = array("IPV4 Report" . $search_str); $titles = array("Number of IPs", $num_slash, "Percent of free IPs", "Percent of assigned IPs", "Percent of reserved IPs"); $data = array(number_format($totalspace) . " IPs in " . number_format($allstats) . " Networks", number_format($data_slash), bcmul(bcdiv($free, $divisor, 5), 100, 2) . "%", bcmul(bcdiv($assigned, $divisor, 5), 100, 2) . "%", bcmul(bcdiv($reserved, $divisor, 5), 100, 2) . "%"); } } $form->setSortable(false); // or false for not sortable $form->setTitles($titles); $form->setHeadings($heading); $form->setData($data); //set the table size $form->setTableWidth("600px"); $form->setTitleWidth("20%"); echo $form->showForm(); $chart_arr = array(free => $free, assigned => $assigned, reserved => $reserved); print report_chart($chart_arr); }