Schorschi
Posts: 220
Joined: Thu Nov 22, 2012 9:38 pm

Determine information about Pi?

Sat Dec 08, 2012 2:38 pm

I have written a small python script that acts as a request agent on each of my Pi devices. The script accepts a Linux CLI command from a remote device, captures the stdout and stderr results of the command, and via simple TCP socket communication sends back the results form said the comamnd. I know nothing earth shattering. I have also written a .NET C# console application to issue the commands, and receive the results. I will soon write a simple .NET C# GUI based application to do the same as the console application and a bit more, such as the ability to create a list of command sequences as a batch command sequence, and implement a few commands to control the python script as well. The .NET C# GUI will act as a simple graphical dashboard I can run from Windows 7, etc., to monitor all of my Pi devices, automating performance metric capture, avoid configuration drift, and near real time query of health metrics (such as they are on the Pi devices). The motivation for this is because I have several Pi devices as always on-devices, and I wanted painless way to validate configuration, and status of the devices, keeping them consistent as possible given the expectation these always on-devices will be live 24x7x365. Capture CPU temperature, memory use, CPU load, Linux kernel version, query of key packages installed, etc., I have, for the most part. But I am not finding some of the information I desire, at a lower level, such as the version firmware the Pi device is running under, the active memory split, the total hours Pi has been used (if possible versus per boot uptime results)? The network statistics of the ethernet port? Although I suspect some of that is buried under /proc and I just need to find it.

ghans
Posts: 7871
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Determine information about Pi?

Sat Dec 08, 2012 3:41 pm

You might want to prod vcgencmd - there is loads of stuff
hidden behind that command. Do you mind sharing the code ?


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Schorschi
Posts: 220
Joined: Thu Nov 22, 2012 9:38 pm

Re: Determine information about Pi?

Mon Dec 10, 2012 2:11 am

Actually, I am not sure why did not think about # uname -a, which shows the firmware revision for the ARM processor. And I found a reference on how to capture the GPU firmware information as well. But I will check out the command you suggested as well.

And... I plan to release the code in a couple of days, I just want to do a bit more testing and some clean up, and then I will post it. I have some reasonable experience with .NET (more VB) than C#, but being an old school C language guy, doing some basic stuff in C# was not too crazy. I have only recently started working with Python, after years of doing BASH based scripting, so I am sure, more knowledgeable Python and even C# gurus may have tons of suggestions for improving the code? If so, please chime in, feedback always welcome, even if it is a bit harsh.

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Mon Dec 10, 2012 6:17 am

I'm running a Pi (soon to be a few) as mission critical servers! I'd love an app I can run on my Win7 pc to keep an eye on them. Free space reporting with an alert would be handy too ;)

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

Schorschi
Posts: 220
Joined: Thu Nov 22, 2012 9:38 pm

Re: Determine information about Pi?

Wed Dec 12, 2012 4:06 am

What type of alerting? What I have is not that fancy, yet, but if I get the time, I might add the feature.

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Wed Dec 12, 2012 6:32 am

Schorschi wrote:What type of alerting? What I have is not that fancy, yet, but if I get the time, I might add the feature.
Well, it could be many types of alerts. The best would be an e-mail, so that alerts me on my cell phone. But simply playing a sound over and over or flashing the app window, etc. I'm sure you can come up with something :)

Check out the amazing live RPi status app on this guys page: http://pi.gadgetoid.co.uk/post/027-live ... stem-stats

I'm currently trying to get it working on my Pi, but having never worked with Ruby or Thin, it's not working for me (errors with "eventmachine"). If I can get it working I'm going to add CPU temp, CPU speed and CPU voltage to the display, so I can see when my Pi is automatically overclocking and how hot she gets under heavy load.

I fully assume I can get alerts working through Ruby as well, and if not through Ruby I'm sure I can do them through PHP with which I am very familiar :)

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

Schorschi
Posts: 220
Joined: Thu Nov 22, 2012 9:38 pm

Re: Determine information about Pi?

Wed Dec 19, 2012 6:07 am

Check this out... I posted my solution... it is a bit more generic in design, but you could use it to get the same basic information if desired.

http://www.raspberrypi.org/phpBB3/viewt ... 96#p233096

sim_tcr
Posts: 326
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

Re: Determine information about Pi?

Wed Dec 19, 2012 5:30 pm

I am working on displaying real time information about my pi in my website. For eg, cpu temp, cpu utilization, memory utilization.
I checked http://pi.gadgetoid.co.uk/ and I can see that he got successfull doing it. I have downloaded Socket.rb from his website.
And as i understood from his website, I needed to install Ruby Rail Server. I have installed that too.
Now how do I run Socket.rb and display the information in my php page?
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Wed Dec 19, 2012 7:00 pm

sim_tcr wrote:I needed to install Ruby Rail Server. I have installed that too.
Now how do I run Socket.rb and display the information in my php page?
I was not able to get Thin, Ruby or eventmachine working together, to get another persons live stats feed working. Another user, atouk on #raspberrypi IRC (freenode), build a super awesome status page for me, which I've customized a bit. If you just want a few things like free memory, cpu temp, etc. It would be easy to pull those values with PHP (no third party programs required!) and use javascript to refresh the values so you have a live feed.

Check out my live status page (assuming port 8000 is not blocked for you): http://tafb.yi.org:8000/

The basic source code for it is located at the bottom of the page. Check out the readme file in there, and look at the php source file, should give you an example of how to use PHP (in a really inefficient manor) to pull the live stats.

I'm running that status page on my Pi with Pancake and PHP5. It works under other webservers as well, Apache, etc. You just have to make sure you give whatever "user" the webserver uses (www-data) the appropriate permissions so PHP can run shell_exec commands.

Let me know if you need more help.

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

sim_tcr
Posts: 326
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

Re: Determine information about Pi?

Thu Dec 20, 2012 6:36 am

Thank you.

I downloaded your source code zip. Still in the process of understanding it.
By the way I deployed it under my apache root. And I am seeing some issues. Here is the url http://raspiabita.no-ip.org/stat.php

CPU INFO - Entire page data refresh in 30 seconds! - This fuction does not work. Infact any of that text or Stop button is visible.
What to do to fix this auto refresh 30 seconds issue?

Code: Select all

<?php
echo shell_exec('sudo vcgencmd version');
?>
above displays empty in browser.Tried this command from putty and it displays the firmware version.
I verified that shell_exec funtion works fine. (I tried date command and it displays fine in browser)
What to do to fix vcgencmd command issue?
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Thu Dec 20, 2012 7:06 am

sim_tcr wrote:I downloaded your source code zip. Still in the process of understanding it.
By the way I deployed it under my apache root. And I am seeing some issues. Here is the url http://raspiabita.no-ip.org/stat.php
Looking really good so far!!! Nice work :)
sim_tcr wrote:CPU INFO - Entire page data refresh in 30 seconds! - This fuction does not work. Infact any of that text or Stop button is visible.
What to do to fix this auto refresh 30 seconds issue?
The page refresh script is from this site: http://www.dynamicdrive.com/dynamicindex6/refresh.htm

To make the stop button you just put this code in the beginning of your body:

Code: Select all

<script language="JavaScript">
function myStopFunction()
{
 clearTimeout(counter);
}
</script>
Then to make the button you put the following code somewhere on your page where you want the stop button:

Code: Select all

<button onclick="myStopFunction()">STOP</button>
sim_tcr wrote:

Code: Select all

<?php
echo shell_exec('sudo vcgencmd version');
?>
above displays empty in browser.Tried this command from putty and it displays the firmware version.
I verified that shell_exec funtion works fine. (I tried date command and it displays fine in browser)
What to do to fix vcgencmd command issue?
Yikes. I tried it on my page, worked fine (direct copy and paste).

When you run this in putty: sudo vcgencmd version

What exactly does it spit out?

You gave the appropriate permissions to www-data like the readme said right?

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Thu Dec 20, 2012 7:16 am

I forgot to write, for those of you who sent me a message letting me know that you were unable to view my page because port 8000 was blocked for you, here ya go!

http://tafb.yi.org

On all of port 80's unblocked goodness :)

Enjoy!

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

sim_tcr
Posts: 326
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

Re: Determine information about Pi?

Thu Dec 20, 2012 7:50 am

Hey new findings from internet!!

