.. _api:
API (Restfull/JSON) documentation
=================================
The Glances Restfull/API server could be ran using the following command line:
.. code-block:: bash
# glances -w --disable-webui
Note: Change request URL api/3 by api/2 if you use Glances 2.x.
GET plugins list
----------------
Get the plugins list::
# curl http://localhost:61208/api/3/pluginslist
['alert',
'amps',
'cloud',
'connections',
'core',
'cpu',
'diskio',
'docker',
'folders',
'fs',
'gpu',
'help',
'ip',
'irq',
'load',
'mem',
'memswap',
'network',
'now',
'percpu',
'ports',
'processcount',
'processlist',
'psutilversion',
'quicklook',
'raid',
'sensors',
'smart',
'system',
'uptime',
'wifi']
GET alert
---------
Get plugin stats::
# curl http://localhost:61208/api/3/alert
[[1626508159.0,
-1,
'WARNING',
'MEM',
75.74408683513587,
75.74408683513587,
75.74408683513587,
75.74408683513587,
1,
[],
'',
'memory_percent']]
GET amps
--------
Get plugin stats::
# curl http://localhost:61208/api/3/amps
[{'count': 0,
'countmax': None,
'countmin': 1.0,
'key': 'name',
'name': 'Dropbox',
'refresh': 3.0,
'regex': True,
'result': None,
'timer': 0.11118960380554199},
{'count': 0,
'countmax': 20.0,
'countmin': None,
'key': 'name',
'name': 'Python',
'refresh': 3.0,
'regex': True,
'result': None,
'timer': 0.11110281944274902}]
Get a specific field::
# curl http://localhost:61208/api/3/amps/name
{'name': ['Dropbox', 'Python', 'Conntrack', 'Nginx', 'Systemd', 'SystemV']}
Get a specific item when field matchs the given value::
# curl http://localhost:61208/api/3/amps/name/Dropbox
{'Dropbox': [{'count': 0,
'countmax': None,
'countmin': 1.0,
'key': 'name',
'name': 'Dropbox',
'refresh': 3.0,
'regex': True,
'result': None,
'timer': 0.11118960380554199}]}
GET core
--------
Get plugin stats::
# curl http://localhost:61208/api/3/core
{'log': 4, 'phys': 2}
Fields descriptions:
* **phys**: Number of physical cores (hyper thread CPUs are excluded) (unit is *number*)
* **log**: Number of logical CPUs. A logical CPU is the number of physical cores multiplied by the number of threads that can run on each core (unit is *number*)
Get a specific field::
# curl http://localhost:61208/api/3/core/phys
{'phys': 2}
GET cpu
-------
Get plugin stats::
# curl http://localhost:61208/api/3/cpu
{'cpucore': 4,
'ctx_switches': 0,
'guest': 0.0,
'guest_nice': 0.0,
'idle': 70.8,
'interrupts': 0,
'iowait': 0.0,
'irq': 0.0,
'nice': 0.0,
'soft_interrupts': 0,
'softirq': 3.2,
'steal': 0.0,
'syscalls': 0,
'system': 5.8,
'time_since_update': 1,
'total': 29.0,
'user': 20.1}
Fields descriptions:
* **total**: Sum of all CPU percentages (except idle) (unit is *percent*)
* **system**: percent time spent in kernel space. System CPU time is the time spent running code in the Operating System kernel (unit is *percent*)
* **user**: CPU percent time spent in user space. User CPU time is the time spent on the processor running your program's code (or code in libraries) (unit is *percent*)
* **iowait**: *