-
Notifications
You must be signed in to change notification settings - Fork 78
/
install_pinpoint_php.sh
74 lines (64 loc) · 2.23 KB
/
install_pinpoint_php.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
PINPOINT_PHP_VERSION=v0.1.11
PINPOINT_PHP_VERSION_MD5SUM=
func_check_command(){
command -v $1 >/dev/null 2>&1 || { echo >&2 " require $1 command. Aborting . "; exit 1; }
}
func_output_w(){
RED='\033[0;31m'
NC='\033[0m'
echo "${RED} $1 ${NC}"
}
func_output_n(){
GREEN='\033[0;32m'
NC='\033[0m'
echo "${RED} $1 ${NC}"
}
func_download_extension(){
mkdir -p /tmp/pinpoint_php && cd /tmp/pinpoint_php && curl -L -o pinpoint_php.tar.gz __PACK_URL__ && tar xvf pinpoint_php.tar.gz && phpize && ./configure && make install
# mkdir -p /tmp/pinpoint_php && cd /tmp/pinpoint_php && curl -L -o pinpoint_php.tar.gz https://github.com/eeliu/pinpoint-c-agent/releases/download/$PINPOINT_PHP_VERSION/pinpoint_php@$PINPOINT_PHP_VERSION.tar.gz && tar xvf pinpoint_php.tar.gz && phpize && ./configure && make install
# && rm /tmp/pinpoint_php* -rf
}
func_install_pinpoint_config(){
echo "enable pinpoint_php into php(php.ini);"
cat << EOF >>/tmp/pinpoint_php.ini
[pinpoint_php]
extension=pinpoint_php.so
# Collector-agent's TCP address, ip,port:Collector-Agent's ip,port
pinpoint_php.CollectorHost=tcp:dev-collector:10000
# 0 is recommanded
pinpoint_php.SendSpanTimeOutMs=0
# request should be captured duing 1 second. < 0 means no limited
pinpoint_php.TraceLimit=-1
# DEBUG the agent
# error_reporting = E_ALL
# log_errors = On
# should be set false if in production env
pinpoint_php.DebugReport=false
EOF
INI_DIR=`php-config --ini-dir`
if [ -d "$INI_DIR" ]; then
cp /tmp/pinpoint_php.ini $INI_DIR
echo "install pinpoint_php into $INI_DIR";
echo "<<< $INI_DIR/pinpoint_php.ini >>>";
else
func_output_w "Your php does not set --ini-dir, enable pinpoint_php into php.ini !!!"
func_output_w ">> php.ini"
cat /tmp/pinpoint_php.ini
func_output_w ">> EOF"
fi
rm /tmp/pinpoint_php.ini
}
func_show_pinpoint_php(){
php -r "echo 'TEST: installed pinpoint_php:'. phpversion('pinpoint_php');"
func_output_n " \n everything looks done !";
}
main(){
for cmd in php phpize gcc make php-config curl autoconf; do
func_check_command $cmd
done
func_download_extension
func_install_pinpoint_config
func_show_pinpoint_php
}
main