Tips en Trucs 2014

De systeemmonitor Glances

Glances is een vrije monitor (LGPL licentie) voor GNU/Linux en BSD systemen met een tekstinterface. Glances gebruikt de psutil bibliotheek om systeeminformatie op te vragen en is in python geschreven.

Het opvallendste verschil met top/htop is het gebruik van drempelwaarden in het configuratiebestand. Deze drempelwaarden worden gebruikt om systeembronnen te kleuren zodat je direct merkt waar het schoentje wringt.

Glances systeemmonitor

Installatie

Glances is aanwezig in de softwarebronnen van sommige distributies (Debian, Arch, Fedora, Redhat, FreeBSD), maar niet in Ubuntu, Mint en openSUSE 13.1. Maar aangezien het een python programma is, kunnen we het installeren via PyPi, het officiële Python pakkettenbeheer.

dany@linux-nlfy:~> sudo zypper install python-pip python-devel python-curses gcc
Gegevens van installatiebron laden...
Lezen van geïnstalleerde pakketten...
Afhankelijkheden tussen pakketten oplossen...

De volgende 12 NIEUWE pakketten zullen worden geïnstalleerd:
  binutils gcc gcc48 glibc-devel libasan0 libatomic1 libitm1 libtsan0 
  linux-glibc-devel python-curses python-devel python-pip 

12 nieuw te installeren pakketten.
Totale downloadgrootte: 16,8 MiB Na de operatie zal aanvullend 85,3 MiB worden 
gebruikt.
Doorgaan? [j/n/? alle opties tonen] (j): 
pakket linux-glibc-devel-3.11-2.1.15.noarch wordt opgehaald
                                            (1/12), 891,0 KiB (  3,6 MiB uitgepakt)
Ophalen: linux-glibc-devel-3.11-2.1.15.noarch.rpm ..........................[klaar]
pakket python-pip-1.4.1-2.2.1.noarch wordt opgehaald
                                            (2/12), 650,7 KiB (  2,6 MiB uitgepakt)
Ophalen: python-pip-1.4.1-2.2.1.noarch.rpm .................................[klaar]
pakket binutils-2.23.2-8.1.2.x86_64 wordt opgehaald
                                            (3/12),   3,6 MiB ( 23,1 MiB uitgepakt)
Ophalen: binutils-2.23.2-8.1.2.x86_64.rpm ......................[klaar (1,7 MiB/s)]
pakket libasan0-4.8.1_20130909-3.2.1.x86_64 wordt opgehaald
                                            (4/12),  68,1 KiB (166,9 KiB uitgepakt)
Ophalen: libasan0-4.8.1_20130909-3.2.1.x86_64.rpm ..........................[klaar]
pakket libatomic1-4.8.1_20130909-3.2.1.x86_64 wordt opgehaald
                                            (5/12),  14,6 KiB ( 26,1 KiB uitgepakt)
Ophalen: libatomic1-4.8.1_20130909-3.2.1.x86_64.rpm ........................[klaar]
pakket libitm1-4.8.1_20130909-3.2.1.x86_64 wordt opgehaald
                                            (6/12),  34,2 KiB (130,4 KiB uitgepakt)
Ophalen: libitm1-4.8.1_20130909-3.2.1.x86_64.rpm ...........................[klaar]
pakket libtsan0-4.8.1_20130909-3.2.1.x86_64 wordt opgehaald
                                            (7/12), 100,5 KiB (298,6 KiB uitgepakt)
Ophalen: libtsan0-4.8.1_20130909-3.2.1.x86_64.rpm ..........................[klaar]
pakket python-curses-2.7.6-8.18.1.x86_64 wordt opgehaald
                                            (8/12),  41,9 KiB (130,7 KiB uitgepakt)
Ophalen: python-curses-2.7.6-8.18.1.x86_64.rpm ...............[klaar (326,8 KiB/s)]
pakket glibc-devel-2.18-4.21.1.x86_64 wordt opgehaald
                                            (9/12), 626,3 KiB (  2,9 MiB uitgepakt)
Ophalen: glibc-devel-2.18-4.21.1.x86_64.rpm ................................[klaar]
pakket python-devel-2.7.6-8.18.1.x86_64 wordt opgehaald
                                           (10/12),   3,1 MiB ( 19,6 MiB uitgepakt)
Ophalen: python-devel-2.7.6-8.18.1.x86_64.rpm ..................[klaar (1,7 MiB/s)]
pakket gcc48-4.8.1_20130909-3.2.1.x86_64 wordt opgehaald
                                           (11/12),   7,7 MiB ( 32,6 MiB uitgepakt)
Ophalen: gcc48-4.8.1_20130909-3.2.1.x86_64.rpm .................[klaar (1,8 MiB/s)]
pakket gcc-4.8-2.1.2.x86_64 wordt opgehaald  (12/12),   4,8 KiB (    0 B uitgepakt)
Ophalen: gcc-4.8-2.1.2.x86_64.rpm ..........................................[klaar]
( 1/12) Installeert: linux-glibc-devel-3.11-2.1.15 .........................[klaar]
( 2/12) Installeert: python-pip-1.4.1-2.2.1 ................................[klaar]
Aanvullende rpm-uitvoer:
update-alternatives: using /usr/bin/pip-2.7 to provide /usr/bin/pip (pip) in auto mode


( 3/12) Installeert: binutils-2.23.2-8.1.2 .................................[klaar]
Aanvullende rpm-uitvoer:
update-alternatives: using /usr/bin/ld.bfd to provide /usr/bin/ld (ld) in auto mode


( 4/12) Installeert: libasan0-4.8.1_20130909-3.2.1 .........................[klaar]
( 5/12) Installeert: libatomic1-4.8.1_20130909-3.2.1 .......................[klaar]
( 6/12) Installeert: libitm1-4.8.1_20130909-3.2.1 ..........................[klaar]
( 7/12) Installeert: libtsan0-4.8.1_20130909-3.2.1 .........................[klaar]
( 8/12) Installeert: python-curses-2.7.6-8.18.1 ............................[klaar]
( 9/12) Installeert: glibc-devel-2.18-4.21.1 ...............................[klaar]
(10/12) Installeert: python-devel-2.7.6-8.18.1 .............................[klaar]
(11/12) Installeert: gcc48-4.8.1_20130909-3.2.1 ............................[klaar]
(12/12) Installeert: gcc-4.8-2.1.2 .........................................[klaar]

Daarna installeer je de recentste Glance versie met de opdracht:

dany@linux-nlfy:~> sudo pip install Glances
Requirement already satisfied (use --upgrade to upgrade): Glances in /usr/lib/python2.7/site-packages
Downloading/unpacking psutil>=2.0.0 (from Glances)
  Downloading psutil-2.1.3.tar.gz (224kB): 224kB downloaded
  Running setup.py egg_info for package psutil
    
    warning: no previously-included files matching '*' found under directory 'docs/_build'
Installing collected packages: psutil
  Running setup.py install for psutil
    building '_psutil_linux' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/_psutil_linux.so
    building '_psutil_posix' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -I/usr/include/python2.7 -c psutil/_psutil_posix.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_posix.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/psutil/_psutil_posix.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/_psutil_posix.so
    
    warning: no previously-included files matching '*' found under directory 'docs/_build'
Successfully installed psutil
Cleaning up...

Overzicht

Glances toont op één pagina veel informatie in verband met de belasting van uw systeem: CPU, geheugen, netwerk, schijf I/O en processen. De kleuren betekenen:

Glances bestuur je met behulp van toetsen:

a Rangschik de processen automatisch, de rangschikking gebeurt dan als volgt: c Rangschik de processen op CPU belasting
m Rangschik de processen op geheugengebruik
p Rangschik de processen op naam
i Rangschik de processen op IO gebruik (Input/Output)
d Toon/Verberg de schijf (disk) invoer/uitvoer (I/O) statistieken
f Toon/Verberg de bestandssysteem (file system) statistieken
n Toon/Verberg de netwerk statistieken
s Toon/verberg de sensor statistieken
b Bits/s of Bytes/s als eenheid voor het netwerktrafiek
w Verwijder de logbestanden met waarschuwingen
x Verwijder de logbestanden met waarschuwingen en kritieke waarden
1 Globale of Per Core CPU statistieken
h Toon/Verberg de help tekst
q Sluiten (quit), Esc en Ctrl+C werken ook l Toon/Verberg de log berichten

Configuratie

De drempelwaarden voor Glances kan je instellen in het configuratiebestand. Het configuratiebestand /etc/glances/glances.conf bevat standaard instellingen. Wil je als gebruiker andere instellingen gebruiken, kopieer dan het /usr/share/doc/glances/glances.conf naar de map $HOME/.config/glances/. Meestal bestaat de map $HOME/.config/glances/ niet en moet je deze eerst nog aanmaken. Dit configuratiebestand bevat commentaarregels met uitleg.

Webserver mode

Om de belasting van een systeem vanuit om het even welke browser te bekijken, start je Glance in de webserver mode. De webserver mode gebruikt een extra python bibliotheek, die je met de volgende opdracht kunt installeren:

dany@linux-nlfy:~> sudo pip install bottle
root's password:
Downloading/unpacking bottle
  Downloading bottle-0.12.7.tar.gz (69kB): 69kB downloaded
  Running setup.py egg_info for package bottle
    
Installing collected packages: bottle
  Running setup.py install for bottle
    changing mode of build/scripts-2.7/bottle.py from 644 to 755
    
    changing mode of /usr/bin/bottle.py to 755
Successfully installed bottle
Cleaning up...

Open de firewall voor de Glance webserver (TCP poort 61208):

dany@linux-nlfy:~> sudo /sbin/yast2 firewall services add zone=EXT tcpport=61208

Daarna start je Glance in de webserver mode:

dany@linux-nlfy:~> glances -w
Glances web server started on http://0.0.0.0:61208/

De uitvoer met het webadres 0.0.0.0 betekent dat de Glance webserver op alle netwerkverbindingen naar inkomende aanvragen luistert. Surf met een browser vanaf om het even welke browser op een apparaat in uw netwerk naar het adres van de computer waarop Glance in webserver mode draait.

Glance in webserver mode

Client/server mode

Naast het locale gebruik van Glances kan je de monitor starten in servermode (glances -s). Glances gebruikt een XML/RPC server en kan daardoor benadert worden door andere client software. In server mode kan je het te beluisteren adres (-B adres) en TCP poort (-p poort) opgeven. Het standaard gebruikte adres is 0.0.0.0 (alle aanwezige netwerkverbindingen beluisteren) en TCP poort 61209.

dany@linux-nlfy:~> glances -s
Glances server is running on 0.0.0.0:61209

Op een andere computer kan je de informatie van Glances dan bekijken via de opdracht:

dany@linux-nlfy:~> glances -c @192.168.1.2
Trying fallback to SNMP...
CRITICAL: PySNMP library not found.
Install it using pip: # pip install pysnmp

Zoals blijkt uit bovenstaande uitvoer, moet de python bibliotheek pysnmp geïnstalleerd zijn.

dany@linux-nlfy:~> sudo pip install pysnmp
root's password:
Downloading/unpacking pysnmp
  Downloading pysnmp-4.2.5.tar.gz (225kB): 225kB downloaded
  Running setup.py egg_info for package pysnmp
    
Downloading/unpacking pyasn1>=0.1.2 (from pysnmp)
  Downloading pyasn1-0.1.7.tar.gz (68kB): 68kB downloaded
  Running setup.py egg_info for package pyasn1
    
Downloading/unpacking pycrypto>=2.4.1 (from pysnmp)
  Downloading pycrypto-2.6.1.tar.gz (446kB): 446kB downloaded
  Running setup.py egg_info for package pycrypto
    
Installing collected packages: pysnmp, pyasn1, pycrypto
  Running setup.py install for pysnmp
    changing mode of build/scripts-2.7/libsmi2pysnmp from 644 to 755
    changing mode of build/scripts-2.7/build-pysnmp-mib from 644 to 755
    
    changing mode of /usr/bin/libsmi2pysnmp to 755
    changing mode of /usr/bin/build-pysnmp-mib to 755
  Running setup.py install for pyasn1
    
  Running setup.py install for pycrypto
    checking for gcc... gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking for __gmpz_init in -lgmp... no
    checking for __gmpz_init in -lmpir... no
    checking whether mpz_powm is declared... no
    checking whether mpz_powm_sec is declared... no
    checking how to run the C preprocessor... gcc -E
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking for inttypes.h... (cached) yes
    checking limits.h usability... yes
    checking limits.h presence... yes
    checking for limits.h... yes
    checking stddef.h usability... yes
    checking stddef.h presence... yes
    checking for stddef.h... yes
    checking for stdint.h... (cached) yes
    checking for stdlib.h... (cached) yes
    checking for string.h... (cached) yes
    checking wchar.h usability... yes
    checking wchar.h presence... yes
    checking for wchar.h... yes
    checking for inline... inline
    checking for int16_t... yes
    checking for int32_t... yes
    checking for int64_t... yes
    checking for int8_t... yes
    checking for size_t... yes
    checking for uint16_t... yes
    checking for uint32_t... yes
    checking for uint64_t... yes
    checking for uint8_t... yes
    checking for stdlib.h... (cached) yes
    checking for GNU libc compatible malloc... yes
    checking for memmove... yes
    checking for memset... yes
    configure: creating ./config.status
    config.status: creating src/config.h
    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
    building 'Crypto.Hash._MD2' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/MD2.c -o build/temp.linux-x86_64-2.7/src/MD2.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/MD2.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Hash/_MD2.so
    building 'Crypto.Hash._MD4' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/MD4.c -o build/temp.linux-x86_64-2.7/src/MD4.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/MD4.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Hash/_MD4.so
    building 'Crypto.Hash._SHA256' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/SHA256.c -o build/temp.linux-x86_64-2.7/src/SHA256.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/SHA256.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Hash/_SHA256.so
    building 'Crypto.Hash._SHA224' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/SHA224.c -o build/temp.linux-x86_64-2.7/src/SHA224.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/SHA224.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Hash/_SHA224.so
    building 'Crypto.Hash._SHA384' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/SHA384.c -o build/temp.linux-x86_64-2.7/src/SHA384.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/SHA384.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Hash/_SHA384.so
    building 'Crypto.Hash._SHA512' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/SHA512.c -o build/temp.linux-x86_64-2.7/src/SHA512.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/SHA512.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Hash/_SHA512.so
    building 'Crypto.Hash._RIPEMD160' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -DPCT_LITTLE_ENDIAN=1 -Isrc/ -I/usr/include/python2.7 -c src/RIPEMD160.c -o build/temp.linux-x86_64-2.7/src/RIPEMD160.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/RIPEMD160.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Hash/_RIPEMD160.so
    building 'Crypto.Cipher._AES' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/AES.c -o build/temp.linux-x86_64-2.7/src/AES.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/AES.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Cipher/_AES.so
    building 'Crypto.Cipher._ARC2' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/ARC2.c -o build/temp.linux-x86_64-2.7/src/ARC2.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/ARC2.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Cipher/_ARC2.so
    building 'Crypto.Cipher._Blowfish' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/Blowfish.c -o build/temp.linux-x86_64-2.7/src/Blowfish.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/Blowfish.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Cipher/_Blowfish.so
    building 'Crypto.Cipher._CAST' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/CAST.c -o build/temp.linux-x86_64-2.7/src/CAST.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/CAST.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Cipher/_CAST.so
    building 'Crypto.Cipher._DES' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -Isrc/libtom/ -I/usr/include/python2.7 -c src/DES.c -o build/temp.linux-x86_64-2.7/src/DES.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/DES.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Cipher/_DES.so
    building 'Crypto.Cipher._DES3' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -Isrc/libtom/ -I/usr/include/python2.7 -c src/DES3.c -o build/temp.linux-x86_64-2.7/src/DES3.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/DES3.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Cipher/_DES3.so
    building 'Crypto.Cipher._ARC4' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/ARC4.c -o build/temp.linux-x86_64-2.7/src/ARC4.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/ARC4.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Cipher/_ARC4.so
    building 'Crypto.Cipher._XOR' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/XOR.c -o build/temp.linux-x86_64-2.7/src/XOR.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/XOR.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Cipher/_XOR.so
    building 'Crypto.Util.strxor' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/strxor.c -o build/temp.linux-x86_64-2.7/src/strxor.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/strxor.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Util/strxor.so
    building 'Crypto.Util._counter' extension
    gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -fstack-protector -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -DOPENSSL_LOAD_CONF -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/_counter.c -o build/temp.linux-x86_64-2.7/src/_counter.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/src/_counter.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/Crypto/Util/_counter.so
    
Successfully installed pysnmp pyasn1 pycrypto
Cleaning up...

Een verbinding maken met de Glance server, bleek na de installatie van de pysnmp bibliotheek niet mogelijk.

dany@linux-nlfy:~> glances -c @192.168.1.2
Trying fallback to SNMP...
Traceback (most recent call last):
  File "/usr/bin/glances", line 9, in 
    load_entry_point('Glances==2.1.2', 'console_scripts', 'glances')()
  File "/usr/lib/python2.7/site-packages/glances/__init__.py", line 134, in main
    if not client.login():
  File "/usr/lib/python2.7/site-packages/glances/core/glances_client.py", line 140, in login
    if not self.stats.check_snmp():
  File "/usr/lib/python2.7/site-packages/glances/core/glances_stats.py", line 258, in check_snmp
    ret = clientsnmp.get_by_oid("1.3.6.1.2.1.1.5.0") != {}
  File "/usr/lib/python2.7/site-packages/glances/core/glances_snmp.py", line 84, in get_by_oid
    cmdgen.UdpTransportTarget((self.host, self.port)),
  File "/usr/lib/python2.7/site-packages/pysnmp/entity/rfc3413/oneliner/target.py", line 10, in __init__
    self.transportAddr = self._resolveAddr(transportAddr)
  File "/usr/lib/python2.7/site-packages/pysnmp/entity/rfc3413/oneliner/target.py", line 45, in _resolveAddr
    raise error.PySnmpError('Bad IPv4/UDP transport address %s: %s' % ('@'.join([ str(x) for x in transportAddr ]), sys.exc_info()[1]))
pysnmp.error.PySnmpError: Bad IPv4/UDP transport address @192.168.1.2@161: [Errno -2] Naam of dienst is niet bekend

In de documentatie van Glance staat duidelijk vermeldt dat dit enkel werkt met een SNMP v2/2c server. Misschien is dit de reden. Verder speurwerk is nodig om dit te achterhalen.

In client mode kan je de TCP poort van de server opgeven (-p poort). Om de toegang tot de server te beperken, kan je een wachtwoord met de server en client instellen (-P wachtwoord).

Conclusie

Glances is een interessant project dat drempelwaarden toevoegt aan opdrachten zoals top. Glance is waardevol als je centraal verschillende systemen wilt beheren, die je eveneens anders kunt bekijken (zo kan je het normaal vinden dat een database server de CPU 95% belast, maar bij een webserver is dit echter kritiek).