version 1.3.1

This commit is contained in:
nicolargo 2011-12-16 21:55:34 +01:00
parent cb07b4a8b3
commit 549bca1b86
6 changed files with 63 additions and 102 deletions

6
NEWS
View File

@ -1,3 +1,9 @@
Version 1.3.1
=============
* Add alert on load (depend on number of CPU core)
* Fix bug when the FS list is very long
Version 1.3 Version 1.3
=========== ===========

6
README
View File

@ -14,12 +14,12 @@ Glances is developed in Python and uses the python-statgrab lib.
Get the latest version: Get the latest version:
$ wget https://github.com/downloads/nicolargo/glances/glances-1.3.tar.gz $ wget https://github.com/downloads/nicolargo/glances/glances-1.3.1.tar.gz
Glances use a standard GNU style installer: Glances use a standard GNU style installer:
$ tar zxvf glances-1.3.tar.gz $ tar zxvf glances-1.3.1.tar.gz
$ cd glances-1.3 $ cd glances-1.3.1
$ ./configure $ ./configure
$ make $ make
$ sudo make install $ sudo make install

View File

@ -1,84 +0,0 @@
Glances -- Eye on your system
=============================
## Description
Glances is a CLI curses based monitoring tool for both GNU/Linux and BSD.
Glances uses the libstatgrab library to get information from your system.
Glances is developed in Python and uses the python-statgrab lib.
![screenshot](https://github.com/nicolargo/glances/raw/master/screenshot.png)
## Installation
Get the latest version:
$ wget https://github.com/downloads/nicolargo/glances/glances-1.3.tar.gz
Glances use a standard GNU style installer:
$ tar zxvf glances-1.3.tar.gz
$ cd glances-1.3
$ ./configure
$ make
$ sudo make install
Pre-requisites:
* Python 2.6+ (not tested with Python 3+)
* python-statgrab 0.5+ (did not work with python-statgrab 0.4)
Notes: The Debian Squeeze repos only include the python-statgrab 0.4.
You had to install the version 0.5 using the following commands:
$ sudo apt-get install libstatgrab-dev pkg-config python-dev make
$ wget http://ftp.uk.i-scream.org/sites/ftp.i-scream.org/pub/i-scream/pystatgrab/pystatgrab-0.5.tar.gz
$ tar zxvf pystatgrab-0.5.tar.gz
$ cd pystatgrab-0.5/
$ ./setup.py build
$ sudo ./setup.py install
Notes: Ubuntu 10.04 and 10.10.
The instruction to install the version 0.5 are here: https://github.com/nicolargo/glances/issues/5#issuecomment-3033194
## Running
Easy:
$ glances.py
## User guide
By default, stats are refrsh every second, to change this setting, you can
use the -t option. For exemple to set the refrech rate to 5 seconds:
$ glances.py -t 5
Importants stats are colored:
* GREEN: stat counter is < 50%
* BLUE: stat counter is > 50% and < 70%
* MAGENTA: stat counter is > 70% and < 90%
* RED: stat counter is > 90%
When Glances is running, you can press:
* 'a' to set the automatic mode. The process list is sorted automatically
If CPU > 70%, sort by process CPU consomption
If MEM > 70%, sort by process size
* 'c' the processes list is sorted by CPU consomption
* 'm' the processes list is sorted by process size
* 'q' Exit
## Todo
You are welcome to contribute to this software.
* Packaging for Debian, Ubuntu, Fedora, Redhat, BSD...
* Check the needed Python library in the configure.ac
* Add file system stats when the python-statgrab is corrected
* Add a user guide window

1
README.md Symbolic link
View File

@ -0,0 +1 @@
README

View File

@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl Created by Anjuta application wizard. dnl Created by Anjuta application wizard.
AC_INIT(Glances, 1.3, , glances) AC_INIT(Glances, 1.3.1, , glances)
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])

View File

@ -11,7 +11,7 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read() return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup( name='Glances', setup( name='Glances',
version='1.3', version='1.3.1',
description='CLI curses-based monitoring tool', description='CLI curses-based monitoring tool',
author='Nicolas Hennion', author='Nicolas Hennion',
author_email='nicolas@nicolargo.com', author_email='nicolas@nicolargo.com',

View File

@ -27,13 +27,14 @@ import time
import datetime import datetime
import curses import curses
import statgrab import statgrab
import multiprocessing
# Globals variables # Globals variables
#================== #==================
# The glances version id # The glances version id
__version__ = "1.3" __version__ = "1.3.1"
# Class # Class
#====== #======
@ -68,7 +69,7 @@ class glancesGrabFs():
self.fs_list = [] self.fs_list = []
# Ignore the following fs # Ignore the following fs
ignore_fsname = ('none', 'gvfs-fuse-daemon', 'fusectl') ignore_fsname = ('none', 'gvfs-fuse-daemon', 'fusectl', 'cgroup')
ignore_fstype = ('binfmt_misc', 'devpts', 'iso9660', 'none', 'proc', 'sysfs', 'usbfs') ignore_fstype = ('binfmt_misc', 'devpts', 'iso9660', 'none', 'proc', 'sysfs', 'usbfs')
# Open the current mounted FS # Open the current mounted FS
@ -89,7 +90,7 @@ class glancesGrabFs():
fs_current['avail'] = float(fs_stats.f_bfree) * long(fs_stats.f_frsize) fs_current['avail'] = float(fs_stats.f_bfree) * long(fs_stats.f_frsize)
self.fs_list.append(fs_current) self.fs_list.append(fs_current)
mtab.close() mtab.close()
def __getmount__(self, path): def __getmount__(self, path):
""" """
@ -148,7 +149,11 @@ class glancesStats():
self.fs = self.glancesgrabfs.get() self.fs = self.glancesgrabfs.get()
self.processcount = statgrab.sg_get_process_count() self.processcount = statgrab.sg_get_process_count()
self.process = statgrab.sg_get_process_stats() self.process = statgrab.sg_get_process_stats()
self.now = datetime.datetime.now() self.now = datetime.datetime.now()
# Get the number of core (CPU)
# Used to display load alerts
self.core_number = multiprocessing.cpu_count()
def end(self): def end(self):
@ -172,6 +177,10 @@ class glancesStats():
def getCpu(self): def getCpu(self):
return self.cpu return self.cpu
def getCore(self):
return self.core_number
def getLoad(self): def getLoad(self):
return self.load return self.load
@ -347,6 +356,35 @@ class glancesScreen():
else: else:
return 0 return 0
def __getLoadColor(self, current = 0, core = 1):
# core is the number of CPU core
# If current > 0.7*core then color = self.if50pc_color / A_DIM
# If current > 1.0*core then color = self.if70pc_color / A_BOLD
# If current > 5.0*core then color = self.if90pc_color / A_REVERSE
# By default: color = self.default_color / 0
if current > (5.0 * core):
if self.hascolors:
return self.if90pc_color
else:
return curses.A_REVERSE
elif current > (1.0 * core):
if self.hascolors:
return self.if70pc_color
else:
return curses.A_BOLD
elif current > (0.7 * core):
if self.hascolors:
return self.if50pc_color
else:
return curses.A_DIM
else:
if self.hascolors:
return self.default_color
else:
return 0
def __catchKey(self): def __catchKey(self):
# Get key # Get key
@ -383,7 +421,7 @@ class glancesScreen():
screen.displayHost(stats.getHost()) screen.displayHost(stats.getHost())
screen.displaySystem(stats.getSystem()) screen.displaySystem(stats.getSystem())
screen.displayCpu(stats.getCpu()) screen.displayCpu(stats.getCpu())
screen.displayLoad(stats.getLoad()) screen.displayLoad(stats.getLoad(), stats.getCore())
screen.displayMem(stats.getMem(), stats.getMemSwap()) screen.displayMem(stats.getMem(), stats.getMemSwap())
net_count = screen.displayNetwork(stats.getNetwork()) net_count = screen.displayNetwork(stats.getNetwork())
disk_count = screen.displayDiskIO(stats.getDiskIO(), net_count) disk_count = screen.displayDiskIO(stats.getDiskIO(), net_count)
@ -455,20 +493,20 @@ class glancesScreen():
self.term_window.addnstr(self.cpu_y+4, self.cpu_x+10, "%.1f" % cpu['idle'], 8) self.term_window.addnstr(self.cpu_y+4, self.cpu_x+10, "%.1f" % cpu['idle'], 8)
def displayLoad(self, load): def displayLoad(self, load, core):
# Load % # Load %
screen_x = self.screen.getmaxyx()[1] screen_x = self.screen.getmaxyx()[1]
screen_y = self.screen.getmaxyx()[0] screen_y = self.screen.getmaxyx()[0]
if ((screen_y > self.load_y+5) if ((screen_y > self.load_y+5)
and (screen_x > self.load_x+18)): and (screen_x > self.load_x+18)):
self.term_window.addnstr(self.load_y, self.load_x, "Load", 8, self.title_color if self.hascolors else curses.A_UNDERLINE) self.term_window.addnstr(self.load_y, self.load_x, "Load", 8, self.title_color if self.hascolors else curses.A_UNDERLINE)
self.term_window.addnstr(self.load_y, self.load_x+10,"", 8) self.term_window.addnstr(self.load_y, self.load_x+10, str(core)+"-Core", 8)
self.term_window.addnstr(self.load_y+1, self.load_x, "1 min:", 8) self.term_window.addnstr(self.load_y+1, self.load_x, "1 min:", 8)
self.term_window.addnstr(self.load_y+2, self.load_x, "5 mins:", 8) self.term_window.addnstr(self.load_y+2, self.load_x, "5 mins:", 8)
self.term_window.addnstr(self.load_y+3, self.load_x, "15 mins:", 8) self.term_window.addnstr(self.load_y+3, self.load_x, "15 mins:", 8)
self.term_window.addnstr(self.load_y+1, self.load_x+10, str(load['min1']), 8) self.term_window.addnstr(self.load_y+1, self.load_x+10, str(load['min1']), 8)
self.term_window.addnstr(self.load_y+2, self.load_x+10, str(load['min5']), 8) self.term_window.addnstr(self.load_y+2, self.load_x+10, str(load['min5']), 8, self.__getLoadColor(load['min5'], core))
self.term_window.addnstr(self.load_y+3, self.load_x+10, str(load['min15']), 8) self.term_window.addnstr(self.load_y+3, self.load_x+10, str(load['min15']), 8, self.__getLoadColor(load['min15'], core))
def displayMem(self, mem, memswap): def displayMem(self, mem, memswap):
@ -511,7 +549,7 @@ class glancesScreen():
self.term_window.addnstr(self.network_y, self.network_x+20, "Tx/ps", 8) self.term_window.addnstr(self.network_y, self.network_x+20, "Tx/ps", 8)
# Adapt the maximum interface to the screen # Adapt the maximum interface to the screen
interface = 0 interface = 0
for interface in range(0, min(12+(screen_y-self.term_h), len(network))): for interface in range(0, min(screen_y-self.term_h, len(network))):
elapsed_time = max (1, network[interface]['systime']) elapsed_time = max (1, network[interface]['systime'])
self.term_window.addnstr(self.network_y+1+interface, self.network_x, network[interface]['interface_name']+':', 8) self.term_window.addnstr(self.network_y+1+interface, self.network_x, network[interface]['interface_name']+':', 8)
self.term_window.addnstr(self.network_y+1+interface, self.network_x+10, self.__autoUnit(network[interface]['rx']/elapsed_time*8) + "b", 8) self.term_window.addnstr(self.network_y+1+interface, self.network_x+10, self.__autoUnit(network[interface]['rx']/elapsed_time*8) + "b", 8)
@ -532,7 +570,7 @@ class glancesScreen():
self.term_window.addnstr(self.diskio_y, self.diskio_x+20, "Out/ps", 8) self.term_window.addnstr(self.diskio_y, self.diskio_x+20, "Out/ps", 8)
# Adapt the maximum disk to the screen # Adapt the maximum disk to the screen
disk = 0 disk = 0
for disk in range(0, min(11+(screen_y-self.term_h), len(diskio))): for disk in range(0, min(screen_y-self.term_h, len(diskio))):
elapsed_time = max(1, diskio[disk]['systime']) elapsed_time = max(1, diskio[disk]['systime'])
self.term_window.addnstr(self.diskio_y+1+disk, self.diskio_x, diskio[disk]['disk_name']+':', 8) self.term_window.addnstr(self.diskio_y+1+disk, self.diskio_x, diskio[disk]['disk_name']+':', 8)
self.term_window.addnstr(self.diskio_y+1+disk, self.diskio_x+10, self.__autoUnit(diskio[disk]['write_bytes']/elapsed_time) + "B", 8) self.term_window.addnstr(self.diskio_y+1+disk, self.diskio_x+10, self.__autoUnit(diskio[disk]['write_bytes']/elapsed_time) + "B", 8)
@ -553,7 +591,7 @@ class glancesScreen():
self.term_window.addnstr(self.fs_y, self.fs_x+20, "Used", 8) self.term_window.addnstr(self.fs_y, self.fs_x+20, "Used", 8)
# Adapt the maximum disk to the screen # Adapt the maximum disk to the screen
mounted = 0 mounted = 0
for mounted in range(0, min(11+(screen_y-self.term_h), len(fs))): for mounted in range(0, min(screen_y-self.term_h, len(fs))):
self.term_window.addnstr(self.fs_y+1+mounted, self.fs_x, fs[mounted]['mnt_point'], 8) self.term_window.addnstr(self.fs_y+1+mounted, self.fs_x, fs[mounted]['mnt_point'], 8)
self.term_window.addnstr(self.fs_y+1+mounted, self.fs_x+10, self.__autoUnit(fs[mounted]['size']), 8) self.term_window.addnstr(self.fs_y+1+mounted, self.fs_x+10, self.__autoUnit(fs[mounted]['size']), 8)
self.term_window.addnstr(self.fs_y+1+mounted, self.fs_x+20, self.__autoUnit(fs[mounted]['used']), 8, self.__getColor(fs[mounted]['used'], fs[mounted]['size'])) self.term_window.addnstr(self.fs_y+1+mounted, self.fs_x+20, self.__autoUnit(fs[mounted]['used']), 8, self.__getColor(fs[mounted]['used'], fs[mounted]['size']))