示例#1
0
function showPercent($per)
{
    $background = get_percentage_colours($per);
    $right_background = $background['right'];
    $left_background = $background['left'];
    $res = print_percentage_bar(350, 20, $per, NULL, "ffffff", $left_background, $per . "%", "ffffff", $right_background);
    return $res;
}
示例#2
0
function showPercent($per)
{
    $background = get_percentage_colours($per);
    $right_background = $background['right'];
    $left_background = $background['left'];
    $res = print_percentage_bar(350, 20, $per, null, 'ffffff', $left_background, $per . '%', 'ffffff', $right_background);
    return $res;
}
示例#3
0
function toner2colour($descr, $percent)
{
    $colour = get_percentage_colours(100 - $percent);
    if (substr($descr, -1) == 'C' || stripos($descr, 'cyan') !== false) {
        $colour['left'] = '55D6D3';
        $colour['right'] = '33B4B1';
    }
    if (substr($descr, -1) == 'M' || stripos($descr, 'magenta') !== false) {
        $colour['left'] = 'F24AC8';
        $colour['right'] = 'D028A6';
    }
    if (substr($descr, -1) == 'Y' || stripos($descr, 'yellow') !== false || stripos($descr, 'giallo') !== false || stripos($descr, 'gul') !== false) {
        $colour['left'] = 'FFF200';
        $colour['right'] = 'DDD000';
    }
    if (substr($descr, -1) == 'K' || stripos($descr, 'black') !== false || stripos($descr, 'nero') !== false) {
        $colour['left'] = '000000';
        $colour['right'] = '222222';
    }
    return $colour;
}
function toner2colour($descr, $percent)
{
    $colour = get_percentage_colours(100 - $percent);
    if (substr($descr, -1) == 'C' || stripos($descr, "cyan") !== false) {
        $colour['left'] = "55D6D3";
        $colour['right'] = "33B4B1";
    }
    if (substr($descr, -1) == 'M' || stripos($descr, "magenta") !== false) {
        $colour['left'] = "F24AC8";
        $colour['right'] = "D028A6";
    }
    if (substr($descr, -1) == 'Y' || stripos($descr, "yellow") !== false || stripos($descr, "giallo") !== false || stripos($descr, "gul") !== false) {
        $colour['left'] = "FFF200";
        $colour['right'] = "DDD000";
    }
    if (substr($descr, -1) == 'K' || stripos($descr, "black") !== false || stripos($descr, "nero") !== false) {
        $colour['left'] = "000000";
        $colour['right'] = "222222";
    }
    return $colour;
}
示例#5
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
$scale_min = "0";
$scale_max = "100";
include_once $config['html_dir'] . "/includes/graphs/common.inc.php";
$rrd_options .= " COMMENT:'                                 Cur    Max\\n'";
$colour = toner2colour($toner['toner_descr']);
if ($colour['left'] == NULL) {
    $colour['left'] = "CC0000";
}
$descr = rrdtool_escape($toner['toner_descr'], 26);
$background = get_percentage_colours(100 - $toner['toner_current']);
$rrd_options .= " DEF:toner" . $toner['toner_id'] . "=" . $rrd_filename . ":toner:AVERAGE ";
$rrd_options .= " LINE1:toner" . $toner['toner_id'] . "#" . $colour['left'] . ":'" . $descr . "' ";
$rrd_options .= " AREA:toner" . $toner['toner_id'] . "#" . $background['right'] . ":";
$rrd_options .= " GPRINT:toner" . $toner['toner_id'] . ":LAST:'%5.0lf%%'";
$rrd_options .= " GPRINT:toner" . $toner['toner_id'] . ":MAX:%5.0lf%%\\\\l";
// EOF
?>
</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']['mem_total'] * 1024);
?>
</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";
$percentage_bar['width'] = "100%";
$percentage_bar['text'] = $swap_free_perc . "%";
$percentage_bar['text_c'] = "#356AA0";
$percentage_bar['bars'][0] = array('percent' => $swap_perc, 'colour' => '#356AA0', 'text' => $swap_perc . '%');
echo '  <tr>';
echo '    <td class="entity">Swap</td>';
echo '    <td>';
echo percentage_bar($percentage_bar);
echo '    </td>';
echo '  </tr>';
?>
         break;
     default:
         echo $entry['']['cc6kxbarModuleModeSwitchingMode'];
 }
 echo "</td>\n      </tr>";
 foreach ($entity_state['group']['c6kxbar'][$index] as $subindex => $fabric) {
     if (is_numeric($subindex)) {
         if ($fabric['cc6kxbarModuleChannelFabStatus'] == "ok") {
             $fabric['mode_class'] = "green";
         } else {
             $fabric['mode_class'] = "red";
         }
         $percent_in = $fabric['cc6kxbarStatisticsInUtil'];
         $background_in = get_percentage_colours($percent_in);
         $percent_out = $fabric['cc6kxbarStatisticsOutUtil'];
         $background_out = get_percentage_colours($percent_out);
         $graph_array = array();
         $graph_array['height'] = "100";
         $graph_array['width'] = "210";
         $graph_array['to'] = $config['time']['now'];
         $graph_array['device'] = $device['device_id'];
         $graph_array['mod'] = $index;
         $graph_array['chan'] = $subindex;
         $graph_array['type'] = "c6kxbar_util";
         $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);
         $text_descr = $entity['entPhysicalName'] . " - Fabric " . $subindex;
示例#8
0
function list_bills()
{
    global $config;
    $app = \Slim\Slim::getInstance();
    $router = $app->router()->getCurrentRoute()->getParams();
    $status = 'ok';
    $err_msg = '';
    $message = '';
    $code = 200;
    $bills = array();
    $bill_id = mres($router['bill_id']);
    $bill_ref = mres($_GET['ref']);
    $bill_custid = mres($_GET['custid']);
    if (!empty($bill_custid)) {
        $sql = '`bill_custid` = ?';
        $param = array($bill_custid);
    } elseif (!empty($bill_ref)) {
        $sql = '`bill_ref` = ?';
        $param = array($bill_ref);
    } elseif (is_numeric($bill_id)) {
        $sql = '`bill_id` = ?';
        $param = array($bill_id);
    } else {
        $sql = '';
        $param = array();
    }
    if (count($param) >= 1) {
        $sql = "WHERE {$sql}";
    }
    foreach (dbFetchRows("SELECT `bills`.*,COUNT(port_id) AS `ports_total` FROM `bills` LEFT JOIN `bill_ports` ON `bill_ports`.`bill_id`=`bills`.`bill_id` {$sql} GROUP BY `bill_name`,`bill_ref` ORDER BY `bill_name`", $param) as $bill) {
        $day_data = getDates($bill['bill_day']);
        $ports_total = $bill['ports_total'];
        $datefrom = $day_data['0'];
        $dateto = $day_data['1'];
        $rate_data = $bill;
        $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 = format_si($bill['bill_cdr']) . "bps";
            $used = format_si($rate_data['rate_95th']) . "bps";
            $percent = round($rate_data['rate_95th'] / $bill['bill_cdr'] * 100, 2);
            $background = get_percentage_colours($percent);
            $overuse = $rate_data['rate_95th'] - $bill['bill_cdr'];
            $overuse = $overuse <= 0 ? "-" : format_si($overuse);
        } elseif ($bill['bill_type'] == "quota") {
            $type = "Quota";
            $allowed = format_bytes_billing($bill['bill_quota']);
            $used = format_bytes_billing($rate_data['total_data']);
            $percent = round($rate_data['total_data'] / $bill['bill_quota'] * 100, 2);
            $background = get_percentage_colours($percent);
            $overuse = $rate_data['total_data'] - $bill['bill_quota'];
            $overuse = $overuse <= 0 ? "-" : format_bytes_billing($overus);
        }
        $bill['allowed'] = $allowed;
        $bill['used'] = $used;
        $bill['percent'] = $percent;
        $bill['overuse'] = $overuse;
        $bills[] = $bill;
    }
    $count = count($bills);
    $output = array("status" => $status, "err-msg" => $err_msg, "count" => $count, "bills" => $bills);
    $app->response->headers->set('Content-Type', 'application/json');
    echo _json_encode($output);
}
示例#9
0
function toner_to_colour($descr, $percent)
{
    if (substr($descr, -1) == 'C' || toner_map($descr, "cyan")) {
        $colour['left'] = "B6F6F6";
        $colour['right'] = "33B4B1";
    }
    if (substr($descr, -1) == 'M' || toner_map($descr, "magenta")) {
        $colour['left'] = "FBA8E6";
        $colour['right'] = "D028A6";
    }
    if (substr($descr, -1) == 'Y' || toner_map($descr, "yellow")) {
        $colour['left'] = "FFF764";
        $colour['right'] = "DDD000";
    }
    if (substr($descr, -1) == 'K' || toner_map($descr, "black")) {
        $colour['left'] = "888787";
        $colour['right'] = "555555";
    }
    if (!isset($colour['left'])) {
        $colour = get_percentage_colours(100 - $percent);
        $colour['found'] = FALSE;
    } else {
        $colour['found'] = TRUE;
    }
    return $colour;
}
示例#10
0
<?php

