Results 1 to 10 of 17
-
18th Jun 2011, 11:24 AM #1OPMember
Output of "watch" -> PHP
Hi,
I'm looking for a way to display the output of watch -n 2 "free -m" to a webpage (or similar commands).
Any ideas?
CheersAndroidApps Reviewed by AndroidApps on . Output of "watch" -> PHP Hi, I'm looking for a way to display the output of watch -n 2 "free -m" to a webpage (or similar commands). Any ideas? Cheers =) Rating: 5
-
18th Jun 2011, 01:32 PM #2
-
18th Jun 2011, 04:34 PM #3OPMember
Cheers, Look interesting!
I just figured I would do it look this:
watch -n 2 "ps aux | grep apache | wc -l > apache.txt"
Stay tuned
-
18th Jun 2011, 05:46 PM #4OPMember
Ok, now I have this:
Code:<?php $cmd = "ps aux | grep apache | wc -l"; $output = system($cmd); printf("Apache: $output\n"); echo "<br \>"; function get_memory() { foreach(file('/proc/meminfo') as $ri) $m[strtok($ri, ':')] = strtok(''); return 100 - round(($m['MemFree'] + $m['Buffers'] + $m['Cached']) / $m['MemTotal'] * 100); } echo get_memory(); ?>
Code:90 Apache: 90 67
* remove the first '90'?
* make the 2nd '90' green untill '95' and red at or above '110'?
(Switch colors @ certain #)
Thanks for the help, I'm just a learner
-
18th Jun 2011, 05:57 PM #5BannedWebsite's:
filester.ws Visionize.infoPHP Code:<?php
$cmd = "ps aux | grep apache | wc -l";
$output = exec($cmd);
//Parse output
if ($output > 10)
{
$output = "Green time!";
}
printf("Apache: $output\n");
echo "<br \>";
function get_memory() {
foreach(file('/proc/meminfo') as $ri)
$m[strtok($ri, ':')] = strtok('');
return 100 - round(($m['MemFree'] + $m['Buffers'] + $m['Cached']) / $m['MemTotal'] * 100);
}
?>
PHP Code:$output = "<font color=green>" . $output . "</font>";
-
19th Jun 2011, 09:18 AM #6OPMember
Awesome!
Made some modifications.
This script now turns the text red if there are more than 80 apache users or green if there are less.
Stay tuned for more
PHP Code:<?php
$cmd = "ps aux | grep apache | wc -l";
$output = exec($cmd);
//Parse output
if ($output > 80)
{
$output = "<font color=red>". $output . "</font> apache users";
printf("Apache: $output\n");
echo "<br \>";
}
elseif ($output < 79)
{
$output = "<font color=green>". $output . "</font> apache users";
printf("Apache: $output\n");
echo "<br \>";
}
function get_memory() {
foreach(file('/proc/meminfo') as $ri)
$m[strtok($ri, ':')] = strtok('');
return 100 - round(($m['MemFree'] + $m['Buffers'] + $m['Cached']) / $m['MemTotal'] * 100);
}
?>
-
19th Jun 2011, 09:37 AM #7BannedWebsite's:
filester.ws Visionize.infoFyi, system was outputting an extra 90 before Apache: 90, thats why i changed it to exec instead.
If you're interested, learn to use shorthand if's, makes your code look neater and shorter, although it is harder to read
-
19th Jun 2011, 09:42 AM #8Member
You can enable stats page (and advanced) from httpd.cnf
-
19th Jun 2011, 09:43 AM #9OPMember
Ah ok, I did not know exec could do the same as system
I'll google shorthand if's, never heard of it
-
19th Jun 2011, 09:43 AM #10
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
"Alpha Kenny Body" A tongue tricker! Must Watch XD
By MoWarez in forum General DiscussionReplies: 5Last Post: 2nd Nov 2011, 06:45 PM -
"reply" to "create" and vice versa is post update?
By Gene_Autry in forum Technical Help Desk SupportReplies: 0Last Post: 16th Sep 2011, 04:37 PM -
How can I make my Back-up website "Immediately" to replace my "Original Site"??
By fuchen in forum Webmaster DiscussionReplies: 11Last Post: 13th Aug 2011, 04:14 PM -
Finally "Avatar" Breaks "Titanic" All Time Worldwide
By Last Word in forum General DiscussionReplies: 36Last Post: 5th Aug 2011, 08:06 AM -
Filesonic "counted downloads" or "Premium sales count" now?
By kariofilis in forum File Host DiscussionReplies: 15Last Post: 18th Jan 2011, 03:18 AM
themaCreator - create posts from...
Version 3.57 released. Open older version (or...