mirror of https://github.com/Lissy93/dashy.git
✨ Adds current memory history widget
This commit is contained in:
parent
4e64ccff3b
commit
e3b3f3c5a8
|
@ -47,6 +47,7 @@ Dashy has support for displaying dynamic content in the form of widgets. There a
|
||||||
- [CPU Usage Per Core](#cpu-usage-per-core)
|
- [CPU Usage Per Core](#cpu-usage-per-core)
|
||||||
- [CPU Usage History](#cpu-usage-history)
|
- [CPU Usage History](#cpu-usage-history)
|
||||||
- [Memory Usage Current](#current-memory-usage)
|
- [Memory Usage Current](#current-memory-usage)
|
||||||
|
- [Memory Usage History](#memory-usage-history)
|
||||||
- [Dynamic Widgets](#dynamic-widgets)
|
- [Dynamic Widgets](#dynamic-widgets)
|
||||||
- [Iframe Widget](#iframe-widget)
|
- [Iframe Widget](#iframe-widget)
|
||||||
- [HTML Embed Widget](#html-embedded-widget)
|
- [HTML Embed Widget](#html-embedded-widget)
|
||||||
|
@ -1257,6 +1258,30 @@ Real-time memory usage gauge, with more info visible on click
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### Memory Usage History
|
||||||
|
|
||||||
|
Recent memory usage chart
|
||||||
|
|
||||||
|
<p align="center"><img width="500" src="https://i.ibb.co/V3wSgW0/gl-mem-history.png" /></p>
|
||||||
|
|
||||||
|
##### Options
|
||||||
|
|
||||||
|
**Field** | **Type** | **Required** | **Description**
|
||||||
|
--- | --- | --- | ---
|
||||||
|
**`limit`** | `number` | _Optional_ | Limit the number of results returned, rendering more data points will take longer to load. Defaults to `100`
|
||||||
|
|
||||||
|
|
||||||
|
##### Example
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- type: gl-mem-history
|
||||||
|
options:
|
||||||
|
hostname: http://localhost:61208
|
||||||
|
limit: 80
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Dynamic Widgets
|
## Dynamic Widgets
|
||||||
|
|
||||||
### Iframe Widget
|
### Iframe Widget
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
<template>
|
||||||
|
<div class="glances-cpu-history-wrapper">
|
||||||
|
<div class="gl-history-chart" :id="chartId"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import WidgetMixin from '@/mixins/WidgetMixin';
|
||||||
|
import ChartingMixin from '@/mixins/ChartingMixin';
|
||||||
|
import { timestampToTime, getTimeAgo } from '@/utils/MiscHelpers';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [WidgetMixin, ChartingMixin],
|
||||||
|
components: {},
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
hostname() {
|
||||||
|
if (!this.options.hostname) this.error('You must specify a \'hostname\' for Glaces');
|
||||||
|
return this.options.hostname;
|
||||||
|
},
|
||||||
|
limit() {
|
||||||
|
return this.options.limit || 100;
|
||||||
|
},
|
||||||
|
endpoint() {
|
||||||
|
return `${this.hostname}/api/3/mem/history/${this.limit}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchData() {
|
||||||
|
this.makeRequest(this.endpoint).then(this.processData);
|
||||||
|
},
|
||||||
|
processData(memData) {
|
||||||
|
const readings = memData.percent;
|
||||||
|
const labels = [];
|
||||||
|
const systemValues = [];
|
||||||
|
readings.forEach((dataPoint) => {
|
||||||
|
labels.push(timestampToTime(dataPoint[0]));
|
||||||
|
systemValues.push(dataPoint[1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
const chartTitle = this.makeTitle(readings);
|
||||||
|
const datasets = [
|
||||||
|
{ name: 'Memory', type: 'bar', values: systemValues },
|
||||||
|
];
|
||||||
|
this.generateChart({ labels, datasets }, chartTitle);
|
||||||
|
},
|
||||||
|
makeTitle(system) {
|
||||||
|
return `Memory Usage over past ${getTimeAgo(system[0][0]).replace('ago', '')}`;
|
||||||
|
},
|
||||||
|
generateChart(timeChartData, chartTitle) {
|
||||||
|
return new this.Chart(`#${this.chartId}`, {
|
||||||
|
title: chartTitle,
|
||||||
|
data: timeChartData,
|
||||||
|
type: 'axis-mixed',
|
||||||
|
height: this.chartHeight,
|
||||||
|
colors: this.chartColors,
|
||||||
|
truncateLegends: true,
|
||||||
|
lineOptions: {
|
||||||
|
regionFill: 1,
|
||||||
|
hideDots: 1,
|
||||||
|
},
|
||||||
|
axisOptions: {
|
||||||
|
xIsSeries: true,
|
||||||
|
xAxisMode: 'tick',
|
||||||
|
},
|
||||||
|
tooltipOptions: {
|
||||||
|
formatTooltipY: d => `${Math.round(d)}%`,
|
||||||
|
// formatTooltipX: d => timestampToTime(d),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.overrideUpdateInterval = 20;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.glances-cpu-history-wrapper {
|
||||||
|
.gl-history-chart {}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -137,6 +137,13 @@
|
||||||
@error="handleError"
|
@error="handleError"
|
||||||
:ref="widgetRef"
|
:ref="widgetRef"
|
||||||
/>
|
/>
|
||||||
|
<GlMemHistory
|
||||||
|
v-else-if="widgetType === 'gl-mem-history'"
|
||||||
|
:options="widgetOptions"
|
||||||
|
@loading="setLoaderState"
|
||||||
|
@error="handleError"
|
||||||
|
:ref="widgetRef"
|
||||||
|
/>
|
||||||
<HealthChecks
|
<HealthChecks
|
||||||
v-else-if="widgetType === 'health-checks'"
|
v-else-if="widgetType === 'health-checks'"
|
||||||
:options="widgetOptions"
|
:options="widgetOptions"
|
||||||
|
@ -331,6 +338,7 @@ export default {
|
||||||
GlCpuGauge: () => import('@/components/Widgets/GlCpuGauge.vue'),
|
GlCpuGauge: () => import('@/components/Widgets/GlCpuGauge.vue'),
|
||||||
GlCpuHistory: () => import('@/components/Widgets/GlCpuHistory.vue'),
|
GlCpuHistory: () => import('@/components/Widgets/GlCpuHistory.vue'),
|
||||||
GlMemGauge: () => import('@/components/Widgets/GlMemGauge.vue'),
|
GlMemGauge: () => import('@/components/Widgets/GlMemGauge.vue'),
|
||||||
|
GlMemHistory: () => import('@/components/Widgets/GlMemHistory.vue'),
|
||||||
HealthChecks: () => import('@/components/Widgets/HealthChecks.vue'),
|
HealthChecks: () => import('@/components/Widgets/HealthChecks.vue'),
|
||||||
IframeWidget: () => import('@/components/Widgets/IframeWidget.vue'),
|
IframeWidget: () => import('@/components/Widgets/IframeWidget.vue'),
|
||||||
Jokes: () => import('@/components/Widgets/Jokes.vue'),
|
Jokes: () => import('@/components/Widgets/Jokes.vue'),
|
||||||
|
|
Loading…
Reference in New Issue