summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolargo@nicolargo-fujitsu.(none)>2012-03-27 20:59:54 +0200
committernicolargo <nicolargo@nicolargo-fujitsu.(none)>2012-03-27 20:59:54 +0200
commitcfcb49054fff0262461e55bf283bb72c7b52ad5f (patch)
tree08c55250e8cc4af82575286179cfe13e9d8d704f
parent091020e72b5ea05d1e592233bc8a7636e21cc33c (diff)
CVS
-rw-r--r--NEWS2
l---------[-rw-r--r--]README.md257
-rwxr-xr-xglances/glances.py70
3 files changed, 63 insertions, 266 deletions
diff --git a/NEWS b/NEWS
index 8957bfc3..fe8c5ec3 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ Version 1.4
===========
* Goodby StatGrab... Welcome to the PsUtil library !
+ * HTML output
+ * CSV output
* No more autotools, use setup.py to install
* Sort by Process name ('p' key)
* Only major stats (CPU, Load and memory) use background colors
diff --git a/README.md b/README.md
index 15e9547b..100b9382 100644..120000
--- a/README.md
+++ b/README.md
@@ -1,256 +1 @@
-[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=nicolargo&url=https://github.com/nicolargo/glances&title=Glances&language=&tags=github&category=software)
-
-=============================
-Glances -- Eye on your system
-=============================
-
-## Description
-
-Glances is a CLI curses based monitoring tool for GNU/Linux and BSD OS.
-
-Glances uses the PsUtil library to get information from your system.
-
-It is developed in Python.
-
-![screenshot](https://github.com/nicolargo/glances/raw/master/screenshot.png)
-
-## Installation
-
-### From package manager (very easy way)
-
-Packages exist for Arch, Fedora, Redhat, FreeBSD...
-
-### From PPA (easy way for Ubuntu/Mint...)
-
-Arnaud Hartmann (thanks to him !) maintains a PPA with the latest Glances version:
-
-To install the PPA just enter:
-
- $ sudo add-apt-repository ppa:arnaud-hartmann/glances-dev
- $ sudo apt-get update
-
-Then install Glances:
-
- $ sudo apt-get install glances
-
-### From PyPi (easy way)
-
-PyPi is an official Python package manager.
-
-You first need to install pypi on your system. For exemple on Debian/Ubuntu:
-
- $ sudo apt-get install python-pip
-
-Then install the latest Glances version:
-
- $ sudo pip install glances
-
-### From source
-
-Get the latest version:
-
- $ wget https://github.com/downloads/nicolargo/glances/glances-1.4.tar.gz
-
-Glances use a standard GNU style installer:
-
- $ tar zxvf glances-1.4.tar.gz
- $ cd glances-1.4
- $ sudo python setup.py install
-
-Pre-requisites:
-
-* Python 2.6+ (not tested with Python 3+)
-
-## Running
-
-Easy way (that's all folks !):
-
- $ 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:
-
-* 'h' to display an help message whith the keys 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
-* 'd' Disable or enable the disk IO stats
-* 'f' Disable or enable the file system stats
-* 'l' Disable or enable the logs
-* 'm' to sort the processes list by process size
-* 'n' Disable or enable the network interfaces stats
-* '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.
-
-### Logs
-
-![screenshot](https://github.com/nicolargo/glances/raw/master/doc/logs.png)
-
-A logs list is displayed in the bottom of the screen if (an only if):
-
-* at least one WARNING or CRITICAL alert was occured.
-* space is available in the bottom of the console/terminal
-
-There is one line per alert with the following information:
-
-* start date
-* end date
-* alert name
-* (min/avg/max) values
-
-### Footer
-
-![screenshot](https://github.com/nicolargo/glances/raw/master/doc/footer.png)
-
-Glances displays a caption and the current time/date.
-
-## Localisation
-
-To generate french locale execute as root or sudo :
-i18n_francais_generate.sh
-
-To generate spanish locale execute as root or sudo :
-i18n_espanol_generate.sh
-
-## 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
+README \ No newline at end of file
diff --git a/glances/glances.py b/glances/glances.py
index 9beeff62..bb72da3f 100755
--- a/glances/glances.py
+++ b/glances/glances.py
@@ -40,7 +40,7 @@ try:
import datetime
import multiprocessing
import gettext
-except:
+except ImportError:
print("Error during Python libraries import: "+str(sys.exc_info()[1]))
sys.exit(1)
@@ -56,7 +56,7 @@ gettext.install(__appname__)
try:
import curses
import curses.panel
-except:
+except ImportError:
print _('Textmode GUI initialization failed, Glances cannot start.')
print _('Use Python 2.6 or higher')
print
@@ -64,7 +64,7 @@ except:
try:
import psutil
-except:
+except ImportError:
print _('PsUtil library initialization failed, Glances cannot start.')
print _('On Debian/Ubuntu, you can try (as root):')
print _('# apt-get install python-dev python-pip')
@@ -117,11 +117,20 @@ else:
try:
# HTML output
import jinja2
-except:
+except ImportError:
jinja_tag = False
else:
jinja_tag = True
+try:
+ # CSV output
+ import csv
+except ImportError:
+ csv_tag = False
+else:
+ csv_tag = True
+
+
# Classes
#========
@@ -155,6 +164,9 @@ class glancesLimits():
'LOAD': [0.7, 1.0, 5.0]
}
+ def __init__(self, careful = 50, warning = 70, critical = 90):
+ self.__limits_list['STD'] = [careful, warning, critical]
+
def getSTDCareful(self):
return self.__limits_list['STD'][0]
@@ -1483,7 +1495,33 @@ class glancesHtml():
#~ self.displayCaption()
#~ self.displayNow(stats.getNow())
#~ self.displayHelp()
+
+class glancesCsv():
+ """
+ This class manages the Csv output
+ """
+
+
+ def __init__(self, cvsfile = "./glances.csv", refresh_time = 1):
+ # Global information to display
+
+ # Init refresh time
+ self.__refresh_time = refresh_time
+
+ # Set the templates path
+ self.__csvfile = csv.writer(open("%s" % cvsfile, "wb"))
+
+
+ def update(self, stats):
+ if (stats.getCpu()):
+ # Update CSV with the CPU stats
+ cpu = stats.getCpu()
+ self.__csvfile.writerow([ "cpu", cpu['user'], cpu['kernel'], cpu['nice']])
+ if (stats.getLoad()):
+ # Update CSV with the LOAD stats
+ load = stats.getLoad()
+ self.__csvfile.writerow([ "load", load['min1'], load['min5'], load['min15']])
# Global def
@@ -1498,7 +1536,7 @@ def printSyntax():
print _("Usage: glances.py [-t|--time sec] [-h|--help] [-v|--version]")
print ""
print _("\t-h:\t\tDisplay the syntax and exit")
- print _("\t-o output:\tGenerate output (available: html)")
+ print _("\t-o output:\tGenerate output (available: html, csv)")
print _("\t-t sec:\t\tSet the refresh time in second default is %d" % refresh_time)
print _("\t-v:\t\tDisplay the version and exit")
print ""
@@ -1517,7 +1555,8 @@ def printSyntax():
def init():
- global limits, logs, stats, screen, html
+ global limits, logs, stats, screen
+ global htmloutput, csvoutput
global html_tag
global refresh_time
@@ -1545,7 +1584,11 @@ def init():
html_tag = True
else:
print _("Error: Need the Jinja library to export into HTML")
- sys.exit(2)
+ sys.exit(2)
+ elif arg == "csv":
+ if (not csv_tag):
+ print _("Error: Need the CSV library to export to CSV")
+ sys.exit(2)
else:
print _("Error: Unknown output %s" % arg)
sys.exit(2)
@@ -1572,12 +1615,15 @@ def init():
stats = glancesStats()
# Init screen
- screen = glancesScreen(refresh_time)
+ screen = glancesScreen(refresh_time = refresh_time)
# Init HTML output
if (html_tag):
- html = glancesHtml(refresh_time)
+ htmloutput = glancesHtml(refresh_time = refresh_time)
+ # Init CSV output
+ if (csv_tag):
+ csvoutput = glancesCsv(refresh_time = refresh_time)
def main():
# Init stuff
@@ -1593,7 +1639,11 @@ def main():
# Update the HTML output
if (html_tag):
- html.update(stats)
+ htmloutput.update(stats)
+
+ # Update the CSV output
+ if (csv_tag):
+ csvoutput.update(stats)
def end():