Ejemplo n.º 1
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>';
Ejemplo n.º 2
0
                break;
            case '4':
                $colour['left'] = '73880A';
                break;
            case '5':
                $colour['left'] = 'D01F3C';
                break;
            case '6':
                $colour['left'] = '36393D';
                break;
            case '7':
            default:
                $colour['left'] = 'FF0000';
                unset($iter);
                break;
        }
        //end switch
    }
    //end if
    $hostname = gethostbyid($toner['device_id']);
    $descr = substr(str_pad($toner['toner_descr'], 16), 0, 16);
    $rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('toner-' . $toner['toner_index'] . '.rrd');
    $toner_id = $toner['toner_id'];
    $rrd_options .= " DEF:toner{$toner_id}={$rrd_filename}:toner:AVERAGE";
    $rrd_options .= " LINE2:toner{$toner_id}#" . $colour['left'] . ":'" . $descr . "'";
    $rrd_options .= " GPRINT:toner{$toner_id}:LAST:'%5.0lf%%'";
    $rrd_options .= " GPRINT:toner{$toner_id}:MIN:'%5.0lf%%'";
    $rrd_options .= " GPRINT:toner{$toner_id}:MAX:%5.0lf%%\\\\l";
    $iter++;
}
//end foreach
Ejemplo n.º 3
0
<?php

$hostname = gethostbyid($alert_entry['device_id']);
$alert_state = $alert_entry['state'];
echo '<tr>
    <td>
    ' . $alert_entry['time_logged'] . '
    </td>';
