-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgnuplotcsv
More file actions
executable file
·28 lines (19 loc) · 786 Bytes
/
Copy pathgnuplotcsv
File metadata and controls
executable file
·28 lines (19 loc) · 786 Bytes
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
#!/usr/bin/gnuplot
set datafile separator ","
set title "CPU usage"
set xlabel "tick"
set ylabel "percent"
set term png size 1024,1024
set key outside
set key right top
min(a,b) = a >= b ? b : a
samples(n) = min(int($0), n)
avg_data = ""
sum_n(data, n) = ( n <= 0 ? 0 : word(data, words(data) - n) + sum_n(data, n - 1))
avg(x, n) = ( avg_data = sprintf("%s %f", (int($0)==0)?"":avg_data, x), sum_n(avg_data, samples(n))/samples(n))
set output "dstat-mvavg.png"
plot "dstat.csv" using 0:(avg(column(2), 10)) every 10::4 title "system" with lines, \
"dstat.csv" using 0:(avg(column(1), 10)) every 10::4 title "user" with lines
set output "dstat.png"
plot "dstat.csv" using 0:2 every 10::4 title "system" with lines, \
"dstat.csv" using 0:1 every 10::4 title "user" with lines