strongloop / strong-supervisor

Application supervisor that automatically adds cluster control and performance monitoring with StrongOps
Other
66 stars 20 forks source link

Emit CPU and memory usage from appmetrics #175

Closed bajtos closed 8 years ago

bajtos commented 8 years ago

Add a new watcher called "appmetrics" that emits the following two events via the IPC channel:

1) cmd: "appmetrics:cpu"
   data: an object with the following properties:
    - time (Number) the milliseconds when the sample was taken.
      This can be converted to a Date using new Date(data.time).
    - process (Number) the percentage of CPU used by the application
      itself. This is a value between 0.0 and 1.0.
    - system (Number) the percentage of CPU used by the system as a whole.
      This is a value between 0.0 and 1.0.

2) cmd: "appmetrics:memory"
   data: an object with the following properties:
    - time (Number) the milliseconds when the sample was taken.
      This can be converted to a Date using new Date(data.time).
    - physical_total (Number) the total amount of RAM available
      on the system in bytes.
    - physical_used (Number) the total amount of RAM in use
      on the system in bytes.
    - physical_free (Number) the total amount of free RAM available
      on the system in bytes.
    - virtual (Number) the memory address space used by the application
      in bytes.
    - private (Number) the amount of memory used by the application
      that cannot be shared with other processes, in bytes.
    - physical (Number) the amount of RAM used by the application in bytes.

Connect to strongloop-internal/scrum-nodeops#1057

@sam-github please review

sam-github commented 8 years ago

I think anything you don't need should be disabled, and lots of things are enabled by default: https://github.com/RuntimeTools/appmetrics#appmetricsenabletype-config

other than that, looks good

tobespc commented 8 years ago

to turn off the MQTT connection, you can modify the appmetrics.properties file and set the com.ibm.diagnostics.healthcenter.mqtt=off

bajtos commented 8 years ago

to turn off the MQTT connection, you can modify the appmetrics.properties file and set the com.ibm.diagnostics.healthcenter.mqtt=off

Thank you @tobespc. I implemented a post-install script to edit that setting in 7c6de0a.

bajtos commented 8 years ago

@sam-github I think this patch is ready for another round of review, PTAL.

bajtos commented 8 years ago

@slnode test please

bajtos commented 8 years ago

@rmg I am confused about the reason why the tests are failing on some platform, could you please help me to investigate?

amazon-5 and ubuntu-5 cannot install appmetrics. I am checking with the appmetrics' team whether 5.x is supported.

However, other platforms are failing because of malformed TAP output, see e.g. http://ci.strongloop.com/job/strong-supervisor/label=amazon-4/1792/console:

org.tap4j.parser.ParserException: Error parsing TAP Stream: Duplicated TAP Plan found.
    at org.tap4j.parser.Tap13Parser.parse(Tap13Parser.java:221)
    at org.tap4j.parser.Tap13Parser.parseFile(Tap13Parser.java:187)
bajtos commented 8 years ago

@slnode test please

sam-github commented 8 years ago

LGTM, other than the stack trace. Please change that, and land.