Example #1
0
    $where .= " AND I.ifAlias LIKE '%" . $_POST['ifAlias'] . "%'";
}
if ($_POST['deleted'] || $_GET['type'] == "deleted") {
    $where .= " AND I.deleted = '1'";
}
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id {$where} ORDER BY D.hostname, I.ifIndex";
$query = mysql_query($sql);
echo "<tr class=tablehead><td></td><th>Device</a></th><th>Interface</th><th>Speed</th><th>Media</th><th>Description</th></tr>";
$row = 1;
while ($interface = mysql_fetch_array($query)) {
    if (is_integer($row / 2)) {
        $row_colour = $list_colour_a;
    } else {
        $row_colour = $list_colour_b;
    }
    $speed = humanspeed($interface['ifSpeed']);
    $type = humanmedia($interface['ifType']);
    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}>\n          <td width=5></td>\n          <td width=200 class=list-bold>" . generatedevicelink($interface) . "</td>\n          <td width=150 class=list-bold>" . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . " {$error_img}</td>\n          <td width=110 >{$speed}</td>\n          <td width=200>{$type}</td>\n          <td>" . $interface['ifAlias'] . "</td>\n        </tr>\n";
        $row++;
    }
}
echo "</table>";
?>

Example #2
0
                 case 'upkts':
                 case 'nupkts':
                 case 'errors':
                     $port['width'] = '130';
                     $port['height'] = '30';
                     $port['from'] = $config['time']['day'];
                     $port['to'] = $config['time']['now'];
                     $port['bg'] = '#' . $bg;
                     $port['graph_type'] = 'port_' . $_GET['optc'];
                     echo "<div style='display: block; padding: 3px; margin: 3px; min-width: 135px; max-width:135px; min-height:75px; max-height:75px;\n                            text-align: center; float: left; background-color: " . $list_colour_b_b . ";'>\n                                <div style='font-weight: bold;'>" . makeshortif($port['ifDescr']) . '</div>';
                     print_port_thumbnail($port);
                     echo "<div style='font-size: 9px;'>" . truncate(short_port_descr($port['ifAlias']), 22, '') . '</div>
                         </div>';
                     break;
                 default:
                     echo $seperator . generate_port_link($port, makeshortif($port['ifDescr']));
                     $seperator = ', ';
                     break;
             }
             //end switch
         }
         //end foreach
         echo '</td></tr>';
         $x++;
     }
     //end foreach
     echo '</table></td>';
     $i++;
 }
 //end foreach
 echo '</table></div>';
