From 23e0df2e1081b0156fbe4631f9c5670e8baf8503 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 29 Jul 2013 16:16:45 +0100 Subject: [PATCH] Fixes for RHEL. - Include processcsv.py script and man page, but on RHEL only (RHBZ#665817, RHBZ#912020) - Clear executable stack flag on PPC, PPC64 (RHBZ#605124). - Ignore *~ files. - Fix broken date in changelog. --- .gitignore | 2 + processcsv.py | 65 +++++++++++++++++++ processcsv.py.pod | 64 ++++++++++++++++++ virt-top-1.0.4-processcsv-documentation.patch | 25 +++++++ virt-top.spec | 53 ++++++++++++++- 5 files changed, 207 insertions(+), 2 deletions(-) create mode 100755 processcsv.py create mode 100644 processcsv.py.pod create mode 100644 virt-top-1.0.4-processcsv-documentation.patch diff --git a/.gitignore b/.gitignore index 7e7e20c..1362986 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*~ + /.build*.log /clog /virt-top-*.tar.gz diff --git a/processcsv.py b/processcsv.py new file mode 100755 index 0000000..e74fb88 --- /dev/null +++ b/processcsv.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# +# https://bugzilla.redhat.com/show_bug.cgi?id=665817 +# +# Usage: +# +# virt-top --csv data.csv +# processcsv.py < data.csv +# +# Note this OVERWRITES the following files in the current directory: +# +# global.csv # all the global data +# domain.csv # data for domain ID (multiple files) + +import sys +import csv + +rows = csv.reader (sys.stdin) + +# Get the header row. +header = rows.next () + +# Find the index of the 'Hostname' and 'Time' cols (usually first two). +hostname_i = header.index ("Hostname") +time_i = header.index ("Time") + +# Find the index of the 'Domain ID' column (i) and the number of +# columns per domain (w). +i = header.index ("Domain ID") +w = len (header) - i + +dom_header = header[i:i+w] +dom_header.insert (0, "Hostname") +dom_header.insert (1, "Time") + +gfile = open ("global.csv", "w") +gfile_writer = csv.writer (gfile) +gfile_writer.writerow (header[0:i]) + +dfiles = dict() + +# Process all the remaining data rows. +for data in rows: + # Global data is columns 0..i-1 + gfile_writer.writerow (data[0:i]) + + hostname = data[hostname_i] + time = data[time_i] + + # For each domain ... + for j in range(i,len(data),w): + dom = data[j:j+w] + domid = dom[0] + + if domid in dfiles: + dfile_writer = dfiles[domid] + else: + dfile = open ("domain%s.csv" % domid, "w") + dfile_writer = csv.writer (dfile) + dfile_writer.writerow (dom_header) + dfiles[domid] = dfile_writer + + dom.insert (0, hostname) + dom.insert (1, time) + dfile_writer.writerow (dom) diff --git a/processcsv.py.pod b/processcsv.py.pod new file mode 100644 index 0000000..8c8893d --- /dev/null +++ b/processcsv.py.pod @@ -0,0 +1,64 @@ +=head1 NAME + +processcsv.py - process virt-top CSV files + +=head1 SUMMARY + + virt-top --csv data.csv + processcsv.py < data.csv + +=head1 DESCRIPTION + +virt-top is a L-like utility for showing stats of virtualized +domains. + +processcsv.py is a simple Python script that post-processes the output +of C. + +It is used like this: + + virt-top --csv data.csv + processcsv.py < data.csv + +The second command will B the following files in the +current directory: + +=over 4 + +=item C + +This contains the global (host) statistics columns from the CSV file. + +=item C.csv> (multiple files) + +For each libvirt domain ID I, a file is created containing +the per-domain statistics from the CSV file. + +=back + +=head1 SEE ALSO + +L + +=head1 AUTHORS + +Richard W.M. Jones + +=head1 COPYRIGHT + +(C) Copyright 2007-2012 Red Hat Inc., Richard W.M. Jones +http://libvirt.org/ + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/virt-top-1.0.4-processcsv-documentation.patch b/virt-top-1.0.4-processcsv-documentation.patch new file mode 100644 index 0000000..010e880 --- /dev/null +++ b/virt-top-1.0.4-processcsv-documentation.patch @@ -0,0 +1,25 @@ +--- virt-top-1.0.4.old/virt-top/virt-top.pod 2011-08-11 14:30:30.560493914 +0100 ++++ virt-top-1.0.4/virt-top/virt-top.pod 2011-08-11 14:34:00.934495607 +0100 +@@ -123,6 +123,22 @@ + + virt-top --csv >(split -d -l 1000 - output.csv.) + ++RHEL provides a short Python script called C which ++can be used to post-process the CSV output. Run it like this: ++ ++ virt-top --csv data.csv ++ processcsv.py < data.csv ++ ++This creates or I the following files in the current ++directory: ++ ++ global.csv ++ domain.csv ++ ++C will contain the global data. One ++CNNNE.csv> file will also be created for each domain ++with ID C, containing the per-domain data. ++ + =item B<--no-csv-cpu> + + Disable domain CPU stats in CSV output. diff --git a/virt-top.spec b/virt-top.spec index 14f6076..aeab522 100644 --- a/virt-top.spec +++ b/virt-top.spec @@ -3,13 +3,21 @@ Name: virt-top Version: 1.0.8 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Utility like top(1) for displaying virtualization stats License: GPLv2+ URL: http://people.redhat.com/~rjones/virt-top/ Source0: http://people.redhat.com/~rjones/virt-top/files/%{name}-%{version}.tar.gz +%if 0%{?rhel} >= 6 +# Post-process output of CSV file (RHBZ#665817, RHBZ#912020). +Source1: processcsv.py +Source2: processcsv.py.pod + +Patch0: virt-top-1.0.4-processcsv-documentation.patch +%endif + # Update configure for aarch64 (bz #926701) Patch1: virt-top-aarch64.patch ExcludeArch: sparc64 s390 s390x @@ -38,6 +46,10 @@ BuildRequires: perl BuildRequires: perl(Pod::Perldoc) BuildRequires: gawk +%ifarch ppc ppc64 +BuildRequires: /usr/bin/execstack +%endif + %description virt-top is a 'top(1)'-like utility for showing stats of virtualized @@ -51,8 +63,13 @@ different virtualization systems. %prep %setup -q +%if 0%{?rhel} >= 6 +%patch0 -p1 +%endif + # Update configure for aarch64 (bz #926701) %patch1 -p1 + chmod -x COPYING @@ -71,6 +88,12 @@ make -C po rm -f virt-top/virt-top.1 make -C virt-top virt-top.1 +%if 0%{?rhel} >= 6 +# Build processcsv.py.1. +pod2man -c "Virtualization Support" --release "%{name}-%{version}" \ + %{SOURCE2} > processcsv.py.1 +%endif + %install make DESTDIR=$RPM_BUILD_ROOT install @@ -84,14 +107,40 @@ make -C po install PODIR="$RPM_BUILD_ROOT%{_datadir}/locale" mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1 install -m 0644 virt-top/virt-top.1 $RPM_BUILD_ROOT%{_mandir}/man1 +%ifarch ppc ppc64 +# Clear executable stack flag. Really this is a bug in the OCaml +# compiler on ppc, but it's simpler to just clear the bit here for all +# architectures. +# https://bugzilla.redhat.com/show_bug.cgi?id=605124 +# http://caml.inria.fr/mantis/view.php?id=4564 +execstack -c $RPM_BUILD_ROOT%{_bindir}/virt-top +%endif + +%if 0%{?rhel} >= 6 +# Install processcsv.py. +install -m 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir} + +# Install processcsv.py(1). +install -m 0644 processcsv.py.1 $RPM_BUILD_ROOT%{_mandir}/man1/ +%endif + %files -f %{name}.lang %doc COPYING README TODO ChangeLog %{_bindir}/virt-top %{_mandir}/man1/virt-top.1* +%if 0%{?rhel} >= 6 +%{_bindir}/processcsv.py +%{_mandir}/man1/processcsv.py.1* +%endif %changelog +* Mon Jul 29 2013 Richard W.M. Jones - 1.0.8-6 +- Include processcsv.py script and man page, but on RHEL only + (RHBZ#665817, RHBZ#912020) +- Clear executable stack flag on PPC, PPC64 (RHBZ#605124). + * Fri Jun 28 2013 Cole Robinson - 1.0.8-5 - Update configure for aarch64 (bz #926701) @@ -181,7 +230,7 @@ install -m 0644 virt-top/virt-top.1 $RPM_BUILD_ROOT%{_mandir}/man1 - New upstream release 1.0.0. - Force rebuild of manpage. -* Tue Mar 19 2008 Richard W.M. Jones - 0.4.1.1-1 +* Tue Mar 18 2008 Richard W.M. Jones - 0.4.1.1-1 - New upstream release 0.4.1.1. - Move configure to build section. - Pass RPM_OPT_FLAGS.