-
Notifications
You must be signed in to change notification settings - Fork 361
/
find_error
executable file
·46 lines (35 loc) · 1.11 KB
/
find_error
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
#!/usr/bin/env bash
# This script is used to help find errors in running bosh VMs by Cloud Controller request ID
#
# Each CC response includes a X-Vcap-Request-Id header. If you have one that has errored with
# a 500 response code, call this script with `find_error <VCAP_REQUEST_ID>`.
#
# This script is not deployed to your bosh VM by default. To install it, run the following script:
#
# apt-get install jq
# wget https://raw.githubusercontent.com/cloudfoundry/cloud_controller_ng/main/scripts/find_error -O /usr/local/bin/find_error
# chmod +x /usr/local/bin/find_error
source /var/vcap/jobs/cloud_controller_ng/bin/ruby_version.sh
request_id=$1
zgrep --no-filename "$request_id" /var/vcap/sys/log/cloud_controller_ng/cloud_controller* | \
grep "Request failed: 500" | \
jq .message --raw-output | \
sed 's/Request failed: 500: //' | \
ruby -e '
def color(id, str)
"\e[#{id}m#{str}\e[0m"
end
def yellow(str)
color 33, str
end
def red(str)
color 31, str
end
error = eval(ARGF.read)
puts <<-RESULT
ERROR DESCRIPTION:
#{yellow error["description"]}
STACKTRACE:
#{red error["backtrace"].join("\n")}
RESULT
'