function mactrack_format_interface_row($stat) { global $colors, $config; /* we will make a row string */ $row = ""; /* calculate a human readable uptime */ if ($stat["ifOperStatus"] == 0) { if ($stat["last_up_time"] == '0000-00-00 00:00:00') { $upTime = "Since Restart"; } else { $lastUp = $stat["last_up_time"]; $now = date("Y-m-d H:i:s"); $time = strtotime($now) - strtotime($lastUp); $days = intval($time / (60 * 60 * 24)); $remainder = $time % (60 * 60 * 24); $hours = intval($remainder / (60 * 60)); $remainder = $remainder % (60 * 60); $minutes = intval($remainder / 60); $upTime = $days . "d:" . $hours . "h:" . $minutes . "m"; } } else { if ($stat["last_down_time"] == '0000-00-00 00:00:00') { $upTime = "Since Restart"; } else { $lastUp = $stat["last_down_time"]; $now = date("Y-m-d H:i:s"); $time = strtotime($now) - strtotime($lastUp); $days = intval($time / (60 * 60 * 24)); $remainder = $time % (60 * 60 * 24); $hours = intval($remainder / (60 * 60)); $remainder = $remainder % (60 * 60); $minutes = intval($remainder / 60); $upTime = $days . "d:" . $hours . "h:" . $minutes . "m"; } } $row .= "<td nowrap style='width:1%;white-space:nowrap;'>" . mactrack_interface_actions($stat["device_id"], $stat["ifName"]) . "</td>"; $row .= "<td><b>" . $stat["device_name"] . "</b></td>"; $row .= "<td>" . strtoupper($stat["device_type"]) . "</td>"; $row .= "<td><b>" . $stat["ifName"] . "</b></td>"; $row .= "<td>" . $stat["ifDescr"] . "</td>"; $row .= "<td>" . $stat["ifAlias"] . "</td>"; $row .= "<td>" . round($stat["inBound"], 1) . " %" . "</td>"; $row .= "<td>" . round($stat["outBound"], 1) . " %" . "</td>"; $row .= "<td>" . mactrack_display_Octets($stat["int_ifHCInOctets"]) . "</td>"; $row .= "<td>" . mactrack_display_Octets($stat["int_ifHCOutOctets"]) . "</td>"; if ($_REQUEST["totals"] == "true" || $_REQUEST["totals"] == "on") { $row .= "<td>" . $stat["ifInErrors"] . "</td>"; $row .= "<td>" . $stat["ifInDiscards"] . "</td>"; $row .= "<td>" . $stat["ifInUnknownProtos"] . "</td>"; $row .= "<td>" . $stat["ifOutErrors"] . "</td>"; $row .= "<td>" . $stat["ifOutDiscards"] . "</td>"; } else { $row .= "<td>" . round($stat["int_ifInErrors"], 1) . "</td>"; $row .= "<td>" . round($stat["int_ifInDiscards"], 1) . "</td>"; $row .= "<td>" . round($stat["int_ifInUnknownProtos"], 1) . "</td>"; $row .= "<td>" . round($stat["int_ifOutErrors"], 1) . "</td>"; $row .= "<td>" . round($stat["int_ifOutDiscards"], 1) . "</td>"; } $row .= "<td>" . ($stat["ifOperStatus"] == 1 ? "Up" : "Down") . "</td>"; $row .= "<td style='white-space:nowrap;'>" . $upTime . "</td>"; $row .= "<td style='white-space:nowrap;'>" . mactrack_date($stat["last_rundate"]) . "</td>"; return $row; }
function mactrack_format_interface_row($stat) { global $config; /* we will make a row string */ $row = ''; /* calculate a human readable uptime */ if ($stat['ifLastChange'] == 0) { $upTime = __('Since Restart'); } else { if ($stat['ifLastChange'] > $stat['sysUptime']) { $upTime = __('Since Restart'); } else { $time = $stat['sysUptime'] - $stat['ifLastChange']; $days = intval($time / (60 * 60 * 24 * 100)); $remainder = $time % (60 * 60 * 24 * 100); $hours = intval($remainder / (60 * 60 * 100)); $remainder = $remainder % (60 * 60 * 100); $minutes = intval($remainder / (60 * 100)); $upTime = $days . 'd:' . $hours . 'h:' . $minutes . 'm'; } } $row .= "<td nowrap style='width:1%;white-space:nowrap;'>" . mactrack_interface_actions($stat['device_id'], $stat['ifName']) . '</td>'; $row .= '<td><b>' . $stat['device_name'] . '</b></td>'; $row .= '<td>' . strtoupper($stat['device_type']) . '</td>'; $row .= '<td><b>' . $stat['ifName'] . '</b></td>'; $row .= '<td>' . $stat['ifDescr'] . '</td>'; $row .= '<td>' . $stat['ifAlias'] . '</td>'; $row .= '<td>' . round($stat['inBound'], 1) . ' %' . '</td>'; $row .= '<td>' . round($stat['outBound'], 1) . ' %' . '</td>'; $row .= '<td>' . mactrack_display_Octets($stat['int_ifHCInOctets']) . '</td>'; $row .= '<td>' . mactrack_display_Octets($stat['int_ifHCOutOctets']) . '</td>'; if (get_request_var('totals') == 'true' || get_request_var('totals') == 'on') { $row .= '<td>' . $stat['ifInErrors'] . '</td>'; $row .= '<td>' . $stat['ifInDiscards'] . '</td>'; $row .= '<td>' . $stat['ifInUnknownProtos'] . '</td>'; $row .= '<td>' . $stat['ifOutErrors'] . '</td>'; $row .= '<td>' . $stat['ifOutDiscards'] . '</td>'; } else { $row .= '<td>' . round($stat['int_ifInErrors'], 1) . '</td>'; $row .= '<td>' . round($stat['int_ifInDiscards'], 1) . '</td>'; $row .= '<td>' . round($stat['int_ifInUnknownProtos'], 1) . '</td>'; $row .= '<td>' . round($stat['int_ifOutErrors'], 1) . '</td>'; $row .= '<td>' . round($stat['int_ifOutDiscards'], 1) . '</td>'; } $row .= '<td>' . ($stat['ifOperStatus'] == 1 ? 'Up' : 'Down') . '</td>'; $row .= "<td style='white-space:nowrap;'>" . $upTime . '</td>'; $row .= "<td style='white-space:nowrap;'>" . mactrack_date($stat['last_rundate']) . '</td>'; return $row; }