From 1d276d1f2a117e1b7edccee065dfed4706d052dc Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sun, 25 Dec 2011 21:35:46 +0100 Subject: version 1.3.4 --- NEWS | 9 +++ README | 9 ++- README-fr | 11 +-- README.md | 218 +-------------------------------------------------------- man/glances.1 | 8 ++- screenshot.png | Bin 85042 -> 82974 bytes setup.py | 4 +- src/glances.py | 94 +++++++++++++++---------- 8 files changed, 90 insertions(+), 263 deletions(-) mode change 100644 => 120000 README.md diff --git a/NEWS b/NEWS index 4c33f853..694971ca 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +Version 1.3.4 +============= + + * New key: 'n' to enable/disable network stats + * New key: 'd' to enable/disable disk IO stats + * New key: 'f' to enable/disable FS stats + * Reorganised the screen when stat are not available|disable + * Force Glances to use the enmbeded fs stats (issue #16) + Version 1.3.3 ============= diff --git a/README b/README index 37e49b23..fff8e47e 100644 --- a/README +++ b/README @@ -20,12 +20,12 @@ Packages exist for Arch, Fedora, Redhat ... Get the latest version: - $ wget https://github.com/downloads/nicolargo/glances/glances-1.3.3.tar.gz + $ wget https://github.com/downloads/nicolargo/glances/glances-1.3.4.tar.gz Glances use a standard GNU style installer: - $ tar zxvf glances-1.3.3.tar.gz - $ cd glances-1.3.3 + $ tar zxvf glances-1.3.4.tar.gz + $ cd glances-1.3.4 $ ./configure $ make $ sudo make install @@ -79,7 +79,10 @@ When Glances is running, you can press: If MEM > 70%, sort by process "memory size" * 'c' to sort the processes list by CPU consumption +* 'd' Disable or enable the disk IO stats +* 'f' Disable or enable the file system stats * 'm' to sort the processes list by process size +* 'n' Disable or enable the network interfaces stats * 'q' Exit ### Header diff --git a/README-fr b/README-fr index 486cce7e..8f2a5d2d 100644 --- a/README-fr +++ b/README-fr @@ -27,14 +27,14 @@ Le projet Glances est hébergé sur GitHUB: https://github.com/nicolargo/glances Pour l'installer, il suffit de suivre les instructions suivantes depuis un terminal. -Récupération de la dernière version (1.3.3): +Récupération de la dernière version (1.3.4): - $ wget https://github.com/downloads/nicolargo/glances/glances-1.3.3.tar.gz + $ wget https://github.com/downloads/nicolargo/glances/glances-1.3.4.tar.gz Procédez ensuite à l'installation: - $ tar zxvf glances-1.3.3.tar.gz - $ cd glances-1.3.3 + $ tar zxvf glances-1.3.4.tar.gz + $ cd glances-1.3.4 $ ./configure $ make $ sudo make install @@ -102,7 +102,10 @@ Quand Glances est lancé, il est possible d'utiliser les touches suivantes: si la mémoire total > 70% alors le tri se fait pas consommation MEMOIRE * 'c' pour forcer le tri par consommation CPU +* 'd' pour desactiver ou activer l'affichage des entrées/sorties disques +* 'f' pour desactiver ou activer l'affichage de l'occupation des FS * 'm' pour forcer le tri par consommation MEMOIRE +* 'n' pour desactiver ou activer l'affichage des interfaces réseau * 'q' sortir de Glances (il est également possible d'utiliser CTRL-C) Passons ensuite à la description de la fenêtre de Glances: diff --git a/README.md b/README.md deleted file mode 100644 index 37e49b23..00000000 --- a/README.md +++ /dev/null @@ -1,217 +0,0 @@ -Glances -- Eye on your system -============================= - -## Description - -Glances is a CLI curses based monitoring tool for GNU/Linux or BSD OS. - -Glances uses the libstatgrab library to get information from your system. -It is developed in Python and uses the python-statgrab lib. - -![screenshot](https://github.com/nicolargo/glances/raw/master/screenshot.png) - -## Installation - -### From package manager - -Packages exist for Arch, Fedora, Redhat ... - -### From source - -Get the latest version: - - $ wget https://github.com/downloads/nicolargo/glances/glances-1.3.3.tar.gz - -Glances use a standard GNU style installer: - - $ tar zxvf glances-1.3.3.tar.gz - $ cd glances-1.3.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: For Debian. -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: For 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 refreshed 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 "OK" -* BLUE: stat counter is "CAREFUL" -* MAGENTA: stat counter is "WARNING" -* RED: stat counter is "CRITICAL" - -When Glances is running, you can press: - -* 'a' to set the automatic mode. The processes are sorted automatically - - If CPU > 70%, sort by process "CPU consumption" - - If MEM > 70%, sort by process "memory size" - -* 'c' to sort the processes list by CPU consumption -* 'm' to sort the processes list by process size -* 'q' Exit - -### Header - -![screenshot](https://github.com/nicolargo/glances/raw/master/doc/header.png) - -The header shows the Glances version, the host name and the operating -system name, version and architecture. - -### CPU - -![screenshot](https://github.com/nicolargo/glances/raw/master/doc/cpu.png) - -The CPU states are shown as a percentage and for the configured refresh -time. - -If user|kernel|nice CPU is < 50%, then status is set to "OK". - -If user|kernel|nice CPU is > 50%, then status is set to "CAREFUL". - -If user|kernel|nice CPU is > 70%, then status is set to "WARNING". - -If user|kernel|nice CPU is > 90%, then status is set to "CRITICAL". - -### Load - -![screenshot](https://github.com/nicolargo/glances/raw/master/doc/load.png) - -On the Nosheep blog, Zach defines the average load: "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 cores to adapt the alerts. With Glances, -alerts on average load are only set on 5 and 15 mins. - -If average load is < O.7*Core, then status is set to "OK". - -If average load is > O.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". - -### Memory - -![screenshot](https://github.com/nicolargo/glances/raw/master/doc/mem.png) - -Glances uses tree columns: memory (RAM), swap and "real". - -Real used memory is: used - cache. - -Real free memory is: free + cache. - -With Glances, alerts are only set for on used swap and real memory. - -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". - -### Network bit rate - -![screenshot](https://github.com/nicolargo/glances/raw/master/doc/network.png) - -Glances display the network interface bit rate. The unit is adapted -dynamicaly (bits per second, Kbits per second, Mbits per second...). - -Alerts are set only if the network interface maximum speed is available. - -If bitrate is < 50%, then status is set to "OK". - -If bitrate is > 50%, then status is set to "CAREFUL". - -If bitrate is > 70%, then status is set to "WARNING". - -If bitrate is > 90%, then status is set to "CRITICAL". - -For exemple, on a 100 Mbps Ethernet interface, the warning status is set -if the bit rate is higher than 70 Mbps. - -### Disk I/O - -![screenshot](https://github.com/nicolargo/glances/raw/master/doc/diskio.png) - -Glances display the disk I/O throughput. The unit is adapted dynamicaly -(bytes per second, Kbytes per second, Mbytes per second...). - -There is no alert on this information. - -### Filesystem - -![screenshot](https://github.com/nicolargo/glances/raw/master/doc/fs.png) - -Glances display the total and used filesytem disk space. The unit is -adapted dynamicaly (bytes per second, Kbytes per second, Mbytes per -second...). - -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". - -### Processes - -![screenshot](https://github.com/nicolargo/glances/raw/master/doc/processlist.png) - -Glances displays a summary and a list of processes. - -By default (or if you hit the 'a' key) the process list is automaticaly -sorted by CPU of memory consumption. - -The number of processes in the list is adapted to the screen size. - -### Footer - -![screenshot](https://github.com/nicolargo/glances/raw/master/doc/footer.png) - -Glances displays a caption and the current time/date. - -## Todo - -You are welcome to contribute to this software. - -* Packaging for Debian, Ubuntu, 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 diff --git a/README.md b/README.md new file mode 120000 index 00000000..100b9382 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +README \ No newline at end of file diff --git a/man/glances.1 b/man/glances.1 index c36a8dcb..cb5cda7f 100644 --- a/man/glances.1 +++ b/man/glances.1 @@ -1,4 +1,4 @@ -.TH glances 1 "December 13, 2011" "version 0.1" "USER COMMANDS" +.TH glances 1 "December 25, 2011" "version 1.3.4" "USER COMMANDS" .SH NAME glances \- CLI curses based monitoring tool .SH SYNOPSIS @@ -16,8 +16,14 @@ You can use the following keys to sort the processesi list: 'a' to set the automatic mode. The process list is sorted automatically .PP 'c' the processes list is sorted by CPU consomption +.PP + 'd' Disable or enable the disk IO stats +.PP + 'f' Disable or enable the file system stats .PP 'm' the processes list is sorted by process size +.PP + 'n' Disable or enable the network interfaces stats .PP 'q' Exit .PP diff --git a/screenshot.png b/screenshot.png index 70c70fb0..8ae0cc4a 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/setup.py b/setup.py index bdc1db4f..78005582 100644 --- a/setup.py +++ b/setup.py @@ -11,8 +11,8 @@ def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup( name='Glances', - version='1.3.3', - download_url='https://github.com/downloads/nicolargo/glances/glances-1.3.3.tar.gz', + version='1.3.4', + download_url='https://github.com/downloads/nicolargo/glances/glances-1.3.4.tar.gz', url='https://github.com/nicolargo/glances', description='CLI curses-based monitoring tool', author='Nicolas Hennion', diff --git a/src/glances.py b/src/glances.py index 0fd10869..1ecbe823 100755 --- a/src/glances.py +++ b/src/glances.py @@ -34,7 +34,7 @@ import multiprocessing #================== # The glances version id -__version__ = "1.3.3" +__version__ = "1.3.4" # Class #====== @@ -170,10 +170,10 @@ class glancesStats(): except: self.diskio = {} try: - self.fs = statgrab.sg_get_fs_stats() - except: # Replace the bugged self.fs = statgrab.sg_get_fs_stats() self.fs = self.glancesgrabfs.get() + except: + self.fs = {} try: self.processcount = statgrab.sg_get_process_count() except: @@ -325,6 +325,11 @@ class glancesScreen(): self.if70pc_color = curses.color_pair(5)|curses.A_BOLD self.if90pc_color = curses.color_pair(2)|curses.A_BOLD + # By default all the stats are displayed + self.network_tag = True + self.diskio_tag = True + self.fs_tag = True + # Init window self.term_window = self.screen.subwin(0, 0) @@ -441,9 +446,18 @@ class glancesScreen(): elif (self.pressedkey == 99): # 'c' > Sort process list by Cpu usage self.setProcessSortedBy('cpu_percent') + elif (self.pressedkey == 100): + # 'n' > Enable/Disable diskio stats + self.diskio_tag = not self.diskio_tag + elif (self.pressedkey == 102): + # 'n' > Enable/Disable fs stats + self.fs_tag = not self.fs_tag elif (self.pressedkey == 109): # 'm' > Sort process list by Mem usage self.setProcessSortedBy('proc_size') + elif (self.pressedkey == 110): + # 'n' > Enable/Disable network stats + self.network_tag = not self.network_tag # Return the key code return self.pressedkey @@ -463,8 +477,8 @@ class glancesScreen(): screen.displayLoad(stats.getLoad(), stats.getCore()) screen.displayMem(stats.getMem(), stats.getMemSwap()) network_count = screen.displayNetwork(stats.getNetwork(), stats.getNetworkInterface()) - diskio_count = screen.displayDiskIO(stats.getDiskIO(), self.network_y + network_count + 3) - screen.displayFs(stats.getFs(), self.network_y + network_count + diskio_count + 6) + diskio_count = screen.displayDiskIO(stats.getDiskIO(), self.network_y + network_count) + screen.displayFs(stats.getFs(), self.network_y + network_count + diskio_count) screen.displayProcess(stats.getProcessCount(), stats.getProcessList(screen.getProcessSortedBy())) screen.displayCaption() screen.displayNow(stats.getNow()) @@ -502,7 +516,7 @@ class glancesScreen(): screen_y = self.screen.getmaxyx()[0] if ((screen_y > self.host_y) and (screen_x > self.host_x+79)): - host_msg = "Glances v"+self.__version+" running on "+host['hostname'] #+" "+str(pressed_key) + host_msg = "Glances v"+self.__version+" running on "+host['hostname']+" "+str(self.pressedkey) self.term_window.addnstr(self.host_y, self.host_x+int(screen_x/2)-len(host_msg)/2, host_msg, 80, self.title_color if self.hascolors else 0) @@ -588,11 +602,11 @@ class glancesScreen(): Return the number of interfaces """ # Network interfaces bitrate - if (not network or not networkinterface): + if (not network or not networkinterface or not self.network_tag): return 0 screen_x = self.screen.getmaxyx()[1] screen_y = self.screen.getmaxyx()[0] - if ((screen_y > self.network_y+len(network)+2) + if ((screen_y > self.network_y+3) and (screen_x > self.network_x+28)): # Get the speed of the network interface # TODO: optimize... @@ -613,18 +627,18 @@ class glancesScreen(): self.term_window.addnstr(self.network_y+1+i, self.network_x, network[i]['interface_name']+':', 8) self.term_window.addnstr(self.network_y+1+i, self.network_x+10, self.__autoUnit(network[i]['rx']/elapsed_time*8) + "b", 8, self.__getColor(network[i]['rx']/elapsed_time*8, speed[network[i]['interface_name']])) self.term_window.addnstr(self.network_y+1+i, self.network_x+20, self.__autoUnit(network[i]['tx']/elapsed_time*8) + "b", 8, self.__getColor(network[i]['tx']/elapsed_time*8, speed[network[i]['interface_name']])) - return i + return i+3 return 0 def displayDiskIO(self, diskio, offset_y = 0): # Disk input/output rate - if (not diskio): + if (not diskio or not self.diskio_tag): return 0 screen_x = self.screen.getmaxyx()[1] screen_y = self.screen.getmaxyx()[0] self.diskio_y = offset_y - if ((screen_y > self.diskio_y+len(diskio)+2) + if ((screen_y > self.diskio_y+3) and (screen_x > self.diskio_x+28)): self.term_window.addnstr(self.diskio_y, self.diskio_x, "Disk I/O", 8, self.title_color if self.hascolors else curses.A_UNDERLINE) self.term_window.addnstr(self.diskio_y, self.diskio_x+10, "In/ps", 8) @@ -636,18 +650,18 @@ class glancesScreen(): 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+20, self.__autoUnit(diskio[disk]['read_bytes']/elapsed_time) + "B", 8) - return disk + return disk+3 return 0 def displayFs(self, fs, offset_y = 0): # Filesystem stats - if (not fs): + if (not fs or not self.fs_tag): return 0 screen_x = self.screen.getmaxyx()[1] screen_y = self.screen.getmaxyx()[0] self.fs_y = offset_y - if ((screen_y > self.fs_y+len(fs)+2) + if ((screen_y > self.fs_y+3) and (screen_x > self.fs_x+28)): self.term_window.addnstr(self.fs_y, self.fs_x, "Mount", 8, self.title_color if self.hascolors else curses.A_UNDERLINE) self.term_window.addnstr(self.fs_y, self.fs_x+10, "Total", 8) @@ -658,7 +672,7 @@ class glancesScreen(): 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+20, self.__autoUnit(fs[mounted]['used']), 8, self.__getColor(fs[mounted]['used'], fs[mounted]['size'])) - return mounted + return mounted+3 return 0 @@ -668,46 +682,54 @@ class glancesScreen(): return 0 screen_x = self.screen.getmaxyx()[1] screen_y = self.screen.getmaxyx()[0] + # If there is no (network&diskio&fs) stats + # then increase process window + if (not self.network_tag and not self.diskio_tag and not self.fs_tag): + process_x = 0 + else: + process_x = self.process_x + # Display the process summary if ((screen_y > self.process_y+3) - and (screen_x > self.process_x+48)): + and (screen_x > process_x+48)): # Processes sumary - self.term_window.addnstr(self.process_y, self.process_x, "Process", 8, self.title_color if self.hascolors else curses.A_UNDERLINE) - self.term_window.addnstr(self.process_y, self.process_x+10,"Total", 8) - self.term_window.addnstr(self.process_y, self.process_x+20,"Running", 8) - self.term_window.addnstr(self.process_y, self.process_x+30,"Sleeping", 8) - self.term_window.addnstr(self.process_y, self.process_x+40,"Other", 8) - self.term_window.addnstr(self.process_y+1, self.process_x, "Number:", 8) - self.term_window.addnstr(self.process_y+1, self.process_x+10,str(processcount['total']), 8) - self.term_window.addnstr(self.process_y+1, self.process_x+20,str(processcount['running']), 8) - self.term_window.addnstr(self.process_y+1, self.process_x+30,str(processcount['sleeping']), 8) - self.term_window.addnstr(self.process_y+1, self.process_x+40,str(processcount['stopped']+stats.getProcessCount()['zombie']), 8) + self.term_window.addnstr(self.process_y, process_x, "Process", 8, self.title_color if self.hascolors else curses.A_UNDERLINE) + self.term_window.addnstr(self.process_y, process_x+10,"Total", 8) + self.term_window.addnstr(self.process_y, process_x+20,"Running", 8) + self.term_window.addnstr(self.process_y, process_x+30,"Sleeping", 8) + self.term_window.addnstr(self.process_y, process_x+40,"Other", 8) + self.term_window.addnstr(self.process_y+1, process_x, "Number:", 8) + self.term_window.addnstr(self.process_y+1, process_x+10,str(processcount['total']), 8) + self.term_window.addnstr(self.process_y+1, process_x+20,str(processcount['running']), 8) + self.term_window.addnstr(self.process_y+1, process_x+30,str(processcount['sleeping']), 8) + self.term_window.addnstr(self.process_y+1, process_x+40,str(processcount['stopped']+stats.getProcessCount()['zombie']), 8) + # Display the process detail if ((screen_y > self.process_y+6) - and (screen_x > self.process_x+49)): + and (screen_x > process_x+49)): # Processes detail if (self.getProcessSortedBy() == 'cpu_percent'): sortchar = '^' else: sortchar = ' ' - self.term_window.addnstr(self.process_y+3, self.process_x,"Cpu %"+sortchar, 8) + self.term_window.addnstr(self.process_y+3, process_x,"Cpu %"+sortchar, 8) if (self.getProcessSortedBy() == 'proc_size'): sortchar = '^' else: sortchar = ' ' - self.term_window.addnstr(self.process_y+3, self.process_x+10,"Size MB"+sortchar, 8) - self.term_window.addnstr(self.process_y+3, self.process_x+20,"Res MB", 8) - self.term_window.addnstr(self.process_y+3, self.process_x+30,"Name", 8) + self.term_window.addnstr(self.process_y+3, process_x+10,"Size MB"+sortchar, 8) + self.term_window.addnstr(self.process_y+3, process_x+20,"Res MB", 8) + self.term_window.addnstr(self.process_y+3, process_x+30,"Name", 8) for processes in range(0, min(screen_y-self.term_h+self.process_y, len(processlist))): - self.term_window.addnstr(self.process_y+4+processes, self.process_x, "%.1f" % processlist[processes]['cpu_percent'], 8, self.__getColor(processlist[processes]['cpu_percent'])) - self.term_window.addnstr(self.process_y+4+processes, self.process_x+10, str((processlist[processes]['proc_size'])/1048576), 8) - self.term_window.addnstr(self.process_y+4+processes, self.process_x+20, str((processlist[processes]['proc_resident'])/1048576), 8) - maxprocessname = screen_x-self.process_x-30 + self.term_window.addnstr(self.process_y+4+processes, process_x, "%.1f" % processlist[processes]['cpu_percent'], 8, self.__getColor(processlist[processes]['cpu_percent'])) + self.term_window.addnstr(self.process_y+4+processes, process_x+10, str((processlist[processes]['proc_size'])/1048576), 8) + self.term_window.addnstr(self.process_y+4+processes, process_x+20, str((processlist[processes]['proc_resident'])/1048576), 8) + maxprocessname = screen_x-process_x-30 # If screen space is available then display long name if ((len(processlist[processes]['proctitle']) > maxprocessname) or (len(processlist[processes]['proctitle']) == 0)): processname = processlist[processes]['process_name'] else: processname = processlist[processes]['proctitle'] - self.term_window.addnstr(self.process_y+4+processes, self.process_x+30, processname, maxprocessname) + self.term_window.addnstr(self.process_y+4+processes, process_x+30, processname, maxprocessname) def displayCaption(self): -- cgit v1.2.3