mirror of https://github.com/nicolargo/glances.git
Format code and update docs/webui
This commit is contained in:
parent
6e95892e41
commit
e8563a0fc4
4
Makefile
4
Makefile
|
|
@ -66,13 +66,13 @@ test: ## Run unit tests
|
|||
./venv/bin/python ./unitest.py
|
||||
./venv/bin/python ./unitest-restful.py
|
||||
./venv/bin/python ./unitest-xmlrpc.py
|
||||
./venv/bin/python -m black ./glances --check --exclude outputs/static
|
||||
./venv-dev/bin/python -m black ./glances --check --exclude outputs/static
|
||||
|
||||
test-with-upgrade: venv-upgrade venv-dev-upgrade ## Upgrade deps and run unit tests
|
||||
./venv/bin/python ./unitest.py
|
||||
./venv/bin/python ./unitest-restful.py
|
||||
./venv/bin/python ./unitest-xmlrpc.py
|
||||
./venv/bin/python -m black ./glances --check --exclude outputs/static
|
||||
./venv/bin-dev/python -m black ./glances --check --exclude outputs/static
|
||||
|
||||
test-min: ## Run unit tests in minimal environment
|
||||
./venv-min/bin/python ./unitest.py
|
||||
|
|
|
|||
244
docs/api.rst
244
docs/api.rst
|
|
@ -141,7 +141,7 @@ Get plugin stats::
|
|||
"refresh": 3.0,
|
||||
"regex": True,
|
||||
"result": None,
|
||||
"timer": 0.3963778018951416},
|
||||
"timer": 0.3574647903442383},
|
||||
{"count": 0,
|
||||
"countmax": 20.0,
|
||||
"countmin": None,
|
||||
|
|
@ -150,7 +150,7 @@ Get plugin stats::
|
|||
"refresh": 3.0,
|
||||
"regex": True,
|
||||
"result": None,
|
||||
"timer": 0.3962833881378174}]
|
||||
"timer": 0.35736703872680664}]
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ Get a specific item when field matches the given value::
|
|||
"refresh": 3.0,
|
||||
"regex": True,
|
||||
"result": None,
|
||||
"timer": 0.3963778018951416}]}
|
||||
"timer": 0.3574647903442383}]}
|
||||
|
||||
GET cloud
|
||||
---------
|
||||
|
|
@ -219,7 +219,23 @@ GET containers
|
|||
Get plugin stats::
|
||||
|
||||
# curl http://localhost:61208/api/4/containers
|
||||
[]
|
||||
[{"command": "tail -f /dev/null",
|
||||
"cpu": {"total": 0.0},
|
||||
"cpu_percent": 0.0,
|
||||
"created": "2024-05-06T08:20:31.859934699Z",
|
||||
"engine": "docker",
|
||||
"id": "f8d78b334f789955ab6dd0739c0bbb7e26ae3f24ed9e42c4a0d218a30377d2c8",
|
||||
"image": ["catthehacker/ubuntu:act-22.04"],
|
||||
"io": {"cumulative_ior": 100855808, "cumulative_iow": 0},
|
||||
"key": "name",
|
||||
"memory": {"inactive_file": 1704656896,
|
||||
"limit": 16422473728,
|
||||
"usage": 1984933888},
|
||||
"memory_usage": 1984933888,
|
||||
"name": "act-test-test-freebsd-700362a4fd49fe930f7ab89909c5ca853cd3a832c27b6ac4e363947b0dd29bef",
|
||||
"network": {},
|
||||
"status": "running",
|
||||
"uptime": "yesterday"}]
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -240,6 +256,35 @@ Fields descriptions:
|
|||
* **pod_name**: Pod name (only with Podman) (unit is *None*)
|
||||
* **pod_id**: Pod ID (only with Podman) (unit is *None*)
|
||||
|
||||
Get a specific field::
|
||||
|
||||
# curl http://localhost:61208/api/4/containers/name
|
||||
{"name": ["act-test-test-freebsd-700362a4fd49fe930f7ab89909c5ca853cd3a832c27b6ac4e363947b0dd29bef"]}
|
||||
|
||||
Get a specific item when field matches the given value::
|
||||
|
||||
# curl http://localhost:61208/api/4/containers/name/act-test-test-freebsd-700362a4fd49fe930f7ab89909c5ca853cd3a832c27b6ac4e363947b0dd29bef
|
||||
{"act-test-test-freebsd-700362a4fd49fe930f7ab89909c5ca853cd3a832c27b6ac4e363947b0dd29bef": [{"command": "tail "
|
||||
"-f "
|
||||
"/dev/null",
|
||||
"cpu": {"total": 0.0},
|
||||
"cpu_percent": 0.0,
|
||||
"created": "2024-05-06T08:20:31.859934699Z",
|
||||
"engine": "docker",
|
||||
"id": "f8d78b334f789955ab6dd0739c0bbb7e26ae3f24ed9e42c4a0d218a30377d2c8",
|
||||
"image": ["catthehacker/ubuntu:act-22.04"],
|
||||
"io": {"cumulative_ior": 100855808,
|
||||
"cumulative_iow": 0},
|
||||
"key": "name",
|
||||
"memory": {"inactive_file": 1704656896,
|
||||
"limit": 16422473728,
|
||||
"usage": 1984933888},
|
||||
"memory_usage": 1984933888,
|
||||
"name": "act-test-test-freebsd-700362a4fd49fe930f7ab89909c5ca853cd3a832c27b6ac4e363947b0dd29bef",
|
||||
"network": {},
|
||||
"status": "running",
|
||||
"uptime": "yesterday"}]}
|
||||
|
||||
GET core
|
||||
--------
|
||||
|
||||
|
|
@ -265,18 +310,18 @@ Get plugin stats::
|
|||
|
||||
# curl http://localhost:61208/api/4/cpu
|
||||
{"cpucore": 16,
|
||||
"ctx_switches": 542181838,
|
||||
"ctx_switches": 100084028,
|
||||
"guest": 0.0,
|
||||
"idle": 3.0,
|
||||
"interrupts": 420410414,
|
||||
"interrupts": 99754405,
|
||||
"iowait": 0.0,
|
||||
"irq": 0.0,
|
||||
"nice": 0.0,
|
||||
"soft_interrupts": 157550864,
|
||||
"soft_interrupts": 30928307,
|
||||
"steal": 0.0,
|
||||
"syscalls": 0,
|
||||
"system": 0.0,
|
||||
"total": 0.0,
|
||||
"system": 1.0,
|
||||
"total": 25.0,
|
||||
"user": 0.0}
|
||||
|
||||
Fields descriptions:
|
||||
|
|
@ -310,7 +355,7 @@ Fields descriptions:
|
|||
Get a specific field::
|
||||
|
||||
# curl http://localhost:61208/api/4/cpu/total
|
||||
{"total": 0.0}
|
||||
{"total": 25.0}
|
||||
|
||||
GET diskio
|
||||
----------
|
||||
|
|
@ -320,14 +365,14 @@ Get plugin stats::
|
|||
# curl http://localhost:61208/api/4/diskio
|
||||
[{"disk_name": "nvme0n1",
|
||||
"key": "disk_name",
|
||||
"read_bytes": 7451868160,
|
||||
"read_count": 348351,
|
||||
"write_bytes": 115766309888,
|
||||
"write_count": 3401479},
|
||||
"read_bytes": 5494942208,
|
||||
"read_count": 276248,
|
||||
"write_bytes": 12631118848,
|
||||
"write_count": 434825},
|
||||
{"disk_name": "nvme0n1p1",
|
||||
"key": "disk_name",
|
||||
"read_bytes": 7489024,
|
||||
"read_count": 601,
|
||||
"read_bytes": 7484416,
|
||||
"read_count": 592,
|
||||
"write_bytes": 1024,
|
||||
"write_count": 2}]
|
||||
|
||||
|
|
@ -363,10 +408,10 @@ Get a specific item when field matches the given value::
|
|||
# curl http://localhost:61208/api/4/diskio/disk_name/nvme0n1
|
||||
{"nvme0n1": [{"disk_name": "nvme0n1",
|
||||
"key": "disk_name",
|
||||
"read_bytes": 7451868160,
|
||||
"read_count": 348351,
|
||||
"write_bytes": 115766309888,
|
||||
"write_count": 3401479}]}
|
||||
"read_bytes": 5494942208,
|
||||
"read_count": 276248,
|
||||
"write_bytes": 12631118848,
|
||||
"write_count": 434825}]}
|
||||
|
||||
GET folders
|
||||
-----------
|
||||
|
|
@ -393,13 +438,13 @@ Get plugin stats::
|
|||
|
||||
# curl http://localhost:61208/api/4/fs
|
||||
[{"device_name": "/dev/mapper/ubuntu--vg-ubuntu--lv",
|
||||
"free": 915914182656,
|
||||
"free": 906483245056,
|
||||
"fs_type": "ext4",
|
||||
"key": "mnt_point",
|
||||
"mnt_point": "/",
|
||||
"percent": 3.9,
|
||||
"percent": 4.8,
|
||||
"size": 1003736440832,
|
||||
"used": 36759752704}]
|
||||
"used": 46190690304}]
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -420,13 +465,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--vg-ubuntu--lv",
|
||||
"free": 915914182656,
|
||||
"free": 906483245056,
|
||||
"fs_type": "ext4",
|
||||
"key": "mnt_point",
|
||||
"mnt_point": "/",
|
||||
"percent": 3.9,
|
||||
"percent": 4.8,
|
||||
"size": 1003736440832,
|
||||
"used": 36759752704}]}
|
||||
"used": 46190690304}]}
|
||||
|
||||
GET gpu
|
||||
-------
|
||||
|
|
@ -499,10 +544,7 @@ GET load
|
|||
Get plugin stats::
|
||||
|
||||
# curl http://localhost:61208/api/4/load
|
||||
{"cpucore": 16,
|
||||
"min1": 1.8212890625,
|
||||
"min15": 1.0576171875,
|
||||
"min5": 1.2783203125}
|
||||
{"cpucore": 16, "min1": 0.52685546875, "min15": 1.25390625, "min5": 1.544921875}
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -514,7 +556,7 @@ Fields descriptions:
|
|||
Get a specific field::
|
||||
|
||||
# curl http://localhost:61208/api/4/load/min1
|
||||
{"min1": 1.8212890625}
|
||||
{"min1": 0.52685546875}
|
||||
|
||||
GET mem
|
||||
-------
|
||||
|
|
@ -522,16 +564,16 @@ GET mem
|
|||
Get plugin stats::
|
||||
|
||||
# curl http://localhost:61208/api/4/mem
|
||||
{"active": 5652090880,
|
||||
"available": 6879588352,
|
||||
"buffers": 609959936,
|
||||
"cached": 6387052544,
|
||||
"free": 6879588352,
|
||||
"inactive": 7342874624,
|
||||
"percent": 58.1,
|
||||
"shared": 1032945664,
|
||||
"total": 16422477824,
|
||||
"used": 9542889472}
|
||||
{"active": 7115952128,
|
||||
"available": 8999600128,
|
||||
"buffers": 268685312,
|
||||
"cached": 9109741568,
|
||||
"free": 8999600128,
|
||||
"inactive": 5429415936,
|
||||
"percent": 45.2,
|
||||
"shared": 1431875584,
|
||||
"total": 16422473728,
|
||||
"used": 7422873600}
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -550,7 +592,7 @@ Fields descriptions:
|
|||
Get a specific field::
|
||||
|
||||
# curl http://localhost:61208/api/4/mem/total
|
||||
{"total": 16422477824}
|
||||
{"total": 16422473728}
|
||||
|
||||
GET memswap
|
||||
-----------
|
||||
|
|
@ -558,13 +600,13 @@ GET memswap
|
|||
Get plugin stats::
|
||||
|
||||
# curl http://localhost:61208/api/4/memswap
|
||||
{"free": 4147900416,
|
||||
"percent": 3.4,
|
||||
"sin": 1359872,
|
||||
"sout": 145010688,
|
||||
{"free": 4293652480,
|
||||
"percent": 0.0,
|
||||
"sin": 0,
|
||||
"sout": 131072,
|
||||
"time_since_update": 1,
|
||||
"total": 4294963200,
|
||||
"used": 147062784}
|
||||
"used": 1310720}
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -589,15 +631,15 @@ Get plugin stats::
|
|||
# curl http://localhost:61208/api/4/network
|
||||
[{"alias": None,
|
||||
"bytes_all": 0,
|
||||
"bytes_all_gauge": 7230851205,
|
||||
"bytes_all_gauge": 2153845053,
|
||||
"bytes_recv": 0,
|
||||
"bytes_recv_gauge": 6965449347,
|
||||
"bytes_recv_gauge": 2054902380,
|
||||
"bytes_sent": 0,
|
||||
"bytes_sent_gauge": 265401858,
|
||||
"bytes_sent_gauge": 98942673,
|
||||
"interface_name": "wlp0s20f3",
|
||||
"key": "interface_name",
|
||||
"speed": 0,
|
||||
"time_since_update": 0.39971184730529785}]
|
||||
"time_since_update": 0.37114882469177246}]
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -626,15 +668,15 @@ Get a specific item when field matches the given value::
|
|||
# curl http://localhost:61208/api/4/network/interface_name/wlp0s20f3
|
||||
{"wlp0s20f3": [{"alias": None,
|
||||
"bytes_all": 0,
|
||||
"bytes_all_gauge": 7230851205,
|
||||
"bytes_all_gauge": 2153845053,
|
||||
"bytes_recv": 0,
|
||||
"bytes_recv_gauge": 6965449347,
|
||||
"bytes_recv_gauge": 2054902380,
|
||||
"bytes_sent": 0,
|
||||
"bytes_sent_gauge": 265401858,
|
||||
"bytes_sent_gauge": 98942673,
|
||||
"interface_name": "wlp0s20f3",
|
||||
"key": "interface_name",
|
||||
"speed": 0,
|
||||
"time_since_update": 0.39971184730529785}]}
|
||||
"time_since_update": 0.37114882469177246}]}
|
||||
|
||||
GET now
|
||||
-------
|
||||
|
|
@ -642,7 +684,7 @@ GET now
|
|||
Get plugin stats::
|
||||
|
||||
# curl http://localhost:61208/api/4/now
|
||||
{"custom": "2024-05-03 09:53:17 CEST", "iso": "2024-05-03T09:53:17+02:00"}
|
||||
{"custom": "2024-05-07 11:46:44 CEST", "iso": "2024-05-07T11:46:44+02:00"}
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -652,7 +694,7 @@ Fields descriptions:
|
|||
Get a specific field::
|
||||
|
||||
# curl http://localhost:61208/api/4/now/iso
|
||||
{"iso": "2024-05-03T09:53:17+02:00"}
|
||||
{"iso": "2024-05-07T11:46:44+02:00"}
|
||||
|
||||
GET percpu
|
||||
----------
|
||||
|
|
@ -676,7 +718,7 @@ Get plugin stats::
|
|||
{"cpu_number": 1,
|
||||
"guest": 0.0,
|
||||
"guest_nice": 0.0,
|
||||
"idle": 0.0,
|
||||
"idle": 1.0,
|
||||
"iowait": 0.0,
|
||||
"irq": 0.0,
|
||||
"key": "cpu_number",
|
||||
|
|
@ -684,7 +726,7 @@ Get plugin stats::
|
|||
"softirq": 0.0,
|
||||
"steal": 0.0,
|
||||
"system": 0.0,
|
||||
"total": 100.0,
|
||||
"total": 99.0,
|
||||
"user": 0.0}]
|
||||
|
||||
Fields descriptions:
|
||||
|
|
@ -719,7 +761,7 @@ Get plugin stats::
|
|||
"port": 0,
|
||||
"refresh": 30,
|
||||
"rtt_warning": None,
|
||||
"status": 0.007143,
|
||||
"status": 0.008626,
|
||||
"timeout": 3}]
|
||||
|
||||
Fields descriptions:
|
||||
|
|
@ -747,7 +789,7 @@ Get a specific item when field matches the given value::
|
|||
"port": 0,
|
||||
"refresh": 30,
|
||||
"rtt_warning": None,
|
||||
"status": 0.007143,
|
||||
"status": 0.008626,
|
||||
"timeout": 3}]}
|
||||
|
||||
GET processcount
|
||||
|
|
@ -756,7 +798,7 @@ GET processcount
|
|||
Get plugin stats::
|
||||
|
||||
# curl http://localhost:61208/api/4/processcount
|
||||
{"pid_max": 0, "running": 1, "sleeping": 292, "thread": 1754, "total": 428}
|
||||
{"pid_max": 0, "running": 1, "sleeping": 287, "thread": 1710, "total": 432}
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -769,7 +811,7 @@ Fields descriptions:
|
|||
Get a specific field::
|
||||
|
||||
# curl http://localhost:61208/api/4/processcount/total
|
||||
{"total": 428}
|
||||
{"total": 432}
|
||||
|
||||
GET processlist
|
||||
---------------
|
||||
|
|
@ -809,14 +851,14 @@ GET quicklook
|
|||
Get plugin stats::
|
||||
|
||||
# curl http://localhost:61208/api/4/quicklook
|
||||
{"cpu": 0.0,
|
||||
{"cpu": 25.0,
|
||||
"cpu_hz": 4475000000.0,
|
||||
"cpu_hz_current": 1338323312.5,
|
||||
"cpu_hz_current": 1527240625.0000005,
|
||||
"cpu_log_core": 16,
|
||||
"cpu_name": "13th Gen Intel(R) Core(TM) i7-13620H",
|
||||
"cpu_phys_core": 10,
|
||||
"load": 6.6,
|
||||
"mem": 58.1,
|
||||
"load": 7.8,
|
||||
"mem": 45.2,
|
||||
"percpu": [{"cpu_number": 0,
|
||||
"guest": 0.0,
|
||||
"guest_nice": 0.0,
|
||||
|
|
@ -833,7 +875,7 @@ Get plugin stats::
|
|||
{"cpu_number": 1,
|
||||
"guest": 0.0,
|
||||
"guest_nice": 0.0,
|
||||
"idle": 0.0,
|
||||
"idle": 1.0,
|
||||
"iowait": 0.0,
|
||||
"irq": 0.0,
|
||||
"key": "cpu_number",
|
||||
|
|
@ -841,7 +883,7 @@ Get plugin stats::
|
|||
"softirq": 0.0,
|
||||
"steal": 0.0,
|
||||
"system": 0.0,
|
||||
"total": 100.0,
|
||||
"total": 99.0,
|
||||
"user": 0.0},
|
||||
{"cpu_number": 2,
|
||||
"guest": 0.0,
|
||||
|
|
@ -885,7 +927,7 @@ Get plugin stats::
|
|||
{"cpu_number": 5,
|
||||
"guest": 0.0,
|
||||
"guest_nice": 0.0,
|
||||
"idle": 1.0,
|
||||
"idle": 0.0,
|
||||
"iowait": 0.0,
|
||||
"irq": 0.0,
|
||||
"key": "cpu_number",
|
||||
|
|
@ -893,7 +935,7 @@ Get plugin stats::
|
|||
"softirq": 0.0,
|
||||
"steal": 0.0,
|
||||
"system": 0.0,
|
||||
"total": 99.0,
|
||||
"total": 100.0,
|
||||
"user": 0.0},
|
||||
{"cpu_number": 6,
|
||||
"guest": 0.0,
|
||||
|
|
@ -937,7 +979,7 @@ Get plugin stats::
|
|||
{"cpu_number": 9,
|
||||
"guest": 0.0,
|
||||
"guest_nice": 0.0,
|
||||
"idle": 0.0,
|
||||
"idle": 1.0,
|
||||
"iowait": 0.0,
|
||||
"irq": 0.0,
|
||||
"key": "cpu_number",
|
||||
|
|
@ -945,7 +987,7 @@ Get plugin stats::
|
|||
"softirq": 0.0,
|
||||
"steal": 0.0,
|
||||
"system": 0.0,
|
||||
"total": 100.0,
|
||||
"total": 99.0,
|
||||
"user": 0.0},
|
||||
{"cpu_number": 10,
|
||||
"guest": 0.0,
|
||||
|
|
@ -963,7 +1005,7 @@ Get plugin stats::
|
|||
{"cpu_number": 11,
|
||||
"guest": 0.0,
|
||||
"guest_nice": 0.0,
|
||||
"idle": 1.0,
|
||||
"idle": 0.0,
|
||||
"iowait": 0.0,
|
||||
"irq": 0.0,
|
||||
"key": "cpu_number",
|
||||
|
|
@ -971,7 +1013,7 @@ Get plugin stats::
|
|||
"softirq": 0.0,
|
||||
"steal": 0.0,
|
||||
"system": 0.0,
|
||||
"total": 99.0,
|
||||
"total": 100.0,
|
||||
"user": 0.0},
|
||||
{"cpu_number": 12,
|
||||
"guest": 0.0,
|
||||
|
|
@ -1015,7 +1057,7 @@ Get plugin stats::
|
|||
{"cpu_number": 15,
|
||||
"guest": 0.0,
|
||||
"guest_nice": 0.0,
|
||||
"idle": 0.0,
|
||||
"idle": 1.0,
|
||||
"iowait": 0.0,
|
||||
"irq": 0.0,
|
||||
"key": "cpu_number",
|
||||
|
|
@ -1023,9 +1065,9 @@ Get plugin stats::
|
|||
"softirq": 0.0,
|
||||
"steal": 0.0,
|
||||
"system": 0.0,
|
||||
"total": 100.0,
|
||||
"total": 99.0,
|
||||
"user": 0.0}],
|
||||
"swap": 3.4}
|
||||
"swap": 0.0}
|
||||
|
||||
Fields descriptions:
|
||||
|
||||
|
|
@ -1063,7 +1105,7 @@ Get plugin stats::
|
|||
"label": "Ambient",
|
||||
"type": "temperature_core",
|
||||
"unit": "C",
|
||||
"value": 34,
|
||||
"value": 35,
|
||||
"warning": 0},
|
||||
{"critical": None,
|
||||
"key": "label",
|
||||
|
|
@ -1131,7 +1173,7 @@ Get a specific item when field matches the given value::
|
|||
"label": "Ambient",
|
||||
"type": "temperature_core",
|
||||
"unit": "C",
|
||||
"value": 34,
|
||||
"value": 35,
|
||||
"warning": 0}]}
|
||||
|
||||
GET smart
|
||||
|
|
@ -1175,7 +1217,7 @@ GET uptime
|
|||
Get plugin stats::
|
||||
|
||||
# curl http://localhost:61208/api/4/uptime
|
||||
"5 days, 15:41:19"
|
||||
"1 day, 2:23:04"
|
||||
|
||||
GET version
|
||||
-----------
|
||||
|
|
@ -1192,8 +1234,8 @@ Get plugin stats::
|
|||
|
||||
# curl http://localhost:61208/api/4/wifi
|
||||
[{"key": "ssid",
|
||||
"quality_level": -57.0,
|
||||
"quality_link": 53.0,
|
||||
"quality_level": -61.0,
|
||||
"quality_link": 49.0,
|
||||
"ssid": "wlp0s20f3"}]
|
||||
|
||||
Get a specific field::
|
||||
|
|
@ -1205,8 +1247,8 @@ Get a specific item when field matches the given value::
|
|||
|
||||
# curl http://localhost:61208/api/4/wifi/ssid/wlp0s20f3
|
||||
{"wlp0s20f3": [{"key": "ssid",
|
||||
"quality_level": -57.0,
|
||||
"quality_link": 53.0,
|
||||
"quality_level": -61.0,
|
||||
"quality_link": 49.0,
|
||||
"ssid": "wlp0s20f3"}]}
|
||||
|
||||
GET all stats
|
||||
|
|
@ -1251,34 +1293,34 @@ GET stats history
|
|||
History of a plugin::
|
||||
|
||||
# curl http://localhost:61208/api/4/cpu/history
|
||||
{"system": [["2024-05-03T09:53:18.269256", 0.0],
|
||||
["2024-05-03T09:53:19.320800", 0.0],
|
||||
["2024-05-03T09:53:20.396402", 0.0]],
|
||||
"user": [["2024-05-03T09:53:18.269244", 0.0],
|
||||
["2024-05-03T09:53:19.320793", 1.0],
|
||||
["2024-05-03T09:53:20.396392", 1.0]]}
|
||||
{"system": [["2024-05-07T11:46:45.322880", 1.0],
|
||||
["2024-05-07T11:46:46.376121", 0.0],
|
||||
["2024-05-07T11:46:47.453787", 0.0]],
|
||||
"user": [["2024-05-07T11:46:45.322868", 0.0],
|
||||
["2024-05-07T11:46:46.376117", 0.0],
|
||||
["2024-05-07T11:46:47.453775", 0.0]]}
|
||||
|
||||
Limit history to last 2 values::
|
||||
|
||||
# curl http://localhost:61208/api/4/cpu/history/2
|
||||
{"system": [["2024-05-03T09:53:19.320800", 0.0],
|
||||
["2024-05-03T09:53:20.396402", 0.0]],
|
||||
"user": [["2024-05-03T09:53:19.320793", 1.0],
|
||||
["2024-05-03T09:53:20.396392", 1.0]]}
|
||||
{"system": [["2024-05-07T11:46:46.376121", 0.0],
|
||||
["2024-05-07T11:46:47.453787", 0.0]],
|
||||
"user": [["2024-05-07T11:46:46.376117", 0.0],
|
||||
["2024-05-07T11:46:47.453775", 0.0]]}
|
||||
|
||||
History for a specific field::
|
||||
|
||||
# curl http://localhost:61208/api/4/cpu/system/history
|
||||
{"system": [["2024-05-03T09:53:17.063839", 0.0],
|
||||
["2024-05-03T09:53:18.269256", 0.0],
|
||||
["2024-05-03T09:53:19.320800", 0.0],
|
||||
["2024-05-03T09:53:20.396402", 0.0]]}
|
||||
{"system": [["2024-05-07T11:46:44.106241", 1.0],
|
||||
["2024-05-07T11:46:45.322880", 1.0],
|
||||
["2024-05-07T11:46:46.376121", 0.0],
|
||||
["2024-05-07T11:46:47.453787", 0.0]]}
|
||||
|
||||
Limit history for a specific field to last 2 values::
|
||||
|
||||
# curl http://localhost:61208/api/4/cpu/system/history
|
||||
{"system": [["2024-05-03T09:53:19.320800", 0.0],
|
||||
["2024-05-03T09:53:20.396402", 0.0]]}
|
||||
{"system": [["2024-05-07T11:46:46.376121", 0.0],
|
||||
["2024-05-07T11:46:47.453787", 0.0]]}
|
||||
|
||||
GET limits (used for thresholds)
|
||||
--------------------------------
|
||||
|
|
|
|||
|
|
@ -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" "May 03, 2024" "4.0.0_rc02" "Glances"
|
||||
.TH "GLANCES" "1" "May 07, 2024" "4.0.0_rc02" "Glances"
|
||||
.SH NAME
|
||||
glances \- An eye on your system
|
||||
.SH SYNOPSIS
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ else:
|
|||
|
||||
|
||||
class GlancesActions(object):
|
||||
|
||||
"""This class manage action if an alert is reached."""
|
||||
|
||||
def __init__(self, args=None):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ from glances.processes import glances_processes
|
|||
|
||||
|
||||
class AmpsList(object):
|
||||
|
||||
"""This class describes the optional application monitoring process list.
|
||||
|
||||
The AMP list is a list of processes with a specific monitoring action.
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ zeroconf_type = "_%s._tcp.local." % 'glances'
|
|||
|
||||
|
||||
class AutoDiscovered(object):
|
||||
|
||||
"""Class to manage the auto discovered servers dict."""
|
||||
|
||||
def __init__(self):
|
||||
|
|
@ -82,7 +81,6 @@ class AutoDiscovered(object):
|
|||
|
||||
|
||||
class GlancesAutoDiscoverListener(object):
|
||||
|
||||
"""Zeroconf listener for Glances server."""
|
||||
|
||||
def __init__(self):
|
||||
|
|
@ -127,7 +125,6 @@ class GlancesAutoDiscoverListener(object):
|
|||
|
||||
|
||||
class GlancesAutoDiscoverServer(object):
|
||||
|
||||
"""Implementation of the Zeroconf protocol (server side for the Glances client)."""
|
||||
|
||||
def __init__(self, args=None):
|
||||
|
|
@ -164,7 +161,6 @@ class GlancesAutoDiscoverServer(object):
|
|||
|
||||
|
||||
class GlancesAutoDiscoverClient(object):
|
||||
|
||||
"""Implementation of the zeroconf protocol (client side for the Glances server)."""
|
||||
|
||||
def __init__(self, hostname, args=None):
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from glances.timer import Counter
|
|||
|
||||
|
||||
class GlancesClientTransport(Transport):
|
||||
|
||||
"""This class overwrite the default XML-RPC transport and manage timeout."""
|
||||
|
||||
def set_timeout(self, timeout):
|
||||
|
|
@ -31,7 +30,6 @@ class GlancesClientTransport(Transport):
|
|||
|
||||
|
||||
class GlancesClient(object):
|
||||
|
||||
"""This class creates and manages the TCP client."""
|
||||
|
||||
def __init__(self, config=None, args=None, timeout=7, return_to_browser=False):
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from glances.outputs.glances_curses_browser import GlancesCursesBrowser
|
|||
|
||||
|
||||
class GlancesClientBrowser(object):
|
||||
|
||||
"""This class creates and manages the TCP client browser (servers list)."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ def default_config_dir():
|
|||
|
||||
|
||||
class Config(object):
|
||||
|
||||
"""This class is used to access/read config file, if it exists.
|
||||
|
||||
:param config_dir: the path to search for config file
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import psutil
|
|||
|
||||
|
||||
class CpuPercent(object):
|
||||
|
||||
"""Get and store the CPU percent."""
|
||||
|
||||
def __init__(self, cached_timer_cpu=3):
|
||||
|
|
|
|||
|
|
@ -61,9 +61,15 @@ class GlancesEvent:
|
|||
"""Return True if the event is finished"""
|
||||
return self.end != -1
|
||||
|
||||
def update(self, state: str, value: float,
|
||||
sort_key: str = None, proc_list: list = None,
|
||||
proc_desc: str = None, global_msg: str = None):
|
||||
def update(
|
||||
self,
|
||||
state: str,
|
||||
value: float,
|
||||
sort_key: str = None,
|
||||
proc_list: list = None,
|
||||
proc_desc: str = None,
|
||||
global_msg: str = None,
|
||||
):
|
||||
"""Update an ongoing event"""
|
||||
|
||||
self.end = -1
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ def build_global_message():
|
|||
|
||||
|
||||
class GlancesEventsList(object):
|
||||
|
||||
"""This class manages events inside the Glances software.
|
||||
GlancesEventsList is a list of GlancesEvent.
|
||||
GlancesEvent is defined in the event.py file
|
||||
|
|
@ -215,9 +214,9 @@ class GlancesEventsList(object):
|
|||
Return -1 if the item is not found.
|
||||
"""
|
||||
for i in range(self.len()):
|
||||
if (self.events_list[i].is_ongoing() or
|
||||
(event_time - self.events_list[i].end < self.min_interval)) and \
|
||||
self.events_list[i].type == event_type:
|
||||
if (
|
||||
self.events_list[i].is_ongoing() or (event_time - self.events_list[i].end < self.min_interval)
|
||||
) and self.events_list[i].type == event_type:
|
||||
return i
|
||||
return -1
|
||||
|
||||
|
|
@ -267,17 +266,16 @@ class GlancesEventsList(object):
|
|||
event_index = self.__event_exist(event_time, event_type)
|
||||
if event_index < 0:
|
||||
# Event did not exist, add it
|
||||
self._create_event(event_time, event_state, event_type, event_value,
|
||||
proc_desc, global_message)
|
||||
self._create_event(event_time, event_state, event_type, event_value, proc_desc, global_message)
|
||||
else:
|
||||
# Event exist, update it
|
||||
self._update_event(event_time, event_index, event_state, event_type, event_value,
|
||||
proc_list, proc_desc, global_message)
|
||||
self._update_event(
|
||||
event_time, event_index, event_state, event_type, event_value, proc_list, proc_desc, global_message
|
||||
)
|
||||
|
||||
return self.len()
|
||||
|
||||
def _create_event(self, event_time, event_state, event_type, event_value,
|
||||
proc_desc, global_message):
|
||||
def _create_event(self, event_time, event_state, event_type, event_value, proc_desc, global_message):
|
||||
"""Add a new item in the log list.
|
||||
|
||||
Item is added only if the criticality (event_state) is WARNING or CRITICAL.
|
||||
|
|
@ -291,14 +289,20 @@ class GlancesEventsList(object):
|
|||
# Create the new log item
|
||||
# Time is stored in Epoch format
|
||||
# Epoch -> DMYHMS = datetime.fromtimestamp(epoch)
|
||||
event = GlancesEvent(begin=event_time,
|
||||
state=event_state,
|
||||
type=event_type,
|
||||
min=event_value, max=event_value, sum=event_value, count=1, avg=event_value,
|
||||
top=[],
|
||||
desc=proc_desc,
|
||||
sort=glances_processes.sort_key,
|
||||
global_msg=global_message)
|
||||
event = GlancesEvent(
|
||||
begin=event_time,
|
||||
state=event_state,
|
||||
type=event_type,
|
||||
min=event_value,
|
||||
max=event_value,
|
||||
sum=event_value,
|
||||
count=1,
|
||||
avg=event_value,
|
||||
top=[],
|
||||
desc=proc_desc,
|
||||
sort=glances_processes.sort_key,
|
||||
global_msg=global_message,
|
||||
)
|
||||
|
||||
# Add the event to the list
|
||||
self.events_list.insert(0, event)
|
||||
|
|
@ -307,8 +311,9 @@ class GlancesEventsList(object):
|
|||
if self.len() > self.max_events:
|
||||
self.events_list.pop()
|
||||
|
||||
def _update_event(self, event_time, event_index, event_state, event_type, event_value,
|
||||
proc_list, proc_desc, global_message):
|
||||
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 in ('OK', 'CAREFUL') and self.events_list[event_index].is_ongoing():
|
||||
# Close the event
|
||||
|
|
@ -327,7 +332,8 @@ class GlancesEventsList(object):
|
|||
sort_key=self.get_event_sort_key(event_type),
|
||||
proc_list=proc_list,
|
||||
proc_desc=proc_desc,
|
||||
global_msg=global_message)
|
||||
global_msg=global_message,
|
||||
)
|
||||
|
||||
def _close_event(self, event_time, event_index):
|
||||
"""Close an event in the list"""
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from glances.logger import logger
|
|||
|
||||
|
||||
class GlancesExport(object):
|
||||
|
||||
"""Main class for Glances export IF."""
|
||||
|
||||
# List of non exportable plugins
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from cassandra import InvalidRequest
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the Cassandra/Scylla export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import pycouchdb
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the CouchDB export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -14,13 +14,11 @@ import csv
|
|||
import sys
|
||||
import time
|
||||
|
||||
from glances.globals import iterkeys, itervalues
|
||||
from glances.logger import logger
|
||||
from glances.exports.export import GlancesExport
|
||||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the CSV export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
@ -112,7 +110,6 @@ class Export(GlancesExport):
|
|||
def export(self, name, columns, points):
|
||||
"""Export the stats to the CSV file.
|
||||
For the moment everything is done in the update method."""
|
||||
pass
|
||||
|
||||
|
||||
def open_csv_file(file_name, file_mode):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ from elasticsearch import Elasticsearch, helpers
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the ElasticSearch (ES) export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from glances.exports.export import GlancesExport
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the Graph export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ from graphitesend import GraphiteClient
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the Graphite export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from glances.exports.export import GlancesExport
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the JSON export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ from kafka import KafkaProducer
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the Kafka export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ from urllib.parse import quote_plus
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the MongoDB export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import paho.mqtt.client as paho
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the MQTT export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
@ -38,7 +37,9 @@ class Export(GlancesExport):
|
|||
|
||||
# Load the MQTT configuration file
|
||||
self.export_enable = self.load_conf(
|
||||
'mqtt', mandatories=['host', 'password'], options=['port', 'devicename', 'user', 'topic', 'tls', 'topic_structure', 'callback_api_version']
|
||||
'mqtt',
|
||||
mandatories=['host', 'password'],
|
||||
options=['port', 'devicename', 'user', 'topic', 'tls', 'topic_structure', 'callback_api_version'],
|
||||
)
|
||||
if not self.export_enable:
|
||||
exit('Missing MQTT config')
|
||||
|
|
@ -63,7 +64,7 @@ class Export(GlancesExport):
|
|||
def init(self):
|
||||
# Get the current callback api version
|
||||
self.callback_api_version = int(self.callback_api_version) or 2
|
||||
|
||||
|
||||
# Set enum for connection
|
||||
if self.callback_api_version == 1:
|
||||
self.callback_api_version = paho.CallbackAPIVersion.VERSION1
|
||||
|
|
@ -74,7 +75,11 @@ class Export(GlancesExport):
|
|||
if not self.export_enable:
|
||||
return None
|
||||
try:
|
||||
client = paho.Client(callback_api_version=self.callback_api_version, client_id='glances_' + self.devicename, clean_session=False)
|
||||
client = paho.Client(
|
||||
callback_api_version=self.callback_api_version,
|
||||
client_id='glances_' + self.devicename,
|
||||
clean_session=False,
|
||||
)
|
||||
client.username_pw_set(username=self.user, password=self.password)
|
||||
if self.tls:
|
||||
client.tls_set(certifi.where())
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import potsdb
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the OpenTSDB export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from prometheus_client import start_http_server, Gauge
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the Prometheus export module."""
|
||||
|
||||
METRIC_SEPARATOR = '_'
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import pika
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the rabbitMQ export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from requests import post
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the RESTful export module.
|
||||
Be aware that stats will be exported in one big POST request"""
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import bernhard
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the Riemann export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from statsd import StatsClient
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the Statsd export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ from zmq.utils.strtypes import asbytes
|
|||
|
||||
|
||||
class Export(GlancesExport):
|
||||
|
||||
"""This class manages the ZeroMQ export module."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ class GlancesFilterList(object):
|
|||
|
||||
|
||||
class GlancesFilter(object):
|
||||
|
||||
"""Allow Glances to filter processes
|
||||
|
||||
>>> f = GlancesFilter()
|
||||
|
|
@ -122,9 +121,9 @@ class GlancesFilter(object):
|
|||
|
||||
self._filter_re = None
|
||||
if self.filter is not None:
|
||||
logger.debug("Set filter to {} on {}".format(
|
||||
self.filter,
|
||||
self.filter_key if self.filter_key else 'name or cmdline'))
|
||||
logger.debug(
|
||||
"Set filter to {} on {}".format(self.filter, self.filter_key if self.filter_key else 'name or cmdline')
|
||||
)
|
||||
# Compute the regular expression
|
||||
try:
|
||||
self._filter_re = re.compile(self.filter)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from glances.logger import logger
|
|||
|
||||
|
||||
class FolderList(object):
|
||||
|
||||
"""This class describes the optional monitored folder list.
|
||||
|
||||
The folder list is a list of 'important' folder to monitor.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ from glances.attribute import GlancesAttribute
|
|||
|
||||
|
||||
class GlancesHistory(object):
|
||||
|
||||
"""This class manage a dict of GlancesAttribute
|
||||
- key: stats name
|
||||
- value: GlancesAttribute"""
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ Examples of use:
|
|||
action='store_true',
|
||||
default=False,
|
||||
dest='percpu',
|
||||
help='start Glances in per CPU mode'
|
||||
help='start Glances in per CPU mode',
|
||||
)
|
||||
parser.add_argument(
|
||||
'-2',
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ PYPI_API_URL = 'https://pypi.python.org/pypi/Glances/json'
|
|||
|
||||
|
||||
class Outdated(object):
|
||||
|
||||
"""
|
||||
This class aims at providing methods to warn the user when a new Glances
|
||||
version is available on the PyPI repository (https://pypi.python.org/pypi/Glances/).
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ from __future__ import division
|
|||
|
||||
from math import modf
|
||||
|
||||
from glances.logger import logger
|
||||
|
||||
|
||||
class Bar(object):
|
||||
"""Manage bar (progression or status).
|
||||
|
|
@ -29,13 +27,18 @@ class Bar(object):
|
|||
sys.stdout.flush()
|
||||
"""
|
||||
|
||||
def __init__(self, size,
|
||||
bar_char='|',
|
||||
empty_char=' ',
|
||||
pre_char='[', post_char=']',
|
||||
unit_char='%',
|
||||
display_value=True,
|
||||
min_value=0, max_value=100):
|
||||
def __init__(
|
||||
self,
|
||||
size,
|
||||
bar_char='|',
|
||||
empty_char=' ',
|
||||
pre_char='[',
|
||||
post_char=']',
|
||||
unit_char='%',
|
||||
display_value=True,
|
||||
min_value=0,
|
||||
max_value=100,
|
||||
):
|
||||
"""Init a bar (used in Quicllook plugin)
|
||||
|
||||
Args:
|
||||
|
|
@ -107,18 +110,15 @@ class Bar(object):
|
|||
# Add the value
|
||||
if self.__display_value:
|
||||
if self.percent >= self.max_value:
|
||||
ret = '{} {}{:3.0f}{}'.format(ret,
|
||||
'>' if self.percent > self.max_value else ' ',
|
||||
self.max_value,
|
||||
self.__unit_char)
|
||||
ret = '{} {}{:3.0f}{}'.format(
|
||||
ret, '>' if self.percent > self.max_value else ' ', self.max_value, self.__unit_char
|
||||
)
|
||||
else:
|
||||
ret = '{}{:5.1f}{}'.format(ret,
|
||||
self.percent,
|
||||
self.__unit_char)
|
||||
ret = '{}{:5.1f}{}'.format(ret, self.percent, self.__unit_char)
|
||||
|
||||
# Add overlay
|
||||
if overlay and len(overlay) < len(ret) - 6:
|
||||
ret = overlay + ret[len(overlay):]
|
||||
ret = overlay + ret[len(overlay) :]
|
||||
|
||||
return ret
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ except ImportError:
|
|||
|
||||
|
||||
class _GlancesCurses(object):
|
||||
|
||||
"""This class manages the curses display (and key pressed).
|
||||
|
||||
Note: It is a private class, use GlancesCursesClient or GlancesCursesBrowser.
|
||||
|
|
@ -200,9 +199,7 @@ class _GlancesCurses(object):
|
|||
# Separator ?
|
||||
self.args.enable_separator = config.get_bool_value('outputs', 'separator', default=True)
|
||||
# Set the left sidebar list
|
||||
self._left_sidebar = config.get_list_value('outputs',
|
||||
'left_menu',
|
||||
default=self._left_sidebar)
|
||||
self._left_sidebar = config.get_list_value('outputs', 'left_menu', default=self._left_sidebar)
|
||||
|
||||
def _init_history(self):
|
||||
"""Init the history option."""
|
||||
|
|
@ -605,13 +602,13 @@ class _GlancesCurses(object):
|
|||
# Compute the plugin max size for the left sidebar
|
||||
plugin_max_width = None
|
||||
if p in self._left_sidebar:
|
||||
plugin_max_width = min(self._left_sidebar_max_width,
|
||||
max(self._left_sidebar_min_width,
|
||||
self.term_window.getmaxyx()[1] - 105))
|
||||
plugin_max_width = min(
|
||||
self._left_sidebar_max_width,
|
||||
max(self._left_sidebar_min_width, self.term_window.getmaxyx()[1] - 105),
|
||||
)
|
||||
|
||||
# Get the view
|
||||
ret[p] = stats.get_plugin(p).get_stats_display(args=self.args,
|
||||
max_width=plugin_max_width)
|
||||
ret[p] = stats.get_plugin(p).get_stats_display(args=self.args, max_width=plugin_max_width)
|
||||
|
||||
return ret
|
||||
|
||||
|
|
@ -888,9 +885,7 @@ class _GlancesCurses(object):
|
|||
if p == 'sensors':
|
||||
self.display_plugin(
|
||||
stat_display['sensors'],
|
||||
max_y=(
|
||||
self.term_window.getmaxyx()[0] - self.get_stats_display_height(stat_display['now']) - 2
|
||||
),
|
||||
max_y=(self.term_window.getmaxyx()[0] - self.get_stats_display_height(stat_display['now']) - 2),
|
||||
)
|
||||
else:
|
||||
self.display_plugin(stat_display[p])
|
||||
|
|
@ -1261,12 +1256,10 @@ class _GlancesCurses(object):
|
|||
|
||||
|
||||
class GlancesCursesStandalone(_GlancesCurses):
|
||||
|
||||
"""Class for the Glances curse standalone."""
|
||||
|
||||
|
||||
class GlancesCursesClient(_GlancesCurses):
|
||||
|
||||
"""Class for the Glances curse client."""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ class GlancesRestfulApi(object):
|
|||
self._app.include_router(APIRouter(prefix=self.url_prefix.rstrip('/')))
|
||||
|
||||
# Set path for WebUI
|
||||
webui_root_path = config.get_value('outputs',
|
||||
'webui_root_path',
|
||||
default=os.path.dirname(os.path.realpath(__file__)))
|
||||
webui_root_path = config.get_value(
|
||||
'outputs', 'webui_root_path', default=os.path.dirname(os.path.realpath(__file__))
|
||||
)
|
||||
if webui_root_path == '':
|
||||
webui_root_path = os.path.dirname(os.path.realpath(__file__))
|
||||
self.STATIC_PATH = os.path.join(webui_root_path, 'static/public')
|
||||
|
|
@ -307,9 +307,9 @@ class GlancesRestfulApi(object):
|
|||
|
||||
def _start_uvicorn(self):
|
||||
# Run the Uvicorn Web server
|
||||
uvicorn_config = uvicorn.Config(self._app,
|
||||
host=self.args.bind_address, port=self.args.port,
|
||||
access_log=self.args.debug)
|
||||
uvicorn_config = uvicorn.Config(
|
||||
self._app, host=self.args.bind_address, port=self.args.port, access_log=self.args.debug
|
||||
)
|
||||
try:
|
||||
self.uvicorn_server = GlancesUvicornServer(config=uvicorn_config)
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -31,13 +31,9 @@ except (UnicodeEncodeError, TypeError) as e:
|
|||
|
||||
|
||||
class Sparkline(object):
|
||||
|
||||
"""Manage sparklines (see https://pypi.org/project/sparklines/)."""
|
||||
|
||||
def __init__(self, size,
|
||||
pre_char='[', post_char=']',
|
||||
unit_char='%',
|
||||
display_value=True):
|
||||
def __init__(self, size, pre_char='[', post_char=']', unit_char='%', display_value=True):
|
||||
# If the sparklines python module available ?
|
||||
self.__available = sparklines_module
|
||||
# Sparkline size
|
||||
|
|
@ -85,12 +81,10 @@ class Sparkline(object):
|
|||
if self.__display_value:
|
||||
percents_without_none = [x for x in self.percents if x is not None]
|
||||
if len(percents_without_none) > 0:
|
||||
ret = '{}{:5.1f}{}'.format(ret,
|
||||
percents_without_none[-1],
|
||||
self.__unit_char)
|
||||
ret = '{}{:5.1f}{}'.format(ret, percents_without_none[-1], self.__unit_char)
|
||||
ret = nativestr(ret)
|
||||
if overwrite and len(overwrite) < len(ret) - 6:
|
||||
ret = overwrite + ret[len(overwrite):]
|
||||
ret = overwrite + ret[len(overwrite) :]
|
||||
return ret
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ from glances.globals import printandflush
|
|||
|
||||
|
||||
class GlancesStdout(object):
|
||||
|
||||
"""This class manages the Stdout display."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
@ -78,10 +77,7 @@ class GlancesStdout(object):
|
|||
else:
|
||||
continue
|
||||
try:
|
||||
printandflush("{}.{}.{}: {}".format(plugin,
|
||||
i_key,
|
||||
attribute,
|
||||
i[attribute]))
|
||||
printandflush("{}.{}.{}: {}".format(plugin, i_key, attribute, i[attribute]))
|
||||
except KeyError as err:
|
||||
logger.error("Can not display stat {}.{} ({})".format(plugin, attribute, err))
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -139,41 +139,47 @@ def print_plugin_description(plugin, stat):
|
|||
print(
|
||||
'* **{}**: {} (unit is *{}*)'.format(
|
||||
field,
|
||||
description['description'][:-1]
|
||||
if description['description'].endswith('.')
|
||||
else description['description'],
|
||||
description['unit']
|
||||
if 'unit' in description
|
||||
else 'None'
|
||||
(
|
||||
description['description'][:-1]
|
||||
if description['description'].endswith('.')
|
||||
else description['description']
|
||||
),
|
||||
description['unit'] if 'unit' in description else 'None',
|
||||
)
|
||||
)
|
||||
if 'rate' in description and description['rate']:
|
||||
time_since_update = True
|
||||
print('* **{}**: {} (unit is *{}* per second)'.format(
|
||||
field + '_rate_per_sec',
|
||||
(description['description'][:-1]
|
||||
if description['description'].endswith('.')
|
||||
else description['description']) + ' per second',
|
||||
description['unit']
|
||||
if 'unit' in description
|
||||
else 'None'
|
||||
))
|
||||
print('* **{}**: {} (unit is *{}*)'.format(
|
||||
field + '_gauge',
|
||||
(description['description'][:-1]
|
||||
if description['description'].endswith('.')
|
||||
else description['description']) + ' (cumulative)',
|
||||
description['unit']
|
||||
if 'unit' in description
|
||||
else 'None'
|
||||
))
|
||||
print(
|
||||
'* **{}**: {} (unit is *{}* per second)'.format(
|
||||
field + '_rate_per_sec',
|
||||
(
|
||||
description['description'][:-1]
|
||||
if description['description'].endswith('.')
|
||||
else description['description']
|
||||
)
|
||||
+ ' per second',
|
||||
description['unit'] if 'unit' in description else 'None',
|
||||
)
|
||||
)
|
||||
print(
|
||||
'* **{}**: {} (unit is *{}*)'.format(
|
||||
field + '_gauge',
|
||||
(
|
||||
description['description'][:-1]
|
||||
if description['description'].endswith('.')
|
||||
else description['description']
|
||||
)
|
||||
+ ' (cumulative)',
|
||||
description['unit'] if 'unit' in description else 'None',
|
||||
)
|
||||
)
|
||||
|
||||
if time_since_update:
|
||||
print('* **{}**: {} (unit is *{}*)'.format(
|
||||
'time_since_update',
|
||||
'Number of seconds since last update',
|
||||
'seconds'
|
||||
))
|
||||
print(
|
||||
'* **{}**: {} (unit is *{}*)'.format(
|
||||
'time_since_update', 'Number of seconds since last update', 'seconds'
|
||||
)
|
||||
)
|
||||
|
||||
print('')
|
||||
else:
|
||||
|
|
@ -310,7 +316,6 @@ def print_limits(stats):
|
|||
|
||||
|
||||
class GlancesStdoutApiDoc(object):
|
||||
|
||||
"""This class manages the fields description display."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ from glances.globals import printandflush
|
|||
|
||||
|
||||
class GlancesStdoutCsv(object):
|
||||
|
||||
"""This class manages the StdoutCsv display."""
|
||||
|
||||
separator = ','
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ class colors:
|
|||
|
||||
|
||||
class GlancesStdoutIssue(object):
|
||||
|
||||
"""This class manages the Issue display."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ from glances.globals import printandflush
|
|||
|
||||
|
||||
class GlancesStdoutJson(object):
|
||||
|
||||
"""This class manages the Stdout JSON display."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ from glances.logger import logger
|
|||
|
||||
|
||||
class GlancesPassword(object):
|
||||
|
||||
"""This class contains all the methods relating to password."""
|
||||
|
||||
def __init__(self, username='glances', config=None):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ from glances.password import GlancesPassword
|
|||
|
||||
|
||||
class GlancesPasswordList(GlancesPassword):
|
||||
|
||||
"""Manage the Glances passwords list for the client|browser/server."""
|
||||
|
||||
_section = "passwords"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
from datetime import datetime
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.events_list import glances_events
|
||||
|
||||
# from glances.logger import logger
|
||||
|
|
@ -90,7 +89,7 @@ fields_description = {
|
|||
'global_msg': {
|
||||
'description': 'Global alert message',
|
||||
'unit': 'string',
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -103,9 +102,7 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
args=args, config=config, stats_init_value=[], fields_description=fields_description
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
|
|
@ -172,9 +169,7 @@ class PluginModel(GlancesPluginModel):
|
|||
if self.approx_equal(alert['min'], alert['max'], tolerance=0.1):
|
||||
msg = ' ({:.1f})'.format(alert['avg'])
|
||||
else:
|
||||
msg = ' (Min:{:.1f} Mean:{:.1f} Max:{:.1f})'.format(alert['min'],
|
||||
alert['avg'],
|
||||
alert['max'])
|
||||
msg = ' (Min:{:.1f} Mean:{:.1f} Max:{:.1f})'.format(alert['min'], alert['avg'], alert['max'])
|
||||
ret.append(self.curse_add_line(msg))
|
||||
# Top processes
|
||||
top_process = ', '.join(alert['top'])
|
||||
|
|
|
|||
|
|
@ -20,32 +20,13 @@ from glances.plugins.plugin.model import GlancesPluginModel
|
|||
# rate: is it a rate ? If yes, // by time_since_update when displayed,
|
||||
# min_symbol: Auto unit should be used if value > than 1 'X' (K, M, G)...
|
||||
fields_description = {
|
||||
'name': {
|
||||
'description': 'AMP name.'
|
||||
},
|
||||
'result': {
|
||||
'description': 'AMP result (a string).'
|
||||
},
|
||||
'refresh': {
|
||||
'description': 'AMP refresh interval.',
|
||||
'unit': 'second'
|
||||
},
|
||||
'timer': {
|
||||
'description': 'Time until next refresh.',
|
||||
'unit': 'second'
|
||||
},
|
||||
'count': {
|
||||
'description': 'Number of matching processes.',
|
||||
'unit': 'number'
|
||||
},
|
||||
'countmin': {
|
||||
'description': 'Minimum number of matching processes.',
|
||||
'unit': 'number'
|
||||
},
|
||||
'countmax': {
|
||||
'description': 'Maximum number of matching processes.',
|
||||
'unit': 'number'
|
||||
},
|
||||
'name': {'description': 'AMP name.'},
|
||||
'result': {'description': 'AMP result (a string).'},
|
||||
'refresh': {'description': 'AMP refresh interval.', 'unit': 'second'},
|
||||
'timer': {'description': 'Time until next refresh.', 'unit': 'second'},
|
||||
'count': {'description': 'Number of matching processes.', 'unit': 'number'},
|
||||
'countmin': {'description': 'Minimum number of matching processes.', 'unit': 'number'},
|
||||
'countmax': {'description': 'Maximum number of matching processes.', 'unit': 'number'},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -55,10 +36,7 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args,
|
||||
config=config,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
args=args, config=config, stats_init_value=[], fields_description=fields_description
|
||||
)
|
||||
self.args = args
|
||||
self.config = config
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class PluginModel(GlancesPluginModel):
|
|||
config=config,
|
||||
# items_history_list=items_history_list,
|
||||
stats_init_value={'net_connections_enabled': True, 'nf_conntrack_enabled': True},
|
||||
fields_description=fields_description
|
||||
fields_description=fields_description,
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
|
|
|
|||
|
|
@ -128,9 +128,7 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
items_history_list=items_history_list,
|
||||
fields_description=fields_description
|
||||
args=args, config=config, items_history_list=items_history_list, fields_description=fields_description
|
||||
)
|
||||
|
||||
# The plugin can be disabled using: args.disable_docker
|
||||
|
|
@ -288,14 +286,13 @@ class PluginModel(GlancesPluginModel):
|
|||
alert = self.get_alert(
|
||||
self.memory_usage_no_cache(i['memory']),
|
||||
maximum=i['memory']['limit'],
|
||||
header=i['name'] + '_mem', action_key=i['name']
|
||||
header=i['name'] + '_mem',
|
||||
action_key=i['name'],
|
||||
)
|
||||
if alert == 'DEFAULT':
|
||||
# Not found ? Get back to default MEM threshold value
|
||||
alert = self.get_alert(
|
||||
self.memory_usage_no_cache(i['memory']),
|
||||
maximum=i['memory']['limit'],
|
||||
header='mem'
|
||||
self.memory_usage_no_cache(i['memory']), maximum=i['memory']['limit'], header='mem'
|
||||
)
|
||||
self.views[i[self.get_key()]]['mem']['decoration'] = alert
|
||||
|
||||
|
|
@ -427,23 +424,13 @@ class PluginModel(GlancesPluginModel):
|
|||
to_bit = 8
|
||||
unit = 'b'
|
||||
try:
|
||||
value = (
|
||||
self.auto_unit(
|
||||
int(container['network_rx'] * to_bit)
|
||||
)
|
||||
+ unit
|
||||
)
|
||||
value = self.auto_unit(int(container['network_rx'] * to_bit)) + unit
|
||||
msg = '{:>7}'.format(value)
|
||||
except (KeyError, TypeError):
|
||||
msg = '{:>7}'.format('_')
|
||||
ret.append(self.curse_add_line(msg))
|
||||
try:
|
||||
value = (
|
||||
self.auto_unit(
|
||||
int(container['network_tx'] * to_bit)
|
||||
)
|
||||
+ unit
|
||||
)
|
||||
value = self.auto_unit(int(container['network_tx'] * to_bit)) + unit
|
||||
msg = ' {:<7}'.format(value)
|
||||
except (KeyError, TypeError):
|
||||
msg = ' {:<7}'.format('_')
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ class DockerContainersExtension:
|
|||
# Container Image
|
||||
try:
|
||||
# API fails on Unraid - See issue 2233
|
||||
stats['image'] = ','.join(container.image.tags if container.image.tags else []),
|
||||
stats['image'] = (','.join(container.image.tags if container.image.tags else []),)
|
||||
except requests.exceptions.HTTPError:
|
||||
stats['image'] = ''
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,7 @@ import psutil
|
|||
# rate: if True then compute and add *_gauge and *_rate_per_is fields
|
||||
# min_symbol: Auto unit should be used if value > than 1 'X' (K, M, G)...
|
||||
fields_description = {
|
||||
'total': {
|
||||
'description': 'Sum of all CPU percentages (except idle).',
|
||||
'unit': 'percent'
|
||||
},
|
||||
'total': {'description': 'Sum of all CPU percentages (except idle).', 'unit': 'percent'},
|
||||
'system': {
|
||||
'description': 'Percent time spent in kernel space. System CPU time is the \
|
||||
time spent running code in the Operating System kernel.',
|
||||
|
|
@ -148,9 +145,7 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the CPU plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
items_history_list=items_history_list,
|
||||
fields_description=fields_description
|
||||
args=args, config=config, items_history_list=items_history_list, fields_description=fields_description
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
|
|
@ -299,8 +294,17 @@ class PluginModel(GlancesPluginModel):
|
|||
self.stats[key], maximum=100 * self.stats['cpucore'], header=key
|
||||
)
|
||||
# Optional
|
||||
for key in ['nice', 'irq', 'idle', 'steal', 'guest',
|
||||
'ctx_switches', 'interrupts', 'soft_interrupts', 'syscalls']:
|
||||
for key in [
|
||||
'nice',
|
||||
'irq',
|
||||
'idle',
|
||||
'steal',
|
||||
'guest',
|
||||
'ctx_switches',
|
||||
'interrupts',
|
||||
'soft_interrupts',
|
||||
'syscalls',
|
||||
]:
|
||||
if key in self.stats:
|
||||
self.views[key]['optional'] = True
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import psutil
|
|||
# rate: if True then compute and add *_gauge and *_rate_per_is fields
|
||||
# min_symbol: Auto unit should be used if value > than 1 'X' (K, M, G)...
|
||||
fields_description = {
|
||||
'disk_name': {
|
||||
'description': 'Disk name.'
|
||||
},
|
||||
'disk_name': {'description': 'Disk name.'},
|
||||
'read_count': {
|
||||
'description': 'Number of reads.',
|
||||
'rate': True,
|
||||
|
|
@ -50,16 +48,8 @@ fields_description = {
|
|||
|
||||
# Define the history items list
|
||||
items_history_list = [
|
||||
{
|
||||
'name': 'read_bytes_rate_per_sec',
|
||||
'description': 'Bytes read per second',
|
||||
'y_unit': 'B/s'
|
||||
},
|
||||
{
|
||||
'name': 'write_bytes_rate_per_sec',
|
||||
'description': 'Bytes write per second',
|
||||
'y_unit': 'B/s'
|
||||
},
|
||||
{'name': 'read_bytes_rate_per_sec', 'description': 'Bytes read per second', 'y_unit': 'B/s'},
|
||||
{'name': 'write_bytes_rate_per_sec', 'description': 'Bytes write per second', 'y_unit': 'B/s'},
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -72,10 +62,11 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
args=args,
|
||||
config=config,
|
||||
items_history_list=items_history_list,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
fields_description=fields_description,
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
|
|
@ -122,8 +113,7 @@ class PluginModel(GlancesPluginModel):
|
|||
|
||||
for disk_name, disk_stat in diskio.items():
|
||||
# By default, RamFS is not displayed (issue #714)
|
||||
if self.args is not None and \
|
||||
not self.args.diskio_show_ramfs and disk_name.startswith('ram'):
|
||||
if self.args is not None and not self.args.diskio_show_ramfs and disk_name.startswith('ram'):
|
||||
continue
|
||||
|
||||
# Shall we display the stats ?
|
||||
|
|
@ -161,12 +151,10 @@ class PluginModel(GlancesPluginModel):
|
|||
for i in self.get_raw():
|
||||
disk_real_name = i['disk_name']
|
||||
self.views[i[self.get_key()]]['read_bytes']['decoration'] = self.get_alert(
|
||||
i['read_bytes'],
|
||||
header=disk_real_name + '_rx'
|
||||
i['read_bytes'], header=disk_real_name + '_rx'
|
||||
)
|
||||
self.views[i[self.get_key()]]['write_bytes']['decoration'] = self.get_alert(
|
||||
i['write_bytes'],
|
||||
header=disk_real_name + '_tx'
|
||||
i['write_bytes'], header=disk_real_name + '_tx'
|
||||
)
|
||||
|
||||
def msg_curse(self, args=None, max_width=None):
|
||||
|
|
@ -220,17 +208,13 @@ class PluginModel(GlancesPluginModel):
|
|||
msg = '{:>7}'.format(txps)
|
||||
ret.append(
|
||||
self.curse_add_line(
|
||||
msg, self.get_views(item=i[self.get_key()],
|
||||
key='read_count',
|
||||
option='decoration')
|
||||
msg, self.get_views(item=i[self.get_key()], key='read_count', option='decoration')
|
||||
)
|
||||
)
|
||||
msg = '{:>7}'.format(rxps)
|
||||
ret.append(
|
||||
self.curse_add_line(
|
||||
msg, self.get_views(item=i[self.get_key()],
|
||||
key='write_count',
|
||||
option='decoration')
|
||||
msg, self.get_views(item=i[self.get_key()], key='write_count', option='decoration')
|
||||
)
|
||||
)
|
||||
else:
|
||||
|
|
@ -240,17 +224,13 @@ class PluginModel(GlancesPluginModel):
|
|||
msg = '{:>7}'.format(txps)
|
||||
ret.append(
|
||||
self.curse_add_line(
|
||||
msg, self.get_views(item=i[self.get_key()],
|
||||
key='read_bytes',
|
||||
option='decoration')
|
||||
msg, self.get_views(item=i[self.get_key()], key='read_bytes', option='decoration')
|
||||
)
|
||||
)
|
||||
msg = '{:>7}'.format(rxps)
|
||||
ret.append(
|
||||
self.curse_add_line(
|
||||
msg, self.get_views(item=i[self.get_key()],
|
||||
key='write_bytes',
|
||||
option='decoration')
|
||||
msg, self.get_views(item=i[self.get_key()], key='write_bytes', option='decoration')
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ from glances.plugins.plugin.model import GlancesPluginModel
|
|||
# rate: is it a rate ? If yes, // by time_since_update when displayed,
|
||||
# min_symbol: Auto unit should be used if value > than 1 'X' (K, M, G)...
|
||||
fields_description = {
|
||||
'path': {
|
||||
'description': 'Absolute path.'
|
||||
},
|
||||
'path': {'description': 'Absolute path.'},
|
||||
'size': {
|
||||
'description': 'Folder size in bytes.',
|
||||
'unit': 'byte',
|
||||
|
|
@ -59,9 +57,7 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
args=args, config=config, stats_init_value=[], fields_description=fields_description
|
||||
)
|
||||
|
||||
self.args = args
|
||||
|
|
|
|||
|
|
@ -25,15 +25,9 @@ import psutil
|
|||
# rate: is it a rate ? If yes, // by time_since_update when displayed,
|
||||
# min_symbol: Auto unit should be used if value > than 1 'X' (K, M, G)...
|
||||
fields_description = {
|
||||
'device_name': {
|
||||
'description': 'Device name.'
|
||||
},
|
||||
'fs_type': {
|
||||
'description': 'File system type.'
|
||||
},
|
||||
'mnt_point': {
|
||||
'description': 'Mount point.'
|
||||
},
|
||||
'device_name': {'description': 'Device name.'},
|
||||
'fs_type': {'description': 'File system type.'},
|
||||
'mnt_point': {'description': 'Mount point.'},
|
||||
'size': {
|
||||
'description': 'Total size.',
|
||||
'unit': 'byte',
|
||||
|
|
@ -104,10 +98,11 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
args=args,
|
||||
config=config,
|
||||
items_history_list=items_history_list,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
fields_description=fields_description,
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ Currently supported:
|
|||
- AMD GPU (no lib needed)
|
||||
"""
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.globals import to_fahrenheit
|
||||
from glances.plugins.gpu.cards.nvidia import NvidiaGPU
|
||||
from glances.plugins.gpu.cards.amd import AmdGPU
|
||||
|
|
@ -69,10 +68,11 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
args=args,
|
||||
config=config,
|
||||
items_history_list=items_history_list,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
fields_description=fields_description,
|
||||
)
|
||||
# Init the GPU API
|
||||
self.nvidia = NvidiaGPU()
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ See: https://wiki.archlinux.org/title/AMDGPU#Manually
|
|||
# └── 0
|
||||
# └── amdgpu_pm_info
|
||||
|
||||
from glances.logger import logger
|
||||
import re
|
||||
import os
|
||||
|
||||
|
|
@ -59,7 +58,6 @@ class AmdGPU:
|
|||
|
||||
def exit(self):
|
||||
"""Close AMD GPU class."""
|
||||
pass
|
||||
|
||||
def get_device_stats(self):
|
||||
"""Get AMD GPU stats."""
|
||||
|
|
@ -91,9 +89,11 @@ def get_device_list(drm_root_folder: str) -> list:
|
|||
ret = []
|
||||
for root, dirs, _ in os.walk(drm_root_folder):
|
||||
for d in dirs:
|
||||
if re.match(CARD_REGEX, d) and \
|
||||
DEVICE_FOLDER in os.listdir(os.path.join(root, d)) and \
|
||||
os.path.isfile(os.path.join(root, d, DEVICE_FOLDER, GPU_PROC_PERCENT)):
|
||||
if (
|
||||
re.match(CARD_REGEX, d)
|
||||
and DEVICE_FOLDER in os.listdir(os.path.join(root, d))
|
||||
and os.path.isfile(os.path.join(root, d, DEVICE_FOLDER, GPU_PROC_PERCENT))
|
||||
):
|
||||
# If the GPU busy file is present then take the card into account
|
||||
ret.append(os.path.join(root, d, DEVICE_FOLDER))
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
from glances.logger import logger
|
||||
from glances.globals import nativestr
|
||||
|
||||
try:
|
||||
import pynvml
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -66,10 +66,7 @@ class PluginModel(GlancesPluginModel):
|
|||
|
||||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
fields_description=fields_description
|
||||
)
|
||||
super(PluginModel, self).__init__(args=args, config=config, fields_description=fields_description)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
self.display_curse = True
|
||||
|
|
@ -83,8 +80,9 @@ class PluginModel(GlancesPluginModel):
|
|||
self.public_field = self.get_conf_value("public_field", default=[None])
|
||||
self.public_template = self.get_conf_value("public_template", default=[None])[0]
|
||||
self.public_disabled = (
|
||||
self.get_conf_value('public_disabled', default='False')[0].lower() != 'false' or
|
||||
self.public_api is None or self.public_field is None
|
||||
self.get_conf_value('public_disabled', default='False')[0].lower() != 'false'
|
||||
or self.public_api is None
|
||||
or self.public_field is None
|
||||
)
|
||||
self.public_address_refresh_interval = self.get_conf_value(
|
||||
"public_refresh_interval", default=self._default_public_refresh_interval
|
||||
|
|
@ -128,9 +126,7 @@ class PluginModel(GlancesPluginModel):
|
|||
if not self.public_disabled and (
|
||||
self.public_address == "" or time_since_update > self.public_address_refresh_interval
|
||||
):
|
||||
self.public_info = PublicIpInfo(
|
||||
self.public_api, self.public_username, self.public_password
|
||||
).get()
|
||||
self.public_info = PublicIpInfo(self.public_api, self.public_username, self.public_password).get()
|
||||
self.public_address = self.public_info['ip']
|
||||
except (KeyError, AttributeError, TypeError) as e:
|
||||
logger.debug("Cannot grab public IP information ({})".format(e))
|
||||
|
|
@ -138,9 +134,7 @@ class PluginModel(GlancesPluginModel):
|
|||
stats['public_address'] = (
|
||||
self.public_address if not self.args.hide_public_info else self.__hide_ip(self.public_address)
|
||||
)
|
||||
stats['public_info_human'] = (
|
||||
self.public_info_for_human(self.public_info)
|
||||
)
|
||||
stats['public_info_human'] = self.public_info_for_human(self.public_info)
|
||||
|
||||
elif self.input_method == 'snmp':
|
||||
# Not implemented yet
|
||||
|
|
|
|||
|
|
@ -44,9 +44,7 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
args=args, config=config, stats_init_value=[], fields_description=fields_description
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ else:
|
|||
if 'phys' in core:
|
||||
nb_phys_core = core['phys']
|
||||
|
||||
|
||||
class PluginModel(GlancesPluginModel):
|
||||
"""Glances load plugin.
|
||||
|
||||
|
|
@ -102,12 +103,7 @@ class PluginModel(GlancesPluginModel):
|
|||
if load is None:
|
||||
stats = self.get_init_value()
|
||||
else:
|
||||
stats = {
|
||||
'min1': load[0],
|
||||
'min5': load[1],
|
||||
'min15': load[2],
|
||||
'cpucore': get_nb_log_core()
|
||||
}
|
||||
stats = {'min1': load[0], 'min5': load[1], 'min15': load[2], 'cpucore': get_nb_log_core()}
|
||||
|
||||
elif self.input_method == 'snmp':
|
||||
# Update stats using SNMP
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@
|
|||
|
||||
"""Virtual memory plugin."""
|
||||
|
||||
from glances.globals import iterkeys
|
||||
from glances.plugins.plugin.model import GlancesPluginModel
|
||||
from glances.logger import logger
|
||||
|
||||
import psutil
|
||||
|
||||
|
|
|
|||
|
|
@ -22,12 +22,8 @@ import psutil
|
|||
# rate: if True then compute and add *_gauge and *_rate_per_is fields
|
||||
# min_symbol: Auto unit should be used if value > than 1 'X' (K, M, G)...
|
||||
fields_description = {
|
||||
'interface_name': {
|
||||
'description': 'Interface name.'
|
||||
},
|
||||
'alias': {
|
||||
'description': 'Interface alias name (optional).'
|
||||
},
|
||||
'interface_name': {'description': 'Interface name.'},
|
||||
'alias': {'description': 'Interface alias name (optional).'},
|
||||
'bytes_recv': {
|
||||
'description': 'Number of bytes received.',
|
||||
'rate': True,
|
||||
|
|
@ -47,10 +43,7 @@ fields_description = {
|
|||
'description': 'Maximum interface speed (in bit per second). Can return 0 on some operating-system.',
|
||||
'unit': 'bitpersecond',
|
||||
},
|
||||
'is_up': {
|
||||
'description': 'Is the interface up ?',
|
||||
'unit': 'bool'
|
||||
}
|
||||
'is_up': {'description': 'Is the interface up ?', 'unit': 'bool'},
|
||||
}
|
||||
|
||||
# SNMP OID
|
||||
|
|
@ -66,16 +59,8 @@ snmp_oid = {
|
|||
|
||||
# Define the history items list
|
||||
items_history_list = [
|
||||
{
|
||||
'name': 'bytes_recv_rate_per_sec',
|
||||
'description': 'Download rate per second',
|
||||
'y_unit': 'B/s'
|
||||
},
|
||||
{
|
||||
'name': 'bytes_sent_rate_per_sec',
|
||||
'description': 'Upload rate per second',
|
||||
'y_unit': 'B/s'
|
||||
},
|
||||
{'name': 'bytes_recv_rate_per_sec', 'description': 'Download rate per second', 'y_unit': 'B/s'},
|
||||
{'name': 'bytes_sent_rate_per_sec', 'description': 'Upload rate per second', 'y_unit': 'B/s'},
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -320,17 +305,15 @@ class PluginModel(GlancesPluginModel):
|
|||
else:
|
||||
msg = '{:>7}'.format(rx)
|
||||
ret.append(
|
||||
self.curse_add_line(msg,
|
||||
self.get_views(item=i[self.get_key()],
|
||||
key='bytes_recv',
|
||||
option='decoration'))
|
||||
self.curse_add_line(
|
||||
msg, self.get_views(item=i[self.get_key()], key='bytes_recv', option='decoration')
|
||||
)
|
||||
)
|
||||
msg = '{:>7}'.format(tx)
|
||||
ret.append(
|
||||
self.curse_add_line(msg,
|
||||
self.get_views(item=i[self.get_key()],
|
||||
key='bytes_sent',
|
||||
option='decoration'))
|
||||
self.curse_add_line(
|
||||
msg, self.get_views(item=i[self.get_key()], key='bytes_sent', option='decoration')
|
||||
)
|
||||
)
|
||||
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -20,12 +20,8 @@ from glances.plugins.plugin.model import GlancesPluginModel
|
|||
# rate: if True then compute and add *_gauge and *_rate_per_is fields
|
||||
# min_symbol: Auto unit should be used if value > than 1 'X' (K, M, G)...
|
||||
fields_description = {
|
||||
'custom': {
|
||||
'description': 'Current date in custom format.'
|
||||
},
|
||||
'iso': {
|
||||
'description': 'Current date in ISO 8601 format.'
|
||||
}
|
||||
'custom': {'description': 'Current date in custom format.'},
|
||||
'iso': {'description': 'Current date in ISO 8601 format.'},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -42,10 +38,8 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args,
|
||||
config=config,
|
||||
fields_description=fields_description,
|
||||
stats_init_value={})
|
||||
args=args, config=config, fields_description=fields_description, stats_init_value={}
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
self.display_curse = True
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
"""Per-CPU plugin."""
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.cpu_percent import cpu_percent
|
||||
from glances.plugins.plugin.model import GlancesPluginModel
|
||||
|
||||
|
|
@ -98,10 +97,11 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
args=args,
|
||||
config=config,
|
||||
items_history_list=items_history_list,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
fields_description=fields_description,
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
|
|
@ -170,7 +170,7 @@ class PluginModel(GlancesPluginModel):
|
|||
percpu_list = self.stats
|
||||
|
||||
# Per CPU stats displayed per column
|
||||
for cpu in percpu_list[0: self.max_cpu_display]:
|
||||
for cpu in percpu_list[0 : self.max_cpu_display]:
|
||||
ret.append(self.curse_new_line())
|
||||
if self.is_disabled('quicklook'):
|
||||
try:
|
||||
|
|
@ -200,8 +200,8 @@ class PluginModel(GlancesPluginModel):
|
|||
for stat in header:
|
||||
if stat not in self.stats[0]:
|
||||
continue
|
||||
cpu_stat = sum([i[stat] for i in percpu_list[0: self.max_cpu_display]]) / len(
|
||||
[i[stat] for i in percpu_list[0: self.max_cpu_display]]
|
||||
cpu_stat = sum([i[stat] for i in percpu_list[0 : self.max_cpu_display]]) / len(
|
||||
[i[stat] for i in percpu_list[0 : self.max_cpu_display]]
|
||||
)
|
||||
try:
|
||||
msg = '{:6.1f}%'.format(cpu_stat)
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ class GlancesPluginModel(object):
|
|||
if raw_history is None or len(raw_history) < nb:
|
||||
return None
|
||||
last_nb = [v[1] for v in raw_history]
|
||||
return mean(last_nb[nb // 2:]) - mean(last_nb[:nb // 2])
|
||||
return mean(last_nb[nb // 2 :]) - mean(last_nb[: nb // 2])
|
||||
|
||||
@property
|
||||
def input_method(self):
|
||||
|
|
@ -350,9 +350,7 @@ class GlancesPluginModel(object):
|
|||
ret = {}
|
||||
if bulk:
|
||||
# Bulk request
|
||||
snmp_result = snmp_client.getbulk_by_oid(0,
|
||||
10,
|
||||
*list(itervalues(snmp_oid)))
|
||||
snmp_result = snmp_client.getbulk_by_oid(0, 10, *list(itervalues(snmp_oid)))
|
||||
logger.info(snmp_result)
|
||||
if len(snmp_oid) == 1:
|
||||
# Bulk command for only one OID
|
||||
|
|
@ -523,11 +521,13 @@ class GlancesPluginModel(object):
|
|||
'additional': False,
|
||||
'splittable': False,
|
||||
'hidden': False,
|
||||
'_zero': self.views[i[self.get_key()]][key]['_zero']
|
||||
if i[self.get_key()] in self.views
|
||||
and key in self.views[i[self.get_key()]]
|
||||
and 'zero' in self.views[i[self.get_key()]][key]
|
||||
else True,
|
||||
'_zero': (
|
||||
self.views[i[self.get_key()]][key]['_zero']
|
||||
if i[self.get_key()] in self.views
|
||||
and key in self.views[i[self.get_key()]]
|
||||
and 'zero' in self.views[i[self.get_key()]][key]
|
||||
else True
|
||||
),
|
||||
}
|
||||
ret[i[self.get_key()]][key] = value
|
||||
elif isinstance(self.get_raw(), dict) and self.get_raw() is not None:
|
||||
|
|
@ -1039,9 +1039,9 @@ class GlancesPluginModel(object):
|
|||
|
||||
# Is it a rate ? Yes, get the pre-computed rate value
|
||||
if (
|
||||
key in self.fields_description and
|
||||
'rate' in self.fields_description[key] and
|
||||
self.fields_description[key]['rate'] is True
|
||||
key in self.fields_description
|
||||
and 'rate' in self.fields_description[key]
|
||||
and self.fields_description[key]['rate'] is True
|
||||
):
|
||||
value = self.stats.get(key + '_rate_per_sec', None)
|
||||
else:
|
||||
|
|
@ -1064,12 +1064,8 @@ class GlancesPluginModel(object):
|
|||
elif unit_type == 'float':
|
||||
msg_value = msg_template_float.format(value, unit_short)
|
||||
elif 'min_symbol' in self.fields_description[key]:
|
||||
msg_value = (
|
||||
msg_template.format(
|
||||
self.auto_unit(int(value),
|
||||
min_symbol=self.fields_description[key]['min_symbol']),
|
||||
unit_short
|
||||
)
|
||||
msg_value = msg_template.format(
|
||||
self.auto_unit(int(value), min_symbol=self.fields_description[key]['min_symbol']), unit_short
|
||||
)
|
||||
else:
|
||||
msg_value = msg_template.format(int(value), unit_short)
|
||||
|
|
@ -1119,7 +1115,7 @@ class GlancesPluginModel(object):
|
|||
return none_symbol
|
||||
symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
|
||||
if min_symbol in symbols:
|
||||
symbols = symbols[symbols.index(min_symbol):]
|
||||
symbols = symbols[symbols.index(min_symbol) :]
|
||||
prefix = {
|
||||
'Y': 1208925819614629174706176,
|
||||
'Z': 1180591620717411303424,
|
||||
|
|
|
|||
|
|
@ -66,15 +66,14 @@ fields_description = {
|
|||
},
|
||||
}
|
||||
|
||||
|
||||
class PluginModel(GlancesPluginModel):
|
||||
"""Glances ports scanner plugin."""
|
||||
|
||||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
args=args, config=config, stats_init_value=[], fields_description=fields_description
|
||||
)
|
||||
self.args = args
|
||||
self.config = config
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
"""Process count plugin."""
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.processes import glances_processes, sort_for_human
|
||||
from glances.plugins.plugin.model import GlancesPluginModel
|
||||
|
||||
|
|
@ -60,9 +59,7 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
items_history_list=items_history_list,
|
||||
fields_description=fields_description
|
||||
args=args, config=config, items_history_list=items_history_list, fields_description=fields_description
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
|
|
|
|||
|
|
@ -155,9 +155,9 @@ class PluginModel(GlancesPluginModel):
|
|||
|
||||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(args=args, config=config,
|
||||
fields_description=fields_description,
|
||||
stats_init_value=[])
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config, fields_description=fields_description, stats_init_value=[]
|
||||
)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
self.display_curse = True
|
||||
|
|
@ -190,8 +190,7 @@ class PluginModel(GlancesPluginModel):
|
|||
if 'export' in config.as_dict()['processlist']:
|
||||
glances_processes.export_process_filter = config.as_dict()['processlist']['export']
|
||||
if args.export:
|
||||
logger.info("Export process filter is set to: {}".format(
|
||||
config.as_dict()['processlist']['export']))
|
||||
logger.info("Export process filter is set to: {}".format(config.as_dict()['processlist']['export']))
|
||||
|
||||
# The default sort key could also be overwrite by command line (see #1903)
|
||||
if args and args.sort_processes_key is not None:
|
||||
|
|
|
|||
|
|
@ -200,8 +200,7 @@ class PluginModel(GlancesPluginModel):
|
|||
msg_freq = ''
|
||||
|
||||
if 'cpu_name' in self.stats and (max_width - len(msg_freq) + 7) > 0:
|
||||
msg_name = '{:{width}}'.format(self.stats['cpu_name'],
|
||||
width=max_width - len(msg_freq) + 7)
|
||||
msg_name = '{:{width}}'.format(self.stats['cpu_name'], width=max_width - len(msg_freq) + 7)
|
||||
else:
|
||||
msg_name = '' if msg_freq == '' else 'Frequency'
|
||||
|
||||
|
|
@ -248,7 +247,7 @@ class PluginModel(GlancesPluginModel):
|
|||
percpu_list = self.stats['percpu']
|
||||
|
||||
# Display the first max_cpu_display CPU
|
||||
for cpu in percpu_list[0: self.max_cpu_display]:
|
||||
for cpu in percpu_list[0 : self.max_cpu_display]:
|
||||
cpu_id = cpu[cpu['key']]
|
||||
if type(data[key]).__name__ == 'Sparkline':
|
||||
# Sparkline display an history
|
||||
|
|
@ -280,8 +279,8 @@ class PluginModel(GlancesPluginModel):
|
|||
else:
|
||||
# Bar will only display the last value
|
||||
sum_other = Bar(max_width, bar_char=self.get_conf_value('bar_char', default=['|'])[0])
|
||||
sum_other.percent = sum([i['total'] for i in percpu_list[self.max_cpu_display:]]) / len(
|
||||
percpu_list[self.max_cpu_display:]
|
||||
sum_other.percent = sum([i['total'] for i in percpu_list[self.max_cpu_display :]]) / len(
|
||||
percpu_list[self.max_cpu_display :]
|
||||
)
|
||||
msg = msg = '{:3}* '.format(key.upper())
|
||||
ret.extend(self._msg_create_line(msg, sum_other, key))
|
||||
|
|
|
|||
|
|
@ -80,9 +80,7 @@ class PluginModel(GlancesPluginModel):
|
|||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args, config=config,
|
||||
stats_init_value=[],
|
||||
fields_description=fields_description
|
||||
args=args, config=config, stats_init_value=[], fields_description=fields_description
|
||||
)
|
||||
|
||||
start_duration = Counter()
|
||||
|
|
@ -174,18 +172,10 @@ class PluginModel(GlancesPluginModel):
|
|||
if self.input_method == 'local':
|
||||
threads_stats = [None] * 4
|
||||
threads = [
|
||||
threading.Thread(name=SENSOR_TEMP_TYPE,
|
||||
target=self.__get_temperature,
|
||||
args=(threads_stats, 0)),
|
||||
threading.Thread(name=SENSOR_FAN_TYPE,
|
||||
target=self.__get_fan_speed,
|
||||
args=(threads_stats, 1)),
|
||||
threading.Thread(name=SENSOR_HDDTEMP_TYPE,
|
||||
target=self.__get_hddtemp,
|
||||
args=(threads_stats, 2)),
|
||||
threading.Thread(name=SENSORS_BATTERY_TYPE,
|
||||
target=self.__get_bat_percent,
|
||||
args=(threads_stats, 3))
|
||||
threading.Thread(name=SENSOR_TEMP_TYPE, target=self.__get_temperature, args=(threads_stats, 0)),
|
||||
threading.Thread(name=SENSOR_FAN_TYPE, target=self.__get_fan_speed, args=(threads_stats, 1)),
|
||||
threading.Thread(name=SENSOR_HDDTEMP_TYPE, target=self.__get_hddtemp, args=(threads_stats, 2)),
|
||||
threading.Thread(name=SENSORS_BATTERY_TYPE, target=self.__get_bat_percent, args=(threads_stats, 3)),
|
||||
]
|
||||
# Start threads in //
|
||||
for t in threads:
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ fields_description = {
|
|||
},
|
||||
'hr_name': {
|
||||
'description': 'Human readable operating sytem name',
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
# SNMP OID
|
||||
|
|
@ -110,7 +110,6 @@ def _linux_os_release():
|
|||
|
||||
|
||||
class PluginModel(GlancesPluginModel):
|
||||
|
||||
"""Glances' host/system plugin.
|
||||
|
||||
stats is a dict
|
||||
|
|
@ -118,11 +117,7 @@ class PluginModel(GlancesPluginModel):
|
|||
|
||||
def __init__(self, args=None, config=None):
|
||||
"""Init the plugin."""
|
||||
super(PluginModel, self).__init__(
|
||||
args=args,
|
||||
config=config,
|
||||
fields_description=fields_description
|
||||
)
|
||||
super(PluginModel, self).__init__(args=args, config=config, fields_description=fields_description)
|
||||
|
||||
# We want to display the stat in the curse interface
|
||||
self.display_curse = True
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ if not wireless_file_exists:
|
|||
# rate: if True then compute and add *_gauge and *_rate_per_is fields
|
||||
# min_symbol: Auto unit should be used if value > than 1 'X' (K, M, G)...
|
||||
fields_description = {
|
||||
'ssid': {
|
||||
'description': 'Wi-Fi network name.'
|
||||
},
|
||||
'ssid': {'description': 'Wi-Fi network name.'},
|
||||
'quality_link': {
|
||||
'description': 'Signal quality level.',
|
||||
'unit': 'dBm',
|
||||
|
|
@ -196,18 +194,15 @@ class PluginModel(GlancesPluginModel):
|
|||
ret.append(self.curse_new_line())
|
||||
# New hotspot
|
||||
hotspot_name = i['ssid']
|
||||
msg = '{:{width}}'.format(
|
||||
nativestr(hotspot_name),
|
||||
width=if_name_max_width
|
||||
)
|
||||
msg = '{:{width}}'.format(nativestr(hotspot_name), width=if_name_max_width)
|
||||
ret.append(self.curse_add_line(msg))
|
||||
msg = '{:>7}'.format(
|
||||
i['quality_level'],
|
||||
)
|
||||
ret.append(
|
||||
self.curse_add_line(msg, self.get_views(item=i[self.get_key()],
|
||||
key='quality_level',
|
||||
option='decoration'))
|
||||
self.curse_add_line(
|
||||
msg, self.get_views(item=i[self.get_key()], key='quality_level', option='decoration')
|
||||
)
|
||||
)
|
||||
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ else:
|
|||
|
||||
|
||||
class GlancesPortsList(object):
|
||||
|
||||
"""Manage the ports list for the ports plugin."""
|
||||
|
||||
_section = "ports"
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ from glances.programs import processes_to_programs
|
|||
from glances.logger import logger
|
||||
|
||||
import psutil
|
||||
|
||||
psutil_version_info = tuple([int(num) for num in psutil.__version__.split('.')])
|
||||
|
||||
# This constant defines the list of available processes sort key
|
||||
|
|
@ -385,14 +386,14 @@ class GlancesProcesses(object):
|
|||
def is_selected_extended_process(self, position):
|
||||
"""Return True if the process is the selected one for extended stats."""
|
||||
return (
|
||||
hasattr(self.args, 'programs') and
|
||||
not self.args.programs and
|
||||
hasattr(self.args, 'enable_process_extended') and
|
||||
self.args.enable_process_extended and
|
||||
not self.disable_extended_tag and
|
||||
hasattr(self.args, 'cursor_position') and
|
||||
position == self.args.cursor_position and
|
||||
not self.args.disable_cursor
|
||||
hasattr(self.args, 'programs')
|
||||
and not self.args.programs
|
||||
and hasattr(self.args, 'enable_process_extended')
|
||||
and self.args.enable_process_extended
|
||||
and not self.disable_extended_tag
|
||||
and hasattr(self.args, 'cursor_position')
|
||||
and position == self.args.cursor_position
|
||||
and not self.args.disable_cursor
|
||||
)
|
||||
|
||||
def update(self):
|
||||
|
|
@ -548,16 +549,14 @@ class GlancesProcesses(object):
|
|||
"""Return the process list after filtering and transformation (namedtuple to dict)."""
|
||||
if self._filter.filter is None:
|
||||
return list_of_namedtuple_to_list_of_dict(processlist)
|
||||
ret = list(filter(lambda p: self._filter.is_filtered(p),
|
||||
processlist))
|
||||
ret = list(filter(lambda p: self._filter.is_filtered(p), processlist))
|
||||
return list_of_namedtuple_to_list_of_dict(ret)
|
||||
|
||||
def update_export_list(self, processlist):
|
||||
"""Return the process export list after filtering and transformation (namedtuple to dict)."""
|
||||
if self._filter_export.filter == []:
|
||||
return []
|
||||
ret = list(filter(lambda p: self._filter_export.is_filtered(p),
|
||||
processlist))
|
||||
ret = list(filter(lambda p: self._filter_export.is_filtered(p), processlist))
|
||||
return list_of_namedtuple_to_list_of_dict(ret)
|
||||
|
||||
def get_count(self):
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from glances.timer import Timer
|
|||
|
||||
|
||||
class GlancesXMLRPCHandler(SimpleXMLRPCRequestHandler, object):
|
||||
|
||||
"""Main XML-RPC handler."""
|
||||
|
||||
rpc_paths = ('/RPC2',)
|
||||
|
|
@ -88,7 +87,6 @@ class GlancesXMLRPCHandler(SimpleXMLRPCRequestHandler, object):
|
|||
|
||||
|
||||
class GlancesXMLRPCServer(SimpleXMLRPCServer, object):
|
||||
|
||||
"""Init a SimpleXMLRPCServer instance (IPv6-ready)."""
|
||||
|
||||
finished = False
|
||||
|
|
@ -117,7 +115,6 @@ class GlancesXMLRPCServer(SimpleXMLRPCServer, object):
|
|||
|
||||
|
||||
class GlancesInstance(object):
|
||||
|
||||
"""All the methods of this class are published as XML-RPC methods."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
@ -182,7 +179,6 @@ class GlancesInstance(object):
|
|||
|
||||
|
||||
class GlancesServer(object):
|
||||
|
||||
"""This class creates and manages the TCP server."""
|
||||
|
||||
def __init__(self, requestHandler=GlancesXMLRPCHandler, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ except ImportError:
|
|||
|
||||
|
||||
class GlancesSNMPClient(object):
|
||||
|
||||
"""SNMP client class (based on pysnmp library)."""
|
||||
|
||||
def __init__(self, host='localhost', port=161, version='2c', community='public', user='private', auth=''):
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ from glances.timer import Counter
|
|||
|
||||
|
||||
class GlancesStandalone(object):
|
||||
|
||||
"""This class creates and manages the Glances standalone session."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ from glances.logger import logger
|
|||
|
||||
|
||||
class GlancesStaticServer(object):
|
||||
|
||||
"""Manage the static servers list for the client browser."""
|
||||
|
||||
_section = "serverlist"
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from glances.timer import Counter
|
|||
|
||||
|
||||
class GlancesStats(object):
|
||||
|
||||
"""This class stores, updates and gives stats."""
|
||||
|
||||
# Script header constant
|
||||
|
|
@ -50,7 +49,7 @@ class GlancesStats(object):
|
|||
# Check if the attribute starts with 'get'
|
||||
if item.startswith('getViews'):
|
||||
# Get the plugin name
|
||||
plugname = item[len('getViews'):].lower()
|
||||
plugname = item[len('getViews') :].lower()
|
||||
# Get the plugin instance
|
||||
plugin = self._plugins[plugname]
|
||||
if hasattr(plugin, 'get_json_views'):
|
||||
|
|
@ -61,7 +60,7 @@ class GlancesStats(object):
|
|||
raise AttributeError(item)
|
||||
elif item.startswith('get'):
|
||||
# Get the plugin name
|
||||
plugname = item[len('get'):].lower()
|
||||
plugname = item[len('get') :].lower()
|
||||
# Get the plugin instance
|
||||
plugin = self._plugins[plugname]
|
||||
if hasattr(plugin, 'get_stats'):
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from glances.logger import logger
|
|||
|
||||
|
||||
class GlancesStatsClient(GlancesStats):
|
||||
|
||||
"""This class stores, updates and gives stats for the client."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ oid_to_short_system_name = {
|
|||
|
||||
|
||||
class GlancesStatsClientSNMP(GlancesStats):
|
||||
|
||||
"""This class stores, updates and gives stats for the SNMP client."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ from glances.logger import logger
|
|||
|
||||
|
||||
class GlancesStatsServer(GlancesStats):
|
||||
|
||||
"""This class stores, updates and gives stats for the server."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ glances_thresholds = GlancesThresholds()
|
|||
|
||||
@total_ordering
|
||||
class _GlancesThreshold(object):
|
||||
|
||||
"""Father class for all other Thresholds"""
|
||||
|
||||
def description(self):
|
||||
|
|
@ -81,28 +80,24 @@ class _GlancesThreshold(object):
|
|||
|
||||
|
||||
class GlancesThresholdOk(_GlancesThreshold):
|
||||
|
||||
"""Ok Threshold class"""
|
||||
|
||||
_threshold = {'description': 'OK', 'value': 0}
|
||||
|
||||
|
||||
class GlancesThresholdCareful(_GlancesThreshold):
|
||||
|
||||
"""Careful Threshold class"""
|
||||
|
||||
_threshold = {'description': 'CAREFUL', 'value': 1}
|
||||
|
||||
|
||||
class GlancesThresholdWarning(_GlancesThreshold):
|
||||
|
||||
"""Warning Threshold class"""
|
||||
|
||||
_threshold = {'description': 'WARNING', 'value': 2}
|
||||
|
||||
|
||||
class GlancesThresholdCritical(_GlancesThreshold):
|
||||
|
||||
"""Warning Threshold class"""
|
||||
|
||||
_threshold = {'description': 'CRITICAL', 'value': 3}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ def getTimeSinceLastUpdate(IOType):
|
|||
|
||||
|
||||
class Timer(object):
|
||||
|
||||
"""The timer class. A simple chronometer."""
|
||||
|
||||
def __init__(self, duration):
|
||||
|
|
@ -57,7 +56,6 @@ class Timer(object):
|
|||
|
||||
|
||||
class Counter(object):
|
||||
|
||||
"""The counter class."""
|
||||
|
||||
def __init__(self):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ from glances.logger import logger
|
|||
|
||||
|
||||
class GlancesWebList(object):
|
||||
|
||||
"""Manage the Web/Url list for the ports plugin."""
|
||||
|
||||
_section = "ports"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
"""Glances Restful/API and Web based interface."""
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.globals import WINDOWS
|
||||
from glances.processes import glances_processes
|
||||
from glances.stats import GlancesStats
|
||||
|
|
@ -17,7 +16,6 @@ from glances.outputs.glances_restful_api import GlancesRestfulApi
|
|||
|
||||
|
||||
class GlancesWebServer(object):
|
||||
|
||||
"""This class creates and manages the Glances Web server session."""
|
||||
|
||||
def __init__(self, config=None, args=None):
|
||||
|
|
|
|||
20
unitest.py
20
unitest.py
|
|
@ -151,14 +151,14 @@ class TestGlances(unittest.TestCase):
|
|||
"""Check NETWORK plugin."""
|
||||
print('INFO: [TEST_007] Check NETWORK stats')
|
||||
stats_grab = stats.get_plugin('network').get_raw()
|
||||
self.assertTrue(type(stats_grab) is list, msg='Network stats is not a list')
|
||||
self.assertTrue(isinstance(stats_grab, list), msg='Network stats is not a list')
|
||||
print('INFO: NETWORK stats: %s' % stats_grab)
|
||||
|
||||
def test_008_diskio(self):
|
||||
"""Check DISKIO plugin."""
|
||||
print('INFO: [TEST_008] Check DISKIO stats')
|
||||
stats_grab = stats.get_plugin('diskio').get_raw()
|
||||
self.assertTrue(type(stats_grab) is list, msg='DiskIO stats is not a list')
|
||||
self.assertTrue(isinstance(stats_grab, list), msg='DiskIO stats is not a list')
|
||||
print('INFO: diskio stats: %s' % stats_grab)
|
||||
|
||||
def test_009_fs(self):
|
||||
|
|
@ -166,7 +166,7 @@ class TestGlances(unittest.TestCase):
|
|||
# stats_to_check = [ ]
|
||||
print('INFO: [TEST_009] Check FS stats')
|
||||
stats_grab = stats.get_plugin('fs').get_raw()
|
||||
self.assertTrue(type(stats_grab) is list, msg='FileSystem stats is not a list')
|
||||
self.assertTrue(isinstance(stats_grab, list), msg='FileSystem stats is not a list')
|
||||
print('INFO: FS stats: %s' % stats_grab)
|
||||
|
||||
def test_010_processes(self):
|
||||
|
|
@ -175,10 +175,10 @@ class TestGlances(unittest.TestCase):
|
|||
print('INFO: [TEST_010] Check PROCESS stats')
|
||||
stats_grab = stats.get_plugin('processcount').get_raw()
|
||||
# total = stats_grab['total']
|
||||
self.assertTrue(type(stats_grab) is dict, msg='Process count stats is not a dict')
|
||||
self.assertTrue(isinstance(stats_grab, dict), msg='Process count stats is not a dict')
|
||||
print('INFO: PROCESS count stats: %s' % stats_grab)
|
||||
stats_grab = stats.get_plugin('processlist').get_raw()
|
||||
self.assertTrue(type(stats_grab) is list, msg='Process count stats is not a list')
|
||||
self.assertTrue(isinstance(stats_grab, list), msg='Process count stats is not a list')
|
||||
print('INFO: PROCESS list stats: %s items in the list' % len(stats_grab))
|
||||
# Check if number of processes in the list equal counter
|
||||
# self.assertEqual(total, len(stats_grab))
|
||||
|
|
@ -188,14 +188,14 @@ class TestGlances(unittest.TestCase):
|
|||
# stats_to_check = [ ]
|
||||
print('INFO: [TEST_011] Check FOLDER stats')
|
||||
stats_grab = stats.get_plugin('folders').get_raw()
|
||||
self.assertTrue(type(stats_grab) is list, msg='Folders stats is not a list')
|
||||
self.assertTrue(isinstance(stats_grab, list), msg='Folders stats is not a list')
|
||||
print('INFO: Folders stats: %s' % stats_grab)
|
||||
|
||||
def test_012_ip(self):
|
||||
"""Check IP plugin."""
|
||||
print('INFO: [TEST_012] Check IP stats')
|
||||
stats_grab = stats.get_plugin('ip').get_raw()
|
||||
self.assertTrue(type(stats_grab) is dict, msg='IP stats is not a dict')
|
||||
self.assertTrue(isinstance(stats_grab, dict), msg='IP stats is not a dict')
|
||||
print('INFO: IP stats: %s' % stats_grab)
|
||||
|
||||
@unittest.skipIf(not LINUX, "IRQs available only on Linux")
|
||||
|
|
@ -203,7 +203,7 @@ class TestGlances(unittest.TestCase):
|
|||
"""Check IRQ plugin."""
|
||||
print('INFO: [TEST_013] Check IRQ stats')
|
||||
stats_grab = stats.get_plugin('irq').get_raw()
|
||||
self.assertTrue(type(stats_grab) is list, msg='IRQ stats is not a list')
|
||||
self.assertTrue(isinstance(stats_grab, list), msg='IRQ stats is not a list')
|
||||
print('INFO: IRQ stats: %s' % stats_grab)
|
||||
|
||||
@unittest.skipIf(not LINUX, "GPU available only on Linux")
|
||||
|
|
@ -211,7 +211,7 @@ class TestGlances(unittest.TestCase):
|
|||
"""Check GPU plugin."""
|
||||
print('INFO: [TEST_014] Check GPU stats')
|
||||
stats_grab = stats.get_plugin('gpu').get_raw()
|
||||
self.assertTrue(type(stats_grab) is list, msg='GPU stats is not a list')
|
||||
self.assertTrue(isinstance(stats_grab, list), msg='GPU stats is not a list')
|
||||
print('INFO: GPU stats: %s' % stats_grab)
|
||||
|
||||
def test_015_sorted_stats(self):
|
||||
|
|
@ -404,7 +404,7 @@ class TestGlances(unittest.TestCase):
|
|||
for plugin in plugins_list:
|
||||
stats.get_plugin(plugin).get_raw()
|
||||
views_grab = stats.get_plugin(plugin).get_views()
|
||||
self.assertTrue(type(views_grab) is dict,
|
||||
self.assertTrue(isinstance(views_grab, dict),
|
||||
msg='{} view is not a dict'.format(plugin))
|
||||
|
||||
def test_097_attribute(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue