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.
This commit is contained in:
Richard W.M. Jones 2013-07-29 16:16:45 +01:00
parent 1c3106abed
commit 23e0df2e10
5 changed files with 207 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*~
/.build*.log
/clog
/virt-top-*.tar.gz

65
processcsv.py Executable file
View File

@ -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<NN>.csv # data for domain ID <NN> (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)

64
processcsv.py.pod Normal file
View File

@ -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<top(1)>-like utility for showing stats of virtualized
domains.
processcsv.py is a simple Python script that post-processes the output
of C<virt-top --csv>.
It is used like this:
virt-top --csv data.csv
processcsv.py < data.csv
The second command will B<overwrite> the following files in the
current directory:
=over 4
=item C<global.csv>
This contains the global (host) statistics columns from the CSV file.
=item C<domainI<NN>.csv> (multiple files)
For each libvirt domain ID I<NN>, a file is created containing
the per-domain statistics from the CSV file.
=back
=head1 SEE ALSO
L<virt-top(1)>
=head1 AUTHORS
Richard W.M. Jones <rjones @ redhat . com>
=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.

View File

@ -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<processcsv.py> 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<overwrites> the following files in the current
+directory:
+
+ global.csv
+ domain<NNN>.csv
+
+C<global.csv> will contain the global data. One
+C<domainE<lt>NNNE<gt>.csv> file will also be created for each domain
+with ID C<NNN>, containing the per-domain data.
+
=item B<--no-csv-cpu>
Disable domain CPU stats in CSV output.

View File

@ -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 <rjones@redhat.com> - 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 <crobinso@redhat.com> - 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 <rjones@redhat.com> - 0.4.1.1-1
* Tue Mar 18 2008 Richard W.M. Jones <rjones@redhat.com> - 0.4.1.1-1
- New upstream release 0.4.1.1.
- Move configure to build section.
- Pass RPM_OPT_FLAGS.