summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2024-03-17 10:18:40 +0100
committernicolargo <nicolas@nicolargo.com>2024-03-17 10:18:40 +0100
commit272dc23443ab364fcbad2294627ac43e5688cb4c (patch)
treee3f6ec7c7cbbab5e93d9ba4eddf0b8e2af2d968a
parent684d1d7b942b0ad48552a1dc6c0b3ac947d5c1a6 (diff)
Correct an issue with the events duration
-rw-r--r--docs/api.rst319
-rw-r--r--docs/man/glances.12
-rw-r--r--glances/events.py56
-rw-r--r--glances/outputs/static/js/components/plugin-alert.vue1
-rw-r--r--glances/outputs/static/public/glances.js2
5 files changed, 195 insertions, 185 deletions
diff --git a/docs/api.rst b/docs/api.rst
index dc2d5f87..29d89a0c 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -109,16 +109,17 @@ GET alert
Get plugin stats::
# curl http://localhost:61208/api/4/alert
- [{"avg": 77.5178777948861,
- "begin": 1710604536.0,
+ [{"avg": 75.96435906685214,
+ "begin": 1710667086.0,
"count": 1,
"desc": "",
"end": -1,
- "max": 77.5178777948861,
- "min": 77.5178777948861,
+ "global": "No warning or critical alert detected",
+ "max": 75.96435906685214,
+ "min": 75.96435906685214,
"sort": "memory_percent",
"state": "WARNING",
- "sum": 77.5178777948861,
+ "sum": 75.96435906685214,
"top": [],
"type": "MEM"}]
@@ -136,25 +137,27 @@ Fields descriptions:
* **top**: Top 3 processes name during the event period (unit is *list*)
* **desc**: Description of the event (unit is *string*)
* **sort**: Sort key of the top processes (unit is *string*)
+* **global**: Global alert message (unit is *string*)
Get a specific field::
# curl http://localhost:61208/api/4/alert/begin
- {"begin": [1710604536.0]}
+ {"begin": [1710667086.0]}
Get a specific item when field matches the given value::
- # curl http://localhost:61208/api/4/alert/begin/1710604536.0
- {"1710604536.0": [{"avg": 77.5178777948861,
- "begin": 1710604536.0,
+ # curl http://localhost:61208/api/4/alert/begin/1710667086.0
+ {"1710667086.0": [{"avg": 75.96435906685214,
+ "begin": 1710667086.0,
"count": 1,
"desc": "",
"end": -1,
- "max": 77.5178777948861,
- "min": 77.5178777948861,
+ "global": "No warning or critical alert detected",
+ "max": 75.96435906685214,
+ "min": 75.96435906685214,
"sort": "memory_percent",
"state": "WARNING",
- "sum": 77.5178777948861,
+ "sum": 75.96435906685214,
"top": [],
"type": "MEM"}]}
@@ -172,7 +175,7 @@ Get plugin stats::
"refresh": 3.0,
"regex": True,
"result": None,
- "timer": 0.7440230846405029},
+ "timer": 0.4694037437438965},
{"count": 0,
"countmax": 20.0,
"countmin": None,
@@ -181,7 +184,7 @@ Get plugin stats::
"refresh": 3.0,
"regex": True,
"result": None,
- "timer": 0.7436609268188477}]
+ "timer": 0.469210147857666}]
Fields descriptions:
@@ -209,7 +212,7 @@ Get a specific item when field matches the given value::
"refresh": 3.0,
"regex": True,
"result": None,
- "timer": 0.7440230846405029}]}
+ "timer": 0.4694037437438965}]}
GET cloud
---------
@@ -352,19 +355,19 @@ Get plugin stats::
# curl http://localhost:61208/api/4/cpu
{"cpucore": 4,
- "ctx_switches": 357566492,
+ "ctx_switches": 397941655,
"guest": 0.0,
- "idle": 64.2,
- "interrupts": 213733514,
- "iowait": 0.5,
+ "idle": 67.7,
+ "interrupts": 232246798,
+ "iowait": 4.2,
"irq": 0.0,
"nice": 0.0,
- "soft_interrupts": 95026288,
+ "soft_interrupts": 105421124,
"steal": 0.0,
"syscalls": 0,
- "system": 5.3,
- "total": 35.3,
- "user": 29.8}
+ "system": 6.5,
+ "total": 28.1,
+ "user": 21.7}
Fields descriptions:
@@ -397,7 +400,7 @@ Fields descriptions:
Get a specific field::
# curl http://localhost:61208/api/4/cpu/total
- {"total": 35.3}
+ {"total": 28.1}
GET diskio
----------
@@ -407,16 +410,16 @@ Get plugin stats::
# curl http://localhost:61208/api/4/diskio
[{"disk_name": "sda",
"key": "disk_name",
- "read_bytes": 50970915328,
- "read_count": 1735461,
- "write_bytes": 62791970816,
- "write_count": 1145248},
+ "read_bytes": 56719797760,
+ "read_count": 2143710,
+ "write_bytes": 126239322112,
+ "write_count": 1308736},
{"disk_name": "sda1",
"key": "disk_name",
- "read_bytes": 12546048,
- "read_count": 344,
+ "read_bytes": 15003648,
+ "read_count": 432,
"write_bytes": 0,
- "write_count": 18}]
+ "write_count": 34}]
Fields descriptions:
@@ -445,10 +448,10 @@ Get a specific item when field matches the given value::
# curl http://localhost:61208/api/4/diskio/disk_name/sda
{"sda": [{"disk_name": "sda",
"key": "disk_name",
- "read_bytes": 50970915328,
- "read_count": 1735461,
- "write_bytes": 62791970816,
- "write_count": 1145248}]}
+ "read_bytes": 56719797760,
+ "read_count": 2143710,
+ "write_bytes": 126239322112,
+ "write_count": 1308736}]}
GET folders
-----------
@@ -475,13 +478,13 @@ Get plugin stats::
# curl http://localhost:61208/api/4/fs
[{"device_name": "/dev/mapper/ubuntu--gnome--vg-root",
- "free": 37301002240,
+ "free": 36942905344,
"fs_type": "ext4",
"key": "mnt_point",
"mnt_point": "/",
- "percent": 83.8,
+ "percent": 84.0,
"size": 243334156288,
- "used": 193645699072},
+ "used": 194003795968},
{"device_name": "zsfpool",
"free": 31195136,
"fs_type": "zfs",
@@ -510,13 +513,13 @@ Get a specific item when field matches the given value::
# curl http://localhost:61208/api/4/fs/mnt_point//
{"/": [{"device_name": "/dev/mapper/ubuntu--gnome--vg-root",
- "free": 37301002240,
+ "free": 36942905344,
"fs_type": "ext4",
"key": "mnt_point",
"mnt_point": "/",
- "percent": 83.8,
+ "percent": 84.0,
"size": 243334156288,
- "used": 193645699072}]}
+ "used": 194003795968}]}
GET gpu
-------
@@ -549,11 +552,11 @@ GET ip
Get plugin stats::
# curl http://localhost:61208/api/4/ip
- {"address": "192.168.0.32",
- "gateway": "192.168.0.254",
+ {"address": "192.168.1.14",
+ "gateway": "192.168.1.1",
"mask": "255.255.255.0",
"mask_cidr": 24,
- "public_address": "91.166.228.228",
+ "public_address": "92.151.148.66",
"public_info_human": ""}
Fields descriptions:
@@ -568,7 +571,7 @@ Fields descriptions:
Get a specific field::
# curl http://localhost:61208/api/4/ip/gateway
- {"gateway": "192.168.0.254"}
+ {"gateway": "192.168.1.1"}
GET irq
-------
@@ -589,7 +592,7 @@ GET load
Get plugin stats::
# curl http://localhost:61208/api/4/load
- {"cpucore": 4, "min1": 1.87841796875, "min15": 2.724609375, "min5": 2.345703125}
+ {"cpucore": 4, "min1": 2.984375, "min15": 1.28515625, "min5": 1.4287109375}
Fields descriptions:
@@ -601,7 +604,7 @@ Fields descriptions:
Get a specific field::
# curl http://localhost:61208/api/4/load/min1
- {"min1": 1.87841796875}
+ {"min1": 2.984375}
GET mem
-------
@@ -609,16 +612,16 @@ GET mem
Get plugin stats::
# curl http://localhost:61208/api/4/mem
- {"active": 2811445248,
- "available": 1758904320,
- "buffers": 236449792,
- "cached": 2580111360,
- "free": 1758904320,
- "inactive": 3522138112,
- "percent": 77.5,
- "shared": 1017028608,
+ {"active": 2766622720,
+ "available": 1880444928,
+ "buffers": 101732352,
+ "cached": 1765371904,
+ "free": 1880444928,
+ "inactive": 3366436864,
+ "percent": 76.0,
+ "shared": 463790080,
"total": 7823568896,
- "used": 6064664576}
+ "used": 5943123968}
Fields descriptions:
@@ -645,13 +648,13 @@ GET memswap
Get plugin stats::
# curl http://localhost:61208/api/4/memswap
- {"free": 5102702592,
- "percent": 36.9,
- "sin": 2302570496,
- "sout": 5334548480,
+ {"free": 4000202752,
+ "percent": 50.5,
+ "sin": 2879971328,
+ "sout": 6910545920,
"time_since_update": 1,
"total": 8082419712,
- "used": 2979717120}
+ "used": 4082216960}
Fields descriptions:
@@ -676,15 +679,15 @@ Get plugin stats::
# curl http://localhost:61208/api/4/network
[{"alias": None,
"bytes_all": 0,
- "bytes_all_gauge": 4407380752,
+ "bytes_all_gauge": 4797781425,
"bytes_recv": 0,
- "bytes_recv_gauge": 4170208788,
+ "bytes_recv_gauge": 4541115619,
"bytes_sent": 0,
- "bytes_sent_gauge": 237171964,
+ "bytes_sent_gauge": 256665806,
"interface_name": "wlp2s0",
"key": "interface_name",
"speed": 0,
- "time_since_update": 0.4740254878997803},
+ "time_since_update": 0.3124685287475586},
{"alias": None,
"bytes_all": 0,
"bytes_all_gauge": 0,
@@ -695,7 +698,7 @@ Get plugin stats::
"interface_name": "br-40875d2e2716",
"key": "interface_name",
"speed": 0,
- "time_since_update": 0.4740254878997803}]
+ "time_since_update": 0.3124685287475586}]
Fields descriptions:
@@ -730,15 +733,15 @@ Get a specific item when field matches the given value::
# curl http://localhost:61208/api/4/network/interface_name/wlp2s0
{"wlp2s0": [{"alias": None,
"bytes_all": 0,
- "bytes_all_gauge": 4407380752,
+ "bytes_all_gauge": 4797781425,
"bytes_recv": 0,
- "bytes_recv_gauge": 4170208788,
+ "bytes_recv_gauge": 4541115619,
"bytes_sent": 0,
- "bytes_sent_gauge": 237171964,
+ "bytes_sent_gauge": 256665806,
"interface_name": "wlp2s0",
"key": "interface_name",
"speed": 0,
- "time_since_update": 0.4740254878997803}]}
+ "time_since_update": 0.3124685287475586}]}
GET now
-------
@@ -746,7 +749,7 @@ GET now
Get plugin stats::
# curl http://localhost:61208/api/4/now
- "2024-03-16 16:55:36 CET"
+ "2024-03-17 10:18:06 CET"
GET percpu
----------
@@ -757,29 +760,29 @@ Get plugin stats::
[{"cpu_number": 0,
"guest": 0.0,
"guest_nice": 0.0,
- "idle": 50.5,
- "iowait": 0.0,
+ "idle": 47.0,
+ "iowait": 4.0,
"irq": 0.0,
"key": "cpu_number",
"nice": 0.0,
"softirq": 0.0,
"steal": 0.0,
- "system": 5.5,
- "total": 49.5,
- "user": 44.0},
+ "system": 4.0,
+ "total": 53.0,
+ "user": 12.0},
{"cpu_number": 1,
"guest": 0.0,
"guest_nice": 0.0,
- "idle": 43.6,
- "iowait": 0.0,
+ "idle": 55.0,
+ "iowait": 1.0,
"irq": 0.0,
"key": "cpu_number",
"nice": 0.0,
"softirq": 0.0,
"steal": 0.0,
- "system": 5.5,
- "total": 56.4,
- "user": 50.9}]
+ "system": 4.0,
+ "total": 45.0,
+ "user": 11.0}]
Fields descriptions:
@@ -808,12 +811,12 @@ Get plugin stats::
# curl http://localhost:61208/api/4/ports
[{"description": "DefaultGateway",
- "host": "192.168.0.254",
+ "host": "192.168.1.1",
"indice": "port_0",
"port": 0,
"refresh": 30,
"rtt_warning": None,
- "status": 0.007952,
+ "status": 0.00853,
"timeout": 3}]
Fields descriptions:
@@ -830,19 +833,19 @@ Fields descriptions:
Get a specific field::
# curl http://localhost:61208/api/4/ports/host
- {"host": ["192.168.0.254"]}
+ {"host": ["192.168.1.1"]}
Get a specific item when field matches the given value::
- # curl http://localhost:61208/api/4/ports/host/192.168.0.254
- {"192.168.0.254": [{"description": "DefaultGateway",
- "host": "192.168.0.254",
- "indice": "port_0",
- "port": 0,
- "refresh": 30,
- "rtt_warning": None,
- "status": 0.007952,
- "timeout": 3}]}
+ # curl http://localhost:61208/api/4/ports/host/192.168.1.1
+ {"192.168.1.1": [{"description": "DefaultGateway",
+ "host": "192.168.1.1",
+ "indice": "port_0",
+ "port": 0,
+ "refresh": 30,
+ "rtt_warning": None,
+ "status": 0.00853,
+ "timeout": 3}]}
GET processcount
----------------
@@ -850,7 +853,7 @@ GET processcount
Get plugin stats::
# curl http://localhost:61208/api/4/processcount
- {"pid_max": 0, "running": 1, "sleeping": 334, "thread": 1645, "total": 402}
+ {"pid_max": 0, "running": 1, "sleeping": 341, "thread": 1773, "total": 410}
Fields descriptions:
@@ -863,7 +866,7 @@ Fields descriptions:
Get a specific field::
# curl http://localhost:61208/api/4/processcount/total
- {"total": 402}
+ {"total": 410}
GET processlist
---------------
@@ -903,66 +906,66 @@ GET quicklook
Get plugin stats::
# curl http://localhost:61208/api/4/quicklook
- {"cpu": 35.3,
+ {"cpu": 28.1,
"cpu_hz": 2025000000.0,
- "cpu_hz_current": 1799572750.0,
+ "cpu_hz_current": 2048951750.0000002,
"cpu_name": "Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz",
"cpucore": 4,
- "load": 68.1,
- "mem": 77.5,
+ "load": 32.1,
+ "mem": 76.0,
"percpu": [{"cpu_number": 0,
"guest": 0.0,
"guest_nice": 0.0,
- "idle": 50.5,
- "iowait": 0.0,
+ "idle": 47.0,
+ "iowait": 4.0,
"irq": 0.0,
"key": "cpu_number",
"nice": 0.0,
"softirq": 0.0,
"steal": 0.0,
- "system": 5.5,
- "total": 49.5,
- "user": 44.0},
+ "system": 4.0,
+ "total": 53.0,
+ "user": 12.0},
{"cpu_number": 1,
"guest": 0.0,
"guest_nice": 0.0,
- "idle": 43.6,
- "iowait": 0.0,
+ "idle": 55.0,
+ "iowait": 1.0,
"irq": 0.0,
"key": "cpu_number",
"nice": 0.0,
"softirq": 0.0,
"steal": 0.0,
- "system": 5.5,
- "total": 56.4,
- "user": 50.9},
+ "system": 4.0,
+ "total": 45.0,
+ "user": 11.0},
{"cpu_number": 2,
"guest": 0.0,
"guest_nice": 0.0,
- "idle": 75.9,
- "iowait": 0.9,
+ "idle": 59.0,
+ "iowait": 0.0,
"irq": 0.0,
"key": "cpu_number",
"nice": 0.0,
- "softirq": 0.9,
+ "softirq": 0.0,
"steal": 0.0,
- "system": 5.4,
- "total": 24.1,
- "user": 17.0},
+ "system": 5.0,
+ "total": 41.0,
+ "user": 4.0},
{"cpu_number": 3,
"guest": 0.0,
"guest_nice": 0.0,
- "idle": 87.2,
- "iowait": 1.8,
+ "idle": 25.0,
+ "iowait": 6.0,
"irq": 0.0,
"key": "cpu_number",
"nice": 0.0,
"softirq": 0.0,
"steal": 0.0,
- "system": 4.6,
- "total": 12.8,
- "user": 6.4}],
- "swap": 36.9}
+ "system": 7.0,
+ "total": 75.0,
+ "user": 30.0}],
+ "swap": 50.5}
Fields descriptions:
@@ -1082,7 +1085,7 @@ GET uptime
Get plugin stats::
# curl http://localhost:61208/api/4/uptime
- "12 days, 7:54:55"
+ "13 days, 1:17:25"
GET version
-----------
@@ -1144,47 +1147,47 @@ Get top 2 processes of the processlist plugin::
"cpu_times": {"children_system": 0.0,
"children_user": 0.0,
"iowait": 0.0,
- "system": 516.6,
- "user": 5808.08},
+ "system": 614.94,
+ "user": 7063.28},
"gids": {"effective": 1000, "real": 1000, "saved": 1000},
- "io_counters": [269836288, 3272704, 0, 0, 0],
+ "io_counters": [372940800, 3305472, 0, 0, 0],
"key": "pid",
- "memory_info": {"data": 1044848640,
+ "memory_info": {"data": 1338855424,
"dirty": 0,
"lib": 0,
- "rss": 468369408,
- "shared": 56168448,
+ "rss": 720982016,
+ "shared": 53673984,
"text": 126423040,
- "vms": 1221796024320},
- "memory_percent": 5.986646429859726,
+ "vms": 1221796945920},
+ "memory_percent": 9.215513093629438,
"name": "code",
"nice": 0,
- "num_threads": 14,
+ "num_threads": 15,
"pid": 35570,
"status": "S",
"time_since_update": 1,
"username": "nicolargo"},
{"cmdline": ["/snap/firefox/3728/usr/lib/firefox/firefox"],
"cpu_percent": 0.0,
- "cpu_times": {"children_system": 963.66,
- "children_user": 7841.22,
+ "cpu_times": {"children_system": 994.29,
+ "children_user": 7945.82,
"iowait": 0.0,
- "system": 2919.84,
- "user": 9394.94},
+ "system": 3044.16,
+ "user": 9792.08},
"gids": {"effective": 1000, "real": 1000, "saved": 1000},
- "io_counters": [3660247040, 7034068992, 0, 0, 0],
+ "io_counters": [4175133696, 7454736384, 0, 0, 0],
"key": "pid",
- "memory_info": {"data": 1652645888,
+ "memory_info": {"data": 1669996544,
"dirty": 0,
"lib": 0,
- "rss": 444485632,
- "shared": 120119296,
+ "rss": 487743488,
+ "shared": 100765696,
"text": 839680,
- "vms": 14011539456},
- "memory_percent": 5.681366623194878,
+ "vms": 13926277120},
+ "memory_percent": 6.234283796610667,
"name": "firefox",
"nice": 0,
- "num_threads": 170,
+ "num_threads": 175,
"pid": 7992,
"status": "S",
"time_since_update": 1,
@@ -1216,34 +1219,34 @@ GET stats history
History of a plugin::
# curl http://localhost:61208/api/4/cpu/history
- {"system": [["2024-03-16T16:55:39.007658", 6.9],
- ["2024-03-16T16:55:40.064874", 6.9],
- ["2024-03-16T16:55:41.655316", 8.1]],
- "user": [["2024-03-16T16:55:39.007640", 20.1],
- ["2024-03-16T16:55:40.064843", 20.1],
- ["2024-03-16T16:55:41.655297", 18.6]]}
+ {"system": [["2024-03-17T10:18:08.487741", 6.5],
+ ["2024-03-17T10:18:09.509980", 3.4],
+ ["2024-03-17T10:18:10.718312", 3.4]],
+ "user": [["2024-03-17T10:18:08.487727", 21.7],
+ ["2024-03-17T10:18:09.509972", 7.9],
+ ["2024-03-17T10:18:10.718285", 7.9]]}
Limit history to last 2 values::
# curl http://localhost:61208/api/4/cpu/history/2
- {"system": [["2024-03-16T16:55:40.064874", 6.9],
- ["2024-03-16T16:55:41.655316", 8.1]],
- "user": [["2024-03-16T16:55:40.064843", 20.1],
- ["2024-03-16T16:55:41.655297", 18.6]]}
+ {"system": [["2024-03-17T10:18:09.509980", 3.4],
+ ["2024-03-17T10:18:10.718312", 3.4]],
+ "user": [["2024-03-17T10:18:09.509972", 7.9],
+ ["2024-03-17T10:18:10.718285", 7.9]]}
History for a specific field::
# curl http://localhost:61208/api/4/cpu/system/history
- {"system": [["2024-03-16T16:55:36.914228", 5.3],
- ["2024-03-16T16:55:39.007658", 6.9],
- ["2024-03-16T16:55:40.064874", 6.9],
- ["2024-03-16T16:55:41.655316", 8.1]]}
+ {"system": [["2024-03-17T10:18:06.895517", 6.5],
+ ["2024-03-17T10:18:08.487741", 6.5],
+ ["2024-03-17T10:18:09.509980", 3.4],
+ ["2024-03-17T10:18:10.718312", 3.4]]}
Limit history for a specific field to last 2 values::
# curl http://localhost:61208/api/4/cpu/system/history
- {"system": [["2024-03-16T16:55:40.064874", 6.9],
- ["2024-03-16T16:55:41.655316", 8.1]]}
+ {"system": [["2024-03-17T10:18:09.509980", 3.4],
+ ["2024-03-17T10:18:10.718312", 3.4]]}
GET limits (used for thresholds)
--------------------------------
diff --git a/docs/man/glances.1 b/docs/man/glances.1
index 081c1d62..c57395da 100644
--- a/docs/man/glances.1
+++ b/docs/man/glances.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "GLANCES" "1" "Mar 16, 2024" "4.0.0_beta01" "Glances"
+.TH "GLANCES" "1" "Mar 17, 2024" "4.0.0_beta01" "Glances"
.SH NAME
glances \- An eye on your system
.SH SYNOPSIS
diff --git a/glances/events.py b/glances/events.py
index 06ddc669..6658c842 100644
--- a/glances/events.py
+++ b/glances/events.py
@@ -12,6 +12,7 @@
import time
from datetime import datetime
+from glances.logger import logger
from glances.processes import glances_processes, sort_stats
from glances.thresholds import glances_thresholds
@@ -336,42 +337,34 @@ class GlancesEvents(object):
def _update_event(self, event_time, event_index, event_state, event_type, event_value,
proc_list, proc_desc, global_message):
"""Update an event in the list"""
- if event_state == "OK" or event_state == "CAREFUL":
- # Reset the automatic process sort key
- self.reset_process_sort()
-
- # Set the end of the events
- end_time = event_time
- if end_time - self.events_list[event_index]['begin'] >= self.min_duration:
- # If event is >= min_duration seconds
- self.events_list[event_index]['end'] = end_time
- else:
- # If event < min_duration seconds, ignore
- self.events_list.remove(self.events_list[event_index])
- else:
- # Update the item
-
- # It's an ongoing event, update the end time
- self.events_list[event_index]['end'] = -1
-
+ if event_state in ('OK', 'CAREFUL') and self.events_list[event_index]['end'] < 0:
+ # Close the event
+ self._close_event(event_time, event_index)
+ elif event_state in ('OK', 'CAREFUL') and self.events_list[event_index]['end'] >= 0:
+ # Event is already closed, do nothing
+ pass
+ else: # event_state == "WARNING" or event_state == "CRITICAL"
# Set process sort key
self.set_process_sort(event_type)
- # State
- if event_state == "CRITICAL":
- self.events_list[event_index]['state'] = event_state
- # Min value
+ # It's an ongoing event, set the end time to -1
+ self.events_list[event_index]['end'] = -1
+
+ # Min/Max/Sum/Count/Avergae value
self.events_list[event_index]['min'] = min(self.events_list[event_index]['min'], event_value)
- # Max value
self.events_list[event_index]['max'] = max(self.events_list[event_index]['max'], event_value)
- # Average value
self.events_list[event_index]['sum'] += event_value
self.events_list[event_index]['count'] += 1
self.events_list[event_index]['avg'] = self.events_list[event_index]['sum'] / self.events_list[event_index]['count']
- # TOP PROCESS LIST (only for CRITICAL ALERT)
if event_state == "CRITICAL":
+ # Avoid to change from CRITICAL to WARNING
+ # If an events have reached the CRITICAL state, it can't go back to WARNING
+ self.events_list[event_index]['state'] = event_state
+
+ # TOP PROCESS LIST (only for CRITICAL ALERT)
events_sort_key = self.get_event_sort_key(event_type)
+
# Sort the current process list to retrieve the TOP 3 processes
self.events_list[event_index]['top'] = [p['name'] for p in sort_stats(proc_list, events_sort_key)[0:3]]
self.events_list[event_index]['sort'] = events_sort_key
@@ -384,6 +377,19 @@ class GlancesEvents(object):
return True
+ def _close_event(self, event_time, event_index):
+ """Close an event in the list"""
+ # Reset the automatic process sort key
+ self.reset_process_sort()
+
+ # Set the end of the events
+ if event_time - self.events_list[event_index]['begin'] >= self.min_duration:
+ # If event is >= min_duration seconds
+ self.events_list[event_index]['end'] = event_time
+ else:
+ # If event < min_duration seconds, ignore
+ self.events_list.remove(self.events_list[event_index])
+
def clean(self, critical=False):
"""Clean the logs list by deleting finished items.
diff --git a/glances/outputs/static/js/components/plugin-alert.vue b/glances/outputs/static/js/components/plugin-alert.vue
index 5eb7cabf..48a0478f 100644
--- a/glances/outputs/static/js/components/plugin-alert.vue
+++ b/glances/outputs/static/js/components/plugin-alert.vue
@@ -53,6 +53,7 @@ export default {
alert.avg = alertalertStats.avg;
alert.max = alertalertStats.max;
alert.top = alertalertStats.top.join(', ');
+ alert.global = alertalertStats.global;
if (!alert.ongoing) {
const duration = alert.end - alert.begin;
diff --git a/glances/outputs/static/public/glances.js b/glances/outputs/static/public/glances.js
index 220bf9ca..5ecc180a 100644
--- a/glances/outputs/static/public/glances.js
+++ b/glances/outputs/static/public/glances.js
@@ -28,4 +28,4 @@ function n(e){return"[object Object]"===Object.prototype.toString.call(e)}Object
* https://jaywcjlove.github.io/hotkeys-js
* Licensed under the MIT license
*/
-var mo="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase().indexOf("firefox")>0;function bo(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),(function(){n(window.event)}))}function vo(e,t){for(var n=t.slice(0,t.length-1),r=0;r<n.length;r++)n[r]=e[n[r].toLowerCase()];return n}function yo(e){"string"!=typeof e&&(e="");for(var t=(e=e.replace(/\s/g,"")).split(","),n=t.lastIndexOf("");n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}for(var wo={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":mo?173:189,"=":mo?61:187,";":mo?59:186,"'":222,"[":219,"]":221,"\\":220},xo={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},_o={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},ko={16:!1,18:!1,17:!1,91:!1},So={},Co=1;Co<20;Co++)wo["f".concat(Co)]=111+Co;var To=[],Ao=!1,Eo="all",Oo=[],Io=function(e){return wo[e.toLowerCase()]||xo[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function Po(e){Eo=e||"all"}function No(){return Eo||"all"}var Lo=function(e){var t=e.key,n=e.scope,r=e.method,i=e.splitKey,s=void 0===i?"+":i;yo(t).forEach((function(e){var t=e.split(s),i=t.length,o=t[i-1],a="*"===o?"*":Io(o);if(So[a]){n||(n=No());var l=i>1?vo(xo,t):[];So[a]=So[a].filter((function(e){return!((!r||e.method===r)&&e.scope===n&&function(e,t){for(var n=e.length>=t.length?e:t,r=e.length>=t.length?t:e,i=!0,s=0;s<n.length;s++)-1===r.indexOf(n[s])&&(i=!1);return i}(e.mods,l))}))}}))};function Do(e,t,n,r){var i;if(t.element===r&&(t.scope===n||"all"===t.scope)){for(var s in i=t.mods.length>0,ko)Object.prototype.hasOwnProperty.call(ko,s)&&(!ko[s]&&t.mods.indexOf(+s)>-1||ko[s]&&-1===t.mods.indexOf(+s))&&(i=!1);(0!==t.mods.length||ko[16]||ko[18]||ko[17]||ko[91])&&!i&&"*"!==t.shortcut||(t.keys=[],t.keys=t.keys.concat(To),!1===t.method(e,t)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function Mo(e,t){var n=So["*"],r=e.keyCode||e.which||e.charCode;if(jo.filter.call(this,e)){if(93!==r&&224!==r||(r=91),-1===To.indexOf(r)&&229!==r&&To.push(r),["ctrlKey","altKey","shiftKey","metaKey"].forEach((function(t){var n=_o[t];e[t]&&-1===To.indexOf(n)?To.push(n):!e[t]&&To.indexOf(n)>-1?To.splice(To.indexOf(n),1):"metaKey"===t&&e[t]&&3===To.length&&(e.ctrlKey||e.shiftKey||e.altKey||(To=To.slice(To.indexOf(n))))})),r in ko){for(var i in ko[r]=!0,xo)xo[i]===r&&(jo[i]=!0);if(!n)return}for(var s in ko)Object.prototype.hasOwnProperty.call(ko,s)&&(ko[s]=e[_o[s]]);e.getModifierState&&(!e.altKey||e.ctrlKey)&&e.getModifierState("AltGraph")&&(-1===To.indexOf(17)&&To.push(17),-1===To.indexOf(18)&&To.push(18),ko[17]=!0,ko[18]=!0);var o=No();if(n)for(var a=0;a<n.length;a++)n[a].scope===o&&("keydown"===e.type&&n[a].keydown||"keyup"===e.type&&n[a].keyup)&&Do(e,n[a],o,t);if(r in So)for(var l=0;l<So[r].length;l++)if(("keydown"===e.type&&So[r][l].keydown||"keyup"===e.type&&So[r][l].keyup)&&So[r][l].key){for(var c=So[r][l],u=c.splitKey,d=c.key.split(u),f=[],p=0;p<d.length;p++)f.push(Io(d[p]));f.sort().join("")===To.sort().join("")&&Do(e,c,o,t)}}}function jo(e,t,n){To=[];var r=yo(e),i=[],s="all",o=document,a=0,l=!1,c=!0,u="+",d=!1;for(void 0===n&&"function"==typeof t&&(n=t),"[object Object]"===Object.prototype.toString.call(t)&&(t.scope&&(s=t.scope),t.element&&(o=t.element),t.keyup&&(l=t.keyup),void 0!==t.keydown&&(c=t.keydown),void 0!==t.capture&&(d=t.capture),"string"==typeof t.splitKey&&(u=t.splitKey)),"string"==typeof t&&(s=t);a<r.length;a++)i=[],(e=r[a].split(u)).length>1&&(i=vo(xo,e)),(e="*"===(e=e[e.length-1])?"*":Io(e))in So||(So[e]=[]),So[e].push({keyup:l,keydown:c,scope:s,mods:i,shortcut:r[a],method:n,key:r[a],splitKey:u,element:o});void 0!==o&&!function(e){return Oo.indexOf(e)>-1}(o)&&window&&(Oo.push(o),bo(o,"keydown",(function(e){Mo(e,o)}),d),Ao||(Ao=!0,bo(window,"focus",(function(){To=[]}),d)),bo(o,"keyup",(function(e){Mo(e,o),function(e){var t=e.keyCode||e.which||e.charCode,n=To.indexOf(t);if(n>=0&&To.splice(n,1),e.key&&"meta"===e.key.toLowerCase()&&To.splice(0,To.length),93!==t&&224!==t||(t=91),t in ko)for(var r in ko[t]=!1,xo)xo[r]===t&&(jo[r]=!1)}(e)}),d))}var Ro={getPressedKeyString:function(){return To.map((function(e){return t=e,Object.keys(wo).find((function(e){return wo[e]===t}))||function(e){return Object.keys(xo).find((function(t){return xo[t]===e}))}(e)||String.fromCharCode(e);var t}))},setScope:Po,getScope:No,deleteScope:function(e,t){var n,r;for(var i in e||(e=No()),So)if(Object.prototype.hasOwnProperty.call(So,i))for(n=So[i],r=0;r<n.length;)n[r].scope===e?n.splice(r,1):r++;No()===e&&Po(t||"all")},getPressedKeyCodes:function(){return To.slice(0)},getAllKeyCodes:function(){var e=[];return Object.keys(So).forEach((function(t){So[t].forEach((function(t){var n=t.key,r=t.scope,i=t.mods,s=t.shortcut;e.push({scope:r,shortcut:s,mods:i,keys:n.split("+").map((function(e){return Io(e)}))})}))})),e},isPressed:function(e){return"string"==typeof e&&(e=Io(e)),-1!==To.indexOf(e)},filter:function(e){var t=e.target||e.srcElement,n=t.tagName,r=!0;return!t.isContentEditable&&("INPUT"!==n&&"TEXTAREA"!==n&&"SELECT"!==n||t.readOnly)||(r=!1),r},trigger:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";Object.keys(So).forEach((function(n){So[n].filter((function(n){return n.scope===t&&n.shortcut===e})).forEach((function(e){e&&e.method&&e.method()}))}))},unbind:function(e){if(void 0===e)Object.keys(So).forEach((function(e){return delete So[e]}));else if(Array.isArray(e))e.forEach((function(e){e.key&&Lo(e)}));else if("object"==typeof e)e.key&&Lo(e);else if("string"==typeof e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i=n[0],s=n[1];"function"==typeof i&&(s=i,i=""),Lo({key:e,scope:i,method:s,splitKey:"+"})}},keyMap:wo,modifier:xo,modifierMap:_o};for(var qo in Ro)Object.prototype.hasOwnProperty.call(Ro,qo)&&(jo[qo]=Ro[qo]);if("undefined"!=typeof window){var Bo=window.hotkeys;jo.noConflict=function(e){return e&&window.hotkeys===jo&&(window.hotkeys=Bo),jo},window.hotkeys=jo}const Uo=kt({args:void 0,config:void 0,data:void 0,status:"IDLE"});var Fo=n(9049),zo=n.n(Fo);const $o=new class{limits={};limitSuffix=["critical","careful","warning"];setLimits(e){this.limits=e}getAlert(e,t,n,r,i){var s=(i=i||!1)?"_log":"",o=100*(n=n||0)/(r=r||100);if(null!=this.limits[e])for(var a=0;a<this.limitSuffix.length;a++){var l=t+this.limitSuffix[a];if(o>=this.limits[e][l]){var c=l.lastIndexOf("_");return l.substring(c+1)+s}}return"ok"+s}getAlertLog(e,t,n,r){return this.getAlert(e,t,n,r,!0)}};const Ho=new class{data=void 0;init(e=60){let t;const n=()=>(Uo.status="PENDING",Promise.all([fetch("api/4/all",{method:"GET"}).then((e=>e.json())),fetch("api/4/all/views",{method:"GET"}).then((e=>e.json()))]).then((e=>{const t={stats:e[0],views:e[1],isBsd:"FreeBSD"===e[0].system.os_name,isLinux:"Linux"===e[0].system.os_name,isSunOS:"SunOS"===e[0].system.os_name,isMac:"Darwin"===e[0].system.os_name,isWindows:"Windows"===e[0].system.os_name};this.data=t,Uo.data=t,Uo.status="SUCCESS"})).catch((e=>{console.log(e),Uo.status="FAILURE"})).then((()=>{t&&clearTimeout(t),t=setTimeout(n,1e3*e)})));n(),fetch("api/4/all/limi