Example #1
0
    }
    $perc = round($drive['storage_perc'], 0);
    $total = formatStorage($drive['storage_size']);
    $free = formatStorage($drive['storage_free']);
    $used = formatStorage($drive['storage_used']);
    $store_url = "graph.php?id=" . $drive['storage_id'] . "&type=storage&from={$month}&to={$now}&width=400&height=125";
    $store_popup = "onmouseover=\"return overlib('<img src=\\'{$store_url}\\'>', LEFT);\" onmouseout=\"return nd();\"";
    $mini_graph = $config['base_url'] . "/graph.php?id=" . $drive['storage_id'] . "&type=storage&from=" . $day . "&to=" . $now . "&width=80&height=20&bg=f4f4f4";
    if ($perc > '90') {
        $left_background = 'c4323f';
        $right_background = 'C96A73';
    } elseif ($perc > '75') {
        $left_background = 'bf5d5b';
        $right_background = 'd39392';
    } elseif ($perc > '50') {
        $left_background = 'bf875b';
        $right_background = 'd3ae92';
    } elseif ($perc > '25') {
        $left_background = '5b93bf';
        $right_background = '92b7d3';
    } else {
        $left_background = '9abf5b';
        $right_background = 'bbd392';
    }
    echo "<tr bgcolor='{$row_colour}'><td>" . generatedevicelink($drive) . "</td><td class=tablehead>" . $drive['storage_descr'] . "</td>\n         <td><img src='{$mini_graph}'></td>\n         <td>\n          <a href='#' {$store_popup}>" . print_percentage_bar(400, 20, $perc, "{$used} / {$total}", "ffffff", $left_background, formatStorage($free), "ffffff", $right_background) . "</a>\n          </td><td>{$perc}" . "%</td></tr>";
    $row++;
}
echo "</table></div>";
?>

Example #2
0
</div>
<?php 
$runtime_end = microtime(true);
$runtime = $runtime_end - $runtime_start;
$gentime = substr($runtime, 0, 5);
# FIXME - move this
if ($config['page_gen']) {
    echo '  <br />MySQL: Cell    ' . ($db_stats['fetchcell'] + 0) . '/' . round($db_stats['fetchcell_sec'] + 0, 3) . 's' . ' Row    ' . ($db_stats['fetchrow'] + 0) . '/' . round($db_stats['fetchrow_sec'] + 0, 3) . 's' . ' Rows   ' . ($db_stats['fetchrows'] + 0) . '/' . round($db_stats['fetchrows_sec'] + 0, 3) . 's' . ' Column ' . ($db_stats['fetchcol'] + 0) . '/' . round($db_stats['fetchcol_sec'] + 0, 3) . 's';
    $fullsize = memory_get_usage();
    unset($cache);
    $cachesize = $fullsize - memory_get_usage();
    if ($cachesize < 0) {
        $cachesize = 0;
    }
    // Silly PHP!
    echo '  <br />Cached data in memory is ' . formatStorage($cachesize) . '. Page memory usage is ' . formatStorage($fullsize) . ', peaked at ' . formatStorage(memory_get_peak_usage()) . '.';
    echo '  <br />Generated in ' . $gentime . ' seconds.';
}
if (isset($pagetitle) && is_array($pagetitle)) {
    # if prefix is set, put it in front
    if ($config['page_title_prefix']) {
        array_unshift($pagetitle, $config['page_title_prefix']);
    }
    # if suffix is set, put it in the back
    if ($config['page_title_suffix']) {
        $pagetitle[] = $config['page_title_suffix'];
    }
    # create and set the title
    $title = join(" - ", $pagetitle);
    echo "<script type=\"text/javascript\">\ndocument.title = '{$title}';\n</script>";
}
function transferOverview($bill_id, $history)
{
    global $list_colour_a, $list_colour_b, $config;
    $i = 0;
    $tot = array();
    $traf = array();
    $start = $history['timestampfrom'];
    $end = $history['timestampto'];
    //$background= $history['background'];
    $res = "";
    $res .= "<table class=\"transferOverview\">";
    $res .= "  <tr bgcolor=\"#000\">";
    $res .= "    <th class=\"period\">Date</th>";
    $res .= "    <th class=\"inbound\">Inbound</th>";
    $res .= "    <th class=\"outbound\">Outbound</th>";
    $res .= "    <th class=\"total\">Total</th>";
    $res .= "  </tr>";
    foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id`= ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data) {
        $date = strftime("%A, %e %B %Y", $data['timestamp']);
        $tot['in'] += gbConvert($data['traf_in']);
        $tot['out'] += gbConvert($data['traf_out']);
        $tot['tot'] += gbConvert($data['traf_total']);
        $traf['in'] = formatStorage(gbConvert($data['traf_in']), "3");
        $traf['out'] = formatStorage(gbConvert($data['traf_out']), "3");
        $traf['tot'] = formatStorage(gbConvert($data['traf_total']), "3");
        $row_colour = !is_integer($i / 2) ? $list_colour_a : $list_colour_b;
        $res .= "  <tr bgcolor=\"" . $row_colour . "\">";
        $res .= "    <td>" . $date . "</td>";
        $res .= "    <td class=\"right\">" . $traf['in'] . "</td>";
        $res .= "    <td class=\"right\">" . $traf['out'] . "</td>";
        $res .= "    <td class=\"right\">" . $traf['tot'] . "</td>";
        $res .= "  </tr>";
        $i++;
    }
    $tot['in'] = formatStorage($tot['in']);
    $tot['out'] = formatStorage($tot['out']);
    $tot['tot'] = formatStorage($tot['tot']);
    $res .= "  <tr bgcolor=\"#ccc\" style=\"border-top: 1px solid #000;\">";
    $res .= "    <td></td>";
    $res .= "    <td class=\"right\"><b>" . $tot['in'] . "</b></td>";
    $res .= "    <td class=\"right\"><b>" . $tot['out'] . "</b></td>";
    $res .= "    <td class=\"right\"><b>" . $tot['tot'] . "</b></td>";
    $res .= "  </tr>";
    $res .= "</table>";
    return $res;
}
Example #4
0
    $mempool['free'] = $mempool['total'] - $mempool['used'];
    $hc = $mempool['mempool_hc'] ? ' (HC)' : '';
    // Update StatsD/Carbon
    if ($config['statsd']['enable'] == TRUE) {
        StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'mempool' . '.' . $mempool['mempool_mib'] . "." . $mempool['mempool_index'] . ".used", $mempool['used']);
        StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'mempool' . '.' . $mempool['mempool_mib'] . "." . $mempool['mempool_index'] . ".free", $mempool['free']);
    }
    rrdtool_update_ng($device, 'mempool', array('used' => $mempool['used'], 'free' => $mempool['free']), $mempool['mempool_mib'] . "-" . $mempool['mempool_index']);
    if (!is_numeric($mempool['mempool_polled'])) {
        dbInsert(array('mempool_id' => $mempool['mempool_id']), 'mempools-state');
    }
    $mempool['state'] = array('mempool_polled' => time(), 'mempool_used' => $mempool['used'], 'mempool_perc' => $mempool['perc'], 'mempool_free' => $mempool['free'], 'mempool_total' => $mempool['total']);
    dbUpdate($mempool['state'], 'mempools-state', '`mempool_id` = ?', array($mempool['mempool_id']));
    $graphs['mempool'] = TRUE;
    check_entity('mempool', $mempool, array('mempool_perc' => $mempool['perc'], 'mempool_free' => $mempool['free'], 'mempool_used' => $mempool['used']));
    //  print_message("Mempool ". $mempool['mempool_descr'] . ': '.$mempool['perc'].'%%'.$hc);
    $table_row = array();
    $table_row[] = $mempool['mempool_descr'];
    $table_row[] = $mempool['mempool_mib'];
    $table_row[] = $mempool['mempool_index'];
    $table_row[] = formatStorage($mempool['total']);
    $table_row[] = formatStorage($mempool['used']);
    $table_row[] = formatStorage($mempool['free']);
    $table_row[] = $mempool['perc'] . '%';
    $table_rows[] = $table_row;
    unset($table_row);
}
$headers = array('%WLabel%n', '%WType%n', '%WIndex%n', '%WTotal%n', '%WUsed%n', '%WFree%n', '%WPerc%n');
print_cli_table($table_rows, $headers);
unset($cache_mempool, $mempool, $index, $table_row, $table_rows, $table_headers);
// EOF
Example #5
0
$stat_ns_vsvrs = dbFetchCell('SELECT COUNT(*) FROM `netscaler_vservers`');
$stat_ns_svcs = dbFetchCell('SELECT COUNT(*) FROM `netscaler_services`');
$stat_vms = dbFetchCell('SELECT COUNT(*) FROM `vminfo`');
$stat_ip_sla = dbFetchCell('SELECT COUNT(*) FROM `slas`');
$stat_db = get_db_size();
$stat_rrd = get_dir_size($config['rrd_dir']);
?>
      <table class="table table-striped table-condensed">
        <tbody>
          <tr>
            <td style="width: 45%;"><i class="oicon-database"></i> <strong>DB size</strong></td><td><span class="pull-right"><?php 
echo formatStorage($stat_db);
?>
</span></td>
            <td style="width: 45%;"><i class="oicon-box-zipper"></i> <strong>RRD size</strong></td><td><span class="pull-right"><?php 
echo formatStorage($stat_rrd);
?>
</span></td>
          </tr>
          <tr>
            <td><i class="oicon-servers"></i> <strong>Devices</strong></td><td><span class="pull-right"><?php 
echo $stat_devices;
?>
</span></td>
            <td><i class="oicon-network-ethernet"></i> <strong>Ports</strong></td><td><span class="pull-right"><?php 
echo $stat_ports;
?>
</span></td>
          </tr>
          <tr>
            <td><i class="oicon-ipv4"></i> <strong>IPv4 Addresses</strong></td><td><span class="pull-right"><?php 
Example #6
0
$graph_type = "toner_usage";
$toners = dbFetchRows("SELECT * FROM `toner` WHERE device_id = ?", array($device['device_id']));
if (count($toners)) {
    echo '<div class="row">
          <div class="col-md-12">
            <div class="panel panel-default panel-condensed">
              <div class="panel-heading">';
    echo '<a href="device/device=' . $device['device_id'] . '/tab=toner/">';
    echo "<img src='images/icons/toner.png'> Toner</a>";
    echo '</div>
        <table class="table table-hover table-condensed table-striped">';
    foreach ($toners as $toner) {
        $percent = round($toner['toner_current'], 0);
        $total = formatStorage($toner['toner_size']);
        $free = formatStorage($toner['toner_free']);
        $used = formatStorage($toner['toner_used']);
        $background = toner2colour($toner['toner_descr'], $percent);
        $graph_array = array();
        $graph_array['height'] = "100";
        $graph_array['width'] = "210";
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $toner['toner_id'];
        $graph_array['type'] = $graph_type;
        $graph_array['from'] = $config['time']['day'];
        $graph_array['legend'] = "no";
        $link_array = $graph_array;
        $link_array['page'] = "graphs";
        unset($link_array['height'], $link_array['width'], $link_array['legend']);
        $link = generate_url($link_array);
        $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $toner['toner_descr']);
        $graph_array['width'] = 80;
     $drive["storage_descr"] = preg_replace("/.*mounted on: (.*)/", "\\1", $drive["storage_descr"]);
 }
 if ($drive['os'] == "freebsd") {
     foreach ($config['ignore_bsd_os_drives'] as $jdrive) {
         if (preg_match($jdrive, $drive["storage_descr"])) {
             $skipdrive = 1;
         }
     }
 }
 if ($skipdrive) {
     continue;
 }
 $perc = round($drive['storage_perc'], 0);
 $total = formatStorage($drive['storage_size']);
 $free = formatStorage($drive['storage_free']);
 $used = formatStorage($drive['storage_used']);
 $graph_array['type'] = $graph_type;
 $graph_array['id'] = $drive['storage_id'];
 $graph_array['from'] = $config['time']['day'];
 $graph_array['to'] = $config['time']['now'];
 $graph_array['height'] = "20";
 $graph_array['width'] = "80";
 $graph_array_zoom = $graph_array;
 $graph_array_zoom['height'] = "150";
 $graph_array_zoom['width'] = "400";
 $link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/";
 $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
 $background = get_percentage_colours($perc);
 echo "<tr class='health'><td>" . generate_device_link($drive) . "</td><td class=tablehead>" . $drive['storage_descr'] . "</td>\n         <td>{$mini_graph}</td>\n         <td>\n          <a href='#' {$store_popup}>" . print_percentage_bar(400, 20, $perc, "{$used} / {$total}", "ffffff", $background['left'], $free, "ffffff", $background['right']) . "</a>\n          </td><td>{$perc}" . "%</td></tr>";
 if ($vars['view'] == "graphs") {
     echo "<tr></tr><tr class='health'><td colspan=5>";
        print_vars($storage);
    }
    if ($storage['size']) {
        $percent = round($storage['used'] / $storage['size'] * 100, 2);
    } else {
        $percent = 0;
    }
    $hc = $storage['storage_hc'] ? ' (HC)' : '';
    print_message("存储 " . $storage['storage_descr'] . ': ' . $percent . '%%' . $hc);
    // Update StatsD/Carbon
    if ($config['statsd']['enable'] == TRUE) {
        StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'storage' . '.' . $storage['storage_mib'] . "-" . safename($storage['storage_descr']) . ".used", $storage['used']);
        StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'storage' . '.' . $storage['storage_mib'] . "-" . safename($storage['storage_descr']) . ".free", $storage['free']);
    }
    // Update RRD
    rrdtool_update($device, $storage_rrd, "N:" . $storage['used'] . ":" . $storage['free']);
    if (!is_numeric($storage['storage_polled'])) {
        dbInsert(array('storage_id' => $storage['storage_id'], 'storage_polled' => time(), 'storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage-state');
    } else {
        $update = dbUpdate(array('storage_polled' => time(), 'storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage-state', '`storage_id` = ?', array($storage['storage_id']));
        if ($storage_size != $storage['storage_size']) {
            log_event('存储容量变更: ' . formatStorage($storage_size) . ' -> ' . formatStorage($storage['storage_size']) . ' (' . $storage['storage_descr'] . ')', $device, 'storage', $storage['storage_id']);
        }
    }
    $graphs['storage'] = TRUE;
    // Check alerts
    check_entity('storage', $storage, array('storage_perc' => $percent, 'storage_free' => $storage['free'], 'storage_used' => $storage['used']));
    echo PHP_EOL;
}
unset($storage);
// EOF
Example #9
0
                </tr>
                <tr>
                  <th>Cached</th><td><?php 
    echo formatStorage($cachesize);
    ?>
</td>
                </tr>
                <tr>
                  <th>Page</th><td><?php 
    echo formatStorage($fullsize);
    ?>
</td>
                </tr>
                <tr>
                  <th>Peak</th><td><?php 
    echo formatStorage(memory_get_peak_usage());
    ?>
</td>
                </tr>
              </table>
            </div>
          </li>

<?php 
    if ($config['profile_sql'] == TRUE && ($SESSION['userlevel'] = '10')) {
        ?>
          <li class="dropdown">
            <a href="<?php 
        echo generate_url(array('page' => 'overview'));
        ?>
" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">
Example #10
0
  $graph_array['legend'] = "no";
  $link_array = $graph_array;
  $link_array['page'] = "graphs";
  unset($link_array['height'], $link_array['width'], $link_array['legend']);
  $link_graph = generate_url($link_array);
  $link = generate_url(array("page" => "device", "device" => $storage['device_id'], "tab" => "health", "metric" => 'storage'));
  $overlib_content = generate_overlib_content($graph_array, $storage['hostname'] . " - " . htmlentities($storage['storage_descr']), NULL);
  $graph_array['width'] = 80;
  $graph_array['height'] = 20;
  $graph_array['bg'] = 'ffffff00';
  # the 00 at the end makes the area transparent.
  $graph_array['from'] = $config['time']['day'];
  $mini_graph = generate_graph_tag($graph_array);
  $total = formatStorage($storage['storage_size']);
  $used = formatStorage($storage['storage_used']);
  $free = formatStorage($storage['storage_free']);
  $background = get_percentage_colours($storage['storage_perc']);
  echo '<tr class="' . $storage['html_row_class'] . '">
      <td class="entity">' . generate_device_link($storage) . '</td>
      <td>' . overlib_link($link, htmlentities($storage['storage_descr']), $overlib_content) . '</td>
      <td>' . $total . '</td>
      <td>' . $used . '</td>
      <td>' . $free . '</td>
      <td>' . overlib_link($link_graph, $mini_graph, $overlib_content) . '</td>
      <td><a href="' . $link_graph . '">
        ' . print_percentage_bar(400, 20, $storage['storage_perc'], $storage['storage_perc'] . '%', "ffffff", $background['left'], 100 - $storage['storage_perc'] . "%", "ffffff", $background['right']) . '
        </a>
      </td>
    </tr>
 ';
  if ($vars['view'] == "graphs") {
Example #11
0
function transferOverview($bill_id, $history)
{
    global $list_colour_a, $list_colour_b, $config;
    $i = 0;
    $tot = array();
    $traf = array();
    $start = $history['timestampfrom'];
    $end = $history['timestampto'];
    // $background= $history['background'];
    $res = '';
    $res .= '<table class="transferOverview">';
    $res .= '  <tr bgcolor="#000">';
    $res .= '    <th class="period">Date</th>';
    $res .= '    <th class="inbound">Inbound</th>';
    $res .= '    <th class="outbound">Outbound</th>';
    $res .= '    <th class="total">Total</th>';
    $res .= '  </tr>';
    foreach (dbFetch('SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id`= ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC', array($bill_id, $start, $end)) as $data) {
        $date = strftime('%A, %e %B %Y', $data['timestamp']);
        $tot['in'] += gbConvert($data['traf_in']);
        $tot['out'] += gbConvert($data['traf_out']);
        $tot['tot'] += gbConvert($data['traf_total']);
        $traf['in'] = formatStorage(gbConvert($data['traf_in']), '3');
        $traf['out'] = formatStorage(gbConvert($data['traf_out']), '3');
        $traf['tot'] = formatStorage(gbConvert($data['traf_total']), '3');
        $row_colour = !is_integer($i / 2) ? $list_colour_a : $list_colour_b;
        $res .= '  <tr bgcolor="' . $row_colour . '">';
        $res .= '    <td>' . $date . '</td>';
        $res .= '    <td class="right">' . $traf['in'] . '</td>';
        $res .= '    <td class="right">' . $traf['out'] . '</td>';
        $res .= '    <td class="right">' . $traf['tot'] . '</td>';
        $res .= '  </tr>';
        $i++;
    }
    $tot['in'] = formatStorage($tot['in']);
    $tot['out'] = formatStorage($tot['out']);
    $tot['tot'] = formatStorage($tot['tot']);
    $res .= '  <tr bgcolor="#ccc" style="border-top: 1px solid #000;">';
    $res .= '    <td></td>';
    $res .= '    <td class="right"><b>' . $tot['in'] . '</b></td>';
    $res .= '    <td class="right"><b>' . $tot['out'] . '</b></td>';
    $res .= '    <td class="right"><b>' . $tot['tot'] . '</b></td>';
    $res .= '  </tr>';
    $res .= '</table>';
    return $res;
}
        print_vars($storage);
    }
    if ($storage['size']) {
        $percent = round($storage['used'] / $storage['size'] * 100, 2);
    } else {
        $percent = 0;
    }
    $hc = $storage['storage_hc'] ? ' (HC)' : '';
    print_message("Storage " . $storage['storage_descr'] . ': ' . $percent . '%%' . $hc);
    // Update StatsD/Carbon
    if ($config['statsd']['enable'] == TRUE) {
        StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'storage' . '.' . $storage['storage_mib'] . "-" . safename($storage['storage_descr']) . ".used", $storage['used']);
        StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'storage' . '.' . $storage['storage_mib'] . "-" . safename($storage['storage_descr']) . ".free", $storage['free']);
    }
    // Update RRD
    rrdtool_update($storage_rrd, "N:" . $storage['used'] . ":" . $storage['free']);
    if (!is_numeric($storage['storage_polled'])) {
        dbInsert(array('storage_id' => $storage['storage_id'], 'storage_polled' => time(), 'storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage-state');
    } else {
        $update = dbUpdate(array('storage_polled' => time(), 'storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage-state', '`storage_id` = ?', array($storage['storage_id']));
        if ($storage_size != $storage['storage_size']) {
            log_event('Storage size changed: ' . formatStorage($storage_size) . ' -> ' . formatStorage($storage['storage_size']) . ' (' . $storage['storage_descr'] . ')', $device, 'storage', $storage['storage_id']);
        }
    }
    $graphs['storage'] = TRUE;
    // Check alerts
    check_entity('storage', $storage, array('storage_perc' => $percent, 'storage_free' => $storage['free']));
    echo PHP_EOL;
}
unset($storage);
// EOF
Example #13
0
function generate_mempool_row($mempool, $vars)
{
    global $config;
    $table_cols = 7;
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $table_cols++;
    }
    // Add a column for device.
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $mempool['mempool_id'];
    $graph_array['type'] = "mempool_usage";
    $graph_array['legend'] = "no";
    $link_array = $graph_array;
    $link_array['page'] = "graphs";
    unset($link_array['height'], $link_array['width'], $link_array['legend']);
    $link_graph = generate_url($link_array);
    $link = generate_url(array("page" => "device", "device" => $mempool['device_id'], "tab" => "health", "metric" => 'mempool'));
    $overlib_content = generate_overlib_content($graph_array, $mempool['hostname'] . " - " . $mempool['mempool_descr']);
    $graph_array['width'] = 80;
    $graph_array['height'] = 20;
    $graph_array['bg'] = 'ffffff00';
    $graph_array['from'] = $config['time']['day'];
    $mini_graph = generate_graph_tag($graph_array);
    if ($mempool['mempool_total'] != '100') {
        $total = formatStorage($mempool['mempool_total']);
        $used = formatStorage($mempool['mempool_used']);
        $free = formatStorage($mempool['mempool_free']);
    } else {
        // If total == 100, than memory not have correct size and uses percents only
        $total = $mempool['mempool_total'] . '%';
        $used = $mempool['mempool_used'] . '%';
        $free = $mempool['mempool_free'] . '%';
    }
    $background = get_percentage_colours($mempool['mempool_perc']);
    $mempool['html_row_class'] = $background['class'];
    $row .= '<tr class="' . $mempool['html_row_class'] . '">
            <td class="state-marker"></td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $row .= '<td class="entity">' . generate_device_link($mempool) . '</td>';
    }
    $row .= '<td class="entity">' . generate_entity_link('mempool', $mempool) . '</td>
        <td>' . overlib_link($link_graph, $mini_graph, $overlib_content) . '</td>
        <td><a href="' . $link_graph . '">
          ' . print_percentage_bar(400, 20, $mempool['mempool_perc'], $used . '/' . $total . ' (' . $mempool['mempool_perc'] . '%)', "ffffff", $background['left'], $free . ' (' . (100 - $mempool['mempool_perc']) . '%)', "ffffff", $background['right']) . '
          </a>
        </td>
        <td>' . $mempool['mempool_perc'] . '%</td>
      </tr>
   ';
    if ($vars['view'] == "graphs") {
        $vars['graph'] = "usage";
    }
    if ($vars['graph']) {
        $row .= '<tr class="' . $mempool['html_row_class'] . '">';
        $row .= '<td class="state-marker"></td>';
        $row .= '<td colspan="' . $table_cols . '">';
        unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $mempool['mempool_id'];
        $graph_array['type'] = 'mempool_' . $vars['graph'];
        print_graph_row($graph_array, TRUE);
        $row .= '</td></tr>';
    }
    # endif graphs
    return $row;
}
Example #14
0
        StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'storage' . '.' . $storage['storage_mib'] . "-" . safename($storage['storage_descr']) . ".used", $storage['used']);
        StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'storage' . '.' . $storage['storage_mib'] . "-" . safename($storage['storage_descr']) . ".free", $storage['free']);
    }
    // Update RRD
    rrdtool_update_ng($device, 'storage', array('used' => $storage['used'], 'free' => $storage['free']), $storage['storage_mib'] . "-" . $storage['storage_descr']);
    if (!is_numeric($storage['storage_polled'])) {
        dbInsert(array('storage_id' => $storage['storage_id'], 'storage_polled' => time(), 'storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage-state');
    } else {
        $update = dbUpdate(array('storage_polled' => time(), 'storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage-state', '`storage_id` = ?', array($storage['storage_id']));
        if ($storage_size != $storage['storage_size']) {
            log_event('Storage size changed: ' . formatStorage($storage_size) . ' -> ' . formatStorage($storage['storage_size']) . ' (' . $storage['storage_descr'] . ')', $device, 'storage', $storage['storage_id']);
        }
    }
    $graphs['storage'] = TRUE;
    // Check alerts
    check_entity('storage', $storage, array('storage_perc' => $percent, 'storage_free' => $storage['free'], 'storage_used' => $storage['used']));
    $table_row = array();
    $table_row[] = $storage['storage_descr'];
    $table_row[] = $storage['storage_mib'];
    $table_row[] = $storage['storage_index'];
    $table_row[] = formatStorage($storage['size']);
    $table_row[] = formatStorage($storage['used']);
    $table_row[] = formatStorage($storage['free']);
    $table_row[] = $percent . '%';
    $table_rows[] = $table_row;
    unset($table_row);
}
$headers = array('%WLabel%n', '%WType%n', '%WIndex%n', '%WTotal%n', '%WUsed%n', '%WFree%n', '%WPerc%n');
print_cli_table($table_rows, $headers);
unset($storage, $table, $table_row, $table_rows);
// EOF
Example #15
0
    $sort = '`D`.`hostname`, `M`.`mempool_descr`';
}
$sql .= " ORDER BY {$sort}";
if (isset($current)) {
    $limit_low = $current * $rowCount - $rowCount;
    $limit_high = $rowCount;
}
if ($rowCount != -1) {
    $sql .= " LIMIT {$limit_low},{$limit_high}";
}
$sql = "SELECT * {$sql}";
foreach (dbFetchRows($sql, $param) as $mempool) {
    $perc = round($mempool['mempool_perc'], 0);
    $total = formatStorage($mempool['mempool_total']);
    $free = formatStorage($mempool['mempool_free']);
    $used = formatStorage($mempool['mempool_used']);
    $graph_array['type'] = $graph_type;
    $graph_array['id'] = $mempool['mempool_id'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['to'] = $config['time']['now'];
    $graph_array['height'] = "20";
    $graph_array['width'] = "80";
    $graph_array_zoom = $graph_array;
    $graph_array_zoom['height'] = "150";
    $graph_array_zoom['width'] = "400";
    $link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/";
    $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
    $background = get_percentage_colours($perc);
    $bar_link = overlib_link($link, print_percentage_bar(400, 20, $perc, "{$used} / {$total}", "ffffff", $background['left'], $free, "ffffff", $background['right']), generate_graph_tag($graph_array_zoom), NULL);
    $response[] = array('hostname' => generate_device_link($mempool), 'mempool_descr' => $mempool['mempool_descr'], 'graph' => $mini_graph, 'mempool_used' => $bar_link, 'mempool_perc' => $perc . "%");
    if ($_POST['view'] == "graphs") {
Example #16
0
            <tr>
              <td colspan="7">
                <?php 
    echo percentage_bar($percentage_bar);
    ?>
              </td>
            </tr>
            <tr class="small">
              <td><i style="font-size: 7px; line-height: 7px; background-color: #EE9955; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Used</td>
              <td><?php 
    echo formatStorage($memory_used) . ' (' . $memory_used_perc . '%)';
    ?>
</td>
              <td><i style="font-size: 7px; line-height: 7px; background-color: #f0e0a0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Cached</td>
              <td><?php 
    echo formatStorage($app_data['memory']['cache']) . ' (' . $memory_cached_perc . '%)';
    ?>
</td>
              <td><i style="font-size: 7px; line-height: 7px; background-color: #f0f0f0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i> Free</td>
              <td><?php 
    echo formatStorage($memory_free) . ' (' . $memory_free_perc . '%)';
    ?>
</td>
            </tr>
          </table>
        </div>
      </div>
<?php 
}
unset($percentage_bar, $graph_array, $overlib_content, $graph, $link, $link_array);
// EOF
Example #17
0
 //end foreach
 if ($config['debug_port'][$port['port_id']]) {
     $port_debug = $port['port_id'] . '|' . $polled . '|' . $polled_period . '|' . $this_port['ifHCInOctets'] . '|' . $this_port['ifHCOutOctets'];
     $port_debug .= '|' . $port['stats']['ifInOctets_rate'] . '|' . $port['stats']['ifOutOctets_rate'] . "\n";
     file_put_contents('/tmp/port_debug.txt', $port_debug, FILE_APPEND);
     echo 'Wrote port debugging data';
 }
 $port['stats']['ifInBits_rate'] = round($port['stats']['ifInOctets_rate'] * 8);
 $port['stats']['ifOutBits_rate'] = round($port['stats']['ifOutOctets_rate'] * 8);
 // If we have a valid ifSpeed we should populate the stats for checking.
 if (is_numeric($this_port['ifSpeed'])) {
     $port['stats']['ifInBits_perc'] = round($port['stats']['ifInBits_rate'] / $this_port['ifSpeed'] * 100);
     $port['stats']['ifOutBits_perc'] = round($port['stats']['ifOutBits_rate'] / $this_port['ifSpeed'] * 100);
 }
 echo 'bps(' . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ')';
 echo 'bytes(' . formatStorage($port['stats']['ifInOctets_diff']) . '/' . formatStorage($port['stats']['ifOutOctets_diff']) . ')';
 echo 'pkts(' . format_si($port['stats']['ifInUcastPkts_rate']) . 'pps/' . format_si($port['stats']['ifOutUcastPkts_rate']) . 'pps)';
 // Port utilisation % threshold alerting. // FIXME allow setting threshold per-port. probably 90% of ports we don't care about.
 if ($config['alerts']['port_util_alert'] && $port['ignore'] == '0') {
     // Check for port saturation of $config['alerts']['port_util_perc'] or higher.  Alert if we see this.
     // Check both inbound and outbound rates
     $saturation_threshold = $this_port['ifSpeed'] * ($config['alerts']['port_util_perc'] / 100);
     echo 'IN: ' . $port['stats']['ifInBits_rate'] . ' OUT: ' . $port['stats']['ifOutBits_rate'] . ' THRESH: ' . $saturation_threshold;
     if (($port['stats']['ifInBits_rate'] >= $saturation_threshold || $port['stats']['ifOutBits_rate'] >= $saturation_threshold) && $saturation_threshold > 0) {
         log_event('Port reached saturation threshold: ' . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ' - ifspeed: ' . formatRates($this_port['stats']['ifSpeed']), $device, 'interface', $port['port_id']);
     }
 }
 // Update RRDs
 $rrdfile = $host_rrd . '/port-' . safename($port['ifIndex'] . '.rrd');
 if (!is_file($rrdfile)) {
     rrdtool_create($rrdfile, ' --step 300 
Example #18
0
function generate_storage_row($storage, $vars)
{
    global $config;
    $table_cols = 8;
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $table_cols++;
    }
    // Add a column for device.
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $storage['storage_id'];
    $graph_array['type'] = 'storage_usage';
    $graph_array['legend'] = "no";
    $link_array = $graph_array;
    $link_array['page'] = "graphs";
    unset($link_array['height'], $link_array['width'], $link_array['legend']);
    $link_graph = generate_url($link_array);
    $link = generate_url(array("page" => "device", "device" => $storage['device_id'], "tab" => "health", "metric" => 'storage'));
    $overlib_content = generate_overlib_content($graph_array, $storage['hostname'] . ' - ' . $storage['storage_descr']);
    $graph_array['width'] = 80;
    $graph_array['height'] = 20;
    $graph_array['bg'] = 'ffffff00';
    $graph_array['from'] = $config['time']['day'];
    $mini_graph = generate_graph_tag($graph_array);
    $total = formatStorage($storage['storage_size']);
    $used = formatStorage($storage['storage_used']);
    $free = formatStorage($storage['storage_free']);
    $background = get_percentage_colours($storage['storage_perc']);
    if ($storage['storage_ignore']) {
        $storage['row_class'] = 'suppressed';
    } else {
        $storage['row_class'] = $background['class'];
    }
    $row .= '<tr class="ports ' . $storage['row_class'] . '">
          <td class="state-marker"></td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $row .= '<td class="entity">' . generate_device_link($storage) . '</td>';
    }
    $row .= '  <td class="entity">' . generate_entity_link('storage', $storage) . '</td>
      <td>' . $total . '</td>
      <td>' . $used . '</td>
      <td>' . $free . '</td>
      <td>' . overlib_link($link_graph, $mini_graph, $overlib_content) . '</td>
      <td><a href="' . $link_graph . '">
        ' . print_percentage_bar(400, 20, $storage['storage_perc'], $storage['storage_perc'] . '%', "ffffff", $background['left'], 100 - $storage['storage_perc'] . "%", "ffffff", $background['right']) . '
        </a>
      </td>
    </tr>
  ';
    if ($vars['view'] == "graphs") {
        $vars['graph'] = "usage";
    }
    if ($vars['graph']) {
        echo '<tr class="' . $storage['row_class'] . '">';
        echo '<td class="state-marker"></td>';
        echo '<td colspan="' . $table_cols . '">';
        unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $storage['storage_id'];
        $graph_array['type'] = 'storage_' . $vars['graph'];
        print_graph_row($graph_array, TRUE);
        $row .= '</td></tr>';
    }
    # endif graphs
    return $row;
}
Example #19
0
 /**
  * @dataProvider providerFormatStorage
  */
 public function testFormatStorage($value, $round, $sf, $result)
 {
     $this->assertSame($result, formatStorage($value, $round, $sf));
 }
    } else {
        $string = "设备 '" . $device['hostname'] . "' 跳过, 因为关闭了正在运行的自动发现进程.";
        print_debug($string);
        logfile($argv[0] . ": {$string}");
    }
}
$end = utime();
$run = $end - $start;
$proctime = substr($run, 0, 5);
if ($discovered_devices) {
    dbInsert(array('type' => 'discover', 'doing' => $doing, 'start' => $start, 'duration' => $proctime, 'devices' => $discovered_devices), 'perf_times');
    if (is_numeric($doing)) {
        $doing = $device['hostname'];
    }
    // Single device ID convert to hostname for log
} else {
    if (!isset($options['q']) && !$options['u']) {
        print_warning("警告: 0 设备被发现." . ($options['h'] != 'new' ? " 您是否指定了一个不存在的设备?" : ''));
    }
}
$string = $argv[0] . ": {$doing} - {$discovered_devices} 设备被发现, 耗时 {$proctime} 分钟";
print_debug($string);
if (!isset($options['q'])) {
    if ($config['snmp']['hide_auth']) {
        print_debug("NOTE, \$config['snmp']['hide_auth'] sets as TRUE, snmp community and snmp v3 auth hidden from debug output.");
    }
    print_message('Memory usage: ' . formatStorage(memory_get_usage(TRUE), 2, 4) . ' (peak: ' . formatStorage(memory_get_peak_usage(TRUE), 2, 4) . ')');
    print_message('MySQL: Cell[' . ($db_stats['fetchcell'] + 0) . '/' . round($db_stats['fetchcell_sec'] + 0, 2) . 's]' . ' Row[' . ($db_stats['fetchrow'] + 0) . '/' . round($db_stats['fetchrow_sec'] + 0, 2) . 's]' . ' Rows[' . ($db_stats['fetchrows'] + 0) . '/' . round($db_stats['fetchrows_sec'] + 0, 2) . 's]' . ' Column[' . ($db_stats['fetchcol'] + 0) . '/' . round($db_stats['fetchcol_sec'] + 0, 2) . 's]' . ' Update[' . ($db_stats['update'] + 0) . '/' . round($db_stats['update_sec'] + 0, 2) . 's]' . ' Insert[' . ($db_stats['insert'] + 0) . '/' . round($db_stats['insert_sec'] + 0, 2) . 's]' . ' Delete[' . ($db_stats['delete'] + 0) . '/' . round($db_stats['delete_sec'] + 0, 2) . 's]');
}
logfile($string);
// EOF
Example #21
0
while ($mempool = mysql_fetch_array($mempools)) {
    if (!is_integer($i / 2)) {
        $row_colour = $list_colour_a;
    } else {
        $row_colour = $list_colour_b;
    }
    $proc_url = "?page=device/" . $device['device_id'] . "/health/memory/";
    $text_descr = $mempool['mempool_descr'];
    $mempool_url = "/device/" . $device['device_id'] . "/health/memory/";
    $mini_url = $config['base_url'] . "/graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from=" . $day . "&to=" . $now . "&width=80&height=20&bg=f4f4f4";
    $mempool_popup = "onmouseover=\"return overlib('<div class=list-large>" . $device['hostname'] . " - " . $text_descr;
    $mempool_popup .= "</div><img src=\\'graph.php?id=" . $mempool['mempool_id'] . "&type=mempool&from={$month}&to={$now}&width=400&height=125\\'>";
    $mempool_popup .= "', RIGHT" . $config['overlib_defaults'] . ");\" onmouseout=\"return nd();\"";
    $total = formatStorage($mempool['mempool_total']);
    $used = formatStorage($mempool['mempool_used']);
    $free = formatStorage($mempool['mempool_free']);
    $perc = round($mempool['mempool_used'] / $mempool['mempool_total'] * 100);
    if ($perc > '90') {
        $left_background = 'c4323f';
        $right_background = 'C96A73';
    } elseif ($perc > '75') {
        $left_background = 'bf5d5b';
        $right_background = 'd39392';
    } elseif ($perc > '50') {
        $left_background = 'bf875b';
        $right_background = 'd3ae92';
    } elseif ($perc > '25') {
        $left_background = '5b93bf';
        $right_background = '92b7d3';
    } else {
        $left_background = '9abf5b';
function transferOverview($bill_id, $start, $end)
{
    $tot = array();
    $traf = array();
    global $cur_days, $total_days;
    //$cur_days     = date('d', ($config['time']['now'] - strtotime($datefrom)));
    //$total_days   = date('d', (strtotime($dateto)));
    $res = "    <table class=\"table table-striped table-bordered table-hover table-condensed table-rounded\" style=\"margin-bottom: 0px;\">";
    $res .= "      <thead>";
    $res .= "        <tr>";
    $res .= "          <th>周期</th>";
    $res .= "          <th style=\"text-align: center;\">流入流量</th>";
    $res .= "          <th style=\"text-align: center;\">流出流量</th>";
    $res .= "          <th style=\"text-align: center;\">合计</th>";
    $res .= "          <th style=\"text-align: center;\">小计</th>";
    $res .= "        </tr>";
    $res .= "      </thead>";
    $res .= "      <tbody>";
    foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id`= ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data) {
        $date = strftime("%A, %e %B %Y", $data['timestamp']);
        $tot['in'] += gbConvert($data['traf_in']);
        $tot['out'] += gbConvert($data['traf_out']);
        $tot['tot'] += gbConvert($data['traf_total']);
        $traf['in'] = formatStorage(gbConvert($data['traf_in']), "3");
        $traf['out'] = formatStorage(gbConvert($data['traf_out']), "3");
        $traf['tot'] = formatStorage(gbConvert($data['traf_total']), "3");
        $traf['stot'] = formatStorage(gbConvert($tot['tot']), "3");
        $res .= "        <tr>";
        $res .= "          <td><i class=\"icon-calendar\"></i> " . $date . "</td>";
        $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-success\">" . $traf['in'] . "</span></td>";
        $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-info\">" . $traf['out'] . "</span></td>";
        $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-inverse\">" . $traf['tot'] . "</span></td>";
        $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge\">" . $traf['stot'] . "</span></td>";
        $res .= "        </tr>";
    }
    $est['in'] = formatStorage($tot['in'] / $cur_days * $total_days);
    $est['out'] = formatStorage($tot['out'] / $cur_days * $total_days);
    $est['tot'] = formatStorage($tot['tot'] / $cur_days * $total_days);
    $res .= "        <tr class=\"alert\">";
    $res .= "          <td><strong>Estimated for this billing period</strong></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-success\"><strong>" . $est['in'] . "</strong></span></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-info\"><strong>" . $est['out'] . "</strong></span></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-inverse\"><strong>" . $est['tot'] . "</strong></span></td>";
    $res .= "          <td></td>";
    $res .= "        </tr>";
    $tot['in'] = formatStorage($tot['in']);
    $tot['out'] = formatStorage($tot['out']);
    $tot['tot'] = formatStorage($tot['tot']);
    $res .= "        <tr class=\"info\">";
    $res .= "          <td><strong>Total of this billing period</strong></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-success\"><strong>" . $tot['in'] . "</strong></span></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-info\"><strong>" . $tot['out'] . "</strong></span></td>";
    $res .= "          <td style=\"text-align: center;\"><span class=\"badge badge-inverse\"><strong>" . $tot['tot'] . "</strong></span></td>";
    $res .= "          <td></td>";
    $res .= "        </tr>";
    $res .= "      </tbody>";
    $res .= "    </table>";
    return $res;
}
Example #23
0
<?php

$graph_type = 'storage_usage';
$row = 1;
foreach (dbFetchRows('SELECT * FROM `storage` WHERE device_id = ? ORDER BY storage_descr', array($device['device_id'])) as $drive) {
    if (is_integer($row / 2)) {
        $row_colour = $list_colour_a;
    } else {
        $row_colour = $list_colour_b;
    }
    $total = $drive['storage_size'];
    $used = $drive['storage_used'];
    $free = $drive['storage_free'];
    $perc = round($drive['storage_perc'], 0);
    $used = formatStorage($used);
    $total = formatStorage($total);
    $free = formatStorage($free);
    $storage_descr = $drive['storage_descr'];
    $fs_url = 'graphs/id=' . $drive['storage_id'] . '/type=storage_usage/';
    $fs_popup = "onmouseover=\"return overlib('<div class=list-large>" . $device['hostname'] . ' - ' . $drive['storage_descr'];
    $fs_popup .= "</div><img src=\\'graph.php?id=" . $drive['storage_id'] . '&amp;type=' . $graph_type . '&amp;from=' . $config['time']['month'] . '&amp;to=' . $config['time']['now'] . "&amp;width=400&amp;height=125\\'>";
    $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"";
    $graph_array['id'] = $drive['storage_id'];
    $graph_array['type'] = $graph_type;
    echo "<div class='panel panel-default'>\n            <div class='panel-heading'>\n                <h3 class='panel-title'>{$storage_descr} <div class='pull-right'>{$used}/{$total} - {$perc}% used</div></h3>\n            </div>";
    echo "<div class='panel-body'>";
    include 'includes/print-graphrow.inc.php';
    echo "</div></div>";
    $row++;
}
//end foreach
Example #24
0
        unset($class);
        $day_data = getDates($bill['bill_day']);
        $datefrom = $day_data['0'];
        $dateto = $day_data['1'];
        $rate_data = getRates($bill['bill_id'], $datefrom, $dateto);
        $rate_95th = $rate_data['rate_95th'];
        $dir_95th = $rate_data['dir_95th'];
        $total_data = $rate_data['total_data'];
        $rate_average = $rate_data['rate_average'];
        if ($bill['bill_type'] == "cdr") {
            $type = "CDR";
            $allowed = formatRates($bill['bill_cdr'] * 1000);
            $used = formatRates($rate_data['rate_95th'] * 1000);
            $percent = round($rate_data['rate_95th'] / $bill['bill_cdr'] * 100, 2);
        } elseif ($bill['bill_type'] == "quota") {
            $type = "Quota";
            $allowed = formatStorage($bill['bill_gb'] * 1024 * 1024 * 1024);
            $used = formatStorage($rate_data['total_data'] * 1024 * 1024);
            $percent = round($rate_data['total_data'] / ($bill['bill_gb'] * 1024) * 100, 2);
        }
        if (!is_integer($i / 2)) {
            $row_colour = $list_colour_a;
        } else {
            $row_colour = $list_colour_b;
        }
        echo "\r\n           <tr bgcolor='{$row_colour}'>\r\n             <td width='7'></td>\r\n             <td width='250'><a href='" . $config['base_url'] . "/bill/" . $bill['bill_id'] . "/'><span style='font-weight: bold;' class=interface>" . $bill['bill_name'] . "</span></a></td>\r\n             <td>{$notes}</td>\r\n\t     <td>{$type}</td>\r\n             <td>{$allowed}</td>\r\n             <td>{$used}</td>\r\n             <td><img src='percentage.php?width=350&per={$percent}'> {$percent}%</td>\r\n\t\t\t\t\t\t <td></td>\r\n\t\t\t\t\t\t <td width=60><a><img src='images/16/wrench.png' align=absmiddle alt='Edit'> Edit</a></td>\r\n           </tr>\r\n         ";
        $i++;
    }
    echo "</table>";
}
echo "</td></tr></table>";
Example #25
0
        $doing = $device['hostname'];
    }
    // Single device ID convert to hostname for log
} else {
    print_warning("WARNING: 0 devices polled. Did you specify a device that does not exist?");
}
$string = $argv[0] . ": {$doing} - {$polled_devices} devices polled in {$poller_time} secs";
print_debug($string);
print_cli_heading("%WCompleted polling run at " . date("Y-m-d H:i:s"), 0);
if (!isset($options['q'])) {
    if ($config['snmp']['hide_auth']) {
        print_debug("NOTE, \$config['snmp']['hide_auth'] is set to TRUE, snmp community and snmp v3 auth hidden from debug output.");
    }
    print_cli_data('Devices Polled', $polled_devices, 0);
    print_cli_data('Poller Time', $poller_time . " secs", 0);
    print_cli_data('Memory usage', formatStorage(memory_get_usage(TRUE), 2, 4) . ' (peak: ' . formatStorage(memory_get_peak_usage(TRUE), 2, 4) . ')', 0);
    $mysql_time = 0;
    foreach ($db_stats as $cmd => $count) {
        if (isset($db_stats[$cmd . '_sec'])) {
            $mysql_times[] = ucfirst(str_replace("fetch", "", $cmd)) . "[" . $count . "/" . round($db_stats[$cmd . '_sec'], 3) . "s]";
            $mysql_time += $db_stats[$cmd . '_sec'];
        }
    }
    print_cli_data('MySQL Usage', implode(" ", $mysql_times) . ' (' . round($mysql_time, 3) . 's ' . round($mysql_time / $poller_time * 100, 3) . '%)', 0);
    $rrd_time = 0;
    foreach ($GLOBALS['rrdtool'] as $cmd => $data) {
        $rrd_times[] = $cmd . "[" . $data['count'] . "/" . round($data['time'], 3) . "s]";
        $rrd_time += $data['time'];
    }
    print_cli_data('RRDTool Usage', implode(" ", $rrd_times) . ' (' . round($rrd_time, 3) . 's ' . round($rrd_time / $poller_time * 100, 3) . '%)', 0);
    $snmp_time = 0;
echo percentage_bar($percentage_bar);
echo '    </td>';
echo '  </tr>';
?>

  <tr class="small">
    <td colspan=2>
      <div class="row" style="margin-left: 5px;">
         <div class="col-md-4"><i style="font-size: 7px; line-height: 7px; background-color: #356AA0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i>
          <strong>已用:</strong>  <?php 
echo formatStorage($swap_used * 1024) . ' (' . $swap_perc . '%)';
?>
</div>
         <div class="col-md-4"><i style="font-size: 7px; line-height: 7px; background-color: #ddd;    border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i>
          <strong>空闲:</strong>  <?php 
echo formatStorage($device_state['ucd_mem']['swap_avail'] * 1024) . ' (' . $swap_free_perc . '%)';
?>
</div>
         <div class="col-md-4"><i style="font-size: 7px; line-height: 7px; background-color: #ddd;    border: 1px #fff solid;">&nbsp;&nbsp;&nbsp;</i>
          <strong>合计:</strong> <?php 
echo formatStorage($device_state['ucd_mem']['swap_total'] * 1024);
?>
</div>
      </div>
    </td>
  </tr>
</table>

    </div>
  </div>
    </div>
  </div>
  <?php 
// FIXME (Mike): $device['ignore'] and get_dev_attrib($device,'disable_notify') it is same/redundant options?
?>
  <div class="control-group">
    <label class="control-label" for="sysLocation">忽略设备</label>
    <div class="controls">
      <input name="ignore" type="checkbox" id="disable" value="1" <?php 
if ($device['ignore']) {
    echo "checked=checked";
}
?>
 />
      <span class="help-inline">忽略设备.</span>
    </div>
  </div>
  </fieldset>

  <div class="form-actions">
    <button type="submit" class="btn btn-primary" name="submit" value="save"><i class="icon-ok icon-white"></i> 保存修改</button>
  </div>

</form>

<?php 
print_optionbar_start();
list($sizeondisk, $numrrds) = foldersize($config['rrd_dir'] . "/" . $device['hostname']);
echo "磁盘大小: <b>" . formatStorage($sizeondisk) . "</b> 存有 <b>" . $numrrds . " 个RRD文件</b>.";
print_optionbar_end();
// EOF
Example #28
0
             //unset($state_insert);
         } else {
             //$updated = dbUpdate($port['state'], 'ports-state', '`port_id` = ?', array($port['port_id']));
             //print_debug("STATE updated rows=$updated");
         }
     }
     // Add table row
     $table_row = array();
     $table_row[] = $port['ifIndex'];
     $table_row[] = $port['port_label_short'];
     $table_row[] = rewrite_iftype($port['ifType']);
     $table_row[] = formatRates($port['ifSpeed']);
     $table_row[] = formatRates($port['stats']['ifInBits_rate']);
     $table_row[] = formatRates($port['stats']['ifOutBits_rate']);
     $table_row[] = formatStorage($port['stats']['ifInOctets_diff']);
     $table_row[] = formatStorage($port['stats']['ifOutOctets_diff']);
     $table_row[] = format_si($port['stats']['ifInUcastPkts_rate']);
     $table_row[] = format_si($port['stats']['ifOutUcastPkts_rate']);
     $table_row[] = $port['port_64bit'] ? "%gY%w" : "%rN%w";
     $table_rows[] = $table_row;
     unset($table_row);
     // End Update Database
 } elseif ($port['disabled'] != "1") {
     print_message("Port Deleted.");
     // Port missing from SNMP cache.
     if (isset($port['ifIndex']) && $port['deleted'] != "1") {
         dbUpdate(array('deleted' => '1', 'ifLastChange' => date('Y-m-d H:i:s', $polled)), 'ports', '`device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $port['ifIndex']));
         log_event("Interface was marked as DELETED", $device, 'port', $port);
     }
 } else {
     print_message("Port Disabled.");
Example #29
0
    </div>
  </div>
  <button type="submit" name="Submit"  class="btn btn-default">Save</button>
</form>
<br />
<script>
    $("#rediscover").click(function() {
        var device_id = $(this).data("device_id");
        $.ajax({
            type: 'POST',
            url: 'ajax_form.php',
            data: { type: "rediscover-device", device_id: device_id },
            dataType: "json",
            success: function(data){
                if(data['status'] == 'ok') {
                    toastr.success(data['message']);
                } else {
                    toastr.error(data['message']);
                }
            },
            error:function(){
                toastr.error('An error occured setting this device to be rediscovered');
            }
        });
    });
</script>
<?php 
print_optionbar_start();
list($sizeondisk, $numrrds) = foldersize($config['rrd_dir'] . "/" . $device['hostname']);
echo "Size on Disk: <b>" . formatStorage($sizeondisk) . "</b> in <b>" . $numrrds . " RRD files</b>.";
print_optionbar_end();
Example #30
0
echo formatStorage($device_state['ucd_mem']['mem_cached'] * 1024) . ' (' . $cach_perc . '%)';
?>
</div>
         <div class="col-sm-4"><i style="font-size: 7px; line-height: 7px; background-color: #ddd;    border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i>
          <strong>Free:</strong>    <?php 
echo formatStorage($device_state['ucd_mem']['mem_avail'] * 1024) . ' (' . $avai_perc . '%)';
?>
</div>
         <div class="col-sm-4"><i style="font-size: 7px; line-height: 7px; background-color: #ddd;    border: 1px #fff solid;">&nbsp;&nbsp;&nbsp;</i>
          <strong>Total:</strong>   <?php 
echo formatStorage($device_state['ucd_mem']['mem_total'] * 1024);
?>
</div>
         <div class="col-sm-4"><i style="font-size: 7px; line-height: 7px; background-color: #356AA0; border: 1px #aaa solid;">&nbsp;&nbsp;&nbsp;</i>
          <strong>Swap:</strong>  <?php 
echo formatStorage($swap_used * 1024) . ' (' . $swap_perc . '%)';
?>
</div>
      </div>
    </td>
  </tr>

<?php 
/**
$swap_used = $device_state['ucd_mem']['swap_total'] - $device_state['ucd_mem']['swap_avail'];
$swap_perc = round(($swap_used / $device_state['ucd_mem']['swap_total']) * 100);
$swap_free_perc = 100 - $swap_perc;
$background = get_percentage_colours('40');
$percentage_bar            = array();
$percentage_bar['border']  = "#356AA0";
$percentage_bar['bg']      = "#f0f0f0";