Activity Stream
48,167 MEMBERS
64375 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1.     
    #1
    Member

    Default 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
    AndroidApps 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

  2.   Sponsored Links

  3.     
    #2
    The Wise One
    Website's:
    twilight.ws ddlrank.com
    You can use system or exec.

    Regards,
    Whoo

  4.     
    #3
    Member
    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

  5.     
    #4
    Member
    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();
    ?>
    Which results in:

    Code: 
    90 Apache: 90 
    67
    How can I:
    * 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

  6.     
    #5
    Banned
    Website's:
    filester.ws Visionize.info
    PHP 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);
    }

    ?>
    Edit: Checked your code, made some modifications for you. You STILL need to edit part of it, esp. the part on the output to make it green, right now as long as it is bigger than 10, it will make it 'green' to make it green you need to output something like
    PHP Code: 
    $output "<font color=green>" $output "</font>"
    Something along those lines. I'm tired. If you still have any problem's ill guide you along tmr

  7.     
    #6
    Member
    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);
    }

    ?>

  8.     
    #7
    Banned
    Website's:
    filester.ws Visionize.info
    Fyi, 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

  9.     
    #8
    Member
    You can enable stats page (and advanced) from httpd.cnf

  10.     
    #9
    Member
    Ah ok, I did not know exec could do the same as system
    I'll google shorthand if's, never heard of it

  11.     
    #10
    Member
    Quote Originally Posted by Gavo View Post
    You can enable stats page (and advanced) from httpd.cnf
    Care to elaborate?

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. "Alpha Kenny Body" A tongue tricker! Must Watch XD
    By MoWarez in forum General Discussion
    Replies: 5
    Last Post: 2nd Nov 2011, 06:45 PM
  2. "reply" to "create" and vice versa is post update?
    By Gene_Autry in forum Technical Help Desk Support
    Replies: 0
    Last Post: 16th Sep 2011, 04:37 PM
  3. Replies: 11
    Last Post: 13th Aug 2011, 04:14 PM
  4. Finally "Avatar" Breaks "Titanic" All Time Worldwide
    By Last Word in forum General Discussion
    Replies: 36
    Last Post: 5th Aug 2011, 08:06 AM
  5. Filesonic "counted downloads" or "Premium sales count" now?
    By kariofilis in forum File Host Discussion
    Replies: 15
    Last Post: 18th Jan 2011, 03:18 AM

Tags for this Thread

BE SOCIAL