[Help] Uptime

How do you use the forum? Also Technical News.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Forum rules
This forum is NOT a forum where you post a technical questions about osRose, osiRose or ospRose. Use the dedicated forum for that!

Re: [Help] Uptime

Postby Souleater on Mon Jun 09, 2008 1:31 pm

You might want to check this out : viewtopic.php?f=28&t=910&p=8263&#p8263

But in some cases it can be way too inaccurate ;)
Image
Souleater
Antares
Antares
 
Posts: 355
Joined: Thu Aug 09, 2007 10:59 pm

Re: [Help] Uptime

Postby Rifke on Mon Jun 09, 2008 4:12 pm

Changing Table(s)

You alter the table: channels and add a new field 'uptime' (see SQL)
  1.  
  2. ALTER TABLE `channels` ADD `uptime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
  3.  




Creating PHP file

This will just give a basic idea.
  1.  
  2. <?php
  3. /* only world server. You can delete the part:
  4. * WHERE port >= 29200
  5. * to show everything, (meaning full names are a pre)
  6. *
  7. */
  8. $sql = "SELECT name,TIME_FORMAT(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(uptime),'%T') AS uptime_t FROM channels WHERE port >= 29200";
  9. $qry = mysql_query($sql);
  10. if ( $qry === false ) {
  11.     echo " Sorry but there has been a database issue, due this issue we where not able to retrieve the uptime status.";
  12. } elseif ( mysql_num_rows($qry) == 0 ) {
  13.     echo 'There are no running services.';
  14. } else {
  15.     while ( $arr = mysql_fetch_assoc($qry) ) {
  16.         echo $arr['name']. 'is running for '.$arr['uptime_t']. '<br />';
  17.     }
  18. }
  19. ?>
  20.  
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Previous

Return to Some Help / News

Who is online

Users browsing this forum: No registered users and 4 guests