From 3dc0a02a25ae7c46acfef50e87092d6deca32664 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Wed, 17 Mar 2010 17:44:29 +0700 Subject: [PATCH] Do not report requirements that are available. Closes: http://bugs.debian.org/574246 Document the requirement for CONFIG_VM_EVENT_COUNTERS and check for it on startup. Closes: http://bugs.debian.org/574346 --- README | 4 ++-- iotop.1 | 6 +++--- iotop/data.py | 28 +++++++++++++++++++--------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/README b/README index 9be097c..43e1458 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ Iotop is a Python program with a top like UI used to show of behalf of which process is the I/O going on. It requires Python >= 2.5 (or Python >= 2.4 with -the ctypes module) and a Linux kernel >= 2.6.20 with the TASK_DELAY_ACCT and -TASK_IO_ACCOUNTING options enabled. +the ctypes module) and a Linux kernel >= 2.6.20 with the TASK_DELAY_ACCT +CONFIG_TASKSTATS, TASK_IO_ACCOUNTING and CONFIG_VM_EVENT_COUNTERS options on. To run a local version of iotop: diff --git a/iotop.1 b/iotop.1 index e881008..4d69348 100644 --- a/iotop.1 +++ b/iotop.1 @@ -8,9 +8,9 @@ iotop \- simple top\-like I/O monitor .SH DESCRIPTION iotop watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes -or threads on the system. At least the CONFIG_TASK_DELAY_ACCT and -CONFIG_TASK_IO_ACCOUNTING options need to be enabled in your Linux kernel -build configuration, these options depend on CONFIG_TASKSTATS. +or threads on the system. At least the CONFIG_TASK_DELAY_ACCT, +CONFIG_TASK_IO_ACCOUNTING, CONFIG_TASKSTATS and CONFIG_VM_EVENT_COUNTERS +options need to be enabled in your Linux kernel build configuration. .PP iotop displays columns for the I/O bandwidth read and written by each process/thread during the sampling period. It also displays the percentage diff --git a/iotop/data.py b/iotop/data.py index bbe3e27..3cf5c55 100644 --- a/iotop/data.py +++ b/iotop/data.py @@ -11,7 +11,7 @@ import time # # Check for requirements: -# o Linux >= 2.6.20 with I/O accounting +# o Linux >= 2.6.20 with I/O accounting and VM event counters # o Python >= 2.5 or Python 2.4 + ctypes # @@ -22,16 +22,26 @@ except ImportError: has_ctypes = False else: has_ctypes = True +try: + from iotop.vmstat import VmStat + vmstat_f = VmStat() +except: + vm_event_counters = False +else: + vm_event_counters = True -if not ioaccounting or not has_ctypes: - def boolean2string(boolean): - return boolean and 'Found' or 'Not found' +if not ioaccounting or not has_ctypes or not vm_event_counters: print 'Could not run iotop as some of the requirements are not met:' - print '- Linux >= 2.6.20 with I/O accounting support ' \ - '(CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, ' \ - 'CONFIG_TASK_IO_ACCOUNTING):', boolean2string(ioaccounting) - print '- Python >= 2.5 or Python 2.4 with the ctypes module:', \ - boolean2string(has_ctypes) + if not ioaccounting or not vm_event_counters: + print '- Linux >= 2.6.20 with' + if not ioaccounting: + print ' - I/O accounting support ' \ + '(CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, ' \ + 'CONFIG_TASK_IO_ACCOUNTING)' + if not vm_event_counters: + print ' - VM event counters (CONFIG_VM_EVENT_COUNTERS)' + if not has_ctypes: + print '- Python >= 2.5 or Python 2.4 with the ctypes module' sys.exit(1) -- 1.7.1