Skip to content

Commit 5da561d

Browse files
committed
Add current time to the docker metrics and save the current time into it
1 parent fdfeb7e commit 5da561d

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

chronos_npm_package/controllers/dockerHelper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ async function readDockerContainer(input) {
4646
out.networksent = data[0].netIO.wx;
4747
out.processcount = data[0].pids;
4848
out.restartcount = data[0].restartCount;
49+
out.time = Date.now();
4950
return out;
5051

5152
} catch (e) {

chronos_npm_package/controllers/mongo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ mongo.health = ({ microservice, interval }) => {
127127
* Collects information on the docker container
128128
*/
129129
mongo.docker = ({ microservice, interval }) => {
130+
// Create collection using name of microservice
131+
const containerInfo = ContainerInfoFunc(`${microservice}-containerinfo`);
130132
dockerHelper.getDockerContainer(microservice)
131133
.then((containerData) => {
132134
setInterval(() => {
133135
dockerHelper.readDockerContainer(containerData)
134136
.then((data) => {
135-
// Create collection using name of microservice
136-
const containerInfo = ContainerInfoFunc(`${microservice}-containerinfo`);
137137
return containerInfo.create(data);
138138
})
139139
.then((_) => console.log(`Docker data recorded in MongoDB collection ${microservice}-containerinfo`))

chronos_npm_package/models/ContainerInfo.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ const ContainerSchema = new Schema({
4242
restartcount: {
4343
type: Number, // count
4444
},
45+
time: {
46+
type: Date,
47+
default: Date.now(),
48+
}
4549
});
4650

4751
module.exports = ContainerName => mongoose.model(ContainerName, ContainerSchema);

0 commit comments

Comments
 (0)