-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst_pass.sh
More file actions
executable file
·37 lines (26 loc) · 1.11 KB
/
Copy pathfirst_pass.sh
File metadata and controls
executable file
·37 lines (26 loc) · 1.11 KB
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
#!/bin/bash
. common.sh
first_arg $1
welcome
echo "verbs ..."
OUTPUT_VERB=verb.uniq
cat $FILE | jq '.verb' | sort | uniq -c | sort -n > $OUTPUT_VERB
echo "resources ..."
OUTPUT_RESOURCE=resource.uniq
cat $FILE | jq '.objectRef.resource' | sort | uniq -c | sort -n > $OUTPUT_RESOURCE
echo "usernames ..."
OUTPUT_USERNAME=username.uniq
cat $FILE | jq '.user.username' | sort | uniq -c | sort -n > $OUTPUT_USERNAME
echo "minutes ..."
OUTPUT_MINUTES=stageTimestamp.minutes.uniq
cat $FILE | jq '.stageTimestamp' | cut -d ":" -f 1-2 | sort | uniq -c > $OUTPUT_MINUTES
sort -n $OUTPUT_MINUTES > ${OUTPUT_MINUTES}.sorted
echo "seconds ..."
OUTPUT_SECONDS=stageTimestamp.seconds.uniq
cat $FILE | jq '.stageTimestamp' | cut -d "." -f 1 | sort | uniq -c > $OUTPUT_SECONDS
sort -n $OUTPUT_SECONDS > ${OUTPUT_SECONDS}.sorted
echo "pod-names ..."
OUTPUT_PODNAME=pod-name.uniq
cat $FILE | jq '.user.extra."authentication.kubernetes.io/pod-name"[0]' | sort | uniq -c | sort -n > $OUTPUT_PODNAME
# print a small report
tail -3 $OUTPUT_VERB $OUTPUT_RESOURCE $OUTPUT_USERNAME $OUTPUT_PODNAME ${OUTPUT_SECONDS}.sorted ${OUTPUT_MINUTES}.sorted