-
Notifications
You must be signed in to change notification settings - Fork 0
/
perfstats.coffee
71 lines (58 loc) · 2.91 KB
/
perfstats.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
loggly.bark.external_command {
perfstats: {
run: (args, stdin, context)->
plotProperty = args[0]
drawChart = ()->
datadisplayed = false
elem = $("<div></div>")
context.$output.append(elem)
dataArray = [["Timestamp", plotProperty]]
minVal = Number.MAX_VALUE
maxVal = Number.MIN_VALUE
jsonProperty = plotProperty.substring(5) if plotProperty.indexOf("json.")==0
for data in stdin.series[0].data
ticks = if jsonProperty!="" then parseInt(data.json[jsonProperty]) else parseInt(data[plotProperty])
dataArray.push([new Date(data.timestamp).toLocaleTimeString(), ticks])
minVal = Math.min(ticks, minVal)
maxVal = Math.max(ticks, maxVal)
emptyArray = [["Timestamp", plotProperty]]
emptyArray.push([new Date(data.timestamp).toLocaleTimeString(), minVal]) for data in stdin.series[0].data
emptyArray[1][1] = maxVal
data = google.visualization.arrayToDataTable(emptyArray)
options = {
title: "Performance",
backgroundColor: "transparent",
height: 400,
chartArea: {
width: "93%"
},
fontName: '"Lucida Grande","Lucida Sans Unicode","Verdana","Arial","Helvetica","sans-serif"'
fontSize: 11,
hAxis: {
textStyle: { color: "#666" }
},
vAxis: {
textStyle: { color: "#666" },
gridlines: { color: "#333" }
baselineColor: "#C0D0E0"
},
titleTextStyle: { color: "#3E576F", fontSize:16 },
animation: {
duration: 500,
easing: "linear"
}
}
chart = new google.visualization.LineChart(elem[0])
google.visualization.events.addListener(chart, 'ready', ()->
if !datadisplayed
datadisplayed = true
data = google.visualization.arrayToDataTable(dataArray)
chart.draw(data, options)
)
chart.draw(data, options)
google.load("visualization", "1", {'packages':['corechart', 'table'], "callback" : drawChart})
}
}
myscript = document.createElement("script")
myscript.src = "https://www.google.com/jsapi"
document.body.appendChild(myscript)