Announcement

Collapse
No announcement yet.

Monitor your server from PHP

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Monitor your server from PHP

    A little script to get the HDD activity and memory / cpu usage. I used popen but you may use other functions as well.

    Code:
    <?PHP
    echo "<PRE>\n";
    echo "IO STATS\n";
    $handle=popen("/usr/bin/iostat -k sda 1 2","r");
    fread($handle,16000);
    $lines=explode("\n",fread($handle,16000));
    array_shift($lines);
    array_shift($lines);
    array_shift($lines);
    echo implode("\n",$lines);
    pclose($handle);
    
    echo "Top\n";
    $handle=popen("/usr/bin/top -b -n 1","r");
    echo fread($handle,16000);
    pclose($handle);
    echo "</PRE>\n";
    ?>
    - Make Web Games
    - Creator of NWE
    - Owner of Nowhere Else and beyond
    - Mad developer

  • #2
    Re: Monitor your server from PHP

    Only *nix systems apply here though
    Originally posted by Spudinsky
    A little philosophy on this matter:
    My posts are my opinion, whomever disagrees with it is *their* problem not *mine*.

    /* You laugh at me because i'm different. I laugh at you because you're all the same. */

    Comment


    • #3
      Re: Monitor your server from PHP

      Honestly you would run your PHP scripts on a windows server? Would be a non-sense... I would run on a windows server only for ASPX applications (with IIS) but certainly not for a PHP installation. I do use PHP on windows but only for the development

      Why? Well simply check the memory usage of your server with just the OS loaded, and tell me which of a Linux box or a Windows box use less memory, add to that cron and ssh and you know why I use Linux as servers.
      - Make Web Games
      - Creator of NWE
      - Owner of Nowhere Else and beyond
      - Mad developer

      Comment


      • #4
        Re: Monitor your server from PHP

        Nice little tip, thanks for sharing

        Comment


        • #5
          Re: Monitor your server from PHP

          a_bertrand: true enough, but then again there is still people that often use windows hosting instead
          Originally posted by Spudinsky
          A little philosophy on this matter:
          My posts are my opinion, whomever disagrees with it is *their* problem not *mine*.

          /* You laugh at me because i'm different. I laugh at you because you're all the same. */

          Comment


          • #6
            Re: Monitor your server from PHP

            Very nice a_bertrand

            Comment


            • #7
              Re: Monitor your server from PHP

              Originally posted by a_bertrand
              Honestly you would run your PHP scripts on a windows server? Would be a non-sense... I would run on a windows server only for ASPX applications (with IIS) but certainly not for a PHP installation. I do use PHP on windows but only for the development

              Why? Well simply check the memory usage of your server with just the OS loaded, and tell me which of a Linux box or a Windows box use less memory, add to that cron and ssh and you know why I use Linux as servers.
              I'll give you a few reasons:
              1.) GUI
              2.) Compatibility with some nifty backend things you dont / cant get with unix / linux
              3.) Memory is cheap 2gb DDR2 sticks are like $20

              Comment


              • #8
                Re: Monitor your server from PHP

                - Remote GUI is not good due to his slowness, unless you are in the same network.
                - Compatibility with some back-ends, then yes, but I rarely saw a back-end which doesn't offer yet web services.
                - Server memory is never cheap, specially if you need to rent your dedicated server.
                - Make Web Games
                - Creator of NWE
                - Owner of Nowhere Else and beyond
                - Mad developer

                Comment


                • #9
                  Re: Monitor your server from PHP

                  Originally posted by yuriorlov
                  Originally posted by a_bertrand
                  Honestly you would run your PHP scripts on a windows server? Would be a non-sense... I would run on a windows server only for ASPX applications (with IIS) but certainly not for a PHP installation. I do use PHP on windows but only for the development

                  Why? Well simply check the memory usage of your server with just the OS loaded, and tell me which of a Linux box or a Windows box use less memory, add to that cron and ssh and you know why I use Linux as servers.
                  I'll give you a few reasons:
                  1.) GUI
                  2.) Compatibility with some nifty backend things you dont / cant get with unix / linux
                  3.) Memory is cheap 2gb DDR2 sticks are like $20
                  GUI, let's see... windows windows windows... (for Windows) Xwindows, gnome, kde, and that tiny awesome fluxbox, among a few dozen more (for *nix).
                  Backend things you can't do with *nix flavours? name a couple...
                  Memory cheap... well as a_bertrand stated... Server memory is not cheap.
                  Originally posted by Spudinsky
                  A little philosophy on this matter:
                  My posts are my opinion, whomever disagrees with it is *their* problem not *mine*.

                  /* You laugh at me because i'm different. I laugh at you because you're all the same. */

                  Comment

                  Working...
                  X