Skip to content

Commit 759bd23

Browse files
committed
Add command line demo from LCA lightning talk
1 parent 8dab2eb commit 759bd23

File tree

2 files changed

+183
-0
lines changed

2 files changed

+183
-0
lines changed

docs/slides/lca2020-lightning/script03

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Script started on 2020-01-17 13:06:15+10:00 [TERM="xterm-256color" TTY="/dev/pts/8" COLUMNS="90" LINES="22"]
2+
]777;notify;Command completed;bma type skim-stdin \]777;precmd\]0;m@localhost:~/.bash-my-aws\]7;file://localhost.localdomain/home/m/.bash-my-aws\
3+
$ 
4+
$ instances
5+
777;preexecœi-0588726918d6ee19b t3.small running huginn-bma 2020-01-17T01:57:33.000Z
6+
i-08ec93cf02239df3d t3.nano running nginx-bma 2020-01-17T01:57:40.000Z
7+
i-09b1a3bc8917b9ca0 t3.nano running grafana-bma 2020-01-17T01:57:42.000Z
8+
i-0120b019f373f8860 t3.small running huginn-bma 2020-01-17T02:40:14.000Z
9+
i-065bf156cdd2d6dc3 t3.nano running grafana-bma 2020-01-17T02:40:20.000Z
10+
i-078337da5262a5d5a t3.nano running nginx-bma 2020-01-17T02:40:28.000Z
11+
]777;notify;Command completed;instances\]777;precmd\]0;m@localhost:~/.bash-my-aws\]7;file://localhost.localdomain/home/m/.bash-my-aws\
12+
$ instance-asg
13+
777;preexecœUSAGE: instance-asg instance-id [instance-id]
14+
]777;notify;Command completed;instance-asg\]777;precmd\]0;m@localhost:~/.bash-my-aws\]7;file://localhost.localdomain/home/m/.bash-my-aws\
15+
$ instance-asgs | instance-asg
16+
777;preexecœgrafana-bma-AutoScalingGroup-1NXJHMJVZQVMB i-09b1a3bc8917b9ca0
17+
nginx-bma-AutoScalingGroup-106KHAYHUSRHU i-08ec93cf02239df3d
18+
nginx-bma-AutoScalingGroup-106KHAYHUSRHU i-078337da5262a5d5a
19+
grafana-bma-AutoScalingGroup-1NXJHMJVZQVMB i-065bf156cdd2d6dc3
20+
huginn-bma-AutoScalingGroup-QS7EQOT1G7OX i-0120b019f373f8860
21+
huginn-bma-AutoScalingGroup-QS7EQOT1G7OX i-0588726918d6ee19b
22+
]777;notify;Command completed;instances | instance-asg\]777;precmd\]0;m@localhost:~/.bash-my-aws\]7;file://localhost.localdomain/home/m/.bash-my-aws\
23+
$ instances | instance-asg | asg-
24+
asg-capacity asg-max-size-set asg-scaling-activities
25+
asg-desired-size-set asg-min-size-set asg-stack
26+
asg-instances asg-processes_suspended asg-suspend
27+
asg-launch-configuration asg-resume
28+
29+
$ instances | instance-asg | asg-capacity
30+
777;preexecœgrafana-bma-AutoScalingGroup-1NXJHMJVZQVMB 1 2 2
31+
huginn-bma-AutoScalingGroup-QS7EQOT1G7OX 1 2 2
32+
nginx-bma-AutoScalingGroup-106KHAYHUSRHU 1 2 2
33+
]777;notify;Command completed;instances | instance-asg | asg-capacity \]777;precmd\]0;m@localhost:~/.bash-my-aws\]7;file://localhost.localdomain/home/m/.bash-my-aws\
34+
$ 
35+
$ bma type instance-asg
36+
777;preexecœinstance-asg is a function
37+
instance-asg ()
38+
{
39+
local instance_ids=$(skim-stdin "$@");
40+
[[ -z $instance_ids ]] && __bma_usage "instance-id [instance-id]" && return 1;
41+
aws ec2 describe-instances --instance-ids $instance_ids --output text --query "
42+
Reservations[].Instances[][
43+
{
44+
"AutoscalingGroupName":
45+
[Tags[?Key=='aws:autoscaling:groupName'].Value][0][0],
46+
"InstanceId": InstanceId
47+
}
48+
][]" | column -s' ' -t
49+
}
50+
]777;notify;Command completed;bma type instance-asg\]777;precmd\]0;m@localhost:~/.bash-my-aws\]7;file://localhost.localdomain/home/m/.bash-my-aws\
51+
$ bma type skim-stdin
52+
777;preexecœskim-stdin is a function
53+
skim-stdin ()
54+
{
55+
echo $@ $([[ -t 0 ]] || awk 'ORS=" " { print $1 }')
56+
}
57+
]777;notify;Command completed;bma type skim-stdin \]777;precmd\]0;m@localhost:~/.bash-my-aws\]7;file://localhost.localdomain/home/m/.bash-my-aws\
58+
$ exit
59+
60+
Script done on 2020-01-17 13:07:32+10:00 [COMMAND_EXIT_CODE="0"]
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
0.369481 153
2+
0.000163 5
3+
1.063417 12
4+
0.785015 1
5+
0.041692 1
6+
0.131068 1
7+
0.130326 1
8+
0.082401 1
9+
0.098469 1
10+
0.115708 1
11+
0.059148 1
12+
0.199305 1
13+
1.043864 2
14+
0.000346 15
15+
1.090803 474
16+
0.005585 142
17+
0.000033 3
18+
0.000015 2
19+
5.949352 1
20+
0.054200 1
21+
0.085777 1
22+
0.157539 1
23+
0.082871 1
24+
0.130696 1
25+
0.126670 1
26+
0.077862 1
27+
0.758478 1
28+
0.556572 1
29+
0.063002 1
30+
0.087636 1
31+
1.962162 2
32+
0.000421 15
33+
0.041817 47
34+
0.006331 145
35+
0.000092 5
36+
5.285878 12
37+
0.211459 8
38+
0.957839 1
39+
0.440574 1
40+
0.321702 1
41+
0.259987 1
42+
0.029368 1
43+
0.156103 1
44+
0.123360 1
45+
0.129010 1
46+
0.122617 1
47+
0.154131 1
48+
0.064068 1
49+
0.185980 1
50+
0.804395 1
51+
0.069904 1
52+
0.072462 1
53+
5.252453 2
54+
1.000253 15
55+
1.752400 390
56+
0.005753 157
57+
0.000040 3
58+
0.000007 2
59+
10.423892 24
60+
5.669835 1
61+
0.536342 1
62+
0.271094 1
63+
0.374355 1
64+
0.062315 1
65+
0.091461 1
66+
0.606527 1
67+
0.440605 1
68+
0.484988 296
69+
1.775263 1
70+
0.061732 1
71+
0.372612 7
72+
1.343720 2
73+
0.001413 15
74+
2.831031 159
75+
0.005721 173
76+
0.000095 5
77+
3.268316 12
78+
2.354384 1
79+
0.055674 1
80+
0.113402 1
81+
0.117561 1
82+
0.279089 1
83+
0.052716 1
84+
0.113280 1
85+
0.127368 1
86+
0.146639 1
87+
0.520760 1
88+
0.042210 1
89+
0.098005 1
90+
0.128062 1
91+
0.086665 1
92+
0.277368 1
93+
0.081706 1
94+
0.059014 1
95+
0.156667 1
96+
0.566025 1
97+
0.075684 1
98+
0.184564 1
99+
0.595689 2
100+
0.000316 15
101+
0.043583 492
102+
0.005919 154
103+
0.000086 5
104+
61.177073 1
105+
0.052595 1
106+
0.148850 1
107+
0.115137 1
108+
0.321458 1
109+
0.065252 1
110+
0.076339 1
111+
0.153379 1
112+
0.126568 1
113+
0.530923 1
114+
0.083884 1
115+
0.130456 1
116+
0.126248 1
117+
0.146988 7
118+
1.254501 2
119+
0.000452 15
120+
0.042885 106
121+
0.006173 153
122+
0.000112 5
123+
11.697056 6

0 commit comments

Comments
 (0)