Determine information about Pi?
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.
Re: Determine information about Pi?
You might want to prod vcgencmd - there is loads of stuff
hidden behind that command. Do you mind sharing the code ?
ghans
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
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Re: Determine information about Pi?
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.
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.
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
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.

-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
Re: Determine information about Pi?
What type of alerting? What I have is not that fancy, yet, but if I get the time, I might add the feature.
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
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 somethingSchorschi wrote:What type of alerting? What I have is not that fancy, yet, but if I get the time, I might add the feature.

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
Re: Determine information about Pi?
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
http://www.raspberrypi.org/phpBB3/viewt ... 96#p233096
Re: Determine information about Pi?
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?
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)
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)
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
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.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?
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
Re: Determine information about Pi?
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?
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?
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');
?>
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)
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)
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
Looking really good so far!!! Nice worksim_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

The page refresh script is from this site: http://www.dynamicdrive.com/dynamicindex6/refresh.htmsim_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?
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>
Code: Select all
<button onclick="myStopFunction()">STOP</button>
Yikes. I tried it on my page, worked fine (direct copy and paste).sim_tcr wrote:above displays empty in browser.Tried this command from putty and it displays the firmware version.Code: Select all
<?php echo shell_exec('sudo vcgencmd 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?
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
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
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.
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
Re: Determine information about Pi?
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
record_count.php
If you are too lazy to deploy it in apache and test here is my link http://raspiabita.no-ip.org/refresh.php
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>
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');
?>
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)
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)
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
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.

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


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
Re: Determine information about Pi?
If I run sudo vcgencmd version from putty it shows,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?
pi@raspiabita ~/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?
pi@raspiabita ~/Desktop $ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)
pi@raspiabita ~/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)
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)
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
Maybe it's because you've got the old old firmware?? Try this to update it: https://github.com/Hexxeh/rpi-updatesim_tcr wrote:If I run sudo vcgencmd version from putty it shows,
pi@raspiabita ~/Desktop $ sudo vcgencmd version
Oct 25 2012 16:37:21
Copyright (c) 2012 Broadcom
version 346337 (release)
After that is done run this: sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
Try this:sim_tcr wrote:How do I modify permissions of www-data? I am posting output of id www-data below. Does it look good?
pi@raspiabita ~/Desktop $ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)
pi@raspiabita ~/Desktop $
Code: Select all
sudo /etc/sudoers.d
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
Re: Determine information about Pi?
Still same issue,
I have updated my firmware to latest now,
pi@raspiabita:~$ 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 have updated my firmware to latest now,
pi@raspiabita:~$ 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)
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)
Re: Determine information about Pi?
I fixed this issue bysim_tcr wrote:Still same issue,
I have updated my firmware to latest now,
pi@raspiabita:~$ 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
Code: Select all
usermod -a -G video www-data
Code: Select all
pi@raspberrypi:~$ ls -l /dev/vchiq
crw-rw---T 1 root video 252, 0 Jan 1 1970 /dev/vchiq
pi@raspberrypi:~$ 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)
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)
Re: Determine information about Pi?
In your site http://tafb.yi.org you displays Current CPU total load: in percentage. What is the command to display that?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 technologyYou 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.
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)
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)
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
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 Linuxsim_tcr wrote:In your site http://tafb.yi.org you displays Current CPU total load: in percentage. What is the command to display that?

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
Code: Select all
sudo apt-get install 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
Re: Determine information about Pi?
Did not work,toysareforboys wrote:That required a command line calculator called "bc". To install it:Code: Select all
ps -e -o pcpu | tail -n +2 | sed \'{:q;N;s/\n/ + /g;t q}\' | bc
.Code: Select all
sudo apt-get install bc
Code: Select all
pi@raspisimon ~ $ 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
pi@raspisimon ~ $
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)
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)
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
Ahhhh. my bad. That's for a PHP script so it has some extra \'s in there. This one should work:sim_tcr wrote:Did not work,
Code: Select all
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
Re: Determine information about Pi?
That worked. My php code is,toysareforboys wrote:Code: Select all
ps -e -o pcpu | tail -n +2 | sed '{:q;N;s/\n/ + /g;t q}' | bc
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');
?>
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)
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)
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
Try:sim_tcr wrote:it displays just the number. Like '1.2' . I want to make it appear '1.2 %'. Any thoughts?
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') . " %";
?>

-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
- toysareforboys
- Posts: 136
- Joined: Thu Dec 06, 2012 11:01 pm
Re: Determine information about Pi?
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
-Jamie M.
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') . "%";
?>
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