In the below example Page has static part and also a div which refresh every 1 second (thats right without the whole page being refreshed)

Refresh.php

Code: Select all

<html>
<title> Example for div refresh without whole page being refreshed </title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(function (){$('#load_tweets').load('record_count.php').fadeIn("slow");}, 1000); // refresh every 10000 milliseconds
</script>
<body>
<div id="load_tweets"> </div>
</body>
Static Part
<img src="/pics/Raspi_Colour_R_small.PNG" alt="some_text">
</html>
record_count.php

Code: Select all

<?php
echo '</pre><strong>UPTIME</strong><br /><pre>' . shell_exec('uptime');
echo '</pre><strong>CPU Temp:</strong><br /><pre>' . shell_exec('cat /sys/class/thermal/thermal_zone0/temp');
?>
If you are too lazy to deploy it in apache and test here is my link http://raspiabita.no-ip.org/refresh.php
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Thu Dec 20, 2012 7:59 am

It looks really good, I like it :)

The problem with the status page is that it uses over 100 shell_exec calls every time it loads. So using your script would make it run each of those shell exec calls each time to get the new data, PER VIEWER too! hehe.

I've built my page using my own custom written dynamic caching technology :) You can see how fast my status page loads, instead of 3 seconds like normal, it loads in .0021 seconds :) http://tafb.yi.org

It can also handle tons and tons of simultaneous viewers (160 page hits per second) with no extra load on PHP :)

I like your idea though, very smooth fluid updates. I just don't know how it would work running 100 shell_exec calls :(

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

sim_tcr
Posts: 326
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

Re: Determine information about Pi?

Thu Dec 20, 2012 9:08 am

toysareforboys wrote:When you run this in putty: sudo vcgencmd version

What exactly does it spit out?

You gave the appropriate permissions to www-data like the readme said right?
If I run sudo vcgencmd version from putty it shows,

[email protected] ~/Desktop $ sudo vcgencmd version
Oct 25 2012 16:37:21
Copyright (c) 2012 Broadcom
version 346337 (release)


How do I modify permissions of www-data? I am posting output of id www-data below. Does it look good?

[email protected] ~/Desktop $ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)
[email protected] ~/Desktop $
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Thu Dec 20, 2012 9:23 am

sim_tcr wrote:If I run sudo vcgencmd version from putty it shows,

[email protected] ~/Desktop $ sudo vcgencmd version
Oct 25 2012 16:37:21
Copyright (c) 2012 Broadcom
version 346337 (release)
Maybe it's because you've got the old old firmware?? Try this to update it: https://github.com/Hexxeh/rpi-update

After that is done run this: sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
sim_tcr wrote:How do I modify permissions of www-data? I am posting output of id www-data below. Does it look good?

[email protected] ~/Desktop $ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)
[email protected] ~/Desktop $
Try this:

Code: Select all

sudo /etc/sudoers.d
under the #include header add this line:

www-data ALL=(ALL) NOPASSWD: ALL

Reboot, and that should enable the www-data account to run all of the shell_exec commands.

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

sim_tcr
Posts: 326
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

Re: Determine information about Pi?

Thu Dec 20, 2012 10:21 am

Still same issue,

I have updated my firmware to latest now,

[email protected]:~$ sudo vcgencmd version
Nov 22 2012 18:12:01
Copyright (c) 2012 Broadcom
version 352766 (release)


I dont have /etc/sudoers.d. And morover I think my www-data account has enough permission to execute shell_exec, because i am able tio run any other than vcgencmd from php. Issue seems to be only with vcgencmd
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

sim_tcr
Posts: 326
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

Re: Determine information about Pi?

Fri Dec 21, 2012 6:49 pm

sim_tcr wrote:Still same issue,

I have updated my firmware to latest now,

[email protected]:~$ sudo vcgencmd version
Nov 22 2012 18:12:01
Copyright (c) 2012 Broadcom
version 352766 (release)


I dont have /etc/sudoers.d. And morover I think my www-data account has enough permission to execute shell_exec, because i am able tio run any other than vcgencmd from php. Issue seems to be only with vcgencmd
I fixed this issue by

Code: Select all

usermod -a -G video www-data
Below is the explanation.

Code: Select all

