Jump to content

aplication - logging server uptime?


final60

Recommended Posts

Hey guys

Id like to be able to track the uptime of a server, the main features i'd like are:

 

Primarily to track in real time the last time server was reset and how long the server has been up since last reset!

 

It might appear like this:

 

Last Reset: 12th Dec 2008 at 23h:11m:24s

Uptime: 00:00:04h:14m:11s

 

Additionally i'd also like to log when the server is restarted in a basic text file if possible.

 

The server IP is :

 

ari1.ryzom.com

 

 

If anyone can suggest where to start I'd greatly appreciate.

Link to comment
Share on other sites

<?php
  $data = shell_exec('uptime');
  $uptime = explode(' up ', $data);
  $uptime = explode(',', $uptime[1]);
  $uptime = $uptime[0].', '.$uptime[1];

  echo 'Uptime: '.$uptime;
?>

 

Not sure if this works on windows, but yea. To get the last reset time you just take the uptime convert it to seconds and subtract it from the current timestamp.

Link to comment
Share on other sites

<?php
  $data = shell_exec('uptime');
  $uptime = explode(' up ', $data);
  $uptime = explode(',', $uptime[1]);
  $uptime = $uptime[0].', '.$uptime[1];

  echo 'Uptime: '.$uptime;
?>

 

Not sure if this works on windows, but yea. To get the last reset time you just take the uptime convert it to seconds and subtract it from the current timestamp.

 

Thanks alot for your suggestions. Im very  much a php nublet. How do I apply the above markup to the server ip address: ari1.ryzom.com?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.