diff options
author | nicolargo <nicolas@nicolargo.com> | 2023-06-04 10:44:42 +0200 |
---|---|---|
committer | nicolargo <nicolas@nicolargo.com> | 2023-06-04 10:44:42 +0200 |
commit | cf2dcb3d6bb7cb92aa15f5591cc051bed5731c46 (patch) | |
tree | a2dcecf9708250617f31b3edd5a3a58e3f721064 /docs/api.rst | |
parent | 513e4486fb66e2e1bef5b923a4bdb1879309fe3c (diff) |
Feature request: support path prefix so we can watch glances via url like http://ip/urlprefix/ #1365
Diffstat (limited to 'docs/api.rst')
-rw-r--r-- | docs/api.rst | 813 |
1 files changed, 196 insertions, 617 deletions
diff --git a/docs/api.rst b/docs/api.rst index d449bf4b..1bd720f9 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -9,7 +9,25 @@ The Glances Restfull/API server could be ran using the following command line: # glances -w --disable-webui -Note: Change request URL api/3 by api/2 if you use Glances 2.x. +API URL +------- + +The default root API URL is ``http://localhost:61208/api/3``. + +The bind addresse and port could be changed using the ``--bind`` and ``--port`` command line options. + +It is also possible to define an URL prefix using the ``url_prefix`` option from the [outputs] section +of the Glances configuration file. The url_prefix should always end with a slash (``/``). + +For example: + +.. code-block:: ini + [outputs] + url_prefix = /glances/ + +will change the root API URL to ``http://localhost:61208/glances/api/3`` and the Web UI URL to +``http://localhost:61208/glances/`` + GET API status -------------- @@ -60,6 +78,37 @@ Get the plugins list:: "uptime", "wifi"] +GET alert +--------- + +Get plugin stats:: + + # curl http://localhost:61208/api/3/alert + [[1685868235.0, + -1, + "WARNING", + "MEM", + 82.5138999890755, + 82.5138999890755, + 82.5138999890755, + 82.5138999890755, + 1, + [], + "", + "memory_percent"], + [1685868235.0, + -1, + "WARNING", + "MEMSWAP", + 71.3584259851909, + 71.3584259851909, + 71.3584259851909, + 71.3584259851909, + 1, + [], + "", + "memory_percent"]] + GET amps -------- @@ -74,8 +123,7 @@ Get plugin stats:: "refresh": 3.0, "regex": True, "result": None, - "timer": 1.3811793327331543}, - "timer": 1.0034148693084717}, + "timer": 0.6977648735046387}, {"count": 0, "countmax": 20.0, "countmin": None, @@ -84,8 +132,7 @@ Get plugin stats:: "refresh": 3.0, "regex": True, "result": None, - "timer": 1.3809046745300293}] - "timer": 1.003244400024414}] + "timer": 0.6975433826446533}] Get a specific field:: @@ -103,7 +150,7 @@ Get a specific item when field matchs the given value:: "refresh": 3.0, "regex": True, "result": None, - "timer": 1.0034148693084717}]} + "timer": 0.6977648735046387}]} GET connections --------------- @@ -124,21 +171,44 @@ GET containers Get plugin stats:: # curl http://localhost:61208/api/3/containers - {"containers": [{"Command": ["top"], + {"containers": [{"Command": ["/portainer"], + "Created": "2022-10-29T14:59:10.266701439Z", + "Id": "3abd51c615968482d9ccff5afc629f267f6dda113ed68b75b432615fae3b49fb", + "Image": ["portainer/portainer-ce:2.9.3"], + "Status": "running", + "Uptime": "6 days", + "cpu": {"total": 0.0}, + "cpu_percent": 0.0, + "engine": "docker", + "io": {"cumulative_ior": 454656, "cumulative_iow": 1601536}, + "io_r": None, + "io_w": None, + "key": "name", + "memory": {"cache": None, + "limit": 7836184576, + "max_usage": None, + "rss": None, + "usage": 14630912}, + "memory_usage": 14630912, + "name": "portainer", + "network": {"cumulative_rx": 4178062, "cumulative_tx": 0}, + "network_rx": None, + "network_tx": None}, + {"Command": ["top"], "Created": "2023-05-08T15:29:34.918692365+02:00", "Id": "4b7f732d43e4bc5d92fe5298cba025b550e6a608754c1c38f9a90aaecd46b8f9", "Image": "["docker.io/library/ubuntu:latest"]", "Status": "running", - "Uptime": "1 weeks", - "cpu": {"total": 7.811242562687869e-07}, - "cpu_percent": 7.811242562687869e-07, + "Uptime": "3 weeks", + "cpu": {"total": 4.595457301269493e-06}, + "cpu_percent": 4.595457301269493e-06, "engine": "podman", "io": {"ior": 0.0, "iow": 0.0, "time_since_update": 1}, "io_r": 0.0, "io_w": 0.0, "key": "name", - "memory": {"limit": 7836184576.0, "usage": 1576960.0}, - "memory_usage": 1576960.0, + "memory": {"limit": 7836184576.0, "usage": 1105920.0}, + "memory_usage": 1105920.0, "name": "frosty_bouman", "network": {"rx": 0.0, "time_since_update": 1, "tx": 0.0}, "network_rx": 0.0, @@ -150,41 +220,22 @@ Get plugin stats:: "Id": "9491515251edcd5bb5dc17205d7ee573c0be96fe0b08b0a12a7e2cea874565ea", "Image": "["k8s.gcr.io/pause:3.5"]", "Status": "running", - "Uptime": "1 weeks", - "cpu": {"total": 2.630294095569028e-10}, - "cpu_percent": 2.630294095569028e-10, + "Uptime": "3 weeks", + "cpu": {"total": 2.917191208219233e-10}, + "cpu_percent": 2.917191208219233e-10, "engine": "podman", "io": {"ior": 0.0, "iow": 0.0, "time_since_update": 1}, "io_r": 0.0, "io_w": 0.0, "key": "name", - "memory": {"limit": 7836184576.0, "usage": 454656.0}, - "memory_usage": 454656.0, + "memory": {"limit": 7836184576.0, "usage": 204800.0}, + "memory_usage": 204800.0, "name": "8d0f1c783def-infra", "network": {"rx": 0.0, "time_since_update": 1, "tx": 0.0}, "network_rx": 0.0, "network_tx": 0.0, "pod_id": "8d0f1c783def", - "pod_name": "8d0f1c783def-infra"}, - {"Command": ["/portainer"], - "Created": "2022-10-29T14:59:10.266701439Z", - "Id": "3abd51c615968482d9ccff5afc629f267f6dda113ed68b75b432615fae3b49fb", - "Image": ["portainer/portainer-ce:2.9.3"], - "Status": "running", - "Uptime": "3 days", - "cpu": {"total": 0.0}, - "cpu_percent": 0.0, - "engine": "docker", - "io": {}, - "io_r": None, - "io_w": None, - "key": "name", - "memory": {}, - "memory_usage": None, - "name": "portainer", - "network": {}, - "network_rx": None, - "network_tx": None}], + "pod_name": "8d0f1c783def-infra"}], "version": {}, "version_podman": {}} @@ -216,19 +267,19 @@ Get plugin stats:: "ctx_switches": 0, "guest": 0.0, "guest_nice": 0.0, - "idle": 73.0, + "idle": 46.5, "interrupts": 0, - "iowait": 0.2, + "iowait": 5.9, "irq": 0.0, "nice": 0.0, "soft_interrupts": 0, - "softirq": 0.4, + "softirq": 0.0, "steal": 0.0, "syscalls": 0, - "system": 4.1, + "system": 8.8, "time_since_update": 1, - "total": 27.4, - "user": 22.7} + "total": 47.6, + "user": 38.8} Fields descriptions: @@ -251,7 +302,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/3/cpu/total - {"total": 27.4} + {"total": 47.6} GET diskio ---------- @@ -297,13 +348,13 @@ Get plugin stats:: # curl http://localhost:61208/api/3/fs [{"device_name": "/dev/mapper/ubuntu--gnome--vg-root", - "free": 7953657856, + "free": 29491679232, "fs_type": "ext4", "key": "mnt_point", "mnt_point": "/", - "percent": 96.6, + "percent": 87.2, "size": 243334156288, - "used": 222993043456}, + "used": 201455022080}, {"device_name": "zsfpool", "free": 41811968, "fs_type": "zfs", @@ -322,13 +373,13 @@ Get a specific item when field matchs the given value:: # curl http://localhost:61208/api/3/fs/mnt_point// {"/": [{"device_name": "/dev/mapper/ubuntu--gnome--vg-root", - "free": 7953657856, + "free": 29491679232, "fs_type": "ext4", "key": "mnt_point", "mnt_point": "/", - "percent": 96.6, + "percent": 87.2, "size": 243334156288, - "used": 222993043456}]} + "used": 201455022080}]} GET ip ------ @@ -354,10 +405,7 @@ GET load Get plugin stats:: # curl http://localhost:61208/api/3/load - {"cpucore": 4, - "min1": 0.55029296875, - "min15": 1.06982421875, - "min5": 0.85693359375} + {"cpucore": 4, "min1": 3.21533203125, "min15": 1.640625, "min5": 2.1494140625} Fields descriptions: @@ -369,7 +417,7 @@ Fields descriptions: Get a specific field:: # curl http://localhost:61208/api/3/load/min1 - {"min1": 0.55029296875} + {"min1": 3.21533203125} GET mem ------- @@ -377,16 +425,16 @@ GET mem Get plugin stats:: # curl http://localhost:61208/api/3/mem - {"active": 3109634048, - "available": 2829815808, - "buffers": 207228928, - "cached": 3178246144, - "free": 2829815808, - "inactive": 3462545408, - "percent": 63.9, - "shared": 451821568, + {"active": 3263922176, + "available": 1370243072, + "buffers": 104714240, + "cached": 1946484736, + "free": 1370243072, + "inactive": 3313500160, + "percent": 82.5, + "shared": 608448512, "total": 7836184576, - "used": 5006368768} + "used": 6465941504} Fields descriptions: @@ -413,13 +461,13 @@ GET memswap Get plugin stats:: # curl http://localhost:61208/api/3/memswap - {"free": 5400473600, - "percent": 33.2, - "sin": 2319233024, - "sout": 4863959040, + {"free": 2314932224, + "percent": 71.4, + "sin": 18428387328, + "sout": 26147098624, "time_since_update": 1, "total": 8082419712, - "used": 2681946112} + "used": 5767487488} Fields descriptions: @@ -443,29 +491,29 @@ Get plugin stats:: # curl http://localhost:61208/api/3/network [{"alias": None, - "cumulative_cx": 130574070, - "cumulative_rx": 65287035, - "cumulative_tx": 65287035, - "cx": 2414, + "cumulative_cx": 620625100, + "cumulative_rx": 310312550, + "cumulative_tx": 310312550, + "cx": 0, "interface_name": "lo", "is_up": True, "key": "interface_name", - "rx": 1207, + "rx": 0, "speed": 0, "time_since_update": 1, - "tx": 1207}, + "tx": 0}, {"alias": None, - "cumulative_cx": 8162673663, - "cumulative_rx": 7914211852, - "cumulative_tx": 248461811, - "cx": 17399, + "cumulative_cx": 25774388477, + "cumulative_rx": 24727418740, + "cumulative_tx": 1046969737, + "cx": 705, "interface_name": "wlp2s0", "is_up": True, "key": "interface_name", - "rx": 13173, + "rx": 465, "speed": 0, "time_since_update": 1, - "tx": 4226}] + "tx": 240}] Fields descriptions: @@ -489,23 +537,25 @@ Get a specific field:: "docker0", "br_grafana", "mpqemubr0", - "vethcddb0e6"]} + "vethb2d0673", + "vboxnet0", + "tap-1e376645a40"]} Get a specific item when field matchs the given value:: # curl http://localhost:61208/api/3/network/interface_name/lo {"lo": [{"alias": None, - "cumulative_cx": 130574070, - "cumulative_rx": 65287035, - "cumulative_tx": 65287035, - "cx": 2414, + "cumulative_cx": 620625100, + "cumulative_rx": 310312550, + "cumulative_tx": 310312550, + "cx": 0, "interface_name": "lo", "is_up": True, "key": "interface_name", - "rx": 1207, + "rx": 0, "speed": 0, "time_since_update": 1, - "tx": 1207}]} + "tx": 0}]} GET now ------- @@ -513,7 +563,7 @@ GET now Get plugin stats:: # curl http://localhost:61208/api/3/now - "2023-05-16 09:31:49 CEST" + "2023-06-04 10:43:55 CEST" GET percpu ---------- @@ -524,29 +574,29 @@ Get plugin stats:: [{"cpu_number": 0, "guest": 0.0, "guest_nice": 0.0, - "idle": 19.8, - "iowait": 0.0, + "idle": 38.0, + "iowait": 9.0, "irq": 0.0, "key": "cpu_number", "nice": 0.0, "softirq": 0.0, "steal": 0.0, - "system": 3.4, - "total": 80.2, - "user": 76.7}, + "system": 12.0, + "total": 62.0, + "user": 32.0}, {"cpu_number": 1, "guest": 0.0, "guest_nice": 0.0, - "idle": 91.2, - "iowait": 0.0, + "idle": 42.0, + "iowait": 7.0, "irq": 0.0, "key": "cpu_number", "nice": 0.0, "softirq": 0.0, "steal": 0.0, - "system": 2.7, - "total": 8.8, - "user": 6.2}] + "system": 9.0, + "total": 58.0, + "user": 31.0}] Get a specific field:: @@ -565,7 +615,7 @@ Get plugin stats:: "port": 0, "refresh": 30, "rtt_warning": None, - "status": 0.005767, + "status": 0.007061, "timeout": 3}] Get a specific field:: @@ -582,7 +632,7 @@ Get a specific item when field matchs the given value:: "port": 0, "refresh": 30, "rtt_warning": None, - "status": 0.005767, + "status": 0.007061, "timeout": 3}]} GET processcount @@ -591,480 +641,12 @@ GET processcount Get plugin stats:: # curl http://localhost:61208/api/3/processcount - {"pid_max": 0, "running": 1, "sleeping": 315, "thread": 1562, "total": 382} + {"pid_max": 0, "running": 1, "sleeping": 355, "thread": 1985, "total": 424} Get a specific field:: # curl http://localhost:61208/api/3/processcount/total - {"total": 382} - -GET processlist ---------------- - -Get plugin stats:: - - # curl http://localhost:61208/api/3/processlist - [{"cmdline": ["/snap/firefox/2605/usr/lib/firefox/firefox"], - "cpu_percent": 0.0, - "cpu_times": [5239.7, 1595.52, 4093.05, 570.73, 0.0], - "gids": [1000, 1000, 1000], - "io_counters": [3503764480, 5856641024, 0, 0, 0], - "key": "pid", - "memory_info": [468434944, 22123225088, 114802688, 618496, 0, 1282670592, 0], - "memory_percent": 5.977844695423366, - "name": "firefox", - "nice": 0, - "num_threads": 160, - "pid": 10541, - "status": "S", - "time_since_update": 1, - "username": "nicolargo"}, - {"cmdline": ["/snap/firefox/2605/usr/lib/firefox/firefox", - "-contentproc", - "-childID", - "6", - "-isForBrowser", - "-prefsLen", - "38436", - "-prefMapSize", - "241898", - "-jsInitLen", - "240056", - "-parentBuildID", - "20230424185118", - "-appDir", - "/snap/firefox/2605/usr/lib/firefox/browser", - "{c94b5dea-52c6-4c75-a314-5de48bda9cdc}", - "10541", - "true", - "tab"], - "cpu_percent": 0.0, - "cpu_times": [914.43, 104.03, 0.0, 0.0, 0.0], - "gids": [1000, 1000, 1000], - "io_counters": [131410944, 0, 0, 0, 0], - "key": "pid", - "memory_info": [438992896, 3601903616, 70893568, 618496, 0, 1002868736, 0], - "memory_percent": 5.602125520939235, - "name": "WebExtensions", - "nice": 0, - "num_threads": 20, - "pid": 11043, - "status": "S", - "time_since_update": 1, - "username": "nicolargo"}] - -Get a specific field:: - - # curl http://localhost:61208/api/3/processlist/pid - {"pid": [10541, - 11043, - 10770, - 55857, - 10778, - 181461, - 59195, - 3927, - 60503, - 10774, - 59454, - 195248, - 228679, - 165661, - 10790, - 4288, - 11646, - 10733, - 59069, - 229507, - 229901, - 229717, - 421, - 59523, - 59161, - 60232, - 60489, - 230002, - 2398, - 230013, - 60104, - 3810, - 60106, - 195141, - 59525, - 4243, - 60134, - 11381, - 10710, - 11380, - 4385, - 1618, - 59663, - 143262, - 143263, - 193297, - 193376, - 59182, - 2636, - 1771, - 4023, - 3730, - 60191, - 4666, - 60192, - 1, - 193364, - 1584, - 227509, - 56140, - 17997, - 4179, - 4091, - 4000, - 4090, - 4403, - 4075, - 3901, - 3115, - 193411, - 2554, - 1605, - 1794, - 1630, - 2168, - 4046, - 36919, - 3991, - 4308, - 3719, - 4339, - 59126, - 20173, - 2607, - 1598, - 3710, - 2341, - 1631, - 3956, - 1727, - 4105, - 59127, - 3908, - 4009, - 1379, - 1764, - 4086, - 4244, - 1818, - 1583, - 197243, - 4127, - 4169, - 4126, - 14243, - 4442, - 74953, - 14266, - 4097, - 1627, - 4078, - 2116, - 1628, - 4080, - 1566, - 3745, - 3498, - 4145, - 4119, - 3748, - 3925, - 2604, - 3939, - 4062, - 3970, - 1591, - 4033, - 3952, - 4099, - 4005, - 1624, - 1612, - 4316, - 4196, - 3825, - 3947, - 1825, - 4107, - 1606, - 3975, - 4098, - 4302, - 2605, - 1579, - 3743, - 4074, - 60199, - 3989, - 10848, - 3819, - 4157, - 461, - 1380, - 4079, - 3753, - 3499, - 56119, - 3727, - 1616, - 1575, - 3728, - 3888, - 3934, - 1593, - 1377, - 1964, - 229977, - 1582, - 12480, - 12489, - 18045, - 4332, - 3118, - 1634, - 1390, - 1391, - 59145, - 3573, - 2361, - 20400, - 16182, - 1725, - 1726, - 12483, - 1567, - 20396, - 20180, - 12492, - 59130, - 230001, - 4593, - 3720, - 56100, - 56106, - 56087, - 3503, - 56081, - 4072, - 3794, - 2358, - 225591, - 2382, - 2345, - 1637, - 2360, - 1392, - 20185, - 1577, - 12486, - 2, - 3, - 4, - 5, - 6, - 8, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 18, - 19, - 20, - 21, - 22, - 24, - 25, - 26, - 27, - 28, - 30, - 31, - 32, - 33, - 34, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99, - 100, - 101, - 103, - 106, - 107, - 109, - 110, - 112, - 117, - 117, - 118, - 119, - 129, - 132, - 138, - 181, - 183, - 206, - 219, - 223, - 226, - 228, - 231, - 232, - 233, - 234, - 249, - 254, - 255, - 256, - 313, - 361, - 362, - 439, - 440, - 530, - 544, - 655, - 700, - 702, - 703, - 898, - 899, - 900, - 901, - 908, - 909, - 910, - 911, - 912, - 913, - 914, - 915, - 962, - 963, - 964, - 965, - 966, - 967, - 968, - 969, - 970, - 971, - 972, - 973, - 974, - 975, - 976, - 977, - 978, - 979, - 980, - 1001, - 1002, - 1009, - 1010, - 1031, - 1032, - 1033, - 1034, - 1035, - 1036, - 1037, - 2138, - 2140, - 2141, - 2142, - 2143, - 2394, - 2410, - 2422, - 2491, - 2492, - 2493, - 2506, - 2508, - 2510, - 2515, - 2525, - 3988, - 190070, - 190071, - 190072, - 193066, - 193067, - 193069, - 193070, - 193072, - 193122, - 199564, - 199838, - 199918, - 200002, - 224417, - 225391, - 226425, - 228320, - 228350, - 228656, - 228870, - 228902, - 229080, - 229081, - 229082, - 229233, - 229447, - 229542, - 229866, - 229894]} - -Get a specific item when field matchs the given value:: - - # curl http://localhost:61208/api/3/processlist/pid/10541 - {"10541": [{"cmdline": ["/snap/firefox/2605/usr/lib/firefox/firefox"], - "cpu_percent": 0.0, - "cpu_times": [5239.7, 1595.52, 4093.05, 570.73, 0.0], - "gids": [1000, 1000, 1000], - "io_counters": [3503764480, 5856641024, 0, 0, 0], - "key": "pid", - "memory_info": [468434944, - 22123225088, - 114802688, - 618496, - 0, - 1282670592, - 0], - "memory_percent": 5.977844695423366, - "name": "firefox", - "nice": 0, - "num_threads": 160, - "pid": 10541, - "status": "S", - "time_since_update": 1, - "username": "nicolargo"}]} + {"total": 424} GET psutilversion ----------------- @@ -1080,69 +662,69 @@ GET quicklook Get plugin stats:: # curl http://localhost:61208/api/3/quicklook - {"cpu": 27.4, + {"cpu": 47.6, "cpu_hz": 2025000000.0, - "cpu_hz_current": 1273975000.0, + "cpu_hz_current": 2048627750.0, "cpu_name": "Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz", - "mem": 63.9, + "mem": 82.5, "percpu": [{"cpu_number": 0, "guest": 0.0, "guest_nice": 0.0, - "idle": 19.8, - "iowait": 0.0, + "idle": 38.0, + "iowait": 9.0, "irq": 0.0, "key": "cpu_number", "nice": 0.0, "softirq": 0.0, "steal": 0.0, - "system": 3.4, - "total": 80.2, - "user": 76.7}, + "system": 12.0, + "total": 62.0, + "user": 32.0}, {"cpu_number": 1, "guest": 0.0, "guest_nice": 0.0, - "idle": 91.2, - "iowait": 0.0, + "idle": 42.0, + "iowait": 7.0, "irq": 0.0, "key": "cpu_number", "nice": 0.0, "softirq": 0.0, "steal": 0.0, - "system": 2.7, - "total": 8.8, - "user": 6.2}, + "system": 9.0, + "total": 58.0, + "user": 31.0}, {"cpu_number": 2, "guest": 0.0, "guest_nice": 0.0, - "idle": 91.3, - "iowait": 0.0, + "idle": 34.0, + "iowait": 3.0, "irq": 0.0, "key": "cpu_number", "nice": 0.0, - "softirq": 1.2, + "softirq": 0.0, "steal": 0.0, - "system": 2.6, - "total": 8.7, - "user": 6.1}, + "system": 6.0, + "total": 66.0, + "user": 46.0}, {"cpu_number": 3, "guest": 0.0, "guest_nice": 0.0, - "idle": 88.6, - "iowait": 0.9, + "idle": 49.0, + "iowait": 2.0, "irq": 0.0, "key": "cpu_number", "nice": 0.0, - "softirq": 0.6, + "softirq": 0.0, "steal": 0.0, - "system": 2.6, - "total": 11.4, - "user": 7.9}], - "swap": 33.2} + "system": 5.0, + "total": 51.0, + "user": 30.0}], + "swap": 71.4} Get a specific field:: # curl http://localhost:61208/api/3/quicklook/cpu - {"cpu": 27.4} + {"cpu": 47.6} GET sensors ----------- |