diff --git a/tools/prstats/Makefile b/tools/prstats/Makefile new file mode 100644 index 0000000000..95db1393e5 --- /dev/null +++ b/tools/prstats/Makefile @@ -0,0 +1,15 @@ +# +# $FreeBSD$ +# + +all: + ./go.tcl + ./eval.tcl + make copy + +copy: + ./cut.tcl 365 __ __365 + ./cut.tcl 30 __ __30 + ./cut.tcl 7 __ __7 + ./cut.tcl 1 __ __1 + /usr/local/bin/gnuplot g diff --git a/tools/prstats/cut.tcl b/tools/prstats/cut.tcl new file mode 100755 index 0000000000..85ee45a134 --- /dev/null +++ b/tools/prstats/cut.tcl @@ -0,0 +1,15 @@ +#!/usr/local/bin/tclsh8.3 +# +# $FreeBSD$ +# + +set t [clock seconds] +set t0 [expr $t - [lindex $argv 0] * 86400] + +set fi [open [lindex $argv 1]] +set fo [open [lindex $argv 2] w] +while {[gets $fi a] >= 0} { + if {[lindex $a 2] > $t0} { + puts $fo $a + } +} diff --git a/tools/prstats/eval.tcl b/tools/prstats/eval.tcl new file mode 100755 index 0000000000..76e6be55e2 --- /dev/null +++ b/tools/prstats/eval.tcl @@ -0,0 +1,33 @@ +#!/usr/local/bin/tclsh8.3 +# +# $FreeBSD$ +# + +set fi [open "|sort -n _"] +set fo [open "__" w] +set v {open feedback analyzed suspended closed } + +foreach i $v { + set $i 0 +} +set m 0 +while {[gets $fi a] >= 0} { + if {![regexp {^[0-9]*$} [lindex $a 1]]} { + puts "Bogus: $a" + continue + } + if {[catch {eval [string tolower [lindex $a 2]]}]} { + puts $a + } + if {[lindex $a 1] > $m} { + set m [lindex $a 1].0 + } + puts -nonewline $fo [clock format [lindex $a 0] -format "%Y/%m/%d %H:%M" -gmt true] + puts -nonewline $fo " [lindex $a 0]" + foreach i $v { + set j [set $i] + #puts -nonewline $fo " [expr $j / $m]" + puts -nonewline $fo " $j" + } + puts $fo "" +} diff --git a/tools/prstats/g b/tools/prstats/g new file mode 100644 index 0000000000..da4f3ecffa --- /dev/null +++ b/tools/prstats/g @@ -0,0 +1,56 @@ +# $FreeBSD$ +# +set term png small color +set xdata time +set timefmt "%Y/%m/%d %H:%M" +set data style line +set grid +set key left + +set output "gnats.png" +set format x "%Y" +plot '__' using 1:4 title "open", \ + '__' using 1:5 title "feedback", \ + '__' using 1:6 title "analyzed" , \ + '__' using 1:7 title "suspended" + +set output "gnats1.png" +set format x "%H:%M" +plot '__1' using 1:4 title "open" with linespo, \ + '__1' using 1:5 title "feedback", \ + '__1' using 1:6 title "analyzed" , \ + '__1' using 1:7 title "suspended" + +set output "gnats1r.png" +plot '__1' using 1:4 title "open" with linespo + +set output "gnats7.png" +set format x "%m/%d" +plot '__7' using 1:4 title "open", \ + '__7' using 1:5 title "feedback", \ + '__7' using 1:6 title "analyzed" , \ + '__7' using 1:7 title "suspended" + +set output "gnats7r.png" +plot '__7' using 1:4 title "open" + +set output "gnats30.png" +set format x "%Y/%m/%d" +plot '__30' using 1:4 title "open", \ + '__30' using 1:5 title "feedback", \ + '__30' using 1:6 title "analyzed" , \ + '__30' using 1:7 title "suspended" + +set output "gnats30r.png" +plot '__30' using 1:4 title "open" + +set output "gnats365.png" +set format x "%Y/%m/%d" +plot '__365' using 1:4 title "open", \ + '__365' using 1:5 title "feedback", \ + '__365' using 1:6 title "analyzed" , \ + '__365' using 1:7 title "suspended" + +set output "gnats365r.png" +plot '__365' using 1:4 title "open" + diff --git a/tools/prstats/go.tcl b/tools/prstats/go.tcl new file mode 100755 index 0000000000..51e35edc40 --- /dev/null +++ b/tools/prstats/go.tcl @@ -0,0 +1,43 @@ +#!/usr/local/bin/tclsh8.3 +# +# $FreeBSD$ +# + +set fo [open _ w] +proc PR {fn} { + global fo + + set n [lrange [split $fn /] end end] + set fi [open $fn] + while {[gets $fi a] >= 0} { + if {[string range $a 0 12] == "State-Changed"} { + if {[lindex $a 0] == "State-Changed-When:"} { + set t [clock scan [lrange $a 1 end]] + #puts "* $t" + } + if {[lindex $a 0] == "State-Changed-From-To:"} { + regsub {\->*[ ]*} [lrange $a 1 end] { } d + set b [lindex $d 1] + set c [lindex $d 0] + if {$b == "" || $c == ""} { + puts stderr "$n <$a> <$d> <$b> <$c>" + break + } + #puts "* - $c + $b" + } + if {[lindex $a 0] == "State-Changed-Why:"} { + puts $fo "$t $n {incr $c -1 ; incr $b}" + } + } elseif {[string range $a 0 13] == ">Arrival-Date:"} { + #puts "* $a" + puts $fo "[clock scan [lrange $a 1 end]] $n {incr open}" + } else { + #puts $a + } + } + close $fi +} + +foreach pr [glob {/c/gnats/*/[1-9]*}] { + PR $pr +}