From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a706p-0003IO-0g for qemu-devel@nongnu.org; Thu, 10 Dec 2015 07:14:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a706k-0003om-Ox for qemu-devel@nongnu.org; Thu, 10 Dec 2015 07:14:06 -0500 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:57776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a706k-0003oK-FE for qemu-devel@nongnu.org; Thu, 10 Dec 2015 07:14:02 -0500 Received: from localhost by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Dec 2015 12:14:01 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id D51701B08078 for ; Thu, 10 Dec 2015 12:14:28 +0000 (GMT) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tBACDxAb40108218 for ; Thu, 10 Dec 2015 12:13:59 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tBACDwMQ025514 for ; Thu, 10 Dec 2015 05:13:59 -0700 From: Janosch Frank Date: Thu, 10 Dec 2015 13:12:59 +0100 Message-Id: <1449749584-23214-30-git-send-email-frankja@linux.vnet.ibm.com> In-Reply-To: <1449749584-23214-1-git-send-email-frankja@linux.vnet.ibm.com> References: <1449749584-23214-1-git-send-email-frankja@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 29/34] scripts/kvm/kvm_stat: Move to argparse and add description List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: cornelia.huck@de.ibm.com, frankja@linux.vnet.ibm.com The OptionParser is deprecated since the introduction of the ArgumentParser in 2.7. Additionally added a description text for the script, so new users don't have to guess its purpose and inner workings. --- scripts/kvm/kvm_stat | 86 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index aa3de71..109c22c 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -15,7 +15,7 @@ import curses import sys import os import time -import optparse +import argparse import ctypes import fcntl import resource @@ -622,38 +622,58 @@ def log(stats): line += 1 def get_options(): - optparser = optparse.OptionParser() - optparser.add_option('-1', '--once', '--batch', - action='store_true', - default=False, - dest='once', - help='run in batch mode for one second', - ) - optparser.add_option('-l', '--log', - action='store_true', - default=False, - dest='log', - help='run in logging mode (like vmstat)', - ) - optparser.add_option('-t', '--tracepoints', - action='store_true', - default=False, - dest='tracepoints', - help='retrieve statistics from tracepoints', - ) - optparser.add_option('-d', '--debugfs', - action='store_true', - default=False, - dest='debugfs', - help='retrieve statistics from debugfs', - ) - optparser.add_option('-f', '--fields', - action='store', - default=None, - dest='fields', - help='fields to display (regex)', - ) - (options, _) = optparser.parse_args(sys.argv) + description_text = """ +This script displays various statistics about VMs running under KVM. +The statistics are gathered from the KVM debugfs entries and / or the +currently available perf traces. + +The monitoring takes additional cpu cycles and might affect the VM's +performance. + +Requirements: +- Access to: + /sys/kernel/debug/kvm + /sys/kernel/debug/trace/events/* + /proc/pid/task +- /proc/sys/kernel/perf_event_paranoid < 1 if user has no + CAP_SYS_ADMIN and perf events are used. +- CAP_SYS_RESOURCE if the hard limit is not high enough to allow + the large number of files that are possibly opened. +""" + formatter = argparse.RawTextHelpFormatter + parser = argparse.ArgumentParser(description=description_text, + formatter_class=formatter) + parser.add_argument('-1', '--once', '--batch', + action='store_true', + default=False, + dest='once', + help='run in batch mode for one second', + ) + parser.add_argument('-l', '--log', + action='store_true', + default=False, + dest='log', + help='run in logging mode (like vmstat)', + ) + parser.add_argument('-t', '--tracepoints', + action='store_true', + default=False, + dest='tracepoints', + help='retrieve statistics from tracepoints', + ) + parser.add_argument('-d', '--debugfs', + action='store_true', + default=False, + dest='debugfs', + help='retrieve statistics from debugfs', + ) + parser.add_argument('-f', '--fields', + action='store', + default=None, + dest='fields', + help='fields to display (regex)', + ) + options = parser.parse_args() return options def get_providers(options): -- 2.3.0