Skip to content

Commit

Permalink
Add totals for running instances only (the existing totals row includ…
Browse files Browse the repository at this point in the history
…es statistics for app instances that are not running)
  • Loading branch information
macmarco committed Apr 17, 2014
1 parent b817afd commit e688592
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
Expand Up @@ -250,6 +250,19 @@ <h2 class="SectionHeading">
<webobject name = "ConfigureLink"><span>Configure</span></webobject></td>
<td><webobject name = "InstDeleteAllLink"><span>Delete</span></webobject></td>
</tr>

<wo:if condition="$showDetailStatistics">
<tr class="TotalsForRunningInstances">
<td colspan="10" class="label">Running Sessions</td>
<td class="TotalTransactionCount"><webobject name = "TotalTransactionsForActiveInstances"></webobject></td>
<td class="TotalActiveSessions"><webobject name = "ActiveSessionsForActiveInstances"></webobject></td>
<td class="TotalAverageTransaction"></td>
<td class="TotalAverageIdleTime"></td>

<td colspan="2"></td>
</tr>
</wo>

</webobject>
</table>
</div>
Expand Down
Expand Up @@ -282,6 +282,19 @@ TotalTransactions: WOString {
value = totalTransactions;
}

TotalTransactionsForActiveInstances: WOString {
value = totalTransactionsForActiveInstances;
numberformat = "#,##0";
}

ActiveSessionsForActiveInstances: WOString {
value = totalActiveSessionsForActiveInstances;
numberformat = "#,##0";
}




// Start of Add Instance Stuff

AddHostsLink : WOHyperlink {
Expand Down
Expand Up @@ -693,10 +693,20 @@ public Integer totalTransactions() {
return StatsUtilities.totalTransactionsForApplication(myApplication());
}

public Integer totalTransactionsForActiveInstances(){
return StatsUtilities.totalTransactionsForActiveInstancesOfApplication(myApplication());
}


public Integer totalActiveSessions() {
return StatsUtilities.totalActiveSessionsForApplication(myApplication());
}

public Integer totalActiveSessionsForActiveInstances(){
return StatsUtilities.totalActiveSessionsForActiveInstancesOfApplication(myApplication());
}


public Float totalAverageTransaction() {
return StatsUtilities.totalAverageTransactionForApplication(myApplication());
}
Expand Down
6 changes: 6 additions & 0 deletions Applications/JavaMonitor/WebServerResources/javamonitor.css
Expand Up @@ -438,3 +438,9 @@ td.PushButtonWrapper {
text-align: right;
}


div.ApplicationDetailsBox table tr.TotalsForRunningInstances .label
{
font-weight: bold;
text-align: right;
}
Expand Up @@ -42,6 +42,19 @@ static public Integer totalTransactionsForApplication(MApplication anApp) {
}
return Integer.valueOf(aTotalTrans);
}


/**
* Returns the total number of transactions for running instances of the given monitored application
* If the monitored application has no running instances, returns Integer.valueOf(0)
*
* @param monitoredApplication
* @return
*/
public static Integer totalTransactionsForActiveInstancesOfApplication(MApplication monitoredApplication) {
Integer totalTransactions = sumStatisticOfActiveInstances(monitoredApplication, "transactions");
return totalTransactions;
}


static public Integer totalActiveSessionsForApplication(MApplication anApp) {
Expand All @@ -66,6 +79,49 @@ static public Integer totalActiveSessionsForApplication(MApplication anApp) {
return Integer.valueOf(aTotalActiveSessions);
}


/**
* Returns the total number of active sessions for running instances of the given monitored application
* If the monitored application has no running instances, returns Integer.valueOf(0)
*
* @param monitoredApplication
* @return
*/
public static Integer totalActiveSessionsForActiveInstancesOfApplication(MApplication monitoredApplication) {
Integer totalActiveSessions = sumStatisticOfActiveInstances(monitoredApplication, "activeSessions");
return totalActiveSessions;
}


/**
* Calculates and returns the sum of the statistic indicated by the given statisticsKey for
* the running instances of the given monitored application.
*
* @param monitoredApplication
* @param statisticsKey
* @return
*/
protected static Integer sumStatisticOfActiveInstances(MApplication monitoredApplication, String statisticsKey){
int sum = 0;
NSArray<MInstance> instances = monitoredApplication.instanceArray();
for (MInstance anInstance : instances) {
if (anInstance.isRunning_M()){
NSDictionary statistics = anInstance.statistics();
if (statistics != null) {
try {
String aValue = (String) statistics.valueForKey(statisticsKey);
sum = sum + Integer.parseInt(aValue);
} catch (Throwable ex) {
// do nothing
}
}
}
}
Integer sumAsInteger = Integer.valueOf(sum);
return sumAsInteger;
}



static public Float totalAverageTransactionForApplication(MApplication anApp) {
NSArray anInstArray = anApp.instanceArray();
Expand Down

0 comments on commit e688592

Please sign in to comment.