tarballed
May 3rd, 2004, 17:06
Hello everyone.
Does anyone know where FreeBSD keeps the loadaverage information on the file system?
For example, in Linux (I know this is FreeBSD...this is purely an example) you can:
cat /proc/loadavg
and get a display of the loadaverage.
Now, I'm working with a web application that can take advantage of displaying the servers load average. The problem is, i'm not sure where it is located.
Some where in proc perhaps?
THanks,
Tarballed
elmore
May 3rd, 2004, 17:58
well I guess it really depends on what your looking for specifically. You could always run top which tries to display real time load averages. it uses the getloadavg(3) function and tries to display averages over the past 1, 5, and 15 minutes respectively.
tarballed
May 3rd, 2004, 18:34
Right right...I follow you.
I'm trying to find the location so the web interface can call the loadaverage and display it on the web interface...
It's a little line you edit and point to the location where loadaverage is called...
I was hoping to modify the php file and to get it to display the average correctly...
Tarballed
Strog
May 3rd, 2004, 19:45
I'd probably look at how phpsysinfo is doing it. I'm not sure if you are using php or not but here's a snippet. (http://phpsysinfo.sourceforge.net)
function loadavg ()
{
$s = $this->grab_key('vm.loadavg');
$s = ereg_replace('{ ', '', $s);
$s = ereg_replace(' }', '', $s);
$results = explode(' ', $s);
return $results;
}
socomm
May 3rd, 2004, 19:46
Have you tried uptime? Run uptime and have a script filter out load average.
tarballed
May 3rd, 2004, 20:09
I'd probably look at how phpsysinfo is doing it. I'm not sure if you are using php or not but here's a snippet. (http://phpsysinfo.sourceforge.net)
function loadavg ()
{
$s = $this->grab_key('vm.loadavg');
$s = ereg_replace('{ ', '', $s);
$s = ereg_replace(' }', '', $s);
$results = explode(' ', $s);
return $results;
}
Yep. Running php 4.3.6...Works fine right now.
I kinda like that project. I wonder how hard it would be to integrate it into the server. Corporate love eye candy so that could be another thing to dazzle them with.
socomm...here is the snip from the php code:
// Load average
if(file_exists("/proc/loadavg") && !DISTRIBUTED_SETUP) {
$loadavg = file("/proc/loadavg");
$loadavg = explode(" ", $loadavg[0]);
$la_1m = $loadavg[0];
$la_5m = $loadavg[1];
$la_15m = $loadavg[2];
Really geared towards Linux...
Tarballed
tarballed
May 3rd, 2004, 20:30
phpsysinfo...piece of cake
Now I just need to password protect the web site..
Pretty nice feature to have.
A lot of people here use it?
Tarballed
soup4you2
May 3rd, 2004, 21:29
uptime | awk '{ print $8 $9 $10 }'
or if you use the screen application you can create a ~/.screenrc and place this in it..
caption always "%{Yb} %Y-%02m-%02d %0c %{k}|%{C} %LD %{k}|%{G} %l %{k}|%{W} %-Lw%{+u}%n %t%{-u}%+Lw"
it will display good info on the bottom of the screen :)