still appears.toysareforboys wrote:-Jamie M.Code: Select all
<?php echo '</pre><strong>CPU Utilization:</strong><pre>' . shell_exec('ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc') . "%"; ?>
1.2
%
still appears.toysareforboys wrote:-Jamie M.Code: Select all
<?php echo '</pre><strong>CPU Utilization:</strong><pre>' . shell_exec('ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc') . "%"; ?>
In looking at my code on my site, I see I had to strip \n and \r from the string to get the % onto the same line. My super crappy php code:sim_tcr wrote:still appears.
1.2
%
Code: Select all
<?php
$total_cpu = 'ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc';
$total_cpu_num = shell_exec($total_cpu);
$total_cpu_num = str_replace(array("\r", "\n", '/\s+/'), '', $total_cpu_num);
echo $total_cpu_num . "%";
?>
That worked.toysareforboys wrote:In looking at my code on my site, I see I had to strip \n and \r from the string to get the % onto the same line. My super crappy php code:sim_tcr wrote:still appears.
1.2
%That should workCode: Select all
<?php $total_cpu = 'ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc'; $total_cpu_num = shell_exec($total_cpu); $total_cpu_num = str_replace(array("\r", "\n", '/\s+/'), '', $total_cpu_num); echo $total_cpu_num . "%"; ?>
-Jamie M.
Love the page, looks great!sim_tcr wrote:That worked.
Here is my page http://raspisimon.no-ip.org/status.php
Wish you all Merry X'mas.
I see the new changes, it looks awsome, especially the CPU load progress bar. Do you mind sharing the source code of whole thing?toysareforboys wrote:I'll be working on it lots tonight so maybe it'll be different by the time you load it: http://tafb.yi.org
I'm glad you like the changessim_tcr wrote:I see the new changes, it looks awsome, especially the CPU load progress bar. Do you mind sharing the source code of whole thing?
Code: Select all
<?php
$total_cpu = 'ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc';
$total_cpu_num = shell_exec($total_cpu);
$total_cpu_num = str_replace(array("\r", "\n", '/\s+/'), '', $total_cpu_num);
echo $total_cpu_num ;
?>