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