glances-doc.rst 15.3 KB
Newer Older
A
Alessio Sergi 已提交
1 2 3 4
=======
Glances
=======

N
Nicolas Hennion 已提交
5
This manual describes *Glances* version 1.7.7.
A
Alessio Sergi 已提交
6

7
Copyright © 2012-2014 Nicolas Hennion <nicolas@nicolargo.com>
A
Alessio Sergi 已提交
8

A
Alessio Sergi 已提交
9
May 2014
A
Alessio Sergi 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

.. contents:: Table of Contents

Introduction
============

Glances is a cross-platform curses-based monitoring tool which aims to
present a maximum of information in a minimum of space, ideally to fit
in a classical 80x24 terminal or higher to have additional information.

Glances can adapt dynamically the displayed information depending on the
terminal size. It can also work in a client/server mode for remote monitoring.

Glances is written in Python and uses the `psutil`_ library to get information from your system.

Console (80x24)

.. image:: images/screenshot.png

Full view (>80x24)

.. image:: images/screenshot-wide.png

Usage
=====

Standalone mode
---------------

Simply run:

.. code-block:: console

    $ glances

Client/Server mode
------------------

If you want to remotely monitor a machine, called ``server``, from another one, called ``client``,
just run on the server:

.. code-block:: console

    server$ glances -s

and on the client:

.. code-block:: console

    client$ glances -c @server

A
Alessio Sergi 已提交
61
where ``@server`` is the IP address or hostname of the server.
A
Alessio Sergi 已提交
62 63 64 65 66 67 68 69 70

In server mode, you can set the bind address ``-B ADDRESS`` and listening TCP port ``-p PORT``.

In client mode, you can set the TCP port of the server ``-p PORT``.

Default binding address is ``0.0.0.0`` (Glances will listen on all the network interfaces) and TCP port is ``61209``.

In client/server mode, limits are set by the server side.

N
Nicolas Hennion 已提交
71
You can also set a password to access to the server ``-P password``.
A
Alessio Sergi 已提交
72

A
Alessio Sergi 已提交
73
Glances is ``IPv6`` compatible. Just use the ``-B ::`` option to bind to all IPv6 addresses.
N
Nicolas Hennion 已提交
74

A
Alessio Sergi 已提交
75 76 77 78 79 80
Command reference
=================

Command-line options
--------------------

N
Nicolas Hennion 已提交
81 82 83
-b             Display network rate in Byte per second (default: bit per second)
-B IP          Bind server to the given IPv4/IPv6 address or hostname
-c IP          Connect to a Glances server by IPv4/IPv6 address or hostname
A
Alessio Sergi 已提交
84
-C FILE        Path to the configuration file
N
Nicolas Hennion 已提交
85 86
-d             Disable disk I/O module
-e             Enable sensors module (requires pysensors, Linux-only)
A
Alessio Sergi 已提交
87
-f FOLDER      Set the HTML or CSV output folder
N
Nicolas Hennion 已提交
88 89 90
-h             Display the help and exit
-m             Disable mount module
-n             Disable network module
A
Alessio Sergi 已提交
91
-o OUTPUT      Define additional output (available: HTML or CSV)
N
Nicolas Hennion 已提交
92
-p PORT        Define the client/server TCP port (default: 61209)
A
Alessio Sergi 已提交
93 94
-P PASSWORD    Define a client/server password
--password     Define a client/server password from the prompt
N
Nicolas Hennion 已提交
95 96
-r             Disable process list (for low CPU consumption)
-s             Run Glances in server mode
A
Alessio Sergi 已提交
97
-t SECONDS     Set refresh time in seconds (default: 3 sec)
N
Nicolas Hennion 已提交
98 99 100 101
-v             Display the version and exit
-y             Enable hddtemp module (requires hddtemp)
-z             Do not use the bold color attribute
-1             Start Glances in per-CPU mode
A
Alessio Sergi 已提交
102 103 104 105

Interactive commands
--------------------

N
Nicolas Hennion 已提交
106
The following commands (key pressed) are supported while in Glances:
A
Alessio Sergi 已提交
107 108 109


``a``
A
Alessio Sergi 已提交
110
    Sort process list automatically
A
Alessio Sergi 已提交
111

A
Alessio Sergi 已提交
112
    - If CPU iowait ``>60%``, sort processes by I/O read and write
A
Alessio Sergi 已提交
113 114 115
    - If CPU ``>70%``, sort processes by CPU usage
    - If MEM ``>70%``, sort processes by memory usage
``b``
A
Alessio Sergi 已提交
116
    Switch between bit/s or Byte/s for network I/O
A
Alessio Sergi 已提交
117
``c``
A
Alessio Sergi 已提交
118
    Sort processes by CPU usage
A
Alessio Sergi 已提交
119 120 121 122 123
``d``
    Show/hide disk I/O stats
``f``
    Show/hide file system stats
``h``
A
Alessio Sergi 已提交
124
    Show/hide the help screen
A
Alessio Sergi 已提交
125
``i``
A
Alessio Sergi 已提交
126
    Sort processes by I/O rate (may need root privileges on some OSes)
A
Alessio Sergi 已提交
127 128 129
``l``
    Show/hide log messages
``m``
A
Alessio Sergi 已提交
130
    Sort processes by MEM usage
A
Alessio Sergi 已提交
131 132 133 134
``n``
    Show/hide network stats
``p``
    Sort processes by name
A
Alessio Sergi 已提交
135 136
``q``
    Quit
A
Alessio Sergi 已提交
137
``s``
A
Alessio Sergi 已提交
138
    Show/hide sensors stats (only available with -e flag)
A
Alessio Sergi 已提交
139
``t``
A
Alessio Sergi 已提交
140
    View network I/O as combination
A
Alessio Sergi 已提交
141
``u``
A
Alessio Sergi 已提交
142
    View cumulative network I/O
A
Alessio Sergi 已提交
143 144 145 146
``w``
    Delete finished warning log messages
``x``
    Delete finished warning and critical log messages
A
Alessio Sergi 已提交
147 148
``y``
    Show/hide hddtemp stats (only available with -y flag)
M
Markus Roth 已提交
149
``z``
150
    Show/hide processes list (for low CPU consumption)
A
Alessio Sergi 已提交
151 152 153 154 155 156
``1``
    Switch between global CPU and per-CPU stats

Configuration
=============

N
Nicolas Hennion 已提交
157
No configuration file is mandatory to use Glances.
A
Alessio Sergi 已提交
158

159
Furthermore a configuration file is needed for setup limits, disks or network interfaces to hide and/or monitored processes list.
A
Alessio Sergi 已提交
160 161 162

By default, the configuration file is under:

163 164 165 166 167 168
:Linux: ``/etc/glances/glances.conf``
:\*BSD and OS X: ``/usr/local/etc/glances/glances.conf``
:Windows: ``%APPDATA%\glances\glances.conf``

On Windows XP, the ``%APPDATA%`` path is:

A
Alessio Sergi 已提交
169 170
.. code-block:: console

171
    C:\Documents and Settings\<User>\Application Data
A
Alessio Sergi 已提交
172

173
Since Windows Vista and newer versions:
A
Alessio Sergi 已提交
174 175 176

.. code-block:: console

177
    C:\Users\<User>\AppData\Roaming
A
Alessio Sergi 已提交
178

179 180 181 182
You can override the default configuration, located in one of the above
directories on your system, except for Windows.

Just copy the ``glances.conf`` file to your ``$XDG_CONFIG_HOME`` directory, e.g. Linux:
A
Alessio Sergi 已提交
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206

.. code-block:: console

    mkdir -p $XDG_CONFIG_HOME/glances
    cp /etc/glances/glances.conf $XDG_CONFIG_HOME/glances/

On OS X, you should copy the configuration file to ``~/Library/Application Support/glances/``.

Anatomy of the application
==========================

Legend
------

| ``GREEN`` stat counter is ``"OK"``
| ``BLUE`` stat counter is ``"CAREFUL"``
| ``MAGENTA`` stat counter is ``"WARNING"``
| ``RED`` stat counter is ``"CRITICAL"``

Header
------

.. image:: images/header.png

207
The header shows the hostname, OS name, release version, platform architecture and system uptime.
A
Alessio Sergi 已提交
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
On Linux, it shows also the kernel version.

CPU
---

Short view:

.. image:: images/cpu.png

If enough horizontal space is available, extended CPU informations are displayed.

Extended view:

.. image:: images/cpu-wide.png

To switch to per-CPU stats, just hit the ``1`` key:

.. image:: images/per-cpu.png

The CPU stats are shown as a percentage and for the configured refresh time.
The total CPU usage is displayed on the first line.

| If user|system|nice CPU is ``<50%``, then status is set to ``"OK"``
| If user|system|nice CPU is ``>50%``, then status is set to ``"CAREFUL"``
| If user|system|nice CPU is ``>70%``, then status is set to ``"WARNING"``
| If user|system|nice CPU is ``>90%``, then status is set to ``"CRITICAL"``

A
Alessio Sergi 已提交
235
*Note*: limit values can be overwritten in the configuration file under the ``[cpu]`` section.
N
Nicolas Hennion 已提交
236

A
Alessio Sergi 已提交
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
Load
----

.. image:: images/load.png

On the *No Sheep* blog, *Zachary Tirrell* defines the average load [1]_:

    "In short it is the average sum of the number of processes
    waiting in the run-queue plus the number currently executing
    over 1, 5, and 15 minute time periods."

Glances gets the number of CPU core to adapt the alerts.
Alerts on average load are only set on 5 and 15 min.
The first line also display the number of CPU core.

| If average load is ``<0.7*core``, then status is set to ``"OK"``
| If average load is ``>0.7*core``, then status is set to ``"CAREFUL"``
| If average load is ``>1*core``, then status is set to ``"WARNING"``
| If average load is ``>5*core``, then status is set to ``"CRITICAL"``

A
Alessio Sergi 已提交
257
*Note*: limit values can be overwritten in the configuration file under the ``[load]`` section.
N
Nicolas Hennion 已提交
258

A
Alessio Sergi 已提交
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
Memory
------

Glances uses two columns: one for the ``RAM`` and another one for the ``Swap``.

.. image:: images/mem.png

If enough space is available, Glances displays extended informations:

.. image:: images/mem-wide.png

With Glances, alerts are only set for on used memory and used swap.

| If memory is ``<50%``, then status is set to ``"OK"``
| If memory is ``>50%``, then status is set to ``"CAREFUL"``
| If memory is ``>70%``, then status is set to ``"WARNING"``
| If memory is ``>90%``, then status is set to ``"CRITICAL"``

A
Alessio Sergi 已提交
277
*Note*: limit values can be overwritten in the configuration file under the ``[memory]`` and ``[swap]`` sections.
N
Nicolas Hennion 已提交
278

A
Alessio Sergi 已提交
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
Network
-------

.. image:: images/network.png

Glances displays the network interface bit rate. The unit is adapted
dynamically (bits per second, kbits per second, Mbits per second, etc).

Alerts are only set if the network interface maximum speed is available.

For example, on a 100 Mbps ethernet interface, the warning status is set
if the bit rate is higher than 70 Mbps.

| If bit rate is ``<50%``, then status is set to ``"OK"``
| If bit rate is ``>50%``, then status is set to ``"CAREFUL"``
| If bit rate is ``>70%``, then status is set to ``"WARNING"``
| If bit rate is ``>90%``, then status is set to ``"CRITICAL"``

297 298
*Note*: In the configuration file, you can define a list of network interfaces to hide.

A
Alessio Sergi 已提交
299 300 301
Sensors
-------

302 303 304
Glances can displays the sensors informations trough `lm-sensors` (only available on Linux).

As of lm-sensors, a filter is processed in order to display temperature only:
305

A
Alessio Sergi 已提交
306 307 308
.. image:: images/sensors.png


309 310 311
Glances can also grab hard disk temperature through the `hddtemp` daemon (see here [2]_ to install hddtemp on your system):

.. image:: images/hddtemp.png
A
Alessio Sergi 已提交
312

A
Alessio Sergi 已提交
313
To enable the lm-sensors module:
A
Alessio Sergi 已提交
314 315 316 317 318

.. code-block:: console

    $ glances -e

A
Alessio Sergi 已提交
319 320 321 322 323 324
To enable the hddtemp module:

.. code-block:: console

    $ glances -y

A
Alessio Sergi 已提交
325 326
There is no alert on this information.

A
Alessio Sergi 已提交
327
*Note*: limit values can be overwritten in the configuration file under the ``[temperature]`` and ``[hddtemperature]`` sections.
N
Nicolas Hennion 已提交
328

A
Alessio Sergi 已提交
329 330 331 332 333 334 335
Disk I/O
--------

