mirror of https://github.com/nicolargo/glances.git
Add container inactive_file & limit to InfluxDB2 export #3206
This commit is contained in:
parent
1365d600a3
commit
cd71b45089
697
docs/api.rst
697
docs/api.rst
File diff suppressed because it is too large
Load Diff
|
|
@ -477,6 +477,7 @@ class GlancesRestfulApi:
|
|||
|
||||
try:
|
||||
# Get the RAW value of the stat ID
|
||||
# TODO in #3211: use getAllExportsAsDict instead but break UI for uptime, processlist, others ?
|
||||
statval = self.stats.getAllAsDict()
|
||||
except Exception as e:
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get stats ({str(e)})")
|
||||
|
|
@ -565,12 +566,11 @@ class GlancesRestfulApi:
|
|||
|
||||
try:
|
||||
# Get the RAW value of the stat ID
|
||||
# TODO in #3211: use get_export instead but break API
|
||||
statval = self.stats.get_plugin(plugin).get_raw()
|
||||
except Exception as e:
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get plugin {plugin} ({str(e)})")
|
||||
|
||||
print(statval)
|
||||
|
||||
if isinstance(statval, list):
|
||||
statval = statval[:nb]
|
||||
|
||||
|
|
@ -612,7 +612,7 @@ class GlancesRestfulApi:
|
|||
|
||||
try:
|
||||
# Get the RAW value of the stat limits
|
||||
ret = self.stats.get_plugin(plugin).limits
|
||||
ret = self.stats.get_plugin(plugin).get_limits()
|
||||
except Exception as e:
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get limits for plugin {plugin} ({str(e)})")
|
||||
|
||||
|
|
@ -655,6 +655,7 @@ class GlancesRestfulApi:
|
|||
|
||||
try:
|
||||
# Get the RAW value of the stat views
|
||||
# TODO in #3211: use a non existing (to be created) get_export_item instead but break API
|
||||
ret = self.stats.get_plugin(plugin).get_raw_stats_item(item)
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
|
|
@ -679,6 +680,7 @@ class GlancesRestfulApi:
|
|||
|
||||
try:
|
||||
# Get the RAW value of the stat views
|
||||
# TODO in #3211: use a non existing (to be created) get_export_key instead but break API
|
||||
ret = self.stats.get_plugin(plugin).get_raw_stats_key(item, key)
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
|
|
@ -811,6 +813,7 @@ class GlancesRestfulApi:
|
|||
|
||||
try:
|
||||
# Get the RAW value
|
||||
# TODO in #3211: use a non existing (to be created) get_export_item_value instead but break API
|
||||
ret = self.stats.get_plugin(plugin).get_raw_stats_value(item, value)
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
|
|
|
|||
|
|
@ -9,29 +9,20 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<td v-show="showPod" scope="col">Pod</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('name')"
|
||||
scope="col"
|
||||
<td v-show="!getDisableStats().includes('name')" scope="col"
|
||||
:class="['sortable', sorter.column === 'name' && 'sort']"
|
||||
@click="args.sort_processes_key = 'name'"
|
||||
>
|
||||
@click="args.sort_processes_key = 'name'">
|
||||
Name
|
||||
</td>
|
||||
<td v-show="!getDisableStats().includes('status')" scope="col">Status</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('cpu')"
|
||||
scope="col"
|
||||
<td v-show="!getDisableStats().includes('cpu')" scope="col"
|
||||
:class="['sortable', sorter.column === 'cpu_percent' && 'sort']"
|
||||
@click="args.sort_processes_key = 'cpu_percent'"
|
||||
>
|
||||
@click="args.sort_processes_key = 'cpu_percent'">
|
||||
CPU%
|
||||
</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('mem')"
|
||||
scope="col"
|
||||
<td v-show="!getDisableStats().includes('mem')" scope="col"
|
||||
:class="['sortable', sorter.column === 'memory_percent' && 'sort']"
|
||||
@click="args.sort_processes_key = 'memory_percent'"
|
||||
>
|
||||
@click="args.sort_processes_key = 'memory_percent'">
|
||||
MEM
|
||||
</td>
|
||||
<td v-show="!getDisableStats().includes('mem')" scope="col">MAX</td>
|
||||
|
|
@ -44,15 +35,11 @@
|
|||
<td v-show="!getDisableStats().includes('name')" scope="row">
|
||||
{{ container.name }}
|
||||
</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('status')"
|
||||
scope="row"
|
||||
:class="[
|
||||
container.status === 'Paused' && 'careful',
|
||||
container.status === 'exited' && 'warning',
|
||||
!['Paused', 'exited'].includes(container.status) && 'ok'
|
||||
]"
|
||||
>
|
||||
<td v-show="!getDisableStats().includes('status')" scope="row" :class="[
|
||||
container.status === 'Paused' && 'careful',
|
||||
container.status === 'exited' && 'warning',
|
||||
!['Paused', 'exited'].includes(container.status) && 'ok'
|
||||
]">
|
||||
{{ container.status }}
|
||||
</td>
|
||||
<td v-show="!getDisableStats().includes('cpu')" scope="row">
|
||||
|
|
@ -72,11 +59,7 @@
|
|||
: $filters.bytes(container.limit)
|
||||
}}
|
||||
</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('command')"
|
||||
scope="row"
|
||||
class="text-truncate"
|
||||
>
|
||||
<td v-show="!getDisableStats().includes('command')" scope="row" class="text-truncate">
|
||||
{{ container.command }}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -89,30 +72,21 @@
|
|||
<tr>
|
||||
<td v-show="showEngine" scope="col">Engine</td>
|
||||
<td v-show="showPod" scope="col">Pod</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('name')"
|
||||
scope="col"
|
||||
<td v-show="!getDisableStats().includes('name')" scope="col"
|
||||
:class="['sortable', sorter.column === 'name' && 'sort']"
|
||||
@click="args.sort_processes_key = 'name'"
|
||||
>
|
||||
@click="args.sort_processes_key = 'name'">
|
||||
Name
|
||||
</td>
|
||||
<td v-show="!getDisableStats().includes('status')" scope="col">Status</td>
|
||||
<td v-show="!getDisableStats().includes('uptime')" scope="col">Uptime</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('cpu')"
|
||||
scope="col"
|
||||
<td v-show="!getDisableStats().includes('cpu')" scope="col"
|
||||
:class="['sortable', sorter.column === 'cpu_percent' && 'sort']"
|
||||
@click="args.sort_processes_key = 'cpu_percent'"
|
||||
>
|
||||
@click="args.sort_processes_key = 'cpu_percent'">
|
||||
CPU%
|
||||
</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('mem')"
|
||||
scope="col"
|
||||
<td v-show="!getDisableStats().includes('mem')" scope="col"
|
||||
:class="['sortable', sorter.column === 'memory_percent' && 'sort']"
|
||||
@click="args.sort_processes_key = 'memory_percent'"
|
||||
>
|
||||
@click="args.sort_processes_key = 'memory_percent'">
|
||||
MEM
|
||||
</td>
|
||||
<td v-show="!getDisableStats().includes('mem')" scope="col">MAX</td>
|
||||
|
|
@ -130,15 +104,11 @@
|
|||
<td v-show="!getDisableStats().includes('name')" scope="row">
|
||||
{{ container.name }}
|
||||
</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('status')"
|
||||
scope="row"
|
||||
:class="[
|
||||
container.status === 'Paused' && 'careful',
|
||||
container.status === 'exited' && 'warning',
|
||||
!['Paused', 'exited'].includes(container.status) && 'ok'
|
||||
]"
|
||||
>
|
||||
<td v-show="!getDisableStats().includes('status')" scope="row" :class="[
|
||||
container.status === 'Paused' && 'careful',
|
||||
container.status === 'exited' && 'warning',
|
||||
!['Paused', 'exited'].includes(container.status) && 'ok'
|
||||
]">
|
||||
{{ container.status }}
|
||||
</td>
|
||||
<td v-show="!getDisableStats().includes('uptime')" scope="row">
|
||||
|
|
@ -189,11 +159,7 @@
|
|||
: $filters.bits(container.network_tx)
|
||||
}}
|
||||
</td>
|
||||
<td
|
||||
v-show="!getDisableStats().includes('command')"
|
||||
scope="row"
|
||||
class="text-truncate"
|
||||
>
|
||||
<td v-show="!getDisableStats().includes('command')" scope="row" class="text-truncate">
|
||||
{{ container.command }}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -237,13 +203,17 @@ export default {
|
|||
const { sorter } = this;
|
||||
const containers = (this.stats || []) //
|
||||
.map((containerData) => {
|
||||
// Memory usage no cache is reflected the algorithm used in Docker top
|
||||
let memory_usage_no_cache;
|
||||
if (containerData.memory.usage != undefined) {
|
||||
memory_usage_no_cache = containerData.memory.usage;
|
||||
if (containerData.memory.inactive_file != undefined) {
|
||||
|
||||
if (containerData.memory_usage != undefined) {
|
||||
memory_usage_no_cache = containerData.memory_usage;
|
||||
if (containerData.memory_inactive_file != undefined) {
|
||||
memory_usage_no_cache =
|
||||
memory_usage_no_cache - containerData.memory.inactive_file;
|
||||
memory_usage_no_cache - containerData.memory_inactive_file;
|
||||
}
|
||||
} else {
|
||||
memory_usage_no_cache = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -51,6 +51,14 @@ fields_description = {
|
|||
'description': 'Container CPU consumption',
|
||||
'unit': 'percent',
|
||||
},
|
||||
'memory_inactive_file': {
|
||||
'description': 'Container memory inactive file',
|
||||
'unit': 'byte',
|
||||
},
|
||||
'memory_limit': {
|
||||
'description': 'Container memory limit',
|
||||
'unit': 'byte',
|
||||
},
|
||||
'memory_usage': {
|
||||
'description': 'Container memory usage',
|
||||
'unit': 'byte',
|
||||
|
|
|
|||
|
|
@ -341,6 +341,8 @@ class DockerExtension:
|
|||
stats['memory_usage'] = stats['memory'].get('usage')
|
||||
if stats['memory'].get('cache') is not None:
|
||||
stats['memory_usage'] -= stats['memory']['cache']
|
||||
stats['memory_inactive_file'] = stats['memory'].get('inactive_file')
|
||||
stats['memory_limit'] = stats['memory'].get('limit')
|
||||
|
||||
if all(k in stats['io'] for k in ('ior', 'iow', 'time_since_update')):
|
||||
stats['io_rx'] = stats['io']['ior'] // stats['io']['time_since_update']
|
||||
|
|
|
|||
|
|
@ -379,6 +379,8 @@ class PodmanExtension:
|
|||
stats['memory_usage'] = stats['memory'].get('usage')
|
||||
if stats['memory'].get('cache') is not None:
|
||||
stats['memory_usage'] -= stats['memory']['cache']
|
||||
stats['memory_inactive_file'] = stats['memory'].get('inactive_file')
|
||||
stats['memory_limit'] = stats['memory'].get('limit')
|
||||
|
||||
if all(k in stats['io'] for k in ('ior', 'iow', 'time_since_update')):
|
||||
stats['io_rx'] = stats['io']['ior'] // stats['io']['time_since_update']
|
||||
|
|
|
|||
|
|
@ -189,15 +189,16 @@ class GlancesPluginModel:
|
|||
def update_stats_history(self):
|
||||
"""Update stats history."""
|
||||
# Build the history
|
||||
if not (self.get_export() and self.history_enable()):
|
||||
_get_export = self.get_export()
|
||||
if not (_get_export and self.history_enable()):
|
||||
return
|
||||
# Itern through items history
|
||||
item_name = '' if self.get_key() is None else self.get_key()
|
||||
for i in self.get_items_history_list():
|
||||
if isinstance(self.get_export(), list):
|
||||
if isinstance(_get_export, list):
|
||||
# Stats is a list of data
|
||||
# Iter through stats (for example, iter through network interface)
|
||||
for l_export in self.get_export():
|
||||
for l_export in _get_export:
|
||||
if i['name'] in l_export:
|
||||
self.stats_history.add(
|
||||
nativestr(l_export[item_name]) + '_' + nativestr(i['name']),
|
||||
|
|
@ -210,7 +211,7 @@ class GlancesPluginModel:
|
|||
# Add the item to the history directly
|
||||
self.stats_history.add(
|
||||
nativestr(i['name']),
|
||||
self.get_export()[i['name']],
|
||||
_get_export[i['name']],
|
||||
description=i['description'],
|
||||
history_max_size=self._limits['history_size'],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue