Mercurial > hg > thermostat-ng > web-client
changeset 219:baa2100c95bb
Add jvm-cpu as a mock endpoint
Reviewed-by: aazores
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/025133.html
author | Christopher Koehler <chkoehle@redhat.com> |
---|---|
date | Wed, 20 Sep 2017 13:29:27 -0400 |
parents | de738e948f0a |
children | b686b8d24638 |
files | mock-api/endpoints/jvm-cpu.endpoint.js |
diffstat | 1 files changed, 44 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mock-api/endpoints/jvm-cpu.endpoint.js Wed Sep 20 13:29:27 2017 -0400 @@ -0,0 +1,44 @@ +function jvmCpu (server) { + var _ = require('lodash'); + server.init('jvmCpu'); + + server.app.get('/jvm-cpu/0.0.1/jvms/:jvmId', function (req, res) { + server.logRequest('jvm-cpu', req); + res.setHeader('Content-Type', 'application/json'); + res.send(JSON.stringify( + { + response: [ + { + agentId: 'foo-agentId', + jvmId: req.params.jvmId, + timeStamp: { $numberLong: Date.now().toString() }, + programTicks: { $numberLong: _.floor(Math.random() * 1000000).toString() }, + cpuLoad: Math.random() + } + ] + } + )); + }); + + server.app.get('/jvm-cpu/0.0.1/systems/:systemId/jvms/:jvmId', function (req, res) { + server.logRequest('jvm-cpu', req); + + res.setHeader('Content-Type', 'application/json'); + res.send(JSON.stringify( + { + response: [ + { + agentId: 'foo-agentId', + systemId: req.params.systemId, + jvmId: req.params.jvmId, + timeStamp: { $numberLong: Date.now().toString() }, + programTicks: { $numberLong: _.floor((Math.random() * 10000000)).toString() }, + cpuLoad: Math.random() + } + ] + } + )); + }); +} + +module.exports = jvmCpu;