if (!isset($alert_entry['device'])) {
    $dev = device_by_id_cache($alert_entry['device_id']);
    echo '<td>
        ' . generate_device_link($dev, shorthost($dev['hostname'])) . '
        </td>';
}
echo '<td>' . htmlspecialchars($alert_entry['name']) . '</td>';
if ($alert_state != '') {
    if ($alert_state == '0') {
        $glyph_icon = 'ok';
        $glyph_color = 'green';
        $text = 'Ok';
    } elseif ($alert_state == '1') {
        $glyph_icon = 'remove';
        $glyph_color = 'red';
        $text = 'Alert';
    } elseif ($alert_state == '2') {
        $glyph_icon = 'info-sign';
        $glyph_color = 'lightgrey';
        $text = 'Ack';
    } elseif ($alert_state == '3') {
        $glyph_icon = 'arrow-down';
        $glyph_color = 'orange';
Ejemplo n.º 4
0
     }
     $query = "SELECT *,DATE_FORMAT(datetime, '" . $config['dateformat']['mysql']['compact'] . "') as humandate  FROM `eventlog` AS E {$sql} ORDER BY `datetime` DESC LIMIT 20";
     foreach (dbFetchRows($query, $param) as $entry) {
         $tbl->addRow(array($entry['datetime'], gethostbyid($entry['host']), $entry['message'], $entry['type'], $entry['reference']));
     }
     echo $tbl->getTable();
 } else {
     if ($options['l'] == 'syslog') {
         $tbl = new Console_Table();
         $tbl->setHeaders(array('Date time', 'Host', 'Program', 'Message', 'Level', 'Facility'));
         if (is_numeric($options['d'])) {
             $sql = "WHERE device_id='" . $options['d'] . "'";
         }
         $query = "SELECT *, DATE_FORMAT(timestamp, '" . $config['dateformat']['mysql']['compact'] . "') AS date from syslog AS S {$sql_query} ORDER BY `timestamp` DESC LIMIT 20";
         foreach (dbFetchRows($query, $param) as $entry) {
             $tbl->addRow(array($entry['timestamp'], gethostbyid($entry['device_id']), $entry['program'], $entry['msg'], $entry['level'], $entry['facility']));
         }
         echo $tbl->getTable();
     } else {
         if ($options['list'] == 'devices') {
             $tbl = new Console_Table();
             $tbl->setHeaders(array('Device ID', 'Device Hostname'));
             $query = 'SELECT device_id,hostname FROM `devices` ORDER BY hostname';
             foreach (dbFetchRows($query, $sql_param) as $device) {
                 $tbl->addRow(array($device['device_id'], $device['hostname']));
             }
             echo $tbl->getTable();
             exit;
         } else {
             if (isset($options['device-stats'])) {
                 $tbl = new Console_Table();
Ejemplo n.º 5
0
<?php

include "includes/graphs/common.inc.php";
$rrd_options .= " -l 0 -E ";
$iter = "1";
$rrd_options .= " COMMENT:'Imaging Drum level     Cur     Min      Max\\n'";
$drums = array('Cyan' => 'c', 'Magenta' => 'm', 'Yellow' => 'y', 'Black' => 'k');
foreach ($drums as $drum => $letter) {
    $descr = rrdtool_escape("{$drum} Drum", 16);
    $colour = toner2colour($descr);
    $hostname = gethostbyid($device['device_id']);
    $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("drum-{$letter}.rrd");
    $rrd_options .= " DEF:drum{$iter}={$rrd_filename}:drum:AVERAGE";
    $rrd_options .= " LINE2:drum{$iter}#" . $colour['left'] . ":'" . $descr . "'";
    $rrd_options .= " GPRINT:drum{$iter}:LAST:'%5.0lf%%'";
    $rrd_options .= " GPRINT:drum{$iter}:MIN:'%5.0lf%%'";
    $rrd_options .= " GPRINT:drum{$iter}:MAX:%5.0lf%%\\\\l";
    $iter++;
}
Ejemplo n.º 6
0
function unixfsgraph($id, $graph, $from, $to, $width, $height, $title, $vertical)
{
    global $config, $installdir;
    $options = "--alt-autoscale-max -E --start {$from} --end {$to} --width {$width} --height {$height} -b 1024 -l 0";
    if ($width <= "300") {
        $options .= " --font LEGEND:7:" . $config['mono_font'] . " --font AXIS:6:" . $config['mono_font'] . " --font-render-mode normal ";
    }
    $hostname = gethostbyid($device);
    $iter = "1";
    $sql = mysql_query("SELECT * FROM storage where storage_id = '{$id}'");
    $options .= "COMMENT:\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ Size\\ \\ \\ \\ \\ \\ Used\\ \\ \\ \\ %age\\l";
    while ($fs = mysql_fetch_array($sql)) {
        $hostname = gethostbyid($fs['device_id']);
        if ($iter == "1") {
            $colour = "CC0000";
        } elseif ($iter == "2") {
            $colour = "008C00";
        } elseif ($iter == "3") {
            $colour = "4096EE";
        } elseif ($iter == "4") {
            $colour = "73880A";
        } elseif ($iter == "5") {
            $colour = "D01F3C";
        } elseif ($iter == "6") {
            $colour = "36393D";
        } elseif ($iter == "7") {
            $colour = "FF0084";
            $iter = "0";
        }
        $descr = str_pad($fs[storage_descr], 14);
        $descr = substr($descr, 0, 14);
        $text = str_replace("/", "_", $fs['storage_descr']);
        $rrd = $config['rrd_dir'] . "/{$hostname}/storage-{$text}.rrd";
        $options .= " DEF:{$fs['storage_id']}={$rrd}:used:AVERAGE";
        $options .= " DEF:{$fs['storage_id']}s={$rrd}:size:AVERAGE";
        $options .= " DEF:{$fs['storage_id']}p={$rrd}:perc:AVERAGE";
        $options .= " LINE1.25:{$fs['storage_id']}p#" . $colour . ":'{$descr}'";
        $options .= " GPRINT:{$fs['storage_id']}s:LAST:%6.2lf%SB";
        $options .= " GPRINT:{$fs['storage_id']}:LAST:%6.2lf%SB";
        $options .= " GPRINT:{$fs['storage_id']}p:LAST:%5.2lf%%\\\\l";
        $iter++;
    }
    shell_exec($config['rrdtool'] . " graph {$graph} {$options}");
    return $graph;
}
Ejemplo n.º 7
0
<?php

$scale_min = "0";
$scale_max = "100";
include $config['html_dir'] . "/includes/graphs/common.inc.php";
$rrd_options .= " -b 1024";
$iter = "1";
$rrd_options .= " COMMENT:'                    Size      Free   % Used\\n'";
$hostname = gethostbyid($storage['device_id']);
$colour = "CC0000";
$colour_area = "ffaaaa";
$descr = rrdtool_escape($storage['storage_descr'], 12);
$percentage = round($storage['storage_perc'], 0);
$background = get_percentage_colours($percentage);
$rrd_options .= " DEF:used={$rrd_filename}:used:AVERAGE";
$rrd_options .= " DEF:free={$rrd_filename}:free:AVERAGE";
$rrd_options .= " CDEF:size=used,free,+";
$rrd_options .= " CDEF:perc=used,size,/,100,*";
$rrd_options .= " AREA:perc#" . $background['right'] . ":";
$rrd_options .= " LINE1.25:perc#" . $background['left'] . ":'{$descr}'";
$rrd_options .= " GPRINT:size:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:free:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:perc:LAST:%5.2lf%%\\\\n";
if ($_GET['trend']) {
    $rrd_options .= " VDEF:slope=perc,LSLSLOPE ";
    $rrd_options .= " VDEF:cons=perc,LSLINT ";
    $rrd_options .= " CDEF:lsl2=perc,POP,slope,COUNT,*,cons,+ ";
    $rrd_options .= ' LINE1.25:lsl2#ff0000::dashes=2';
}
if ($_GET['previous']) {
    $descr = rrdtool_escape("Prev " . $storage['storage_descr'], 12);
Ejemplo n.º 8
0
$options['filter']['ignore'] = array('=', 0);
$options['type'] = 'Cisco-OTV';
$COMPONENTS = $COMPONENT->getComponents(null, $options);
foreach ($COMPONENTS as $DEVICE_ID => $COMP) {
    $LINK = generate_url(array('page' => 'device', 'device' => $DEVICE_ID, 'tab' => 'routing', 'proto' => 'cisco-otv'));
    ?>
<div class="panel panel-default" id="overlays-<?php 
    echo $DEVICE_ID;
    ?>
">
    <div class="panel-heading">
        <h3 class="panel-title"><a href="<?php 
    echo $LINK;
    ?>
"><?php 
    echo gethostbyid($DEVICE_ID);
    ?>
 - Overlay's & Adjacencies</a></h3>
    </div>
    <div class="panel list-group">
        <?php 
    // Loop over each component, pulling out the Overlays.
    foreach ($COMP as $OID => $OVERLAY) {
        if ($OVERLAY['otvtype'] == 'overlay') {
            if ($OVERLAY['status'] == 1) {
                $OVERLAY_STATUS = "<span class='green pull-right'>Normal</span>";
                $GLI = "";
            } else {
                $OVERLAY_STATUS = "<span class='pull-right'>" . $OVERLAY['error'] . " - <span class='red'>Alert</span></span>";
                $GLI = "list-group-item-danger";
            }
Ejemplo n.º 9
0
<?php

$hostname = gethostbyid($_GET[id]);
if (mysql_result(mysql_query("select count(service_id) from services WHERE device_id = '{$_GET['id']}'"), 0) > '0') {
    echo "<div style='margin: 5px;'><table cellpadding=7 border=0 cellspacing=0 width=100%>";
    $i = "1";
    $service_query = mysql_query("select * from services WHERE device_id = '{$_GET['id']}' ORDER BY service_type");
    while ($service = mysql_fetch_array($service_query)) {
        include "includes/print-service.inc";
    }
    echo "</table></div>";
} else {
    echo "No Services";
}
?>

Ejemplo n.º 10
0
            $colour = "008C00";
            break;
        case "3":
            $colour = "4096EE";
            break;
        case "4":
            $colour = "73880A";
            break;
        case "5":
            $colour = "D01F3C";
            break;
        case "6":
            $colour = "36393D";
            break;
        case "7":
        default:
            $colour = "FF0084";
            unset($iter);
            break;
    }
    $hostname = gethostbyid($voltage['device_id']);
    $descr = substr(str_pad($voltage['volt_descr'], 17), 0, 17);
    $rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . safename("volt-" . $voltage['volt_descr'] . ".rrd");
    $volt_id = $voltage['volt_id'];
    $rrd_options .= " DEF:volt{$volt_id}={$rrd_filename}:volt:AVERAGE";
    $rrd_options .= " LINE1:volt{$volt_id}#" . $colour . ":'" . $descr . "'";
    $rrd_options .= " GPRINT:volt{$volt_id}:AVERAGE:%5.2lfV";
    $rrd_options .= " GPRINT:volt{$volt_id}:MIN:%5.2lfV";
    $rrd_options .= " GPRINT:volt{$volt_id}:MAX:%5.2lfV\\\\l";
    $iter++;
}
Ejemplo n.º 11
0
<?php

## Generate a list of ports and then call the multi_bits grapher to generate from the list
$device = mres($_GET['device']);
$hostname = gethostbyid($device);
$query = mysql_query("SELECT `ifIndex`,`interface_id` FROM `ports` WHERE `device_id` = '{$device}' AND `ifType` NOT LIKE '%oopback%' AND `ifType` NOT LIKE '%SVI%' AND `ifType` != 'l2vlan'");
while ($int = mysql_fetch_row($query)) {
    if (is_file($config['rrd_dir'] . "/" . $hostname . "/" . safename($int[0] . ".rrd"))) {
        $rrd_filenames[] = $config['rrd_dir'] . "/" . $hostname . "/" . safename($int[0] . ".rrd");
    }
}
$rra_in = "INOCTETS";
$rra_out = "OUTOCTETS";
$colour_line_in = "006600";
$colour_line_out = "000099";
$colour_area_in = "CDEB8B";
$colour_area_out = "C3D9FF";
include "generic_multi_bits.inc.php";
Ejemplo n.º 12
0
            $colour = "008C00";
            break;
        case "3":
            $colour = "4096EE";
            break;
        case "4":
            $colour = "73880A";
            break;
        case "5":
            $colour = "D01F3C";
            break;
        case "6":
            $colour = "36393D";
            break;
        case "7":
        default:
            $colour = "FF0084";
            unset($iter);
            break;
    }
    $hostname = gethostbyid($fanspeed['device_id']);
    $descr = substr(str_pad($fanspeed['fan_descr'], 17), 0, 17);
    $rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . safename("fan-" . $fanspeed['fan_descr'] . ".rrd");
    $fan_id = $fanspeed['fan_id'];
    $rrd_options .= " DEF:fan{$fan_id}={$rrd_filename}:fan:AVERAGE";
    $rrd_options .= " LINE1:fan{$fan_id}#" . $colour . ":'" . $descr . "'";
    $rrd_options .= " GPRINT:fan{$fan_id}:AVERAGE:%5.0lf\\ ";
    $rrd_options .= " GPRINT:fan{$fan_id}:MIN:%5.0lf\\ ";
    $rrd_options .= " GPRINT:fan{$fan_id}:MAX:%5.0lf\\\\l";
    $iter++;
}
Ejemplo n.º 13
0
include "../includes/rewrites.php";
include "includes/authenticate.inc.php";
#  if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
if ($_GET['device']) {
    $device_id = $_GET['device'];
} elseif ($_GET['if']) {
    $device_id = getifhost($_GET['if']);
    $ifIndex = getifindexbyid($_GET['if']);
} elseif ($_GET['port']) {
    $device_id = getifhost($_GET['port']);
    $ifIndex = getifindexbyid($_GET['port']);
} elseif ($_GET['peer']) {
    $device_id = getpeerhost($_GET['peer']);
}
if ($device_id) {
    $hostname = gethostbyid($device_id);
}
$from = mres($_GET['from']);
$to = mres($_GET['to']);
$width = mres($_GET['width']);
$height = mres($_GET['height']);
$title = mres($_GET['title']);
$vertical = mres($_GET['vertical']);
$type = mres($_GET['type']);
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
$os = gethostosbyid($device_id);
$os_lower = strtolower($os);
if ($os_groups[$os_lower]) {
    $os_group = $os_groups[$os_lower];
}
if (is_file($config['install_dir'] . "/html/includes/graphs/" . $type . "_" . $os_lower . ".inc.php")) {
Ejemplo n.º 14
0
 unset($cpw_count);
 unset($cpw_exists);
 echo "Cisco Pseudowires : ";
 $oids = shell_exec($config['snmpwalk'] . " -m CISCO-IETF-PW-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . ":" . $device['port'] . " cpwVcID");
 $oids = str_replace(".1.3.6.1.4.1.9.10.106.1.2.1.10.", "", $oids);
 $oids = trim($oids);
 foreach (explode("\n", $oids) as $oid) {
     if ($oid) {
         list($cpwOid, $cpwVcID) = explode(" ", $oid);
         if ($cpwOid) {
             list($cpw_remote_id) = split(":", shell_exec($config['snmpget'] . " -m CISCO-IETF-PW-MPLS-MIB -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . ":" . $device['port'] . " cpwVcMplsPeerLdpID." . $cpwOid));
             $interface_descr = trim(shell_exec($config['snmpwalk'] . " -m CISCO-IETF-PW-MIB -Oqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . ":" . $device['port'] . " cpwVcName." . $cpwOid));
             $cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '" . $cpw_remote_id . "' AND A.interface_id = I.interface_id"), 0);
             $if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `ifDescr` = '{$interface_descr}' AND `device_id` = '" . $device['device_id'] . "'"), 0);
             if ($cpw_remote_device && $if_id) {
                 $hostname = gethostbyid($cpw_remote_device);
                 #echo("\nOid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id))");
                 if (mysql_result(mysql_query("SELECT count(*) FROM pseudowires WHERE `interface_id` = '{$if_id}'\n                                     AND `cpwVcID`='" . $cpwVcID . "'"), 0)) {
                     echo ".";
                 } else {
                     $insert_query = "INSERT INTO `pseudowires` (`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`) ";
                     $insert_query .= "VALUES ('{$if_id}','{$cpw_remote_device}','{$cpw_remote_id}','{$cpwVcID}', '{$cpwOid}')";
                     mysql_query($insert_query);
                     echo "+";
                     #echo($device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID\n");
                 }
                 $cpw_exists[] = $device['device_id'] . " {$cpwOid} {$cpw_remote_device} {$if_id} {$cpwVcID}";
             }
         }
     }
 }