Example #3
0
    <span class=list-device-down>Device Down</span> <br />
    <span class=body-date-1>' . truncate($device['location'], 20) . '</span>');
    ++$count_boxes;
}
if (is_admin() === true || is_read() === true) {
    $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1' LIMIT " . $config['front_page_down_box_limit'];
} else {
    $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND  I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0' AND `D`.`status` = '1'  LIMIT " . $config['front_page_down_box_limit'];
}
// These things need to become more generic, and more manageable across different frontpages... rewrite inc :>
// Port down boxes
if ($config['warn']['ifdown']) {
    foreach (dbFetchRows($sql) as $interface) {
        if (!$interface['deleted']) {
            $interface = ifNameDescr($interface);
            generate_front_box('alert alert-danger', generate_device_link($interface, shorthost($interface['hostname'])) . "<br />\n        <span class=\"interface-updown\">Port Down</span><br />\n<!--      <img src='graph.php?type=bits&amp;if=" . $interface['port_id'] . '&amp;from=' . $config['time']['day'] . '&amp;to=' . $config['time']['now'] . "&amp;width=100&amp;height=32' /> -->\n        " . generate_port_link($interface, truncate(makeshortif($interface['label']), 13, '')) . ' <br />
        ' . ($interface['ifAlias'] ? '<span class="body-date-1">' . truncate($interface['ifAlias'], 20, '') . '</span>' : ''));
            ++$count_boxes;
        }
    }
}
/*
    FIXME service permissions? seem nonexisting now.. */
// Service down boxes
if (is_admin() === true || is_read() === true) {
    $sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0' AND `D`.`status` = '2' LIMIT " . $config['front_page_down_box_limit'];
    $param[] = '';
} else {
    $sql = "SELECT * FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0' AND `D`.`status` = '2' LIMIT " . $config['front_page_down_box_limit'];
    $param[] = $_SESSION['user_id'];
}
        $bg_colour = $list_colour_a;
    } else {
        $bg_colour = $list_colour_b;
    }
    foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ?", array($customer['port_descr_descr'])) as $port) {
        $device = device_by_id_cache($port['device_id']);
        unset($class);
        $ifname = fixifname($device['ifDescr']);
        $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
        if ($device['os'] == "ios") {
            if ($port['ifTrunk']) {
                $vlan = "<span class=box-desc><span class=red>" . $port['ifTrunk'] . "</span></span>";
            } elseif ($port['ifVlan']) {
                $vlan = "<span class=box-desc><span class=blue>VLAN " . $port['ifVlan'] . "</span></span>";
            } else {
                $vlan = "";
            }
        }
        echo "\n           <tr bgcolor='{$bg_colour}'>\n             <td width='7'></td>\n             <td width='250'><span style='font-weight: bold;' class=interface>" . $customer_name . "</span></td>\n             <td width='150'>" . generate_device_link($device) . "</td>\n             <td width='100'>" . generate_port_link($port, makeshortif($port['ifDescr'])) . "</td>\n             <td width='100'>" . $port['port_descr_speed'] . "</td>\n             <td width='100'>" . $port['port_descr_circuit'] . "</td>\n             <td>" . $port['port_descr_notes'] . "</td>\n           </tr>\n         ";
        unset($customer_name);
    }
    echo "<tr bgcolor='{$bg_colour}'><td></td><td colspan=6>";
    $graph_array['type'] = "customer_bits";
    $graph_array['height'] = "100";
    $graph_array['width'] = "220";
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $customer['port_descr_descr'];
    include "includes/print-graphrow.inc.php";
    echo "</tr>";
}
echo "</table>";
Example #5
0
$traverse_ifvlan = true;
$otherports = dbFetchRows('SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id', array($device['device_id'], $vlan['vlan_vlan']));
foreach ($otherports as $otherport) {
    if ($otherport['untagged']) {
        $traverse_ifvlan = false;
    }
    $vlan_ports[$otherport[ifIndex]] = $otherport;
}
if ($traverse_ifvlan) {
    $otherports = dbFetchRows('SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?', array($device['device_id'], $vlan['vlan_vlan']));
    foreach ($otherports as $otherport) {
        $vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('untagged' => '1'));
    }
}
ksort($vlan_ports);
foreach ($vlan_ports as $port) {
    $port = ifLabel($port, $device);
    if ($vars['view'] == 'graphs') {
        echo "<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: " . $list_colour_b_b . ";'>\n    <div style='font-weight: bold;'>" . makeshortif($port['ifDescr']) . "</div>\n    <a href='device/device=" . $device['device_id'] . '/tab=port/port=' . $port['port_id'] . "/' onmouseover=\"return overlib('\\\n    <div style=\\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\\'>" . $device['hostname'] . ' - ' . $port['ifDescr'] . '</div>\\
    ' . $port['ifAlias'] . " \\\n    <img src=\\'graph.php?type={$graph_type}&amp;id=" . $port['port_id'] . '&amp;from=' . $config['time']['twoday'] . '&amp;to=' . $config['time']['now'] . "&amp;width=450&amp;height=150\\'>\\\n    ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >" . "<img src='graph.php?type={$graph_type}&amp;id=" . $port['port_id'] . '&amp;from=' . $config['time']['twoday'] . '&amp;to=' . $config['time']['now'] . "&amp;width=132&amp;height=40&amp;legend=no'>\n    </a>\n    <div style='font-size: 9px;'>" . truncate(short_port_descr($port['ifAlias']), 22, '') . '</div>
   </div>';
    } else {
        echo $vlan['port_sep'] . generate_port_link($port, makeshortif($port['label']));
        $vlan['port_sep'] = ', ';
        if ($port['untagged']) {
            echo '(U)';
        }
    }
}
//end foreach
echo '</td></tr>';
Example #6
0
    if ($vars['graph'] == $type && $vars['view'] == 'minigraphs') {
        echo '</span>';
    }
    echo ')';
    $type_sep = ' | ';
}
//end foreach
print_optionbar_end();
if ($vars['view'] == 'minigraphs') {
    $timeperiods = array('-1day', '-1week', '-1month', '-1year');
    $from = '-1day';
    echo "<div style='display: block; clear: both; margin: auto; min-height: 500px;'>";
    unset($seperator);
    // FIXME - FIX THIS. UGLY.
    foreach (dbFetchRows('select * from ports WHERE device_id = ? ORDER BY ifIndex', array($device['device_id'])) as $port) {
        echo "<div style='display: block; padding: 3px; margin: 3px; min-width: 183px; max-width:183px; min-height:90px; max-height:90px; text-align: center; float: left; background-color: #e9e9e9;'>\n            <div style='font-weight: bold;'>" . makeshortif($port['ifDescr']) . '</div>
            <a href="' . generate_port_url($port) . "\" onmouseover=\"return overlib('\\\n            <div style=\\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\\'>" . $device['hostname'] . ' - ' . $port['ifDescr'] . '</div>\\
            ' . $port['ifAlias'] . " \\\n            <img src=\\'graph.php?type=" . $graph_type . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . $config['time']['now'] . "&amp;width=450&amp;height=150\\'>\\\n            ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >" . "<img src='graph.php?type=" . $graph_type . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . $config['time']['now'] . "&amp;width=180&amp;height=45&amp;legend=no'>\n            </a>\n            <div style='font-size: 9px;'>" . truncate(short_port_descr($port['ifAlias']), 32, '') . '</div>
            </div>';
    }
    echo '</div>';
} else {
    if ($vars['view'] == 'arp' || $vars['view'] == 'adsl' || $vars['view'] == 'neighbours') {
        include 'ports/' . $vars['view'] . '.inc.php';
    } else {
        if ($vars['view'] == 'details') {
            $port_details = 1;
        }
        ?>
<div style='margin: 0px;'><table class='table'>
  <tr>
Example #7
0
    if (!$ignore) {
        if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) {
            $error_img = generate_port_link($entry, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", port_errors);
        } else {
            $error_img = '';
        }
        $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address']));
        if ($arp_host) {
            $arp_name = generate_device_link($arp_host);
        } else {
            unset($arp_name);
        }
        if ($arp_host) {
            $arp_if = generate_port_link($arp_host);
        } else {
            unset($arp_if);
        }
        if ($arp_host['device_id'] == $entry['device_id']) {
            $arp_name = 'Localhost';
        }
        if ($arp_host['port_id'] == $entry['port_id']) {
            $arp_if = 'Local port';
        }
        $response[] = array('mac_address' => formatMac($entry['mac_address']), 'ipv4_address' => $entry['ipv4_address'], 'hostname' => generate_device_link($entry), 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, 'remote_device' => $arp_name, 'remote_interface' => $arp_if);
    }
    //end if
    unset($ignore);
}
//end foreach
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
Example #8
0
    $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0'";
}
foreach (dbFetchRows($sql) as $device) {
    generate_front_box("#ffaaaa", "<center><strong>" . generate_device_link($device, shorthost($device['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span> <br />\n      <span class=body-date-1>" . truncate($device['location'], 20) . "</span>\n      </center>");
}
if ($_SESSION['userlevel'] == '10') {
    $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
} else {
    $sql = "SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND  I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
}
// These things need to become more generic, and more manageable across different frontpages... rewrite inc :>
if ($config['warn']['ifdown']) {
    foreach (dbFetchRows($sql) as $interface) {
        if (!$interface['deleted']) {
            $interface = ifNameDescr($interface);
            generate_front_box("#ffdd99", "<center><strong>" . generate_device_link($interface, shorthost($interface['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />\n<!--      <img src='graph.php?type=bits&amp;if=" . $interface['port_id'] . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=100&amp;height=32' /> -->\n        <strong>" . generate_port_link($interface, truncate(makeshortif($interface['label']), 13, '')) . "</strong> <br />\n        " . ($interface['ifAlias'] ? '<span class="body-date-1">' . truncate($interface['ifAlias'], 20, '') . '</span>' : '') . "\n        </center>");
        }
    }
}
/* FIXME service permissions? seem nonexisting now.. */
$sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'";
foreach (dbFetchRows($sql) as $service) {
    generate_front_box("#ffaaaa", "<center><strong>" . generate_device_link($service, shorthost($service['hostname'])) . "</strong><br />\n    <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>\n    <strong>" . $service['service_type'] . "</strong><br />\n    <span class=body-date-1>" . truncate($interface['ifAlias'], 20) . "</span>\n    </center>");
}
if (isset($config['enable_bgp']) && $config['enable_bgp']) {
    if ($_SESSION['userlevel'] == '10') {
        $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0";
    } else {
        $sql = "SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND  bgpPeerAdminStatus != 'start' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0";
    }
    foreach (dbFetchRows($sql) as $peer) {
Example #9
0
        }
        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++;
        }
    }
    unset($ignore);
}
echo "</table>";
Example #10
0
 unset($sub);
 $hostname = $ip['hostname'];
 $real_hostname = $hostname;
 $hostname = str_replace(".vostron.net", "", $hostname);
 list($loc, $host) = explode("-", $hostname);
 if ($host) {
     $hostname = "{$host}.{$loc}.v4.vostron.net";
 } else {
     $host = $loc;
     unset($loc);
     $hostname = "{$host}.v4.vostron.net";
 }
 $interface = $ip['ifDescr'];
 $address = $ip['addr'];
 $cidr = $ip['cidr'];
 $interface = strtolower(makeshortif(fixifname($interface)));
 $interface = str_replace("/", "-", $interface);
 list($interface, $sub) = explode(".", $interface);
 if ($sub) {
     $sub = str_replace(" ", "", $sub);
     $sub = str_replace("aal5", "", $sub);
     $interface = "{$sub}.{$interface}";
 }
 $hostip = trim(gethostbyname($real_hostname));
 if (strstr($hostname, ".vostron.net")) {
     list($first, $second, $third, $fourth) = explode(".", $address);
     $revzone = "{$third}.{$second}.{$first}.in-addr.arpa";
     $reverse = "{$fourth}.{$revzone}";
     $dnsname = "{$interface}.{$hostname}";
     $rev_sql = "SELECT `domain_id` FROM `domains` WHERE domain = '" . $revzone . "'";
     $rev_domain_id = @mysql_result(mysql_query($rev_sql, $dnsdblink), 0);
Example #11
0
    $port['port_id'] = $if_list;
    include 'includes/print-interface-graphs.inc.php';
    echo '</td></tr>';
    foreach ($ports as $port) {
        $done = 'yes';
        unset($class);
        $port['ifAlias'] = str_ireplace($type . ': ', '', $port['ifAlias']);
        $port['ifAlias'] = str_ireplace('[PNI]', 'Private', $port['ifAlias']);
        $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
        if ($bg == '#ffffff') {
            $bg = '#e5e5e5';
        } else {
            $bg = '#ffffff';
        }
        echo "<tr class='iftype'>\n            <td><span class=list-large>" . generate_port_link($port, $port['port_descr_descr']) . "</span><br />\n            <span class=interface-desc style='float: left;'>" . generate_device_link($port) . ' ' . generate_port_link($port) . ' </span></td>
            <td>' . generate_port_link($port, makeshortif($port['ifDescr'])) . '</td>
            <td>' . $port['port_descr_speed'] . '</td>
            <td>' . $port['port_descr_circuit'] . '</td>
            <td>' . $port['port_descr_notes'] . "</td>\n            </tr>\n            <tr class='iftype'>\n            <td colspan='5'";
        if (dbFetchCell('SELECT count(*) FROM mac_accounting WHERE port_id = ?', array($port['port_id']))) {
            echo "<span style='float: right;'><a href='" . generate_url(array('page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id'], 'view' => 'macaccounting')) . "'><img src='images/16/chart_curve.png' align='absmiddle'> MAC Accounting</a></span>";
        }
        echo '<br />';
        if (file_exists(get_port_rrdfile_path($port['hostname'], $port['port_id']))) {
            $graph_type = 'port_bits';
            include 'includes/print-interface-graphs.inc.php';
        }
        echo '</td></tr>';
    }
} else {
    echo 'None found.</td></tr>';
Example #12
0
<?php

// Generate a list of ports and then call the multi_bits grapher to generate from the list
$i = 0;
if (!is_array($config['customers_descr'])) {
    $config['customers_descr'] = array($config['customers_descr']);
}
$descr_type = "'" . implode("', '", $config['customers_descr']) . "'";
foreach (dbFetchRows('SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ? AND D.device_id = I.device_id', array(array($descr_type), $vars['id'])) as $port) {
    if (is_file($config['rrd_dir'] . '/' . $port['hostname'] . '/port-' . safename($port['ifIndex'] . '.rrd'))) {
        $rrd_filename = $config['rrd_dir'] . '/' . $port['hostname'] . '/port-' . safename($port['ifIndex'] . '.rrd');
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = $port['hostname'] . '-' . $port['ifDescr'];
        $rrd_list[$i]['descr_in'] = shorthost($port['hostname']);
        $rrd_list[$i]['descr_out'] = makeshortif($port['ifDescr']);
        $i++;
    }
}
// echo($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"));
$units = 'bps';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = '8';
$colours_out = 'blues';
$nototal = 1;
$ds_in = 'INOCTETS';
$ds_out = 'OUTOCTETS';
require 'includes/graphs/generic_multi_bits_separated.inc.php';
Example #13
0
    echo '<tr>
          <td colspan="4">';
    echo overlib_link($link, $graph, $overlib_content, null);
    echo '  </td>
        </tr>';
    echo '
    <tr>
      <td><img src="images/16/connect.png" align="absmiddle"> ' . $ports['total'] . '</td>
      <td><img src="images/16/if-connect.png" align="absmiddle"> ' . $ports['up'] . '</td>
      <td><img src="images/16/if-disconnect.png" align="absmiddle"> ' . $ports['down'] . '</td>
      <td><img src="images/16/if-disable.png" align="absmiddle"> ' . $ports['disabled'] . '</td>
    </tr>';
    echo '<tr>
          <td colspan="4">';
    $ifsep = '';
    foreach (dbFetchRows("SELECT * FROM `ports` WHERE device_id = ? AND `deleted` != '1'", array($device['device_id'])) as $data) {
        $data = ifNameDescr($data);
        $data = array_merge($data, $device);
        echo "{$ifsep}" . generate_port_link($data, makeshortif(strtolower($data['label'])));
        $ifsep = ', ';
    }
    unset($ifsep);
    echo '  </td>';
    echo '</tr>';
    echo '</table>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
}
//end if
Example #14
0
            $already = 'yes';
        }
        $i++;
    }
    if (!$already) {
        $nodes[] = $device['device_id'];
    }
}
$sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'";
foreach (dbFetchRows($sql) as $device) {
    echo "<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffbbbb; margin: 4px;'>\n        <center><strong>" . generate_device_link($device, shorthost($device['hostname'])) . "</strong><br />\n        <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span>\n        <span class=body-date-1>" . truncate($device['location'], 20) . '</span>
        </center></div>';
}
$sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
foreach (dbFetchRows($sql) as $interface) {
    echo "<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>\n        <center><strong>" . generate_device_link($interface, shorthost($interface['hostname'])) . "</strong><br />\n        <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span>\n        <strong>" . generate_port_link($interface, makeshortif($interface['ifDescr'])) . '</strong> <br />
        <span class=body-date-1>' . truncate($interface['ifAlias'], 20) . '</span>
        </center></div>';
}
$sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'";
foreach (dbFetchRows($sql) as $service) {
    echo "<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>\n        <center><strong>" . generate_device_link($service, shorthost($service['hostname'])) . "</strong><br />\n        <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>\n        <strong>" . $service['service_type'] . '</strong><br />
        <span class=body-date-1>' . truncate($interface['ifAlias'], 20) . '</span>
        </center></div>';
}
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id";
foreach (dbFetchRows($sql) as $peer) {
    echo "<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>\n        <center><strong>" . generate_device_link($peer, shorthost($peer['hostname'])) . "</strong><br />\n        <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span>\n        <strong>" . $peer['bgpPeerIdentifier'] . '</strong> <br />
        <span class=body-date-1>AS' . $peer['bgpPeerRemoteAs'] . ' ' . truncate($peer['astext'], 10) . '</span>
        </center></div>';
}
Example #15
0
if ($_SESSION['userlevel'] == '10') {
    $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
} else {
    $sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0'");
}
while ($device = mysql_fetch_array($sql)) {
    generate_front_box("alert", "<center><strong>" . generatedevicelink($device, shorthost($device['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span> <br />\n      <span class=body-date-1>" . truncate($device['location'], 20) . "</span>\n      </center>");
}
if ($_SESSION['userlevel'] == '10') {
    $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
} else {
    $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND  I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
}
while ($interface = mysql_fetch_array($sql)) {
    $interface = ifNameDescr($interface);
    generate_front_box("warn", "<center><strong>" . generatedevicelink($interface, shorthost($interface['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />\n<!--      <img src='graph.php?type=bits&if=" . $interface['interface_id'] . "&from={$day}&to={$now}&width=100&height=32' /> -->\n      <strong>" . generateiflink($interface, truncate(makeshortif($interface['label']), 13, '')) . "</strong> <br />\n      " . ($interface['ifAlias'] ? '<span class="body-date-1">' . truncate($interface['ifAlias'], 20, '') . '</span>' : '') . "\n      </center>");
}
/* FIXME service permissions? seem nonexisting now.. */
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while ($service = mysql_fetch_array($sql)) {
    generate_front_box("alert", "<center><strong>" . generatedevicelink($service, shorthost($service['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span> \n      <strong>" . $service['service_type'] . "</strong><br />\n      <span class=body-date-1>" . truncate($interface['ifAlias'], 20) . "</span>\n      </center>");
}
if ($_SESSION['userlevel'] == '10') {
    $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
} else {
    $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0");
}
while ($peer = mysql_fetch_array($sql)) {
    generate_front_box("alert", "<center><strong>" . generatedevicelink($peer, shorthost($peer['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span> \n      <span style='" . (strstr($peer['bgpPeerIdentifier'], ':') ? 'font-size: 10px' : '') . "'><strong>" . $peer['bgpPeerIdentifier'] . "</strong></span><br />\n      <span title='" . $peer['astext'] . "' class=body-date-1>AS" . $peer['bgpPeerRemoteAs'] . " " . truncate($peer['astext'], 10) . "</span>\n      </center>");
}
if ($_SESSION['userlevel'] == '10') {
<?php

if (is_numeric($vars['id']) && ($auth || port_permitted($vars['id']))) {
    $port = get_port_by_id($vars['id']);
    $device = device_by_id_cache($port['device_id']);
    $title = generate_device_link($device);
    $title .= " :: Port  " . generate_port_link($port);
    $graph_title = shorthost($device['hostname']) . "::" . strtolower(makeshortif($port['ifDescr']));
    $auth = TRUE;
    $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
}
Example #17
0
        } else {
            $insert_query = "INSERT INTO `vrfs` (`vrf_oid`,`vrf_name`,`mplsVpnVrfRouteDistinguisher`,`mplsVpnVrfDescription`,`device_id`) ";
            $insert_query .= "VALUES ('" . $vrf['oid'] . "','" . $vrf['name'] . "','" . $vrf['mplsVpnVrfRouteDistinguisher'] . "','" . $vrf['mplsVpnVrfDescription'] . "','" . $device['device_id'] . "')";
            mysql_query($insert_query);
        }
        $vrf_id = @mysql_result(mysql_query("SELECT vrf_id FROM vrfs WHERE `device_id` = '" . $device['device_id'] . "' AND `vrf_oid`='" . $vrf['oid'] . "'"), 0);
        $valid_vrf[$vrf_id] = 1;
        echo "\nRD:" . $vrf['mplsVpnVrfRouteDistinguisher'] . " " . $vrf['name'] . " " . $vrf['mplsVpnVrfDescription'] . " ";
        $ports_oid = ".1.3.6.1.3.118.1.2.1.1.2." . $vrf['oid'];
        $ports = shell_exec($config['snmpwalk'] . " -m MPLS-VPN-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . ":" . $device['port'] . " {$ports_oid}");
        $ports = trim(str_replace($ports_oid . ".", "", $ports));
        #    list($ports) = explode(" ", $ports);
        echo " ( ";
        foreach (explode("\n", $ports) as $if_id) {
            $interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE ifIndex = '{$if_id}' AND device_id = '" . $device['device_id'] . "'"));
            echo makeshortif($interface['ifDescr']) . " ";
            mysql_query("UPDATE ports SET ifVrf = '" . $vrf_id . "' WHERE interface_id = '" . $interface['interface_id'] . "'");
            $if = $interface['interface_id'];
            $valid_vrf_if[$vrf_id][$if] = 1;
        }
        echo ") ";
    }
}
echo "\n";
$sql = "SELECT * FROM ports WHERE device_id = '" . $device['device_id'] . "'";
$data = mysql_query($sql);
while ($row = mysql_fetch_array($data)) {
    $if = $row['interface_id'];
    $vrf_id = $row['ifVrf'];
    if ($row['ifVrf']) {
        if (!$valid_vrf_if[$vrf_id][$if]) {
Example #18
0
    $src = str_replace("." . $config['mydomain'], "", $src);
    $dst = str_replace("." . $config['mydomain'], "", $dst);
    $info = "";
    if ($src_speed >= "10000000000") {
        $info .= "color=lightred weight=10 style=\"setlinewidth(8)\"";
    } elseif ($src_speed >= "1000000000") {
        $info .= "color=lightblue weight=5 style=\"setlinewidth(4)\"";
    } elseif ($src_speed >= "100000000") {
        $info .= "color=lightgrey weight=1 style=\"setlinewidth(2)\"";
    } elseif ($src_speed >= "10000000") {
        $info .= "style=\"setlinewidth(1)\" weight=1";
    }
    unset($die);
    $i = 0;
    while ($i < count($linkdone)) {
        $thislink = "{$dst} " . $link_data['dif'] . " {$src} " . $link_data['sif'];
        if ($linkdone[$i] == $thislink) {
            $die = "yes";
        }
        $i++;
    }
    $sif = makeshortif($link_data['sif']);
    $dif = makeshortif($link_data['dif']);
    if (!$die) {
        echo "\"{$src}\" -> \"{$dst}\" [taillabel=\"{$dif}\"  headlabel=\"{$sif}\" arrowhead=dot arrowtail=dot {$info}];\n";
        #       echo("\"$src\" -> \"$dst\" [ arrowhead=none arrowtail=none $info];\n");
        $linkdone[] = "{$src} " . $link_data['sif'] . " {$dst} " . $link_data['dif'];
        $x++;
    }
}
echo "}";
Example #19
0
<?php

// fixme new url format
if (is_integer($i / 2)) {
    $bg_colour = $list_colour_a;
} else {
    $bg_colour = $list_colour_b;
}
echo "<tr bgcolor='{$bg_colour}'>";
echo "<td width=200 class=list-large><a href='routing/vrf/" . $vrf['mplsVpnVrfRouteDistinguisher'] . "/'>" . $vrf['vrf_name'] . "</a></td>";
echo "<td width=150 class=box-desc>" . $vrf['mplsVpnVrfDescription'] . "</td>";
echo "<td width=100 class=box-desc>" . $vrf['mplsVpnVrfRouteDistinguisher'] . "</td>";
echo '<td class="list-bold">';
foreach (dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVrf` = ?", array($device['device_id'], $vrf['vrf_id'])) as $port) {
    if ($vars['view'] == "graphs") {
        $graph_type = "port_" . $vars['graph'];
        echo "<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: #e9e9e9;'>\n    <div style='font-weight: bold;'>" . makeshortif($port['ifDescr']) . "</div>\n    <a href='device/" . $device['device_id'] . "/port/" . $port['port_id'] . "/' onmouseover=\"return overlib('\\\n    <div style=\\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\\'>" . $device['hostname'] . " - " . $port['ifDescr'] . "</div>\\\n    " . $port['ifAlias'] . " \\\n    <img src=\\'graph.php?type={$graph_type}&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['twoday'] . "&amp;to=" . $config['time']['now'] . "&amp;width=450&amp;height=150\\'>\\\n    ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >" . "<img src='graph.php?type={$graph_type}&amp;id=" . $port['port_id'] . "&amp;from=" . $config['time']['twoday'] . "&amp;to=" . $config['time']['now'] . "&amp;width=132&amp;height=40&amp;legend=no'>\n    </a>\n    <div style='font-size: 9px;'>" . truncate(short_port_descr($port['ifAlias']), 22, '') . "</div>\n   </div>";
    } else {
        echo $vrf['port_sep'] . generate_port_link($port, makeshortif($port['ifDescr']));
        $vrf['port_sep'] = ", ";
    }
}
echo "</td>";
echo "</tr>";
Example #20
0
echo "<a href='" . $config['base_url'] . "/device/" . $device['device_id'] . "/ports/'>Basic</a> | \r\n<a href='" . $config['base_url'] . "/device/" . $device['device_id'] . "/ports/details/'>Details</a> | \r\n<a href='" . $config['base_url'] . "/device/" . $device['device_id'] . "/ports/arp/'>ARP Table</a> | Graphs: ";
$graph_types = array("bits" => "Bits", "upkts" => "Unicast Packets", "nupkts" => "Non-Unicast Packets", "errors" => "Errors", "etherlike" => "Etherlike");
foreach ($graph_types as $type => $descr) {
    echo "{$type_sep} \r\n  <a href='" . $config['base_url'] . "/device/" . $device['device_id'] . "/ports/graphs/{$type}/'>{$descr}</a> \r\n  (<a href='" . $config['base_url'] . "/device/" . $device['device_id'] . "/ports/graphs/{$type}/thumbs/'>Mini</a>) ";
    $type_sep = " | ";
}
print_optionbar_end();
if ($_GET['optc'] == thumbs) {
    $timeperiods = array('-1day', '-1week', '-1month', '-1year');
    $from = '-1day';
    echo "<div style='display: block; clear: both; margin: auto;'>";
    $sql = "select * from ports WHERE device_id = '" . $device['device_id'] . "' ORDER BY ifIndex";
    $query = mysql_query($sql);
    unset($seperator);
    while ($interface = mysql_fetch_array($query)) {
        echo "<div style='display: block; padding: 3px; margin: 3px; min-width: 183px; max-width:183px; min-height:90px; max-height:90px; text-align: center; float: left; background-color: #e9e9e9;'>\r\n    <div style='font-weight: bold;'>" . makeshortif($interface['ifDescr']) . "</div>\r\n    <a href='device/" . $device['device_id'] . "/interface/" . $interface['interface_id'] . "/' onmouseover=\"return overlib('\\\r\n    <div style=\\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\\'>" . $device['hostname'] . " - " . $interface['ifDescr'] . "</div>\\\r\n    " . $interface['ifAlias'] . " \\\r\n    <img src=\\'graph.php?type={$graph_type}&if=" . $interface['interface_id'] . "&from=" . $from . "&to=" . $now . "&width=450&height=150\\'>\\\r\n    ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >" . "<img src='graph.php?type={$graph_type}&if=" . $interface['interface_id'] . "&from=" . $from . "&to=" . $now . "&width=180&height=45&legend=no'>\r\n    </a>\r\n    <div style='font-size: 9px;'>" . truncate(short_port_descr($interface['ifAlias']), 32, '') . "</div>\r\n    </div>";
    }
    echo "</div>";
} else {
    if ($_GET['opta'] == "arp") {
        include "arp.inc.php";
    } else {
        if ($_GET['opta'] == "details") {
            $port_details = 1;
        }
        echo "<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>";
        $i = "1";
        $interface_query = mysql_query("select * from ports WHERE device_id = '" . $device['device_id'] . "' AND deleted = '0' ORDER BY `ifIndex` ASC");
        while ($interface = mysql_fetch_array($interface_query)) {
            include "includes/print-interface.inc.php";
            $i++;
            }
            if ($int_links_v4[$int_link]) {
                echo " <b style='color: #00a100'>v4</b>";
            }
            $br = "<br />";
        }
    }
    #     unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
}
if ($port_details && $config['enable_port_relationship'] === TRUE) {
    foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `port_id` = ?", array($port['port_id'])) as $pseudowire) {
        #`port_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`
        $pw_peer_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($pseudowire['peer_device_id']));
        $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, pseudowires AS P WHERE I.device_id = ? AND P.cpwVcID = ? AND P.port_id = I.port_id", array($pseudowire['peer_device_id'], $pseudowire['cpwVcID']));
        $pw_peer_int = ifNameDescr($pw_peer_int);
        echo "{$br}<img src='images/16/arrow_switch.png' align=absmiddle><b> " . generate_port_link($pw_peer_int, makeshortif($pw_peer_int['label'])) . " on " . generate_device_link($pw_peer_dev, shorthost($pw_peer_dev['hostname'])) . "</b>";
        $br = "<br />";
    }
    foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) {
        echo "{$br}<img src='images/16/brick_link.png' align=absmiddle> <strong>" . generate_port_link($member) . " (PAgP)</strong>";
        $br = "<br />";
    }
    if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) {
        $parent = dbFetchRow("SELECT * FROM `ports` WHERE `ifIndex` = ? and `device_id` = ?", array($port['pagpGroupIfIndex'], $device['device_id']));
        echo "{$br}<img src='images/16/bricks.png' align=absmiddle> <strong>" . generate_port_link($parent) . " (PAgP)</strong>";
        $br = "<br />";
    }
    foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if) {
        if ($higher_if['port_id_high']) {
            $this_port = get_port_by_index_cache($device['device_id'], $higher_if['port_id_high']);
            echo "{$br}<img src='images/16/arrow_divide.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>";
Example #22
0
$accs = dbFetchRows("SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) AS bps,\n        (M.cipMacHCSwitchedPkts_input_rate + M.cipMacHCSwitchedPkts_output_rate) AS pps\n        FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.port_id = ?\n        AND I.port_id = M.port_id AND D.device_id = I.device_id ORDER BY {$sort} DESC LIMIT 0," . $topn, array($port));
$pluses = '';
$iter = '0';
$rrd_options .= " COMMENT:'                                     In\\: Current     Maximum      Total      Out\\: Current     Maximum     Total\\\\n'";
foreach ($accs as $acc) {
    $this_rrd = $config['rrd_dir'] . '/' . $acc['hostname'] . '/' . safename('cip-' . $acc['ifIndex'] . '-' . $acc['mac'] . '.rrd');
    if (is_file($this_rrd)) {
        $mac = formatmac($acc['mac']);
        $name = $mac;
        $addy = dbFetchRow('SELECT * FROM ipv4_mac where mac_address = ? AND port_id = ?', array($acc['mac'], $acc['port_id']));
        if ($addy) {
            $name = $addy['ipv4_address'] . ' (' . $mac . ')';
            $peer = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D
              WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($addy['ipv4_address']));
            if ($peer) {
                $name = $peer['hostname'] . ' ' . makeshortif($peer['ifDescr']) . ' (' . $mac . ')';
            }
            if (dbFetchCell("SELECT count(*) FROM bgpPeers WHERE device_id = '" . $acc['device_id'] . "' AND bgpPeerIdentifier = ?", array($addy['ipv4_address']))) {
                $peer_info = dbFetchRow('SELECT * FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?', array($acc['device_id'], $addy['ipv4_address']));
                $name .= ' - AS' . $peer_info['bgpPeerRemoteAs'];
            }
            if ($peer_info) {
                $asn = 'AS' . $peer_info['bgpPeerRemoteAs'];
                $astext = $peer_info['astext'];
            } else {
                unset($as);
                unset($astext);
                unset($asn);
            }
        }
        //end if
Example #23
0
<?php

$hostname = gethostbyid($entry['host']);
unset($icon);
$icon = geteventicon($entry['message']);
if ($icon) {
    $icon = '<img src="images/16/' . $icon . '" />';
}
echo '<tr>
  <td>
    ' . $entry['datetime'] . '
  </td>';
if (!isset($vars['device'])) {
    $dev = device_by_id_cache($entry['host']);
    echo '<td>
    ' . generate_device_link($dev, shorthost($dev['hostname'])) . '
  </td>';
}
if ($entry['type'] == 'interface') {
    $this_if = ifLabel(getifbyid($entry['reference']));
    $entry['link'] = '<b>' . generate_port_link($this_if, makeshortif(strtolower($this_if['label']))) . '</b>';
} else {
    $entry['link'] = 'System';
}
echo '<td>' . $entry['link'] . '</td>';
echo '<td>' . $entry['message'] . '</td>
</tr>';
Example #24
0
$sql = "SELECT * {$sql}";
foreach (dbFetchRows($sql, $param) as $customer) {
    $i++;
    $customer_name = $customer['port_descr_descr'];
    foreach (dbFetchRows('SELECT * FROM `ports` WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ?', array(array($descr_type), $customer['port_descr_descr'])) as $port) {
        $device = device_by_id_cache($port['device_id']);
        $ifname = fixifname($device['ifDescr']);
        $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
        if ($device['os'] == 'ios') {
            if ($port['ifTrunk']) {
                $vlan = '<span class=box-desc><span class=red>' . $port['ifTrunk'] . '</span></span>';
            } elseif ($port['ifVlan']) {
                $vlan = '<span class=box-desc><span class=blue>VLAN ' . $port['ifVlan'] . '</span></span>';
            } else {
                $vlan = '';
            }
        }
        $response[] = array('port_descr_descr' => $customer_name, 'device_id' => generate_device_link($device), 'ifDescr' => generate_port_link($port, makeshortif($port['ifDescr'])), 'port_descr_speed' => $port['port_descr_speed'], 'port_descr_circuit' => $port['port_descr_circuit'], 'port_descr_notes' => $port['port_descr_notes']);
        unset($customer_name);
    }
    $graph_array['type'] = 'customer_bits';
    $graph_array['height'] = '100';
    $graph_array['width'] = '220';
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $customer['port_descr_descr'];
    $return_data = true;
    include 'includes/print-graphrow.inc.php';
    $response[] = array('port_descr_descr' => $graph_data[0], 'device_id' => $graph_data[1], 'ifDescr' => '', 'port_descr_speed' => '', 'port_descr_circuit' => $graph_data[2], 'port_descr_notes' => $graph_data[3]);
}
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
Example #25
0
<?php

$i = 0;
foreach (explode(",", $vars['id']) as $ifid) {
    $port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
    if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) {
        $port = ifLabel($port);
        $rrd_list[$i]['filename'] = $config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
        $rrd_list[$i]['descr'] = $port['hostname'] . " " . $port['ifDescr'];
        $rrd_list[$i]['descr_in'] = $port['hostname'];
        $rrd_list[$i]['descr_out'] = makeshortif($port['label']);
        $i++;
    }
}
$units = 'bps';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = "8";
$colours_out = 'blues';
$nototal = 1;
$ds_in = "INOCTETS";
$ds_out = "OUTOCTETS";
include "includes/graphs/generic_multi_bits_separated.inc.php";
Example #26
0
}
$navbar['class'] = "navbar-narrow";
$navbar['brand'] = "Ports";
print_navbar($navbar);
unset($navbar);
if (is_array($navbar_b)) {
    print_navbar($navbar_b);
}
if ($vars['view'] == 'minigraphs') {
    $timeperiods = array('-1day', '-1week', '-1month', '-1year');
    $from = '-1day';
    echo "<div style='display: block; clear: both; margin: auto; min-height: 500px;'>";
    unset($seperator);
    // FIXME - FIX THIS. UGLY.
    foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port) {
        echo "<div style='display: block; padding: 3px; margin: 3px; min-width: 183px; max-width:183px; min-height:90px; max-height:90px; text-align: center; float: left; background-color: #e9e9e9;'>\n    <div style='font-weight: bold;'>" . makeshortif($port['ifDescr']) . "</div>\n    <a href=\"" . generate_port_url($port) . "\" onmouseover=\"return overlib('\\\n    <div style=\\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\\'>" . $device['hostname'] . " - " . $port['ifDescr'] . "</div>\\\n    " . $port['ifAlias'] . " \\\n    <img src=\\'graph.php?type=" . $graph_type . "&amp;id=" . $port['port_id'] . "&amp;from=" . $from . "&amp;to=" . $config['time']['now'] . "&amp;width=450&amp;height=150\\'>\\\n    ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >" . "<img src='graph.php?type=" . $graph_type . "&amp;id=" . $port['port_id'] . "&amp;from=" . $from . "&amp;to=" . $config['time']['now'] . "&amp;width=180&amp;height=45&amp;legend=no'>\n    </a>\n    <div style='font-size: 9px;'>" . truncate(short_port_descr($port['ifAlias']), 32, '') . "</div>\n    </div>";
    }
    echo "</div>";
} elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours" || $vars['view'] == "fdb" || $vars['view'] == "map") {
    include "ports/" . $vars['view'] . ".inc.php";
} else {
    if ($vars['view'] == "details") {
        $port_details = 1;
    }
    if ($vars['view'] == "graphs") {
        $table_class = "table-striped-two";
    } else {
        $table_class = "table-striped";
    }
    echo '<table class="table table-hover table-bordered table-condensed table-rounded ' . $table_class . '"
             style="vertical-align: middle; margin-top: 5px; margin-bottom: 10px;">';
Example #27
0
    if ($vlan['state'] == "blocking") {
        $class = "red";
    } elseif ($vlan['state'] == "forwarding") {
        $class = "green";
    } else {
        $class = "none";
    }
    echo "<td>" . $vlan['cost'] . "</td><td>" . $vlan['priority'] . "</td><td class={$class}>" . $vlan['state'] . "</td>";
    $vlan_ports = array();
    $otherports = dbFetchRows("SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id", array($device['device_id'], $vlan['vlan']));
    foreach ($otherports as $otherport) {
        $vlan_ports[$otherport[ifIndex]] = $otherport;
    }
    $otherports = dbFetchRows("SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?", array($device['device_id'], $vlan['vlan']));
    foreach ($otherports as $otherport) {
        $vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('untagged' => '1'));
    }
    ksort($vlan_ports);
    echo "<td>";
    $vsep = '';
    foreach ($vlan_ports as $otherport) {
        echo $vsep . generate_port_link($otherport, makeshortif($otherport['ifDescr']));
        if ($otherport['untagged']) {
            echo "(U)";
        }
        $vsep = ", ";
    }
    echo "</td>";
    echo "</tr>";
}
echo "</table>";
Example #28
0
<table border=0 cellpadding=10 cellspacing=10 width=100%>
  <tr>
    <td bgcolor=#e5e5e5 valign=top>
<?php 
#      <table width=100% border=0><tr><td><div style="margin-bottom: 5px; font-size: 18px; font-weight: bold;">Devices with Alerts</div></td><td width=35 align=center><div class=tablehead>Host</div></td><td align=center width=35><div class=tablehead>Int</div></td><td align=center width=35><div class=tablehead>Srv</div></tr>
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while ($device = mysql_fetch_array($sql)) {
    echo "<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffbbbb; margin: 4px;'>\n      <center><strong>" . generatedevicelink($device, shorthost($device['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span><br /> \n      <span class=body-date-1>" . truncate($device['location'], 20) . "</span>\n      </center></div>";
}
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND D.status = '1' AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
while ($interface = mysql_fetch_array($sql)) {
    echo "<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>\n      <center><strong>" . generatedevicelink($interface, shorthost($interface['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span> \n      <strong>" . generateiflink($interface, makeshortif($interface['ifDescr'])) . "</strong> <br />\n      <span class=body-date-1>" . truncate($interface['ifAlias'], 20) . "</span>\n      </center></div>";
}
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND  D.status = '1' AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while ($service = mysql_fetch_array($sql)) {
    echo "<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>\n      <center><strong>" . generatedevicelink($service, shorthost($service['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span> \n      <strong>" . $service['service_type'] . "</strong><br />\n      <span class=body-date-1>" . truncate($interface['ifAlias'], 20) . "</span>\n      </center></div>";
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE  D.status = '1' AND bgpPeerState != 'established' AND B.device_id = D.device_id");
while ($peer = mysql_fetch_array($sql)) {
    echo "<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>\n      <center><strong>" . generatedevicelink($peer, shorthost($peer['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span> \n      <strong>" . $peer['bgpPeerIdentifier'] . "</strong> <br />\n      <span class=body-date-1>AS" . $peer['bgpPeerRemoteAs'] . " " . truncate($peer['astext'], 10) . "</span>\n      </center></div>";
}
$sql = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND `uptime` < '84600'");
while ($device = mysql_fetch_array($sql)) {
    echo "<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ddffdd; margin: 4px;'>\n      <center><strong>" . generatedevicelink($device, shorthost($device['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br /> \n      <span class=body-date-1>" . formatUptime($device['uptime']) . "</span>\n      </center></div>";
}
echo "\n\n\t<div style='clear: both;'>{$errorboxes}</div> <div style='margin: 4px; clear: both;'>  \n\n<h3>Recent Syslog Messages</h3>\n\n";
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog AS S, devices AS D \n        WHERE S.device_id = D.device_id ORDER BY timestamp DESC LIMIT 20";
$query = mysql_query($sql);
echo "<table cellspacing=0 cellpadding=2 width=100%>";
while ($entry = mysql_fetch_array($query)) {
Example #29
0
    }
    if (!$already) {
        $nodes[] = $device['device_id'];
    }
}
$sql = "SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'";
foreach (dbFetchRows($sql) as $device) {
    if (device_permitted($device['device_id'])) {
        echo "<div style='text-align: center; margin: 2px; border: solid 2px #d0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffbbbb;'>\n       <strong>" . generate_device_link($device, shorthost($device['hostname'])) . "</strong><br />\n       <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span><br />\n       <span class=body-date-1>" . truncate($device['location'], 35) . "</span>\n      </div>";
    }
}
if ($config['warn']['ifdown']) {
    $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'";
    foreach (dbFetchRows($sql) as $interface) {
        if (port_permitted($interface['port_id'])) {
            echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n       <strong>" . generate_device_link($interface, shorthost($interface['hostname'])) . "</strong><br />\n       <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />\n       <strong>" . generate_port_link($interface, makeshortif($interface['ifDescr'])) . "</strong><br />\n       <span class=body-date-1>" . truncate($interface['ifAlias'], 15) . "</span>\n      </div>";
        }
    }
}
$sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'";
foreach (dbFetchRows($sql) as $service) {
    if (device_permitted($service['device_id'])) {
        echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n      <strong>" . generate_device_link($service, shorthost($service['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span><br />\n      <strong>" . $service['service_type'] . "</strong><br />\n      <span class=body-date-1>" . truncate($interface['ifAlias'], 15) . "</span>\n      </center></div>";
    }
}
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id";
foreach (dbFetchRows($sql) as $peer) {
    if (device_permitted($peer['device_id'])) {
        echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n      <strong>" . generate_device_link($peer, shorthost($peer['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span><br />\n      <strong>" . $peer['bgpPeerIdentifier'] . "</strong><br />\n      <span class=body-date-1>AS" . $peer['bgpPeerRemoteAs'] . " " . truncate($peer['astext'], 10) . "</span>\n      </div>";
    }
}
Example #30
0
        if (!$mask) {
            $mask = "128";
        }
        if (!Net_IPv6::isInNetmask($interface['ipv6_address'], $addy, $mask)) {
            $ignore = 1;
        } else {
            $ignore = 0;
        }
    }
    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['ipv6_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></td>\n          <td class=list-bold>" . generatedevicelink($interface) . "</td>\n          <td class=list-bold>" . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . " {$error_img}</td>\n          <td>" . Net_IPv6::compress($interface['ipv6_address']) . "/" . $length . "</td>\n          <td>" . $interface['ifAlias'] . "</td>\n        </tr>\n";
            $row++;
        }
    }
    unset($ignore);
}
echo "</table>";