From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Fri, 19 Oct 2007 14:44:41 +0000 (+0100) Subject: * virt-top/virt_top_calendar.ml: Added --end-time option. X-Git-Tag: 1.0.4~110 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=02f659ab60024d194977a58795232398350eec13;p=virt-top.git * virt-top/virt_top_calendar.ml: Added --end-time option. Extra optional dep on ocaml-calendar. * virt-top/virt-top.pod: Document how to compress and split CSV files. Document --end-time option and time formats. * virt-top/virt_top.ml: Allow sub-second delays when in batch and script mode. --- diff --git a/ChangeLog b/ChangeLog index 250a8dd..6f2a981 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2007-10-19 Richard Jones + * virt-top/virt_top_calendar.ml: Added --end-time option. + Extra optional dep on ocaml-calendar. + * virt-top/virt-top.pod: Document how to compress and split + CSV files. Document --end-time option and time formats. + * virt-top/virt_top.ml: Allow sub-second delays when in batch + and script mode. * virt-top/virt_top_utils.mli, virt-top/virt_top.mli: Reorganise the code and add some interfaces. diff --git a/README b/README index 1737c47..8f09eae 100644 --- a/README +++ b/README @@ -30,6 +30,7 @@ To build virt-top (optional): ocaml-curses (from http://www.nongnu.org/ocaml-tmk/) xml-light (from http://tech.motion-twin.com/doc/xml-light/) ocaml CSV library (from http://merjis.com/developers/csv) + ocaml-calendar (http://www.lri.fr/~signoles/prog.en.html) [Only ocaml-curses is required for building virt-top. The other packages are not required, but you will get reduced functionality]. diff --git a/TODO.virt-top b/TODO.virt-top index 03cda9c..442ba1c 100644 --- a/TODO.virt-top +++ b/TODO.virt-top @@ -69,13 +69,15 @@ Thinking about maybe this is something we could controly via a be true for other options such as the selection of subsystems and/or ordering/sorting ? -*** 10 [jmh] End time for data collection +*** 10 [jmh] End time for data collection [DONE 0.3.3.0] In --script mode allow an end time to be specified (when the program quits). Be nice to allow the end time to also be specified relative to the current time. *** 11 [jmh] Roll over CSV log file + [PUNTED, but documented a way to do it using ordinary shell + scripting in the manual page] In --csv mode, allow the CSV file to be rolled over and compressed periodically (eg. every so often, specific time of day, etc.) diff --git a/configure.ac b/configure.ac index 6246fb4..97b8533 100644 --- a/configure.ac +++ b/configure.ac @@ -77,12 +77,14 @@ AC_CHECK_OCAML_PKG(curses) AC_CHECK_OCAML_PKG(gettext) AC_CHECK_OCAML_PKG(xml-light) AC_CHECK_OCAML_PKG(csv) +AC_CHECK_OCAML_PKG(calendar) AC_SUBST(pkg_lablgtk2) AC_SUBST(pkg_curses) AC_SUBST(pkg_gettext) AC_SUBST(pkg_xml_light) AC_SUBST(pkg_csv) +AC_SUBST(pkg_calendar) dnl Check for optional perldoc (for building manual pages). AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc) diff --git a/virt-top/.depend b/virt-top/.depend index 4a36b22..97dce08 100644 --- a/virt-top/.depend +++ b/virt-top/.depend @@ -1,5 +1,7 @@ virt_top.cmi: ../libvirt/libvirt.cmi virt_top_utils.cmi: ../libvirt/libvirt.cmi +virt_top_calendar.cmo: virt_top.cmi +virt_top_calendar.cmx: virt_top.cmx virt_top_csv.cmo: virt_top.cmi virt_top_csv.cmx: virt_top.cmx virt_top_main.cmo: virt_top.cmi ../libvirt/libvirt.cmi diff --git a/virt-top/Makefile.in b/virt-top/Makefile.in index 8eec720..1b80472 100644 --- a/virt-top/Makefile.in +++ b/virt-top/Makefile.in @@ -28,6 +28,7 @@ bindir = @bindir@ pkg_curses = @pkg_curses@ pkg_xml_light = @pkg_xml_light@ pkg_csv = @pkg_csv@ +pkg_calendar = @pkg_calendar@ OCAMLCPACKAGES := -package unix,extlib,curses,str @@ -40,6 +41,10 @@ ifeq ($(pkg_csv),yes) OBJS += virt_top_csv.cmo OCAMLCPACKAGES := $(OCAMLCPACKAGES),csv endif +ifeq ($(pkg_calendar),yes) +OBJS += virt_top_calendar.cmo +OCAMLCPACKAGES := $(OCAMLCPACKAGES),calendar +endif OBJS += virt_top_main.cmo XOBJS := $(OBJS:.cmo=.cmx) diff --git a/virt-top/README b/virt-top/README index f557c9b..3b64e88 100644 --- a/virt-top/README +++ b/virt-top/README @@ -36,6 +36,12 @@ The code is structured into these files: Any code which needs the optional ocaml-csv library goes in here. This implements the --csv command line option. + virt_top_calendar.ml + + Any code which needs the optional ocaml-calendar library + goes in here. This implements the --end-time command line + option. + virt_top_main.ml This is just a small bit of code to glue whatever modules diff --git a/virt-top/virt-top.1 b/virt-top/virt-top.1 index 137b61f..cf33621 100644 --- a/virt-top/virt-top.1 +++ b/virt-top/virt-top.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "VIRT-TOP 1" -.TH VIRT-TOP 1 "2007-10-17" "ocaml-libvirt-0.3.2.9" "Virtualization Support" +.TH VIRT-TOP 1 "2007-10-19" "ocaml-libvirt-0.3.3.0" "Virtualization Support" .SH "NAME" virt\-top \- 'top'\-like utility for virtualization stats .SH "SUMMARY" @@ -214,6 +214,21 @@ those to process the \s-1CSV\s0 file). Not every version of virt-top supports \s-1CSV\s0 output \- it depends how the program was compiled (see \fI\s-1README\s0\fR file in the source distribution for details). +.Sp +To save space you can compress your \s-1CSV\s0 files (if your shell supports +this feature, eg. \fIbash\fR): +.Sp +.Vb 1 +\& virt-top --csv >(gzip -9 > output.csv.gz) +.Ve +.Sp +You can use a similar trick to split the \s-1CSV\s0 file up. In this example +the \s-1CSV\s0 file is split every 1000 lines into files called +\&\fIoutput.csv.00\fR, \fIoutput.csv.01\fR etc. +.Sp +.Vb 1 +\& virt-top --csv >(split -d -l 1000 - output.csv.) +.Ve .IP "\fB\-\-no\-csv\-cpu\fR" 4 .IX Item "--no-csv-cpu" Disable domain \s-1CPU\s0 stats in \s-1CSV\s0 output. @@ -244,6 +259,44 @@ Do not read any init file. .IX Item "--script" Script mode. There will be no user interface. This is most useful when used together with the \fI\-\-csv\fR and \fI\-n\fR options. +.IP "\fB\-\-end\-time time\fR" 4 +.IX Item "--end-time time" +The program will exit at the \fItime\fR given. +.Sp +The time may be given in one of the following formats: +.RS 4 +.IP "\fIYYYY-MM-DD \s-1HH:MM:SS\s0\fR" 4 +.IX Item "YYYY-MM-DD HH:MM:SS" +End time is the date and time given. +.IP "\fI\s-1HH:MM:SS\s0\fR" 4 +.IX Item "HH:MM:SS" +End time is the time given, today. +.IP "\fI+HH:MM:SS\fR" 4 +.IX Item "+HH:MM:SS" +End time is \s-1HH\s0 hours, \s-1MM\s0 minutes, \s-1SS\s0 seconds in the future (counted +from the moment that program starts). +.IP "\fI+secs\fR" 4 +.IX Item "+secs" +End time is \fIsecs\fR seconds in the future. +.RE +.RS 4 +.Sp +For example to run the program for 3 minutes you could do: +.Sp +.Vb 1 +\& virt-top --end-time +00:03:00 +.Ve +.Sp +or: +.Sp +.Vb 1 +\& virt-top --end-time +180 +.Ve +.Sp +Not every version of virt-top supports this option \- it depends how the +program was compiled (see \fI\s-1README\s0\fR file in the source distribution +for details). +.RE .IP "\fB\-\-help\fR" 4 .IX Item "--help" Display usage summary. @@ -361,6 +414,10 @@ Sets secure mode. .IP "\fBscript\fR \fItrue|false\fR" 4 .IX Item "script true|false" Sets script mode. +.IP "\fBend-time\fR \fItime\fR" 4 +.IX Item "end-time time" +Set the time at which the program exits. See above for the +time formats supported. .IP "\fBoverwrite-init-file\fR \fIfalse\fR" 4 .IX Item "overwrite-init-file false" If set to \fIfalse\fR then the \fIW\fR key will not overwrite the diff --git a/virt-top/virt-top.pod b/virt-top/virt-top.pod index af31c27..a708357 100644 --- a/virt-top/virt-top.pod +++ b/virt-top/virt-top.pod @@ -99,6 +99,17 @@ Not every version of virt-top supports CSV output - it depends how the program was compiled (see I file in the source distribution for details). +To save space you can compress your CSV files (if your shell supports +this feature, eg. I): + + virt-top --csv >(gzip -9 > output.csv.gz) + +You can use a similar trick to split the CSV file up. In this example +the CSV file is split every 1000 lines into files called +I, I etc. + + virt-top --csv >(split -d -l 1000 - output.csv.) + =item B<--no-csv-cpu> Disable domain CPU stats in CSV output. @@ -134,6 +145,45 @@ Do not read any init file. Script mode. There will be no user interface. This is most useful when used together with the I<--csv> and I<-n> options. +=item B<--end-time time> + +The program will exit at the I