Announcement

Collapse
No announcement yet.

uptime and load average

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

  • uptime and load average

    Would like to put those informations on my index.php
    any ideas ?

  • #2
    You could use exec(), system(), or passthru() then run the shell command 'uptime'.

    Comment


    • #3
      Thank you, I'll try when I'll come home

      Comment


      • #4
        At the bottom of index.php before the closing ?>

        Add:
        PHP Code:
        $uptime=passthru("uptime"); 

        And now edit your forumhome template, and add the var, $uptime, to where ever you want the information to show up....

        Comment


        • #5
          Originally posted by The Prohacker
          At the bottom of index.php before the closing ?>

          Add:
          PHP Code:
          $uptime=passthru("uptime"); 

          And now edit your forumhome template, and add the var, $uptime, to where ever you want the information to show up....
          I tried this but the display comes up blank where I insert $uptime in the forumhome template. Any other ideas? I saw something about running uptime from the shell command line (I'm a novice at this) a few posts up. Do I also have to do tht?
          Last edited by Marc Smith; Sat 22 Sep '01, 6:09pm.

          Comment


          • #6
            did work for me either. even tried changing the passthru to include the exact path to uptime.

            Comment


            • #7
              Try placing this in your index.php file

              PHP Code:
              $uptime=exec('uptime'); 

              Then place $uptime in your forumhome template
              Real Web Host

              Comment


              • #8
                Changing it from:
                PHP Code:
                $uptime=passthru("uptime"); 
                to
                PHP Code:
                $uptime=exec('uptime'); 
                Didn't do it for me. Neither did:
                PHP Code:
                $uptime=exec("uptime"); 
                Thanks for the suggestion, however. Have you gotten it to work? I'm on a virtual server running FreeBSD / Apache.
                Last edited by Marc Smith; Tue 16 Oct '01, 4:19pm.

                Comment


                • #9
                  well i still have this code but don't use it
                  PHP Code:
                  <?php
                  $uptime 
                  = `uptime`;
                  $uptime eregi_replace("(.*up |, .[0-9] user.*)"""$uptime);
                  echo 
                  '<FONT FACE="Verdana, Arial" SIZE="1">Server uptime: '$uptime '.</font>';
                  ?>
                  you can place it in a file like uptime.php and include it into the page
                  :: Always Back Up Forum Database + Attachments BEFORE upgrading !
                  :: Nginx SPDY SSL - World Flags Demo [video results]
                  :: vBulletin hacked forums: Clean Up Guide for VPS/Dedicated hosting users [ vbulletin.com blog summary ]

                  Comment


                  • #10
                    Thanks for the idea. I may try that later. It's not really a big deal - mostly for my own curiosity.

                    Comment


                    • #11
                      Look Here

                      At the bottom
                      I used this for the middle one number 2 that you see there

                      PHP Code:
                      $uptime=exec('uptime'); 
                      then I put this in the template

                      PHP Code:
                      <tr>
                      <
                      smallfont><nobr><b>Server 1</b$ubuptime</smallfont><br>    
                      <
                      smallfont><nobr><b>Server 2</b$uptime</smallfont><br>        
                      <
                      smallfont><nobr><b>Server 3</b$uauptime</smallfont>
                      </
                      tr>
                          </
                      table

                      I used other coding for the other 2 because I am tracking some other servers also for someone else.
                      Real Web Host

                      Comment


                      • #12
                        or you could fread() /proc/uptime & /proc/loadavg.. just parse the first value in /proc/uptime.. it's how many seconds since the computer booted
                        My open eyes see everything, and you see nothing. . .
                        That forum

                        Comment


                        • #13
                          Or, this may work:
                          $uptime = `uptime`;
                          Then put $uptime in the template.

                          Comment


                          • #14
                            Cool

                            Works with WinXP using MS uptime.exe proggy. Added after the copyright in the template.

                            \\WEBSERVER has been up for: 24 day(s), 23 hour(s), 25 minute(s), 18 second(s)

                            Comment

                            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                            Working...
                            X