Show uptime after logging in
authorJamie Cameron <jcameron@webmin.com>
Wed, 5 Mar 2008 18:41:14 +0000 (18:41 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 5 Mar 2008 18:41:14 +0000 (18:41 +0000)
blue-theme/CHANGELOG
blue-theme/lang/en
blue-theme/right.cgi

index ff4c427..cbd7480 100644 (file)
@@ -16,3 +16,5 @@ Added a whole new set of icons from Virtualmin.
 ---- Changes since 1.340 ----
 Fixed bad table indentation on some browsers.
 Changed link colors to be darker.
+---- Changes since 1.400 ----
+Display system uptime in the right frame after logging in.
index 61142de..4877b96 100644 (file)
@@ -25,6 +25,8 @@ right_out=$1&nbsp;of&nbsp;$2
 right_quota=Disk usage and quota
 right_header5=Account Information
 right_uquota=Disk quota and usage
-right_time=Time on server
-
-
+right_time=Time on system
+right_uptime=System uptime
+right_updays=$1 days, $2 hours, $3 minutes
+right_uphours=$1 hours, $2 minutes
+right_upmins=$1 minutes
index 7cd0150..86e6e47 100755 (executable)
@@ -51,6 +51,24 @@ if ($level == 0) {
        print "<tr> <td><b>$text{'right_time'}</b></td>\n";
        print "<td>$tm</td> </tr>\n";
 
+       # System uptime
+       $out = &backquote_command("uptime");
+       $uptime = undef;
+       if ($out =~ /up\s+(\d+)\s+days,\s+(\d+):(\d+)/) {
+               # up 198 days,  2:06
+               $uptime = &text('right_updays', int($1), int($2), int($3));
+               }
+       elsif ($out =~ /up\s+(\d+):(\d+)/) {
+               $uptime = &text('right_uphours', int($1), int($2));
+               }
+       elsif ($out =~ /up\s+(\d+)\s+mins/) {
+               $uptime = &text('right_upmins', int($1));
+               }
+       if ($uptime) {
+               print "<tr> <td><b>$text{'right_uptime'}</b></td>\n";
+               print "<td>$uptime</td> </tr>\n";
+               }
+
        # Load and memory info
        if (&foreign_check("proc")) {
                &foreign_require("proc", "proc-lib.pl");