
HOW TO TRANSLATE qtop OUTPUT TO HTML FORMAT

Here is an example on how to generate valid HTML v4.01 from qtop's output.
This can be handy for auto-generating html pages for monitoring your site,
a feature handy for use by eg. Safari's Dashboard or a smartphone's browser.

The following example would work nicely with a crontab entry like:
* * * * * /root/qtop2html >/tmp/qtop2html.stdout 2>/tmp/qtop2html.stderr

# for black and white output
(
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'
echo '"http://www.w3.org/TR/html4/strict.dtd">'
echo '<HEAD><TITLE>qtop output</TITLE>'
echo '<META http-equiv="Content-Type" content="text/html; charset=utf-8">'
echo '<META http-equiv="refresh" content="60">'
echo '</HEAD><BODY><H1>qtop</H1><PRE>'
qtop -c OFF
echo '</PRE> </BODY></HTML>'
) |tee qtop_bw.html

# for colored output, converting ansi to html equivalent colors
# For the latter you will need: http://www.pixelbeat.org/scripts/ansi2html.sh
(
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'
echo '"http://www.w3.org/TR/html4/strict.dtd">'
/opt/cscs/bin/qtop -c ON \
  | ./ansi2html.sh --bg=dark \
  | sed 's/\/>/>/g' \
  | sed 's/<head>/<HEAD><TITLE>qtop output<\/TITLE><META http-equiv="refresh" content="60">/g' \
  | sed 's/<pre>/<H1>qtop<\/H1><PRE>/g' \
  | sed 's/<\/pre>/<\/PRE><p> <A HREF="http:\/\/validator.w3.org\/check?uri=referer"><IMG SRC="http:\/\/www.w3.org\/Icons\/valid-html401" ALT="Valid HTML 4.01 Strict" HEIGHT="31" WIDTH="88"><\/A>/g'
) |tee qtop_color.html