/**
 * Observium Network Management and Monitoring System
 * Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
 *
 * @package    observium
 * @subpackage applications
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$cpu_counter = $app_data['cpu']['proc'];
$time_counter = $app_data['cpu']['time'];
$cpu_load_percent = round($cpu_counter / $time_counter * 100, 2);
$background = get_percentage_colours($cpu_load_percent);
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "512";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_mssql_cpu_usage';
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no";
$graph = generate_graph_tag($graph_array);
$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, $app['app_instance'] . " - CPU Usage");
$percentage_bar = array();
示例#11
0
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$scale_min = "0";
$scale_max = "100";
include_once $config['html_dir'] . "/includes/graphs/common.inc.php";
$rrd_options .= " COMMENT:'                                 Cur     Max\\n'";
if ($supply['supply_colour'] != '') {
    $colour = toner_to_colour($supply['supply_colour'], $perc);
} else {
    $colour = toner_to_colour($supply['supply_descr'], $perc);
}
if ($colour['left'] == NULL) {
    $colour['left'] = "CC0000";
}
$descr = rrdtool_escape($supply['supply_descr'], 26);
$background = get_percentage_colours(100 - $supply['supply_value']);
$rrd_options .= " DEF:level" . $supply['supply_id'] . "=" . $rrd_filename . ":level:AVERAGE ";
$rrd_options .= " LINE1:level" . $supply['supply_id'] . "#" . $colour['left'] . ":'" . $descr . "' ";
$rrd_options .= " AREA:level" . $supply['supply_id'] . "#" . $background['right'] . ":";
$rrd_options .= " GPRINT:level" . $supply['supply_id'] . ":LAST:'%5.0lf%%'";
$rrd_options .= " GPRINT:level" . $supply['supply_id'] . ":MAX:%5.0lf%%\\l";
// EOF
示例#12
0
  $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") {
      echo "<tr><td colspan=7>";
示例#13
0
function generate_processor_row($processor, $vars)
{
    global $config;
    $table_cols = 4;
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $table_cols++;
    }
    // Add a column for device.
    // FIXME should that really be done here? :-)
    // FIXME - not it shouldn't. we need some per-os rewriting on discovery-time.
    $text_descr = $processor['processor_descr'];
    $text_descr = str_replace("Routing Processor", "RP", $text_descr);
    $text_descr = str_replace("Switching Processor", "SP", $text_descr);
    $text_descr = str_replace("Sub-Module", "Module ", $text_descr);
    $text_descr = str_replace("DFC Card", "DFC", $text_descr);
    $graph_array = array();
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $processor['processor_id'];
    $graph_array['type'] = 'processor_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" => $processor['device_id'], "tab" => "health", "metric" => 'processor'));
    $overlib_content = generate_overlib_content($graph_array, $processor['hostname'] . " - " . $text_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);
    $perc = round($processor['processor_usage']);
    $background = get_percentage_colours($perc);
    $processor['html_row_class'] = $background['class'];
    $row .= '<tr class="' . $processor['html_row_class'] . '">
          <td class="state-marker"></td>';
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $row .= '<td class="entity">' . generate_device_link($processor) . '</td>';
    }
    $row .= '  <td class="entity">' . generate_entity_link('processor', $processor) . '</td>
      <td>' . overlib_link($link_graph, $mini_graph, $overlib_content) . '</td>
      <td><a href="' . $link_graph . '">
        ' . print_percentage_bar(400, 20, $perc, $perc . "%", "ffffff", $background['left'], 100 - $perc . "%", "ffffff", $background['right']) . '
        </a>
      </td>
    </tr>
   ';
    if ($vars['view'] == "graphs") {
        $vars['graph'] = "usage";
    }
    if ($vars['graph']) {
        $row .= '<tr class="' . $processor['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'] = $processor['processor_id'];
        $graph_array['type'] = 'processor_' . $vars['graph'];
        print_graph_row($graph_array, TRUE);
        $row .= '</td></tr>';
    }
    # endif graphs
    return $row;
}
示例#14
0
 *
 */
