Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2005
    Location
    South Wales!
    Posts
    3,535
    Tokens
    2,371

    Latest Awards:

    Default Need some simple PHP help please

    Well ive got this script for displaying server status, however I need the info to a line down not one after another.

    Heres the script:

    PHP Code:
    <?php
        
    # status.php -- very simple server status monitor
        # Get and display load average times 3
        
    $load sys_getloadavg();
        echo 
    "Load Average: $load[0]\n";
        echo 
    "Load Average2: $load[1]\n";
        echo 
    "Load Average3: $load[2]\n";

        
    # Get and display disk usage percentages
        
    $df = `/bin/df`;
        foreach( 
    split"\n"$df ) as $line )
        {
            if( 
    preg_match"/(\d+%)\s+(\S+)$/"$line$matches ) )
            {
                
    $fs $matches];
                
    $usage $matches];
                echo 
    "Disk Usage_$fs$usage\n";
            }
        }
        
    # Count running processes
        
    $procs = `/bin/ps -e|wc -l`;
        echo 
    "Running Processes: $procs\n";
    ?>
    I need it so the

    echo "Load Average: $load[0]\n";
    echo "Load Average2: $load[1]\n";
    echo "Load Average3: $load[2]\n";

    Show below eachother like

    Load Average: 10.34
    Load Average2: 13.51
    Load Average3: 15.78

    Not like below as thats what it comes up as now. Same for the disk useage too. This cant be hard can it? I think im just missing something very simple

    Load Average: 10.34 Load Average2: 13.51 Load Average3: 15.78


    Thread moved from 'Designing & Development' by Yoshimitsui (Forum Super Moderator): Please post in the correct sub-section.
    Last edited by Yoshimitsui; 28-02-2009 at 06:22 PM.

  2. #2
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    could you not do something like this?

    <?php
    # status.php -- very simple server status monitor
    # Get and display load average times 3
    $load = sys_getloadavg();
    echo
    "Load Average: $load[0]\n";
    echo
    "Load Average2: $load[1]\n";
    echo
    "Load Average3: $load[2]\n";

    # Get and display disk usage percentages
    $df = `/bin/df`;
    foreach(
    split( "\n", $df ) as $line )
    {
    if(
    preg_match( "/(\d+%)\s+(\S+)$/", $line, $matches ) )
    {
    $fs = $matches[ 2 ];
    $usage = $matches[ 1 ];
    echo
    "Disk Usage_$fs: $usage\n";
    }
    }
    # Count running processes
    $procs = `/bin/ps -e|wc -l`;
    echo
    "Running Processes: $procs<br>";
    ?>

  3. #3
    Join Date
    Apr 2005
    Location
    South Wales!
    Posts
    3,535
    Tokens
    2,371

    Latest Awards:

    Default

    EDIT: nevermind, fixed ti thanks

  4. #4
    Join Date
    Feb 2009
    Location
    London
    Posts
    935
    Tokens
    100
    Habbo
    Sameer!

    Latest Awards:

    Default

    I was just to reply on how to fix it lol. Good job!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •