From patchwork Sat Aug 13 17:51:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wieser X-Patchwork-Id: 9278593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D4C1600CB for ; Sat, 13 Aug 2016 21:26:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10E9328AA5 for ; Sat, 13 Aug 2016 21:26:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3D2128AC5; Sat, 13 Aug 2016 21:26:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9496628AA5 for ; Sat, 13 Aug 2016 21:26:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bYgNu-0005uD-CO; Sat, 13 Aug 2016 21:22:26 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bYd5y-0003FY-SK for xen-devel@lists.xenproject.org; Sat, 13 Aug 2016 17:51:43 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id BC/1E-21406-D2E5FA75; Sat, 13 Aug 2016 17:51:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA1VSXUhTYRj223bmSXfqOC1f18ocWmKbqYlZXaQ 3otCPhCj0o53Z0Y22aTszZ3Th38UYIZUgpgbeKCY6rTQMtXBKOEGLpZYugjRhijorTKWh7XSm 2Xf18D7P+zzv9/LifPEiJsFpo4HW6yiNTOgnUJ3wqVTIszuyYuqWziSudVXzklDq4Mq4IB1dw dQ6ZYHxBqaqH5MXtp41/uhzYqVoU2FGe3ABeZ8PZfZ4M8JxRGbA+JPTZuSHi0k3Ardr05fVCM lI6GqyYKwmiAwHR38MW+aTCWCqWRWwOJCkYa1zi89ZRsDHp9NCFhNkMsy2zP7VAHkYbG+rMa4 eALbH3wScD8CA08nnNGHQ98bpy84AZAWCyuleHkuIyVCY3xjlcaILUNVchThRixDW2zq83Skw bV3GONyPgWk5mcMa+PS63luPAsvEdz7X/ApB+covr6sUpsarvNGrAjC3vxCwXxaTSlh3nuTqJ hF8+WzydruEYG5c4nELkICrx4Y4LIXO2gbvpw9CxXuHkMMX4ZG51jtGHCxvNmIPUFjdrn3U7d pHI+K1okiG1t+h9YrYxGilXp2vMmgptUYRG5MQraUZhsqnNZSSic4t0D5Hnivw8bweNPUs3Yp CcJ5sPyE/ZckS71UW3CxRUYwqR1+koRkrkuK4DAjiekeWOEBP59PGPLXGc0rbNOAiWRDhz9IE U0hpGXU+R42gMEkwMX7NQ5AsoSrS7bRtH6EdHZIEEsgziFhUSOu1asP//AIKxpEskJhhXURqn WHHfcETzPMEDye0scEG6h8lKUURY5GpuavZl8iMdzMDm6Fo3ukPxWlW+92JGqrs99cy01z3hv 2qI6flsn1hJKVZmhncl5bXNFxc065zO1Bm2DmL23Y0qeRl+b7Fmbh7SZPdPZIPvQPnQ1yx9dk Pt6pvWcGe6zf380jG4FD47bz4UTdzbHIubWikKV5+vKK14YBMwKio2Ci+nqH+ADY33Yl/AwAA X-Env-Sender: swieser@edu.aau.at X-Msg-Ref: server-6.tower-27.messagelabs.com!1471110700!53900599!1 X-Originating-IP: [104.47.0.132] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47729 invoked from network); 13 Aug 2016 17:51:40 -0000 Received: from mail-he1eur01on0132.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (104.47.0.132) by server-6.tower-27.messagelabs.com with AES256-SHA encrypted SMTP; 13 Aug 2016 17:51:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aauklagenfurt.onmicrosoft.com; s=selector1-edu-aau-at; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Oqk9CB0SexuIg338grjfz+7fZf5lmjFmdzLls2NhwtA=; b=eMKnNBX20STpt6bmJEBF8T0IMa1ZYUnObe3a2PvHxMGPd6RNh5jvB2a56JmAk4HHgxQ97VOq2+H5hJ8seUuamVlM38tDSmqloC/grJBAdIZnQ6fS3PDL9yyGw77ZKK7xp6Q7DLmZvWjxUY1aEc0gZ96Itl8fT6swkyVYp914O6g= Received: from d0-ovh.pawdgame.com (158.69.27.157) by AMSPR03MB0643.eurprd03.prod.outlook.com (10.242.15.141) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.549.15; Sat, 13 Aug 2016 17:51:37 +0000 From: Stefan Wieser To: Date: Sat, 13 Aug 2016 17:51:21 +0000 Message-ID: <1471110681-6665-1-git-send-email-swieser@edu.aau.at> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [158.69.27.157] X-ClientProxiedBy: BN6PR01CA0049.prod.exchangelabs.com (10.172.194.139) To AMSPR03MB0643.eurprd03.prod.outlook.com (10.242.15.141) X-MS-Office365-Filtering-Correlation-Id: 0365c5f4-d230-4166-b89e-08d3c3a27977 X-Microsoft-Exchange-Diagnostics: 1; AMSPR03MB0643; 2:oeznZMYNcw7GZiZVlksb4eVzsOOM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sqn4+CaPlCkUDTdOux1n3Jr/k8g5/w86nXKv7y8ay/+84iguG5pvbHBfGTBcnVtYnbJbIix87QW1XQ2EapQEsqIbmUvd+INTPFNCNb3PlKJbAefhWnVTDA9jQWJHpB0MO22FqofrW9KtE4Fk+JsdLC/hJAIpAFm1Ujojps0EoroDks6JFj/S1Y/8r/0VBoMsrik3dFZtt+g1ELSwfrZCDNbRCo/cdVAKH3tD/xMVj5MRtDQFpc38Jv31aOdkmDUfrSgldWwOdJFn4EbzVb4OJdByd88NCaculRkICj6WW7BnoG1Q6BM/6RSAXyxH7lkqu3RULImx8s3/ev3ilL3DgrxrEFW8L8TSZtkj72V2Jw5C6MTJbbdUmWVNs5+mPJdLFnmj8D1XQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001); SRVR:AMSPR03MB0643; BCL:0; PCL:0; RULEID:; SRVR:AMSPR03MB0643; X-Forefront-PRVS: 0033AAD26D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(69596002)(4326007)(50226002)(3846002)(189998001)(53416004)(86362001)(74482002)(2906002)(106356001)(305945005)(68736007)(6116002)(8676002)(81166006)(2351001)(110136002)(8666005)(36756003)(7736002)(66066001)(229853001)(77096005)(586003)(48376002)(7846002)(81156014)(97736004)(33646002)(105586002)(47776003)(101416001)(92566002)(74826001)(19580405001)(42186005)(19580395003)(50986999)(50466002)(5003940100001)(7059030); DIR:OUT; SFP:1102; SCL:1; SRVR:AMSPR03MB0643; H:d0-ovh.pawdgame.com; FPR:; SPF:None; PTR:InfoNoRecords; A:0; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: edu.aau.at does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AMSPR03MB0643; 23:jKt0KCk9smrA3Nd2upU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JQvQCI4h0Zpg1n5Rt+0ZHRO8D8yLcB7JXDRUInzebFPLUj6cOUVG2RbPRNwInwOlARjhExxeAWcXsEdVXu4kEQMbQTqlQnI+Uy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: edu.aau.at X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2016 17:51:37.4047 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR03MB0643 X-Mailman-Approved-At: Sat, 13 Aug 2016 21:22:25 +0000 Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com Subject: [Xen-devel] [PATCH] xentop: Adds options for tabs-separators, and including the domain ID in the output. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This change adds two options to xentop: -T adds a tabulator (\t) character after each field, to allow easier and more robust parsing. This affects batch mode only. -I includes a column with the domain ID in the output (both the graphical output, and the batch output) This makes the output easier to parse for automated tools. If none of the options are passed, the output is unchanged, so none of them would break existing tools. Signed-off-by: Stefan Wieser --- tools/xenstat/xentop/xentop.c | 82 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 17 deletions(-) diff --git a/tools/xenstat/xentop/xentop.c b/tools/xenstat/xentop/xentop.c index 2fd2b67..d6a927f 100644 --- a/tools/xenstat/xentop/xentop.c +++ b/tools/xenstat/xentop/xentop.c @@ -126,6 +126,9 @@ static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2); static void print_vbd_rsect(xenstat_domain *domain); static int compare_vbd_wsect(xenstat_domain *domain1, xenstat_domain *domain2); static void print_vbd_wsect(xenstat_domain *domain); +static int compare_domid(xenstat_domain *domain1, xenstat_domain *domain2); +static void print_domid(xenstat_domain *domain); + static void reset_field_widths(void); static void adjust_field_widths(xenstat_domain *domain); @@ -172,6 +175,7 @@ typedef struct field { } field; field fields[] = { + { FIELD_DOMID, "DOMID", 6, compare_domid, print_domid }, { FIELD_NAME, "NAME", 10, compare_name, print_name }, { FIELD_STATE, "STATE", 6, compare_state, print_state }, { FIELD_CPU, "CPU(sec)", 10, compare_cpu, print_cpu }, @@ -206,6 +210,8 @@ unsigned int delay = 3; unsigned int batch = 0; unsigned int loop = 1; unsigned int iterations = 0; +int use_tabs = 0; +int show_domid = 0; int show_vcpus = 0; int show_networks = 0; int show_vbds = 0; @@ -239,6 +245,8 @@ static void usage(const char *program) "-r, --repeat-header repeat table header before each domain\n" "-v, --vcpus output vcpu data\n" "-b, --batch output in batch mode, no user input accepted\n" + "-I, --include-domid includes the domain ID column\n" + "-T, --tabs use tabs as a field-separator in batch mode\n" "-i, --iterations number of iterations before exiting\n" "-f, --full-name output the full domain name (not truncated)\n" "\n" XENTOP_BUGSTO, @@ -426,6 +434,19 @@ static int compare(unsigned long long i1, unsigned long long i2) return 0; } +/* Compares domain ID of two domains, returning -1,0,1 for <,=,> */ +static int compare_domid(xenstat_domain *domain1, xenstat_domain *domain2) +{ + return -compare(xenstat_domain_id(domain1), + xenstat_domain_id(domain2)); +} + +/* Prints the domain ID */ +static void print_domid(xenstat_domain *domain) +{ + print("%6u", xenstat_domain_id(domain)); +} + /* Comparison function for use with qsort. Compares two domains using the * current sort field. */ static int compare_domains(xenstat_domain **domain1, xenstat_domain **domain2) @@ -914,12 +935,15 @@ void do_summary(void) void do_header(void) { field_id i; + int fields_shown = 0; /* Turn on REVERSE highlight attribute for headings */ xentop_attron(A_REVERSE); - for(i = 0; i < NUM_FIELDS; i++) { - if (i != 0) - print(" "); + for(i = 0; i < NUM_FIELDS; i++, fields_shown++) { + if (i == FIELD_DOMID && !show_domid) + continue; + if (fields_shown) + print("%c", use_tabs ? '\t' : ' '); /* The BOLD attribute is turned on for the sort column */ if (i == sort_field) xentop_attron(A_BOLD); @@ -978,17 +1002,22 @@ void do_bottom_line(void) /* Prints Domain information */ void do_domain(xenstat_domain *domain) { - unsigned int i; - for (i = 0; i < NUM_FIELDS; i++) { - if (i != 0) - print(" "); + field_id i; + int fields_shown = 0; + + for (i = 0; i < NUM_FIELDS; i++, fields_shown++) { + /* Skip the domain ID field if it wasn't requested. */ + if (i == FIELD_DOMID && !show_domid) + continue; + if (fields_shown) + print(use_tabs ? "\t" : " "); if (i == sort_field) xentop_attron(A_BOLD); fields[i].print(domain); if (i == sort_field) xentop_attroff(A_BOLD); } - print("\n"); + print(use_tabs ? "\t" : "\n"); } /* Output all vcpu information */ @@ -1007,13 +1036,13 @@ void do_vcpu(xenstat_domain *domain) vcpu = xenstat_domain_vcpu(domain,i); if (xenstat_vcpu_online(vcpu) > 0) { - if (i != 0 && (i%5)==0) + if (i != 0 && (i%5)==0 && !use_tabs) print("\n "); print(" %2u: %10llus", i, xenstat_vcpu_ns(vcpu)/1000000000); } } - print("\n"); + print(use_tabs ? "\t" : "\n"); } /* Output all network information */ @@ -1038,11 +1067,12 @@ void do_network(xenstat_domain *domain) xenstat_network_rerrs(network), xenstat_network_rdrop(network)); - print("TX: %8llubytes %8llupkts %8lluerr %8lludrop\n", + print("TX: %8llubytes %8llupkts %8lluerr %8lludrop%c", xenstat_network_tbytes(network), xenstat_network_tpackets(network), xenstat_network_terrs(network), - xenstat_network_tdrop(network)); + xenstat_network_tdrop(network), + use_tabs ? '\t' : '\n'); } } @@ -1075,14 +1105,15 @@ void do_vbd(xenstat_domain *domain) MINOR(xenstat_vbd_dev(vbd))); #endif - print("VBD %s %4d %s OO: %8llu RD: %8llu WR: %8llu RSECT: %10llu WSECT: %10llu\n", + print("VBD %s %4d %s OO: %8llu RD: %8llu WR: %8llu RSECT: %10llu WSECT: %10llu%c", vbd_type[xenstat_vbd_type(vbd)], xenstat_vbd_dev(vbd), details, xenstat_vbd_oo_reqs(vbd), xenstat_vbd_rd_reqs(vbd), xenstat_vbd_wr_reqs(vbd), xenstat_vbd_rd_sects(vbd), - xenstat_vbd_wr_sects(vbd)); + xenstat_vbd_wr_sects(vbd), + use_tabs ? '\t' : '\n'); } } @@ -1097,9 +1128,10 @@ void do_tmem(xenstat_domain *domain) if (curr_eph_pages | succ_eph_gets | succ_pers_puts | succ_pers_gets) print("Tmem: Curr eph pages: %8llu Succ eph gets: %8llu " - "Succ pers puts: %8llu Succ pers gets: %8llu\n", + "Succ pers puts: %8llu Succ pers gets: %8llu%c", curr_eph_pages, succ_eph_gets, - succ_pers_puts, succ_pers_gets); + succ_pers_puts, succ_pers_gets, + use_tabs ? '\t' : '\n'); } @@ -1157,6 +1189,10 @@ static void top(void) do_vbd(domains[i]); if (show_tmem) do_tmem(domains[i]); + + /* If we were told to separate with tabs, add a new-line once the domain is done. */ + if (use_tabs) + printf("\n"); } if (!batch) @@ -1188,9 +1224,11 @@ int main(int argc, char **argv) { "batch", no_argument, NULL, 'b' }, { "iterations", required_argument, NULL, 'i' }, { "full-name", no_argument, NULL, 'f' }, + { "tabs", no_argument, NULL, 'T' }, + { "include-domid", no_argument, NULL, 'I' }, { 0, 0, 0, 0 }, }; - const char *sopts = "hVnxrvd:bi:f"; + const char *sopts = "hVnxrvd:bi:fTI"; if (atexit(cleanup) != 0) fail("Failed to install cleanup handler.\n"); @@ -1235,9 +1273,19 @@ int main(int argc, char **argv) case 't': show_tmem = 1; break; + case 'T': + use_tabs = 1; + break; + case 'I': + show_domid = 1; + break; } } + if (use_tabs && !batch) { + fail("Cannot use tabs in interactive mode.\n"); + } + /* Get xenstat handle */ xhandle = xenstat_init(); if (xhandle == NULL)