yum install -y redis
yum install -y mysql-server
wget https://www.cloudelf.cn/url/schema.sql
mysql -u root -p < schema.sql
https://www.cloudelf.cn/url/urlooker.tar.gz
[root@urlooker ]# ls
agent alarm urlooker.sh web
"debug": true,
"salt": "have fun!",
"admin":["admin"], #这里的用户是会变成admin用户
"past": 30, #查看最近几分钟内的报警历史和绘图,默认为30分钟
"http": {
"listen": "0.0.0.0:1984",
"secret": "secret"
},
"rpc": {
"listen": "0.0.0.0:1985"
},
"mysql": {
"addr": "root:123@tcp(127.0.0.1:3306)/urlooker?charset=utf8&&loc=Asia%2FShanghai",
"idle": 10,
"max": 20
},
"alarm":{
"enable": true,
"batch": 200,
"replicas": 500,
"connTimeout": 1000,
"callTimeout": 5000,
"maxConns": 32,
"maxIdle": 32,
"sleepTime":30,
"cluster":{
"node-1":"127.0.0.1:1986"
}
},
"monitorMap": {
"default":["hostname.1"], #监控指标多了之后agent地址可以填多个
},
"falcon":{
"enable": false, # 为true表示向falcon推送数据
"addr":"http://falcon.transfer.addr/api/push",
"interval": 60
},
"internalDns":{ #通过公司内部接口获取url对应ip所在机房
"enable": false,
"addr":""
}
{
"debug": false,
"remain":10, #配置策略中支持的最大连续次数
"rpc":{
"listen":"0.0.0.0:1986"
},
"web": {
"addrs": ["127.0.0.1:1985"], #可以填多个web地址
"timeout": 300,
"interval": 60
},
"alarm": {
"enabled": true,
"minInterval": 180,
"queuePattern": "event",
"redis": {
"dsn": "127.0.0.1:6379",
"maxIdle": 5,
"connTimeout": 20000,
"readTimeout": 20000,
"writeTimeout": 20000
}
},
"queue": {
"sms": "/sms",
"mail": "/mail"
},
"worker": {
"sms": 10,
"mail": 50
},
"smtp": {
"addr": "mail.addr:25",
"username": "mail@mail.com",
"password": "",
"from": "mail@mail.com"
}
}
{
"debug": false,
"hostname": "hostname.1", #hostname.1 和 web组件配置文件中monitorMap的值对应
"worker": 1000, # 同时访问url的并发数
"web": {
"addrs": ["127.0.0.1:1985"],
"interval": 60,
"timeout": 1000
}
}
#!/bin/bash
PID(){
ps -ef |grep "urlooker-$1" |grep -v grep |awk '{print $2}'
}
url(){
if [ ! `PID $1` ];then
cd $(dirname $0)/$1
nohup ./urlooker-$1 -c cfg.json >> $(dirname $0)urlooker.log 2>&1 &
if [ $?=0 ];then
sleep 3
echo -e "\t\033[32murlooker-$1\033[0m_Successful_PID=\033[31m`PID $1`\033[0m"
cd ..
fi
else
echo -e "\turlooker-$1...\033[32mrunning\033[0m..."
fi
}
dir(){
file=$(dirname $0)/$1/urlooker-$1
if [ ! -f $file ];then
echo -e "\tNo \033[31m$file\033[m file or directory"
else
url $1
fi
}
state(){
if [ ! `PID $1` ];then
echo -e "\turlooker-$1...\033[31mnone\033[0m..."
else
echo -e "\turlooker-$1...\033[32mrunning\033[0m..."
fi
}
Stoprunning(){
if [ ! `PID $1` ];then
echo -e "\turlooker-$1...\033[31mnone\033[0m..."
else
kill -15 `PID $1`
fi
}
case $1 in
start)
dir web
dir alarm
dir agent
;;
status)
state web
state alarm
state agent
;;
stop)
Stoprunning web
Stoprunning alarm
Stoprunning agent
;;
*)
echo ""
echo -e $"Usage: $0 { start | status |stop | help }\n"
;;
esac
exit 0
网友评论