pepebe
7/1/2013 - 5:08 PM

Simple snippet to output uptime information (only on linux systems)

Simple snippet to output uptime information (only on linux systems)

<?php
/*
  Simple snippet to output uptime information (only on linux systems)
  Author: info@pepebe.de

  Snippet call:
  [[!uptime]]
*/

ob_start(); /* Prevent direct output of system function */
$input  = system('uptime', $input);
ob_clean();

$input  = explode("," , $input );
$time   = explode("up" , $input[0]);
$hm     = explode(":" , $input[1] );

$output['systemTime'] = $time[0];
$output['upTime']   = $time[1] . $hm[0] . " hours " . $hm[1] . " minutes";
$output['users']    = $input[2];
$output['load']     =  $input[3] . " " . $input[4] . " " . $input[5];

$upTime = "<pre>" . print_r($output,true) . "</pre>";

return $upTime;