$graph_type = "printersupply_usage";
$supplies = dbFetchRows("SELECT * FROM `printersupplies` WHERE `device_id` = ? ORDER BY `supply_type`", array($device['device_id']));
if (count($supplies)) {
    $box_args = array('title' => 'Printer Supplies', 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'printing')), 'icon' => 'oicon-contrast');
    echo generate_box_open($box_args);
    echo '<table class="table table-condensed table-striped">';
    foreach ($supplies as $supply) {
        $percent = round($supply['supply_value'], 0);
        if ($supply['supply_colour'] != '') {
            $background = toner_to_colour($supply['supply_colour'], $percent);
        } else {
            $background = toner_to_colour($supply['supply_descr'], $percent);
        }
        $background_percent = get_percentage_colours($percent - 100);
        $graph_array = array();
        $graph_array['height'] = "100";
        $graph_array['width'] = "210";
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $supply['supply_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'] . " - " . $supply['supply_descr']);
        $graph_array['width'] = 80;
        $graph_array['height'] = 20;
示例#15
0
        #    $graph_array['to']     = $config['time']['now'];
        #    $graph_array['id']     = $proc['processor_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'] . " - " . $text_descr);
        #    $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent.
        #    $graph_array['style'][] = 'margin-top: -6px';
        #    $minigraph =  generate_graph_tag($graph_array);
        #    echo('<tr>
        #           <td><span class="entity">'.overlib_link($link, $text_descr, $overlib_content).'</span></td>
        #           <td width=90>'.overlib_link($link, $minigraph, $overlib_content).'</td>
        #           <td width=200>'.overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content).'
        #           </a></td>
        #         </tr>');
    }
    $average_percent = round($total_percent / $numprocs);
    $background = get_percentage_colours($average_percent);
    echo '<table class="table table-condensed-more table-striped table-bordered">';
    echo '<tr>
           <td><span class="entity">' . overlib_link($link, $text_descr, $overlib_content) . '</span><span class="label pull-right" style="margin-top: 2px; font-size: 11px;"><i class="icon-remove"></i> ' . $numprocs . '</span></td>
           <td style="width: 200px">' . overlib_link($link, print_percentage_bar(200, 20, $average_percent, NULL, "ffffff", $background['left'], $average_percent . "%", "ffffff", $background['right']), $overlib_content) . '</td>
         </tr>';
    echo "</table>";
    echo "</div></div>";
}
// EOF
function toner2colour($descr, $percent)
{
    $colour = get_percentage_colours(100 - $percent);
    if (substr($descr, -1) == 'C' || toner_map($descr, "cyan")) {
        $colour['left'] = "55D6D3";
        $colour['right'] = "33B4B1";
    }
    if (substr($descr, -1) == 'M' || toner_map($descr, "magenta")) {
        $colour['left'] = "F24AC8";
        $colour['right'] = "D028A6";
    }
    if (substr($descr, -1) == 'Y' || toner_map($descr, "yellow")) {
        $colour['left'] = "FFF200";
        $colour['right'] = "DDD000";
    }
    if (substr($descr, -1) == 'K' || toner_map($descr, "black")) {
        $colour['left'] = "111111";
        $colour['right'] = "555555";
    }
    return $colour;
}
示例#17
0
        $graph_array['type'] = 'device_processor';
        $graph = generate_lazy_graph_tag($graph_array);
        //Generate link to graphs
        $link_array = $graph_array;
        $link_array['page'] = 'graphs';
        unset($link_array['height'], $link_array['width']);
        $link = generate_url($link_array);
        //Generate tooltip
        $graph_array['width'] = '210';
        $overlib_content = generate_overlib_content($graph_array, $device['hostname'] . ' - CPU usage');
        echo '<tr>
              <td colspan="4">';
        echo overlib_link($link, $graph, $overlib_content, null);
        echo '  </td>
            </tr>';
        //Add a row with CPU desc, count and percent graph
        $totalPercent = $totalPercent / count($processors);
        $background = get_percentage_colours($totalPercent);
        echo '<tr>
             <td>' . overlib_link($link, $text_descr, $overlib_content) . '</td>
             <td>' . overlib_link($link, 'x' . count($processors), $overlib_content) . '</td>
             <td>' . overlib_link($link, print_percentage_bar(200, 20, $totalPercent, null, 'ffffff', $background['left'], $percent . '%', 'ffffff', $background['right']), $overlib_content) . '</td>
           </tr>';
    }
    echo '</table>
        </div>
        </div>
        </div>
        </div>';
}
//end if
示例#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;
}
foreach (dbFetchRows("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname") as $proc) {
    if (device_permitted($proc['device_id'])) {
        $device = $proc;
        // FIXME should that really be done here? :-)
        $text_descr = $proc['processor_descr'];
        $text_descr = str_replace("Routing Processor", "RP", $text_descr);
        $text_descr = str_replace("Switching Processor", "SP", $text_descr);
        $text_descr = str_replace("Sub-Module", "Module ", $text_descr);
        $text_descr = str_replace("DFC Card", "DFC", $text_descr);
        $proc_url = "device/" . $device['device_id'] . "/health/processor/";
        $mini_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=80&amp;height=20&amp;bg=f4f4f400";
        $proc_popup = "onmouseover=\"return overlib('<div class=list-large>" . $device['hostname'] . " - " . $text_descr;
        $proc_popup .= "</div><img src=\\'graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['month'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=125\\'>";
        $proc_popup .= "', RIGHT" . $config['overlib_defaults'] . ");\" onmouseout=\"return nd();\"";
        $perc = round($proc['processor_usage']);
        $background = get_percentage_colours($perc);
        echo "    <tr class=\"health\">\n               <td>" . generate_device_link($proc) . "</td>\n               <td class=\"tablehead\"><a href='" . $proc_url . "' {$proc_popup}>" . $text_descr . "</a></td>\n               <td width=\"90\"><a href=\"" . $proc_url . "\"  {$proc_popup}><img src=\"{$mini_url}\" /></a></td>\n               <td width=\"200\"><a href=\"" . $proc_url . "\" {$proc_popup}>\n           " . print_percentage_bar(400, 20, $perc, $perc . "%", "ffffff", $background['left'], 100 - $perc . "%", "ffffff", $background['right']);
        echo '</a></td>
             </tr>';
        if ($vars['view'] == "graphs") {
            echo '    <tr></tr><tr class="health"><td colspan="5">';
            $daily_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=211&amp;height=100";
            $daily_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150";
            $weekly_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['week'] . "&amp;to=" . $config['time']['now'] . "&amp;width=211&amp;height=100";
            $weekly_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['week'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150";
            $monthly_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['month'] . "&amp;to=" . $config['time']['now'] . "&amp;width=211&amp;height=100";
            $monthly_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['month'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150";
            $yearly_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['year'] . "&amp;to=" . $config['time']['now'] . "&amp;width=211&amp;height=100";
            $yearly_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['year'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150";
            echo "      <a onmouseover=\"return overlib('<img src=\\'{$daily_url}\\'>', LEFT);\" onmouseout=\"return nd();\">\n        <img src=\"{$daily_graph}\" border=\"0\"></a> ";
            echo "      <a onmouseover=\"return overlib('<img src=\\'{$weekly_url}\\'>', LEFT);\" onmouseout=\"return nd();\">\n        <img src=\"{$weekly_graph}\" border=\"0\"></a> ";
    $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'], 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($mempool['mempool_total']);
    $used = formatStorage($mempool['mempool_used']);
    $free = formatStorage($mempool['mempool_free']);
    $background = get_percentage_colours($mempool['mempool_perc']);
    echo '<tr>
      <td class="entity">' . generate_device_link($mempool) . '</td>
      <td>' . overlib_link($link, $mempool['mempool_descr'], $overlib_content) . '</td>
      <td>' . overlib_link($link_graph, $mini_graph, $overlib_content) . '</td>
      <td><a href="' . $proc_url . '" ' . $proc_popup . '>
        ' . print_percentage_bar(400, 20, $mempool['mempool_perc'], $used . ' / ' . $total, "ffffff", $background['left'], $free, "ffffff", $background['right']) . '
        </a>
      </td>
      <td>' . $mempool['mempool_perc'] . '%</td>
    </tr>
 ';
    if ($vars['view'] == "graphs") {
        echo "<tr><td colspan=5>";
        unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
        $graph_array['to'] = $config['time']['now'];
// Page Layout
$portret = $pdf->serializeTCPDFtagParameters(array('P'));
$landscape = $pdf->serializeTCPDFtagParameters(array('L'));
// History Database content
foreach (dbFetchRows("SELECT * FROM `bill_hist` WHERE `bill_id`= ? AND `id` = ? ORDER BY `bill_datefrom` DESC LIMIT 1", array($bill_id, $history_id)) as $row) {
    if (bill_permitted($row['bill_id'])) {
        $history['datefrom'] = strftime("%A, %e %B %Y @ %T", strtotime($row['bill_datefrom']));
        $history['dateto'] = strftime("%A, %e %B %Y @ %T", strtotime($row['bill_dateto']));
        $history['timestampfrom'] = strtotime($row['bill_datefrom']);
        $history['timestampto'] = strtotime($row['bill_dateto']);
        $history['type'] = $row['bill_type'];
        $history['percent'] = $row['bill_percent'];
        $history['dir_95th'] = $row['dir_95th'];
        $history['rate_95th'] = formatRates($row['rate_95th']);
        $history['total_data'] = formatStorage($row['traf_total'] * $config['billing']['base'] * $config['billing']['base']);
        $history['background'] = get_percentage_colours($row['bill_percent']);
        if ($row['bill_type'] == "CDR") {
            $history['allowed'] = format_number($row['bill_allowed'], $config['billing']['base']) . "B";
            $history['used'] = format_number($row['rate_95th'], $config['billing']['base']) . "B";
            $history['in'] = format_number($row['rate_95th_in'], $config['billing']['base']) . "B";
            $history['out'] = format_number($row['rate_95th_out'], $config['billing']['base']) . "B";
            $history['overusage'] = $row['bill_overuse'] <= 0 ? "-" : "<span style=\"color: #" . $history['background']['left'] . "; \">" . format_number($row['bill_overuse'] * 1000) . "</span>";
        } else {
            $history['allowed'] = formatStorage($row['bill_allowed'] * $config['billing']['base'] * $config['billing']['base']);
            $history['used'] = formatStorage($row['traf_total'] * $config['billing']['base'] * $config['billing']['base']);
            $history['in'] = formatStorage($row['traf_in'] * $config['billing']['base'] * $config['billing']['base']);
            $history['out'] = formatStorage($row['traf_out'] * $config['billing']['base'] * $config['billing']['base']);
            $history['overusage'] = $row['bill_overuse'] <= 0 ? "-" : "<span style=\"color: #" . $history['background']['left'] . "; \">" . formatStorage($row['bill_overuse'] * $config['billing']['base'] * $config['billing']['base']) . "</span>";
        }
    }
}
示例#22
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;
}