Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83f51fb
commit 9e700a9
Showing
36 changed files
with
67 additions
and
66 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This app is designed to run on iPhone (but you can also load it in any modern browser). | ||
|
||
It display live application performance data. The simplest way to load the application is running: | ||
|
||
ab -k -c 100 -n 1000000 http://localhost:9000/load |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package models; | ||
|
||
import com.sun.management.OperatingSystemMXBean; | ||
import java.lang.management.*; | ||
|
||
public class CPU { | ||
|
||
private int availableProcessors = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors(); | ||
|
||
private long lastSystemTime = 0; | ||
private long lastProcessCpuTime = 0; | ||
|
||
public synchronized double getCpuUsage() { | ||
if(lastSystemTime == 0) { | ||
baselineCounters(); | ||
return 0; | ||
} | ||
|
||
long systemTime = System.nanoTime(); | ||
long processCpuTime = 0; | ||
|
||
if(ManagementFactory.getOperatingSystemMXBean() instanceof OperatingSystemMXBean) { | ||
processCpuTime = ((OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean()).getProcessCpuTime(); | ||
} | ||
|
||
double cpuUsage = (double) (processCpuTime - lastProcessCpuTime) / (systemTime - lastSystemTime); | ||
|
||
lastSystemTime = systemTime; | ||
lastProcessCpuTime = processCpuTime; | ||
|
||
return cpuUsage / availableProcessors; | ||
} | ||
|
||
private void baselineCounters() { | ||
lastSystemTime = System.nanoTime(); | ||
|
||
if (ManagementFactory.getOperatingSystemMXBean() instanceof OperatingSystemMXBean) { | ||
lastProcessCpuTime = ( (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean() ).getProcessCpuTime(); | ||
} | ||
} | ||
|
||
} |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...es/scala/rps/app/views/monitor.scala.html → ...e-monitoring/app/views/monitor.scala.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
@(totalMemory: Long) | ||
|
||
@main("RPS") { | ||
<script type="text/javascript"> | ||
window.App = { }; | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Comment to get more information during initialization | ||
logLevel := Level.Warn | ||
|
||
// The Typesafe repository contains all required dependencies | ||
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" | ||
|
||
// Use the Play sbt plugin for Play projects | ||
addSbtPlugin("play" % "sbt-plugin" % Option(System.getProperty("play.version")).getOrElse("2.0")) |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.