.. image:: images/diskio.png

Glances displays the disk I/O throughput. The unit is adapted dynamically.

336
*Note*: There is no alert on this information.
A
Alessio Sergi 已提交
337

338 339
*Note*: In the configuration file, you can define a list of disk to hide.

A
Alessio Sergi 已提交
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
File system
-----------

.. image:: images/fs.png

Glances displays the used and total file system disk space. The unit is
adapted dynamically.

Alerts are set for used disk space:

| If disk used is ``<50%``, then status is set to ``"OK"``
| If disk used is ``>50%``, then status is set to ``"CAREFUL"``
| If disk used is ``>70%``, then status is set to ``"WARNING"``
| If disk used is ``>90%``, then status is set to ``"CRITICAL"``

A
Alessio Sergi 已提交
355
*Note*: limit values can be overwritten in the configuration file under ``[filesystem]`` section.
N
Nicolas Hennion 已提交
356

A
Alessio Sergi 已提交
357 358 359 360 361 362 363 364 365 366 367
Processes list
--------------

Compact view:

.. image:: images/processlist.png

Full view:

.. image:: images/processlist-wide.png

N
Nicolas Hennion 已提交
368
Three views are available for processes:
A
Alessio Sergi 已提交
369 370 371

* Processes summary
* Optional monitored processes list (new in 1.7)
N
Nicolas Hennion 已提交
372
* Processes list
A
Alessio Sergi 已提交
373

374 375 376
The processes summary line display:

* Tasks number (total number of processes)
A
Alessio Sergi 已提交
377
* Threads number
378 379 380 381
* Running tasks number
* Sleeping tasks number
* Other tasks number (not running or sleeping)

A
Alessio Sergi 已提交
382 383 384
By default, or if you hit the ``a`` key, the processes list is automatically
sorted by CPU of memory usage.

A
Alessio Sergi 已提交
385
*Note*: limit values can be overwritten in the configuration file under the ``[process]`` section.
N
Nicolas Hennion 已提交
386

A
Alessio Sergi 已提交
387 388 389
The number of processes in the list is adapted to the screen size.

``VIRT``
390
    Total program size (VMS)
A
Alessio Sergi 已提交
391
``RES``
392
    Resident set size (RSS)
A
Alessio Sergi 已提交
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
``CPU%``
    % of CPU used by the process
``MEM%``
    % of MEM used by the process
``PID``
    Process ID
``USER``
    User ID per process
``NI``
    Nice level of the process
``S``
    Process status
``TIME+``
    Cumulative CPU time used
``IOR/s``
    Per process IO read rate (in Byte/s)
``IOW/s``
    Per process IO write rate (in Byte/s)
``NAME``
    Process name or command line

Process status legend:

``R``
    running
``S``
    sleeping (may be interrupted)
``D``
    disk sleep (may not be interrupted)
``T``
    traced/stopped
``Z``
    zombie

A
Alessio Sergi 已提交
427
Monitored processes list
N
Nicolas Hennion 已提交
428 429
------------------------

A
Alessio Sergi 已提交
430
New in version 1.7. Optional.
N
Nicolas Hennion 已提交
431

A
Alessio Sergi 已提交
432 433
The monitored processes list allows user, through the configuration file,
to group processes and quickly show if the number of running process is not good.
N
Nicolas Hennion 已提交
434

435 436
.. image:: images/monitored.png

N
Nicolas Hennion 已提交
437 438
Each item is defined by:

A
Alessio Sergi 已提交
439 440 441 442 443
* ``description``: description of the processes (max 16 chars).
* ``regex``: regular expression of the processes to monitor.
* ``command`` (optional): full path to shell command/script for extended stat. Should return a single line string. Use with caution.
* ``countmin`` (optional): minimal number of processes. A warning will be displayed if number of processes < count.
* ``countmax`` (optional): maximum number of processes. A warning will be displayed if number of processes > count.
N
Nicolas Hennion 已提交
444 445 446

Up to 10 items can be defined.

447
For example, if you want to monitor the Nginx processes on a Web server, the following definition should do the job:
A
Alessio Sergi 已提交
448 449

.. code-block:: console
N
Nicolas Hennion 已提交
450 451

    [monitor]
452
    list_1_description=Nginx server
N
Nicolas Hennion 已提交
453 454 455 456 457
    list_1_regex=.*nginx.*
    list_1_command=nginx -v
    list_1_countmin=1
    list_1_countmax=4

A
Alessio Sergi 已提交
458 459 460
If you also want to monitor the PHP-FPM daemon processes, you should add another item:

.. code-block:: console
N
Nicolas Hennion 已提交
461 462

    [monitor]
463
    list_1_description=Nginx server
N
Nicolas Hennion 已提交
464 465 466 467 468 469 470 471 472
    list_1_regex=.*nginx.*
    list_1_command=nginx -v
    list_1_countmin=1
    list_1_countmax=4
    list_1_description=PHP-FPM
    list_1_regex=.*php-fpm.*
    list_1_countmin=1
    list_1_countmax=20

473 474
In client/server mode, the list is defined on the server side.
A new method, called getAllMonitored, is available in the APIs and get the JSON representation of the monitored processes list.
475

476
Alerts are set as following:
477 478

| If number of processes is 0, then status is set to ``"CRITICAL"``
479
| If number of processes is min < current < max, then status is set to ``"OK"``
480 481
| Else status is set to ``"WARNING"``

A
Alessio Sergi 已提交
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
Logs
----

.. image:: images/logs.png

A log messages list is displayed in the bottom of the screen if (and only if):

- at least one ``WARNING`` or ``CRITICAL`` alert was occurred
- space is available in the bottom of the console/terminal

Each alert message displays the following information:

1. start date
2. end date
3. alert name
497
4. {min/avg/max} values or number of running processes for monitored processes list alerts
A
Alessio Sergi 已提交
498 499 500 501 502 503 504 505

Footer
------

.. image:: images/footer.png

Glances displays the current date & time and access to the embedded help screen.

506 507
If one or mode batteries were found on your machine and if the batinfo Python library [3]_
is installed on your system then Glances displays the available percent capacity in the middle on the footer.
508 509 510

.. image:: images/battery.png

A
Alessio Sergi 已提交
511 512 513 514 515 516 517 518 519 520 521 522
If you have ran Glances in client mode ``-c``, you can also see if the client is connected to the server.

If client is connected:

.. image:: images/client-connected.png

else:

.. image:: images/client-disconnected.png

On the left, you can easily see if you are connected to a Glances server.

N
Nicolas Hennion 已提交
523

A
Alessio Sergi 已提交
524 525 526 527 528 529 530
API documentation
=================

Glances uses a `XML-RPC server`_ and can be used by another client software.

API documentation is available at https://github.com/nicolargo/glances/wiki/The-Glances-API-How-To

A
Alessio Sergi 已提交
531 532
Other outputs
=============
N
Nicolas Hennion 已提交
533

A
Alessio Sergi 已提交
534
Thanks to the -o (output) option, it is possible to export statistics to `CSV` or `HTML` files.
N
Nicolas Hennion 已提交
535 536 537

.. code-block:: console

A
Alessio Sergi 已提交
538 539 540
    $ glances -o CSV -f /tmp

The CSV output file is named ``glances.csv``.
N
Nicolas Hennion 已提交
541 542 543 544 545 546

CSV files have on line per stats:

- load,load1,load5,load15
- mem,total,used,free
- swap,total,used,free
A
Alessio Sergi 已提交
547
- cpu,user,system,nice,idle,iowait,irq
N
Nicolas Hennion 已提交
548 549 550 551 552

.. code-block:: console

    $ glances -o HTML -f /tmp

A
Alessio Sergi 已提交
553 554 555
The HTML output file is named ``glances.html``.

*Note*: The css and img folders (glances/data) should be in the /tmp folder.
N
Nicolas Hennion 已提交
556

A
Alessio Sergi 已提交
557 558 559 560 561 562 563 564 565
Support
=======

To report a bug or a feature request use the bug tracking system at https://github.com/nicolargo/glances/issues

Feel free to contribute!


.. [1] http://nosheep.net/story/defining-unix-load-average/
566 567
.. [2] http://www.cyberciti.biz/tips/howto-monitor-hard-drive-temperature.html
.. [3] https://github.com/nicolargo/batinfo
A
Alessio Sergi 已提交
568 569 570

.. _psutil: https://code.google.com/p/psutil/
.. _XML-RPC server: http://docs.python.org/2/library/simplexmlrpcserver.html