-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo
executable file
·43 lines (35 loc) · 1.2 KB
/
demo
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
#! /bin/bash
set -e
DIR='.demo-pipes'
rm -rf "$DIR"
mkdir -p "$DIR"
mem_used() {
free -h | awk '/^Mem:/ {printf "%s / %s\n", $3, $2; exit 0}'
}
disk_rem() {
df -h / | awk 'NR == 2 {printf "%s / %s\n", $3, $2; exit 0}'
}
loadavg() {
cat /proc/loadavg
}
mkfifo "$DIR"/counter; while :; do echo $((i++)) > "$DIR"/counter; sleep 1; done &
mkfifo "$DIR"/mem; while :; do mem_used > "$DIR"/mem; sleep 1; done &
mkfifo "$DIR"/disk; while :; do disk_rem > "$DIR"/disk; sleep 1; done &
mkfifo "$DIR"/loadavg; while :; do loadavg > "$DIR"/loadavg; sleep 1; done &
mkfifo "$DIR"/expire; echo 'will expire' > "$DIR"/expire &
mkfifo "$DIR"/error; (echo 'will error' > "$DIR"/error; sleep 1; rm "$DIR"/error) &
mkfifo "$DIR"/date; while :; do date > "$DIR"/date; sleep 1; done &
mkfifo "$DIR"/never-expire; echo 'never exprires' > "$DIR"/never-expire &
./pista \
-f '(' \
-s ') (' \
-r ')' \
-l 0 \
"$DIR"/counter 5 2 \
"$DIR"/mem 15 2 \
"$DIR"/disk 15 2 \
"$DIR"/loadavg 30 2 \
"$DIR"/expire 15 5 \
"$DIR"/error 15 2 \
"$DIR"/date 31 2 \
"$DIR"/never-expire 15 -1