コード例 #1
0
ファイル: ports.csv.inc.php プロジェクト: sfromm/librenms
    case 'errors':
        $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC);
        break;
    case 'speed':
        $ports = array_sort($ports, 'ifSpeed', SORT_DESC);
        break;
    case 'port':
        $ports = array_sort($ports, 'ifDescr', SORT_ASC);
        break;
    case 'media':
        $ports = array_sort($ports, 'ifType', SORT_ASC);
        break;
    case 'descr':
        $ports = array_sort($ports, 'ifAlias', SORT_ASC);
        break;
    case 'device':
    default:
        $ports = array_sort($ports, 'hostname', SORT_ASC);
}
//end switch
$csv[] = array('Device', 'Port', 'Speed', 'Down', 'Up', 'Media', 'Description');
foreach ($ports as $port) {
    if (port_permitted($port['port_id'], $port['device_id'])) {
        $speed = humanspeed($port['ifSpeed']);
        $type = humanmedia($port['ifType']);
        $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8);
        $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8);
        $port = ifLabel($port, $device);
        $csv[] = array($port['hostname'], fixIfName($port['label']), $speed, $port['in_rate'], $port['out_rate'], $type, $port['ifAlias']);
    }
}
コード例 #2
0
ファイル: ipv4.php プロジェクト: kyrisu/observernms
     list($addy, $mask) = explode("/", $_POST['address']);
     if (!$mask) {
         $mask = "32";
     }
     if (!match_network($addy . "/" . $mask, $interface['ipv4_address'])) {
         $ignore = 1;
     }
 }
 if (!$ignore) {
     if (is_integer($row / 2)) {
         $row_colour = $list_colour_a;
     } else {
         $row_colour = $list_colour_b;
     }
     $speed = humanspeed($interface['ifSpeed']);
     $type = humanmedia($interface['ifType']);
     list($prefix, $length) = explode("/", $interface['ipv4_network']);
     if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
         $error_img = generateiflink($interface, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors);
     } else {
         $error_img = "";
     }
     if (interfacepermitted($interface['interface_id'])) {
         echo '<tr bgcolor="' . $row_colour . '">
       <td class="list-bold">' . generatedevicelink($interface) . '</td>
       <td class="list-bold">' . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . ' ' . $error_img . '</td>
       <td>' . $interface['ipv4_address'] . '/' . $length . '</td>
       <td>' . $interface['ifAlias'] . "</td>\n        </tr>\n";
         $row++;
     }
 }
コード例 #3
0
ファイル: ports.inc.php プロジェクト: vrillusions/librenms
        $sql .= " ORDER BY `{$sort_column}` {$sort_order}";
    }
}
if (isset($current)) {
    $limit_low = $current * $rowCount - $rowCount;
    $limit_high = $rowCount;
}
if ($rowCount != -1) {
    $sql .= " LIMIT {$limit_low},{$limit_high}";
}
$query = 'SELECT DISTINCT(`ports`.`port_id`),`ports`.*';
// calculate ifLastChange as seconds ago
$query .= ',`D`.`uptime` - `ports`.`ifLastChange` / 100 as secondsIfLastChange ';
$query .= $sql;
foreach (dbFetchRows($query, $param) as $port) {
    $device = device_by_id_cache($port['device_id']);
    // FIXME what actions should we have?
    $actions = '<div class="container-fluid"><div class="row">';
    $actions .= '<div class="col-xs-1"><a href="';
    $actions .= generate_device_url($device, array('tab' => 'alerts'));
    $actions .= '"><img src="images/16/bell.png" border="0" align="absmiddle" alt="View alerts" title="View alerts" /></a></div>';
    if ($_SESSION['userlevel'] >= '7') {
        $actions .= '<div class="col-xs-1"><a href="';
        $actions .= generate_device_url($device, array('tab' => 'edit', 'section' => 'ports'));
        $actions .= '"><img src="images/16/wrench.png" border="0" align="absmiddle" alt="Edit ports" title="Edit ports" /></a></div>';
    }
    $actions .= '</div></div>';
    $response[] = array('device' => generate_device_link($device), 'port' => generate_port_link($port), 'ifLastChange' => ceil($port['secondsIfLastChange']), 'ifConnectorPresent' => $port['ifConnectorPresent'] == 'true' ? 'yes' : 'no', 'ifSpeed' => $port['ifSpeed'], 'ifMtu' => $port['ifMtu'], 'ifInOctets_rate' => $port['ifInOctets_rate'] * 8, 'ifOutOctets_rate' => $port['ifOutOctets_rate'] * 8, 'ifInUcastPkts_rate' => $port['ifInUcastPkts_rate'], 'ifOutUcastPkts_rate' => $port['ifOutUcastPkts_rate'], 'ifInErrors' => $port['ifInErrors'], 'ifOutErrors' => $port['ifOutErrors'], 'ifType' => humanmedia($port['ifType']), 'description' => display($port['ifAlias']), 'actions' => $actions);
}
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
コード例 #4
0
$query .= "AND `ifPhysAddress` LIKE ?";
$param = array("%" . str_replace(array(':', ' ', '-', '.', '0x'), '', mres($_POST['address'])) . "%");
if (is_numeric($_POST['device_id'])) {
    $query .= " AND P.device_id = ?";
    $param[] = $_POST['device_id'];
}
if ($_POST['interface']) {
    $query .= " AND P.ifDescr LIKE ?";
    $param[] = $_POST['interface'];
}
$query .= " ORDER BY P.ifPhysAddress";
echo '<tr><th>Device</a></th><th>Interface</th><th>MAC Address</th><th>Description</th></tr>';
foreach (dbFetchRows($query, $param) as $entry) {
    if (!$ignore) {
        $speed = humanspeed($entry['ifSpeed']);
        $type = humanmedia($entry['ifType']);
        if ($entry['in_errors'] > 0 || $entry['out_errors'] > 0) {
            $error_img = generate_port_link($entry, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors);
        } else {
            $error_img = "";
        }
        if (port_permitted($entry['port_id'])) {
            $interface = ifLabel($interface, $interface);
            echo '<tr>
          <td>' . generate_device_link($entry) . '</td>
          <td>' . generate_port_link($entry, makeshortif(fixifname($entry['ifDescr']))) . ' ' . $error_img . '</td>
          <td>' . formatMac($entry['ifPhysAddress']) . '</td>
          <td>' . $entry['ifAlias'] . "</td>\n        </tr>\n";
        }
    }
    unset($ignore);