summaryrefslogtreecommitdiff
path: root/man/html/importdata/mk.mover.log
blob: 0d182d69a02800c8e3b263630b5c540844bd0a28 (plain)
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
#!/bin/sh
#
# Generate a mover.log to be used with mover2pcp
#

find $HOME -type f \
| sed -e 5000q \
| while read f
do
    stat --format="%n %s" "$f"
done \
| awk '
BEGIN	{ now = systime(); start = now - 30*24*3600
	  maxbatch = 60;
	  want = int(rand()*maxbatch);
	  n = c[0] = c[1] = c[2] = max_b = b = 0
	}
	#debug# { print }
	{ want--;
	  if (want < 0) {
	    if (rand() < 0.15) {
		# 15% of the time, output a no activity line
	      n = c[0] = c[1] = c[2] = max_b = b = 0
	    }
	    printf "%s %d files (%d, %d, %d) %d bytes (%d)\n", strftime("%Y-%m-%d %H:%M:%S", start), n, c[0], c[1], c[2], b, max_b
	    start += 30;
	    want = int(rand()*maxbatch);
	    n = c[0] = c[1] = c[2] = max_b = b = 0
	  }
	  n++; b += $2
	  if ($2 <= 1024) c[0]++
	  else if ($2 <= 1024*1024) c[1]++
	  else c[2]++
	  if ($2 > max_b) max_b = $2
	}'