-
Notifications
You must be signed in to change notification settings - Fork 2
/
aws-queues.sh
executable file
·58 lines (50 loc) · 1.57 KB
/
aws-queues.sh
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
#!/usr/bin/env bash
#
set -e
queues=(
"_aaa_async_jobs_deadletter.fifo"
"_aaa_background_jobs_deadletter.fifo"
"_aaa_batch_jobs_deadletter"
"_aaa_data_sync_jobs_deadletter"
"_aaa_delayed_jobs_deadletter"
"_aaa_elastic_jobs_deadletter"
"_aaa_elastic_report_jobs_deadletter"
"_aaa_import_jobs_deadletter"
"_aaa_marketing_jobs_deadletter.fifo"
"_aaa_pdf_jobs_deadletter.fifo"
"_aaa_slow_jobs_deadletter"
"_aaa_sysop_jobs_deadletter"
)
aws_profile="$1"
[ -z "$1" ] && echo "please specify aws profile" && exit
get_aws_account_id() {
aws sts get-caller-identity --profile $1|jq -r .Account
}
strip_cdk() {
echo "$1" |cut -d- -f2
}
strip_deadletter() {
echo "$1" |sed 's/_deadletter//g'
}
get_number_of_msgs(){
aws sqs get-queue-attributes --attribute-names ApproximateNumberOfMessages \
--queue-url https://sqs.us-east-1.amazonaws.com/$(get_aws_account_id $aws_profile)/$1 \
--profile $aws_profile|jq -r .Attributes.ApproximateNumberOfMessages
}
deadletters() {
for q in ${queues[@]}; do
#echo "https://sqs.us-east-1.amazonaws.com/$(get_aws_account_id $aws_profile)/production_phpweb-$(strip_cdk $1)$q"
queue="production_phpweb-$(strip_cdk $1)$q"
echo "$queue: $(get_number_of_msgs $queue)"
done
}
queues() {
echo "queues"
for q in ${queues[@]}; do
#echo "https://sqs.us-east-1.amazonaws.com/$(get_aws_account_id $aws_profile)/production_phpweb-$(strip_cdk $1)$q"
dead_queue="production_phpweb-$(strip_cdk $1)$q"
queue="$(strip_deadletter $dead_queue)"
echo "$queue: $(get_number_of_msgs $queue)"
done
}
[ -z "$2" ] && deadletters "$1" || queues "$1"