[email protected]:~$ ls -l /dev/vchiq
crw-rw---T 1 root video 252, 0 Jan  1  1970 /dev/vchiq
[email protected]:~$ groups
pi adm dialout cdrom sudo audio video plugdev games users netdev input
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

sim_tcr
Posts: 326
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

Re: Determine information about Pi?

Mon Dec 24, 2012 12:19 pm

toysareforboys wrote:It looks really good, I like it :)

The problem with the status page is that it uses over 100 shell_exec calls every time it loads. So using your script would make it run each of those shell exec calls each time to get the new data, PER VIEWER too! hehe.

I've built my page using my own custom written dynamic caching technology :) You can see how fast my status page loads, instead of 3 seconds like normal, it loads in .0021 seconds :) http://tafb.yi.org

It can also handle tons and tons of simultaneous viewers (160 page hits per second) with no extra load on PHP :)

I like your idea though, very smooth fluid updates. I just don't know how it would work running 100 shell_exec calls :(

-Jamie M.
In your site http://tafb.yi.org you displays Current CPU total load: in percentage. What is the command to display that?
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Mon Dec 24, 2012 3:40 pm

sim_tcr wrote:In your site http://tafb.yi.org you displays Current CPU total load: in percentage. What is the command to display that?
I haven't got the total cpu% workin on my new server replacement for the Pi (a Seagate GoFlex Home docking station, hacked with Arch Linux :)).

To make it work on Wheezy I used the following command:

Code: Select all

ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc
That required a command line calculator called "bc". To install it:

Code: Select all

sudo apt-get install bc
I'm sure there's a way to do it without BC but I'm a linux noob ;)

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

sim_tcr
Posts: 326
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

Re: Determine information about Pi?

Mon Dec 24, 2012 5:37 pm

toysareforboys wrote:

Code: Select all

ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc
That required a command line calculator called "bc". To install it:

Code: Select all

sudo apt-get install bc
.
Did not work,

Code: Select all

[email protected] ~ $ ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc
sed: -e expression #1, char 1: unknown command: `''
-bash: N: command not found
-bash: s/n/: No such file or directory
-bash: t: command not found
[email protected] ~ $
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Mon Dec 24, 2012 5:50 pm

sim_tcr wrote:Did not work,
Ahhhh. my bad. That's for a PHP script so it has some extra \'s in there. This one should work:

Code: Select all

ps -e -o pcpu | tail -n +2 | sed '{:q;N;s/\n/ + /g;t q}' | bc
Sorry bout that.

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

sim_tcr
Posts: 326
Joined: Tue Nov 06, 2012 1:01 pm
Location: Bangalore
Contact: Website

Re: Determine information about Pi?

Mon Dec 24, 2012 8:34 pm

toysareforboys wrote:

Code: Select all

ps -e -o pcpu | tail -n +2 | sed '{:q;N;s/\n/ + /g;t q}' | bc
That worked. My php code is,

Code: Select all

<?php
echo '</pre><strong>CPU Utlization:</strong><br /><pre>' . shell_exec('ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc');
?>
it displays just the number. Like '1.2' . I want to make it appear '1.2 %'. Any thoughts?
http://raspisimon.no-ip.org
Raspberry Pi Model B x 2, Raspberry Pi 2 x 2, Transcend 32GB Class 10, Transcend 16GB Class 10, Transcend 8GB Class 4, Custom 12V 1.5A (stepped down to 5.5V)

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Mon Dec 24, 2012 8:43 pm

sim_tcr wrote:it displays just the number. Like '1.2' . I want to make it appear '1.2 %'. Any thoughts?
Try:

Code: Select all

<?php
echo '</pre><strong>CPU Utilization:</strong><br /><pre>' . shell_exec('ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc') . " %";
?>
Let me know if it works :)

-Jamie M.
Last edited by toysareforboys on Mon Dec 24, 2012 8:50 pm, edited 1 time in total.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

User avatar
toysareforboys
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm

Re: Determine information about Pi?

Mon Dec 24, 2012 8:47 pm

Also, if you wanted it to say:

CPU Utilization: 27%

instead of:

CPU Utilization:
27%

then you gotta get rid of the <br /> in there too ;)

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') . "%";
?>
-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org

Return to “General discussion”