Mantis - Resin
Viewing Issue Advanced Details
3706 trivial always 10-08-09 13:39 01-20-11 17:28
stbu  
ferg  
normal  
closed 3.1.9  
fixed  
none    
none 4.0.15  
0003706: Resin Administration (php) shows increasing uptime for already stopped web-apps
The PHP Resin Administration (/resin-admin) shows the uptime for all Web-Apps in tab 'Summary' and 'WebApp', but the uptime is continuously increasing even if the web-app has been stopped after it was once in state 'active'.

For the uptime calculation, the PHP code is using '$webapp->StartTime' which returns the time of the ***last start** accordingly to the JavaDoc comment of DeployControllerMXBean.java independent from current lifecycle state.

  @Description("The current time of the last start")
  public Date getStartTime();


Therefore the uptime calculation is not correct in my opinion.

I have changed the following two .php files in Resin 3.1/php/admin code and afterwards the uptime is only displayed for active web-apps.
$ svn diff php/admin/webapp.php
Index: php/admin/webapp.php
===================================================================
--- php/admin/webapp.php (revision 5604)
+++ php/admin/webapp.php (working copy)
@@ -92,7 +92,12 @@
 function display_webapp($mbean_server, $webapp)
 {
   $session = $webapp->SessionManager;
-
+ $activeStartTime = $webapp->StartTime;
+ if ($webapp->State != 'active')
+ {
+ $activeStartTime = null;
+ }
+
   echo <<<END
 <h2>WebApp</h2>

@@ -121,8 +126,8 @@
 echo " </td>\n";
 echo " <td>" . $webapp->RequestCount . "</td>\n";
 echo " <td>" . $session->SessionActiveCount . "</td>\n";
-echo " <td class='" . format_ago_class($webapp->StartTime) . "'>\n";
-echo " " . format_ago($webapp->StartTime) . "\n";
+echo " <td class='" . format_ago_class($activeStartTime) . "'>\n";
+echo " " . format_ago($activeStartTime) . "\n";
 echo " </td>\n";

         format_ago_td_pair($webapp->Status500CountTotal,
@@ -207,6 +212,12 @@
 foreach ($webapps as $webapp) {

   $session = $webapp->SessionManager;
+ $activeStartTime = $webapp->StartTime;
+ if ($webapp->State != 'active')
+ {
+ $activeStartTime = null;
+ }
+
 ?>

   <tr class='<?= row_style($count++) ?>'>
@@ -216,15 +227,15 @@
 $object_name = $webapp->mbean_name;

 echo "<a href='webapp.php?id=" . $object_name . "'>" . $context_path . "</a>";
-?>
+?>
     </td>
     <td class='<?= format_state_class($webapp->State) ?>'>
        <?= $webapp->State ?>
     </td>
     <td><?= $webapp->RequestCount ?></td>
     <td><?= $session->SessionActiveCount ?></td>
- <td class='<?= format_ago_class($webapp->StartTime) ?>'>
- <?= format_ago($webapp->StartTime) ?>
+ <td class='<?= format_ago_class($activeStartTime)?>'>
+ <?= format_ago($activeStartTime) ?>
     </td>
     <?php
         format_ago_td_pair($webapp->Status500CountTotal,




$ svn diff php/admin/status.php
Index: php/admin/status.php
===================================================================
--- php/admin/status.php (revision 5604)
+++ php/admin/status.php (working copy)
@@ -500,6 +500,11 @@
 $count = 0;
 foreach ($webapps as $webapp) {
   $session = $webapp->SessionManager;
+ $activeStartTime = $webapp->StartTime;
+ if ($webapp->State != 'active')
+ {
+ $activeStartTime = null;
+ }
 ?>

   <tr class='<?= row_style($count++) ?>'>
@@ -511,8 +516,8 @@
     </td>
     <td><?= $webapp->RequestCount ?></td>
     <td><?= $session->SessionActiveCount ?></td>
- <td class='<?= format_ago_class($webapp->StartTime) ?>'>
- <?= format_ago($webapp->StartTime) ?>
+ <td class='<?= format_ago_class($activeStartTime) ?>'>
+ <?= format_ago($activeStartTime) ?>
     </td>
     <?php
         format_ago_td_pair($webapp->Status500CountTotal,

Notes
(0004262)
ferg   
10-13-09 12:13   
We could also add a StateChangeTime and count the time since the last state change.
(0004263)
stbu   
10-13-09 13:22   
Scott, that's a good idea.
Today I've seen that the status of one of my web-apps is changed to 'active-modified' until a new request has changed it again. The StateChangeTime sounds to fulfil a lot of interests.