Commit a85f0bfe by Johannes Edmeier

Make loading of System Load in Details optional

The system.load.average.1m metric is not available on all platforms. Therefore we ignore errors from fetching it. closes #697
parent 306f0326
......@@ -8651,9 +8651,9 @@
"dev": true
},
"popper.js": {
"version": "1.14.2",
"resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.2.tgz",
"integrity": "sha1-Bm6OFhPmXmm6BQ9LeOe9TI1U5EM="
"version": "1.14.3",
"resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.3.tgz",
"integrity": "sha1-FDj5jQRqz3tNeM1QK/QYrGTU8JU="
},
"posix-character-classes": {
"version": "0.1.1",
......@@ -13607,9 +13607,9 @@
"integrity": "sha512-/ffmsiVuPC8PsWcFkZngdpas19ABm5mh2wA7iDqcltyCTwlgZjHGeJYOXkBMo422iPwIcviOtrTCUpSfXmToLQ=="
},
"vue-clickaway": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/vue-clickaway/-/vue-clickaway-2.1.0.tgz",
"integrity": "sha1-OS3nZHUfMc0geH6Ps6bjGYJfjU8=",
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/vue-clickaway/-/vue-clickaway-2.2.2.tgz",
"integrity": "sha512-25SpjXKetL06GLYoLoC8pqAV6Cur9cQ//2g35GRFBV4FgoljbZZjTINR8g2NuVXXDMLSUXaKx5dutgO4PaDE7A==",
"requires": {
"loose-envify": "1.3.1"
}
......@@ -13635,9 +13635,9 @@
"dev": true
},
"vue-jest": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/vue-jest/-/vue-jest-2.3.0.tgz",
"integrity": "sha512-c/ZxWSBA30AXfheSCe9YoFXsVQQh3mv99+GOTuG3hQf1CDuFU9y936EeNs/xM/bgaUvhyfzAb2TVMlmYGG3P3Q==",
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/vue-jest/-/vue-jest-2.4.1.tgz",
"integrity": "sha512-LpiUwga4xmzmpUY73gMnujryZvXJ9a273LWG4Kuz9Rw47Vnav86Fe/+h8tAOR4w/zRb5JBy5WgisoCIPTUzQew==",
"dev": true,
"requires": {
"babel-plugin-transform-es2015-modules-commonjs": "6.26.0",
......
......@@ -29,12 +29,12 @@
"lodash": "^4.17.5",
"moment": "^2.22.0",
"moment-shortformat": "^2.1.0",
"popper.js": "^1.14.2",
"popper.js": "^1.14.3",
"pretty-bytes": "^4.0.2",
"resize-observer-polyfill": "^1.5.0",
"rxjs": "^5.5.8",
"vue": "^2.5.16",
"vue-clickaway": "^2.1.0",
"vue-clickaway": "^2.2.2",
"vue-router": "^3.0.1",
"yamljs": "^0.3.0"
},
......@@ -72,7 +72,7 @@
"sass-loader": "^6.0.7",
"style-loader": "^0.20.3",
"url-loader": "^0.6.2",
"vue-jest": "^2.3.0",
"vue-jest": "^2.4.1",
"vue-loader": "^14.2.2",
"vue-svg-loader": "^0.5.0",
"vue-template-compiler": "^2.5.16",
......
......@@ -33,24 +33,24 @@
<p v-text="pid"/>
</div>
</div>
<div class="level-item has-text-centered" v-if="metrics['process.uptime']">
<div class="level-item has-text-centered" v-if="uptime">
<div>
<p class="heading">Uptime</p>
<p>
<process-uptime :value="metrics['process.uptime']"/>
<process-uptime :value="uptime"/>
</p>
</div>
</div>
<div class="level-item has-text-centered" v-if="metrics['system.cpu.count']">
<div class="level-item has-text-centered" v-if="cpuCount">
<div>
<p class="heading">CPUs</p>
<p v-text="metrics['system.cpu.count']"/>
<p v-text="cpuCount"/>
</div>
</div>
<div class="level-item has-text-centered" v-if="metrics['system.load.average.1m']">
<div class="level-item has-text-centered" v-if="systemLoad">
<div>
<p class="heading">System Load (last 1m)</p>
<p v-text="metrics['system.load.average.1m'].toFixed(2)"/>
<p v-text="systemLoad.toFixed(2)"/>
</div>
</div>
</div>
......@@ -60,7 +60,6 @@
<script>
import Instance from '@/services/instance';
import _ from 'lodash'
import processUptime from './process-uptime';
export default {
......@@ -75,43 +74,55 @@
hasLoaded: false,
error: null,
pid: null,
metrics: {
'process.uptime': null,
'system.load.average.1m': null,
'system.cpu.count': null,
}
uptime: null,
systemLoad: null,
cpuCount: null
}),
created() {
this.fetchMetrics();
this.fetchUptime();
this.fetchCpuCount();
this.fetchSystemLoad();
this.fetchPid();
},
methods: {
async fetchMetrics() {
if (this.instance) {
const vm = this;
vm.error = null;
try {
await Promise.all(_.entries(vm.metrics)
.map(async ([name]) => {
const response = await vm.instance.fetchMetric(name);
vm.metrics[name] = response.data.measurements[0].value;
}
));
} catch (error) {
console.warn('Fetching process metrics failed:', error);
this.error = error;
}
this.hasLoaded = true;
async fetchUptime() {
try {
this.uptime = await this.fetchMetric('process.uptime');
} catch (error) {
this.error = error;
console.warn('Fetching Uptime failed:', error);
}
this.hasLoaded = true;
},
async fetchSystemLoad() {
try {
this.systemLoad = await this.fetchMetric('system.load.average.1m');
} catch (error) {
console.warn('Fetching System Load failed:', error);
}
this.hasLoaded = true;
},
async fetchCpuCount() {
try {
this.cpuCount = await this.fetchMetric('system.cpu.count');
} catch (error) {
console.warn('Fetching Cpu Count failed:', error);
}
this.hasLoaded = true;
},
async fetchMetric(name) {
const response = await this.instance.fetchMetric(name);
return response.data.measurements[0].value;
},
async fetchPid() {
if (this.instance && this.instance.hasEndpoint('env')) {
if (this.instance.hasEndpoint('env')) {
try {
const response = await this.instance.fetchEnv('PID');
this.pid = response.data.property.value;
} catch (error) {
console.warn('Fetching PID failed:', error);
}
this.hasLoaded = true;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment