Tag: FreeBSD

  • For Anyone Who’s Sad Enough To Be Interested…

    There appears to be a bug in phpsysinfo on FreeBSD 8.1, where it formats the network interfaces section wrong, due to a change in how netstat operates; it seems they’ve changed the amount of columns and spacing with “netstat -nibd”, which is how phpsysinfo gets its networking info. I thought at first it was just me breaking shit, but after searching around on several other peoples phpsysinfo pages, it seems to be a common issue.

    It took me a while to find the issue, but I’ve fixed it through trial and error, for anyone who’s interested, the fix is here:

    phpsysinfo/includes/os/class.FreeBSD.inc.php:

    function network () {
    $netstat = execute_program('netstat', '-nibd | grep Link');
    $lines = split("\n", $netstat);
    $results = array();
    for ($i = 0, $max = sizeof($lines); $i < $max; $i++) {
    $ar_buf = preg_split("/\s+/", $lines[$i]);
    if (!empty($ar_buf[0])) {
    $results[$ar_buf[0]] = array();if (strlen($ar_buf[3]) < 15) {
    $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[6];
    $results[$ar_buf[0]]['rx_packets'] = $ar_buf[3];
    $results[$ar_buf[0]]['rx_errs'] = $ar_buf[4];
    $results[$ar_buf[0]]['rx_drop'] = $ar_buf[11];$results[$ar_buf[0]]['tx_bytes'] = $ar_buf[9];
    $results[$ar_buf[0]]['tx_packets'] = $ar_buf[7];
    $results[$ar_buf[0]]['tx_errs'] = $ar_buf[8];
    $results[$ar_buf[0]]['tx_drop'] = $ar_buf[11];

    $results[$ar_buf[0]]['errs'] = $ar_buf[4] + $ar_buf[8];
    $results[$ar_buf[0]]['drop'] = $ar_buf[11];
    } else {
    $results[$ar_buf[0]]['rx_bytes'] = $ar_buf[7];
    $results[$ar_buf[0]]['rx_packets'] = $ar_buf[4];
    $results[$ar_buf[0]]['rx_errs'] = $ar_buf[5];
    $results[$ar_buf[0]]['rx_drop'] = $ar_buf[12];

    $results[$ar_buf[0]]['tx_bytes'] = $ar_buf[10];
    $results[$ar_buf[0]]['tx_packets'] = $ar_buf[8];
    $results[$ar_buf[0]]['tx_errs'] = $ar_buf[9];
    $results[$ar_buf[0]]['tx_drop'] = $ar_buf[12];

    $results[$ar_buf[0]]['errs'] = $ar_buf[5] + $ar_buf[9];
    $results[$ar_buf[0]]['drop'] = $ar_buf[12];
    }
    }
    }
    return $results;
    }

    That might not fix it for everyone, but it seems to have done the trick for me.