@@ -24,6 +24,8 @@ import (
24
24
"github.com/wcharczuk/go-chart/seq"
25
25
)
26
26
27
+ const titleBarSize = 25
28
+
27
29
type graphSpec struct {
28
30
fields []field
29
31
}
@@ -37,6 +39,8 @@ type field struct {
37
39
38
40
func main () {
39
41
url := flag .String ("url" , "" , "URL to fetch every second. Read JSON objects from stdin if not specified." )
42
+ interval := flag .Duration ("interval" , time .Second , "When url is provided, defines the interval between fetches." +
43
+ " Note that counter fields are computed based on this interval." )
40
44
steps := flag .Int ("steps" , 100 , "Number of values to plot." )
41
45
flag .Parse ()
42
46
@@ -64,17 +68,17 @@ func main() {
64
68
}
65
69
select {
66
70
case <- t .C :
67
- render (specs , dp , width , height - 25 )
71
+ render (specs , dp , width , height - titleBarSize )
68
72
case <- exit :
69
- render (specs , dp , width , height - 25 )
73
+ render (specs , dp , width , height - titleBarSize )
70
74
return
71
75
}
72
76
}
73
77
}()
74
78
75
79
var s source.Getter = source .NewStdin ()
76
80
if * url != "" {
77
- s = source .NewHTTP (* url , time . Second )
81
+ s = source .NewHTTP (* url , * interval )
78
82
}
79
83
defer s .Close ()
80
84
for {
0 commit comments