aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2011-07-07 21:57:01 +0000
committerRob Austein <sra@hactrn.net>2011-07-07 21:57:01 +0000
commit0fe6b732c4da8375de0fa70a9c8fecde3141316f (patch)
treeae14aa4fb2ef7fd82432e7c18208110693170fb1
parentf64d3f1fe45ce0f3e900900e92b23355285f43db (diff)
Feh, was testing wrong version of script
svn path=/rcynic-ng/show.awk; revision=3921
-rw-r--r--rcynic-ng/show.awk104
-rw-r--r--rcynic-ng/show.xsl5
2 files changed, 53 insertions, 56 deletions
diff --git a/rcynic-ng/show.awk b/rcynic-ng/show.awk
index 7c69ea12..bb7ac93e 100644
--- a/rcynic-ng/show.awk
+++ b/rcynic-ng/show.awk
@@ -19,71 +19,71 @@
BEGIN {
FS = "\t";
- got_labels = 0;
}
!NF {
- got_labels = 1;
- next;
+ got_labels = 1;
+ next;
}
!got_labels {
- label[++nlabels] = $1;
- nh = split($2, h, /[ \t]+/);
- for (i = 1; i <= nh; i++) {
- head[$1, i] = h[i];
- if (length(h[i]) > width[i])
- width[$1] = length(h[i]);
- }
+ label[++nlabels] = $1;
+ nh = split($2, h, /[ \t]+/);
+ for (i = 1; i <= nh; i++) {
+ head[$1, i] = h[i];
+ if (length(h[i]) > width[$1])
+ width[$1] = length(h[i]);
+ }
}
got_labels && $3 ~ /^rsync:\/\/.+/ {
- hostname = $3;
- sub(/^rsync:\/\//, "", hostname);
- sub(/\/.*$/, "", hostname);
- hostnames[hostname]++;
- data[hostname, $2]++;
- total[$2]++;
- if (length(hostname) > width["hostname"])
- width["hostname"] = length(hostname);
+ hostname = $3;
+ sub(/^rsync:\/\//, "", hostname);
+ sub(/\/.*$/, "", hostname);
+ if (!seen[hostname])
+ seen[hostname] = ++nhostnames;
+ data[hostname, $2]++;
+ total[$2]++;
+ if (length(hostname) > width["hostname"])
+ width["hostname"] = length(hostname);
}
END {
- for (i = 1;; i++) {
- #
- # Figure out whether we have another header line to print
- #
- blank = 1;
- for (j = 2; j <= nlabels; j++)
- if (head[label[j], i] && total[label[j]] > 0)
- blank = 0;
- if (blank)
- break;
- for (j = 1; j <= nlabels; j++)
- if (j == 1)
- printf "%*s", width[label[j]], head[label[j], i];
- else if (total[j] > 0)
- printf " %*s", width[label[j]], head[label[j], i];
- print "";
+
+ for (i = 1;; i++) {
+ blank = 1;
+ for (j = 1; j <= nlabels; j++)
+ if (head[label[j], i] && (j == 1 || total[label[j]] > 0))
+ blank = 0;
+ if (blank)
+ break;
+ for (j = 1; j <= nlabels; j++) {
+ if (j == 1)
+ printf "%*s", width[label[j]], head[label[j], i];
+ else if (total[label[j]] > 0)
+ printf " %*s", width[label[j]], head[label[j], i];
}
- #
- # Next, print the data
- #
- for (h in data) {
- for (j = 1; j <= nlabels; j++)
- if (j == 1)
- printf "%*s", width[label[j]], data[h, j];
- else if (total[j] > 0)
- printf " %*s", width[label[j]], data[h, j];
- print "";
+ print "";
+ }
+
+ for (i in seen)
+ hostnames[seen[i]] = i;
+
+ for (i = 1; i <= nhostnames; i++) {
+ for (j = 1; j <= nlabels; j++) {
+ if (j == 1)
+ printf "%-*s", width[label[j]], hostnames[i];
+ else if (total[label[j]] > 0)
+ printf " %*s", width[label[j]], data[hostnames[i], label[j]];
}
- #
- # Finally, print the totals
- #
- for (j = 1; j <= nlabels; j++)
- if (j == 1)
- printf "%*s", width[label[j]], "Total";
- else if (total[j] > 0)
- printf " %*s", width[label[j]], total[label[j]];
print "";
+ }
+
+ for (j = 1; j <= nlabels; j++) {
+ if (j == 1)
+ printf "%-*s", width[label[j]], "Total";
+ else if (total[label[j]] > 0)
+ printf " %*s", width[label[j]], total[label[j]];
+ }
+ print "";
}
diff --git a/rcynic-ng/show.xsl b/rcynic-ng/show.xsl
index 91fea74c..9a31082f 100644
--- a/rcynic-ng/show.xsl
+++ b/rcynic-ng/show.xsl
@@ -17,10 +17,6 @@
<!-- $Id$ -->
-<!--
- - XSL stylesheet to render rcynic's xml-summary output as tab-delimited text.
- -->
-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="US-ASCII"/>
@@ -34,6 +30,7 @@
</xsl:for-each>
<xsl:text>&#10;</xsl:text>
<xsl:for-each select="rcynic-summary/validation_status">
+ <xsl:sort order="ascending" data-type="text" select="."/>
<xsl:value-of select="@timestamp"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="@status"/>