本文整理汇总了PHP中formatStorage函数的典型用法代码示例。如果您正苦于以下问题:PHP formatStorage函数的具体用法?PHP formatStorage怎么用?PHP formatStorage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatStorage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: round
}
$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>";
?>
示例2: microtime
</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>";
}
示例3: transferOverview
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;
}
示例4: rrdtool_update_ng
$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
示例5: dbFetchCell
$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
示例6: dbFetchRows
$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;
示例7: preg_replace
$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>";
示例8: print_vars
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
示例9: formatStorage
</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">
示例10: unset
$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") {
示例11: transferOverview
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;
}
示例12: print_vars
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
示例13: generate_mempool_row
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;
}
示例14: safename
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
示例15: foreach
$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") {